Merge remote-tracking branch 'origin/master' into HEAD

This commit is contained in:
Jackie Elliott 2018-06-04 15:08:33 -07:00
Родитель 48b5c4b9c6 a2ec19b04c
Коммит 05d93a6a9e
9 изменённых файлов: 557 добавлений и 2 удалений

26
ack/acknowledge.go Normal file
Просмотреть файл

@ -0,0 +1,26 @@
package ack
import (
"playground/listpr/github"
"time"
)
func determineAck(request github.Request) bool {
//return request.Assignee == nil
const sla = 24 * time.Hour
return request.UpadatedAt.Sub(request.CreatedAt) > sla
}
func getUnacknowledgedPR(pullRequests *github.PullRequestsResult) []*github.Request {
var unacknowledged []*github.Request
for _, item := range pullRequests.Items {
if determineAck(*item) {
unacknowledged = append(unacknowledged, item)
}
}
return unacknowledged
}
func filterByAssignee() {
}

Просмотреть файл

@ -7,7 +7,7 @@ import (
"github.com/gobuffalo/envy"
"github.com/unrolled/secure"
"github.com/Azure/spec_sla_bot/models"
"github.com/Azure/spec-sla-bot/models"
"github.com/gobuffalo/x/sessions"
"github.com/rs/cors"
)

41
assigneeTemplate.tmpl Normal file
Просмотреть файл

@ -0,0 +1,41 @@
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
{{if .Items -}}
Current Requests:<br>
<table style="width:100%">
<caption>Specs Repository Pull Requests</caption>
<tr>
<th>Number</th>
<th>User</th>
<th>Assignee</th>
<th>Time Created</th>
<th>Title</th>
</tr>
{{- range .Items }}
<tr>
<td><a href={{.HTMLURL}}>{{ .Number | FormatNumber}}</a></td>
<td>{{ .User | FormatUser}}</td>
{{if .Assignee -}}
<td>{{ .Assignee | FormatAssignee}}</td>
{{- else}}
<td>NONE</td>
{{- end}}
<td>{{.CreatedAt | FormatTime}}</td>
<td>{{.Title | FormatTitle}}</td>
</tr>
{{- end}}
</table>
{{- else}}
There are no requests.
{{- end}}

36
email/email.go Normal file
Просмотреть файл

@ -0,0 +1,36 @@
package email
import (
"fmt"
"io/ioutil"
"os"
"playground/listpr/template"
"gopkg.in/gomail.v2"
)
//SendEmailToAssignee sends an email to a list of users
func SendEmailToAssignee() error {
template.GenerateTemplate()
b, err := ioutil.ReadFile("finalTemplate.html")
if err != nil {
fmt.Print(err)
}
str := string(b) // convert content to a 'string'
//fmt.Print(str)
m := gomail.NewMessage()
m.SetHeader("From", "t-jaelli@microsoft.com")
m.SetHeader("To", "t-jaelli@microsoft.com")
m.SetHeader("Subject", "TEST")
m.SetBody("text/html", str)
user := os.Getenv("USERNAME")
password := os.Getenv("PASSWORD")
//Send the email
d := gomail.NewDialer("smtp.office365.com", 587, user, password)
if err = d.DialAndSend(m); err != nil {
return err
}
return nil
}

263
finalTemplate.html Normal file
Просмотреть файл

@ -0,0 +1,263 @@
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
Current Requests:<br>
<table style="width:100%">
<caption>Specs Repository Pull Requests</caption>
<tr>
<th>Number</th>
<th>User</th>
<th>Assignee</th>
<th>Time Created</th>
<th>Title</th>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3172>#3172 </a></td>
<td> mboersma</td>
<td>annatisch</td>
<td>2018-06-01 16:31:05 &#43;0000 UTC</td>
<td>[AKS] update go SDK configuration and fix a consistency
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3171>#3171 </a></td>
<td>shalinved</td>
<td> lmazuel</td>
<td>2018-06-01 04:00:52 &#43;0000 UTC</td>
<td>Consumption specifications for cost insights and report
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3170>#3170 </a></td>
<td>samkreter</td>
<td> marstr</td>
<td>2018-05-31 23:06:20 &#43;0000 UTC</td>
<td>Adding June Swagger Update - Azure Container Instance
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3166>#3166 </a></td>
<td>yaakoviyu</td>
<td> marstr</td>
<td>2018-05-31 17:05:46 &#43;0000 UTC</td>
<td>Adding serverSecurityAlertPolicies.json from pr
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3165>#3165 </a></td>
<td> jillcary</td>
<td> hovsepm</td>
<td>2018-05-31 00:28:42 &#43;0000 UTC</td>
<td>Adding appRole property to ApplicationCreateParameters
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3164>#3164 </a></td>
<td>Developer</td>
<td>annatisch</td>
<td>2018-05-31 00:14:15 &#43;0000 UTC</td>
<td>Fixing schedule.json and definition file to conform to
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3162>#3162 </a></td>
<td>tatliciog</td>
<td>sergey-sh</td>
<td>2018-05-30 22:19:43 &#43;0000 UTC</td>
<td>Introduce Azure Traffic Manager 2018-04-01 API version
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3154>#3154 </a></td>
<td> olsoro</td>
<td>jhendrixM</td>
<td>2018-05-30 05:53:10 &#43;0000 UTC</td>
<td>Remove uiDefinitionUri property from managed app respon
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3152>#3152 </a></td>
<td>hyonholee</td>
<td>sarangan1</td>
<td>2018-05-30 04:00:15 &#43;0000 UTC</td>
<td>[Compute] Fix List VM Extension API name, description u
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3151>#3151 </a></td>
<td> lmazuel</td>
<td> lmazuel</td>
<td>2018-05-30 00:23:09 &#43;0000 UTC</td>
<td>Python Authorization to multi api
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3149>#3149 </a></td>
<td>juhee0202</td>
<td> lmazuel</td>
<td>2018-05-29 23:06:24 &#43;0000 UTC</td>
<td>Reservations RP 2018-06-01 specs
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3147>#3147 </a></td>
<td> refortie</td>
<td> hovsepm</td>
<td>2018-05-29 20:46:49 &#43;0000 UTC</td>
<td>Add new map types
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3145>#3145 </a></td>
<td> cthrash</td>
<td>anuchandy</td>
<td>2018-05-29 15:22:05 &#43;0000 UTC</td>
<td>ComputerVision - collection of fixes
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3139>#3139 </a></td>
<td>sarangan1</td>
<td>jhendrixM</td>
<td>2018-05-25 21:42:06 &#43;0000 UTC</td>
<td>Suppress Operations API Implemenetation Error
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3124>#3124 </a></td>
<td>zhangyd20</td>
<td>annatisch</td>
<td>2018-05-23 05:04:33 &#43;0000 UTC</td>
<td>Add APIs for integration runtime sharing feature.
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3121>#3121 </a></td>
<td>anuchandy</td>
<td>NONE</td>
<td>2018-05-22 20:40:33 &#43;0000 UTC</td>
<td>Adding express route 2018-04 multi api version entry
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3119>#3119 </a></td>
<td> ranisha2</td>
<td> dsgouda</td>
<td>2018-05-22 13:29:21 &#43;0000 UTC</td>
<td>[Do Not Merge] Add Information Protection APIs
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3112>#3112 </a></td>
<td> abversqr</td>
<td>annatisch</td>
<td>2018-05-21 17:27:34 &#43;0000 UTC</td>
<td>Adding patch support for SQR API
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3111>#3111 </a></td>
<td> vrdmr</td>
<td> marstr</td>
<td>2018-05-21 15:47:21 &#43;0000 UTC</td>
<td>[Automation] Provisioning State Enum to String in DSCCo
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3094>#3094 </a></td>
<td>ankurkhem</td>
<td> marstr</td>
<td>2018-05-17 21:45:42 &#43;0000 UTC</td>
<td>add Azure Container Registry policies api and update Op
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3092>#3092 </a></td>
<td>vinayada1</td>
<td>jianghaol</td>
<td>2018-05-16 23:44:04 &#43;0000 UTC</td>
<td>Fixexamples
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3085>#3085 </a></td>
<td>Alexander</td>
<td>anuchandy</td>
<td>2018-05-16 19:57:45 &#43;0000 UTC</td>
<td>[Don&#39;t Merge, service deployment scheduled for ~May-30]
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3084>#3084 </a></td>
<td>alexeldei</td>
<td> marstr</td>
<td>2018-05-16 00:56:42 &#43;0000 UTC</td>
<td>[App Insights/Operational Insights] New Data Plane API
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3076>#3076 </a></td>
<td> marstr</td>
<td> hovsepm</td>
<td>2018-05-15 17:22:41 &#43;0000 UTC</td>
<td>Sql/blob auditing
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3075>#3075 </a></td>
<td>yaakoviyu</td>
<td>jhendrixM</td>
<td>2018-05-15 06:19:09 &#43;0000 UTC</td>
<td>[DO NOT MERGE] Adding Vulnerability Assessment APIs on
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3070>#3070 </a></td>
<td>vinayada1</td>
<td> lmazuel</td>
<td>2018-05-14 21:03:50 &#43;0000 UTC</td>
<td>Fix swagger warnings
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3066>#3066 </a></td>
<td>promoisha</td>
<td> hovsepm</td>
<td>2018-05-14 17:43:41 &#43;0000 UTC</td>
<td>[API Management] New Api version introduced along with
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3057>#3057 </a></td>
<td> jaredmoo</td>
<td> hovsepm</td>
<td>2018-05-11 20:13:56 &#43;0000 UTC</td>
<td>Added GET DB extension API
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/3010>#3010 </a></td>
<td> johanste</td>
<td> johanste</td>
<td>2018-05-04 00:11:08 &#43;0000 UTC</td>
<td>[DO NOT MERGE] Testing code gen
</td>
</tr>
<tr>
<td><a href=https://github.com/Azure/azure-rest-api-specs/pull/2987>#2987 </a></td>
<td>asarkar84</td>
<td>jhendrixM</td>
<td>2018-05-01 02:14:23 &#43;0000 UTC</td>
<td>&lt;Please do not review/merge&gt; Added api specs fro GTM su
</td>
</tr>
</table>

60
finalTemplate.tmpl Normal file
Просмотреть файл

@ -0,0 +1,60 @@
Your Requests:
#3159 carissasu Created: 2018-05-30 19:28:18 &#43;0000 UTC [Disk swagger] Removing resourceUpdate, adding contents
#3154 olsoro Created: 2018-05-30 05:53:10 &#43;0000 UTC Remove uiDefinitionUri property from managed app respon
#3152 hyonholee Created: 2018-05-30 04:00:15 &#43;0000 UTC [Compute] Fix List VM Extension API name, description u
#3151 lmazuel Created: 2018-05-30 00:23:09 &#43;0000 UTC Python Authorization to multi api
#3149 juhee0202 Created: 2018-05-29 23:06:24 &#43;0000 UTC Reservations RP 2018-06-01 specs
#3147 refortie Created: 2018-05-29 20:46:49 &#43;0000 UTC Add new map types
#3145 cthrash Created: 2018-05-29 15:22:05 &#43;0000 UTC ComputerVision - collection of fixes
#3143 yaakoviyu Created: 2018-05-27 06:39:12 &#43;0000 UTC Adding new value to VA baseline name
#3139 sarangan1 Created: 2018-05-25 21:42:06 &#43;0000 UTC Suppress Operations API Implemenetation Error
#3131 mboersma Created: 2018-05-24 16:20:45 &#43;0000 UTC [AKS] add new 2018-03-31 API
#3130 caross Created: 2018-05-24 01:25:21 &#43;0000 UTC Admin Subscriptions move should not contain error codes
#3124 zhangyd20 Created: 2018-05-23 05:04:33 &#43;0000 UTC Add APIs for integration runtime sharing feature.
#3121 anuchandy Created: 2018-05-22 20:40:33 &#43;0000 UTC Adding express route 2018-04 multi api version entry
#3119 ranisha2 Created: 2018-05-22 13:29:21 &#43;0000 UTC [Do Not Merge] Add Information Protection APIs
#3112 abversqr Created: 2018-05-21 17:27:34 &#43;0000 UTC Adding patch support for SQR API
#3111 vrdmr Created: 2018-05-21 15:47:21 &#43;0000 UTC [Automation] Provisioning State Enum to String in DSCCo
#3094 ankurkhem Created: 2018-05-17 21:45:42 &#43;0000 UTC add Azure Container Registry policies api and update Op
#3092 vinayada1 Created: 2018-05-16 23:44:04 &#43;0000 UTC Fixexamples
#3085 Alexander Created: 2018-05-16 19:57:45 &#43;0000 UTC [Don&#39;t Merge, service deployment scheduled for ~May-30]
#3084 alexeldei Created: 2018-05-16 00:56:42 &#43;0000 UTC [App Insights/Operational Insights] New Data Plane API
#3076 marstr Created: 2018-05-15 17:22:41 &#43;0000 UTC Sql/blob auditing
#3075 yaakoviyu Created: 2018-05-15 06:19:09 &#43;0000 UTC [DO NOT MERGE] Adding Vulnerability Assessment APIs on
#3070 vinayada1 Created: 2018-05-14 21:03:50 &#43;0000 UTC Fix swagger warnings
#3066 promoisha Created: 2018-05-14 17:43:41 &#43;0000 UTC [API Management] New Api version introduced along with
#3057 jaredmoo Created: 2018-05-11 20:13:56 &#43;0000 UTC Added GET DB extension API
#3010 johanste Created: 2018-05-04 00:11:08 &#43;0000 UTC [DO NOT MERGE] Testing code gen
#2987 asarkar84 Created: 2018-05-01 02:14:23 &#43;0000 UTC &lt;Please do not review/merge&gt; Added api specs fro GTM su
#2976 Tiano2017 Created: 2018-04-30 18:58:46 &#43;0000 UTC &lt;Do Not Merge&gt; New APIs for Microsoft.Resources
#2954 shahabhij Created: 2018-04-26 19:51:40 &#43;0000 UTC Creating separate csharp readme for multiApi support
#2950 ericc1103 Created: 2018-04-26 02:52:55 &#43;0000 UTC Created newer version (2018-04-01-preview) of workbook

72
github/github.go Normal file
Просмотреть файл

@ -0,0 +1,72 @@
package github
import (
"encoding/json"
"fmt"
"net/http"
"time"
)
//PullRequestURL URL for pull request api
const PullRequestURL = "https://api.github.com/repos/Azure/azure-rest-api-specs/pulls"
type PullRequestsResult struct {
// TotalCount int
Items []*Request
}
type Request struct {
Number int
HTMLURL string `json:"html_url"`
ID int
Title string
State string
User *User
Assignee *Assignee
Assignees Assignees
CreatedAt time.Time `json:"created_at"`
UpadatedAt time.Time `json:"updated_at"`
Labels Labels
ClosedAt time.Time `json:"closed_at"`
MergedAt time.Time `json:"merged_at"`
Body string
}
type User struct {
Login string
HTMLURL string `json:"html_url"`
}
type Assignee struct {
Login string
HTMLURL string `json:"html_url"`
}
type Label struct {
ID int
Name string
}
type Assignees []*Assignee
type Labels []*Label
func PullRequests() (*PullRequestsResult, error) {
resp, err := http.Get(PullRequestURL)
if err != nil {
return nil, err
}
//Pushed onto the call stack
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
//resp.Body.Close()
return nil, fmt.Errorf("search query failed: %s", resp.Status)
}
var result PullRequestsResult
if err := json.NewDecoder(resp.Body).Decode(&result.Items); err != nil {
//resp.Body.Close()
return nil, err
}
//resp.Body.Close()
return &result, nil
}

Просмотреть файл

@ -3,7 +3,7 @@ package main
import (
"log"
"github.com/Azure/spec_sla_bot/actions"
"github.com/Azure/spec-sla-bot/actions"
)
func main() {

57
template/template.go Normal file
Просмотреть файл

@ -0,0 +1,57 @@
package template
import (
"fmt"
"html/template"
"log"
"os"
"playground/listpr/github"
"time"
)
func GenerateTemplate() {
//Map of function names to functions
fmap := template.FuncMap{
"FormatNumber": FormatNumber,
"FormatUser": FormatUser,
"FormatAssignee": FormatAssignee,
"FormatTime": FormatTime,
"FormatTitle": FormatTitle}
t := template.Must(template.New("assigneeTemplate.tmpl").Funcs(fmap).ParseFiles("assigneeTemplate.tmpl"))
result, err := github.PullRequests()
if err != nil {
log.Fatal(err)
}
handle, err := os.Create("finalTemplate.html")
//fred, err := ioutil.TempFile()
err = t.Execute(handle, *result)
if err != nil {
panic(err)
}
}
/*func FormatPullRequest(item github.Request) string {
formattedString := fmt.Sprintf("#%-5d %9.9s Created: %.55s %.55s\n",
item.Number, item.User.Login, item.CreatedAt, item.Title)
return formattedString
}*/
func FormatNumber(number int) string {
return fmt.Sprintf("#%-5d", number)
}
func FormatUser(user github.User) string {
return fmt.Sprintf("%9.9s", user.Login)
}
func FormatAssignee(assignee github.Assignee) string {
return fmt.Sprintf("%9.9s", assignee.Login)
}
func FormatTime(createdAt time.Time) string {
return fmt.Sprintf("%.55s", createdAt)
}
func FormatTitle(title string) string {
return fmt.Sprintf("%.55s\n", title)
}