import_query.go

  1package github
  2
  3import "github.com/shurcooL/githubv4"
  4
  5type rateLimit struct {
  6	Cost      githubv4.Int
  7	Limit     githubv4.Int
  8	NodeCount githubv4.Int
  9	Remaining githubv4.Int
 10	ResetAt   githubv4.DateTime
 11	Used      githubv4.Int
 12}
 13
 14type rateLimiter interface {
 15	rateLimit() rateLimit
 16}
 17
 18type userQuery struct {
 19	RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
 20	User      user      `graphql:"user(login: $login)"`
 21}
 22
 23func (q *userQuery) rateLimit() rateLimit {
 24	return q.RateLimit
 25}
 26
 27type labelsQuery struct {
 28	//RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
 29	Repository struct {
 30		Labels struct {
 31			Nodes []struct {
 32				ID          string `graphql:"id"`
 33				Name        string `graphql:"name"`
 34				Color       string `graphql:"color"`
 35				Description string `graphql:"description"`
 36			}
 37			PageInfo pageInfo
 38		} `graphql:"labels(first: $first, after: $after)"`
 39	} `graphql:"repository(owner: $owner, name: $name)"`
 40}
 41
 42type loginQuery struct {
 43	//RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
 44	Viewer struct {
 45		Login string `graphql:"login"`
 46	} `graphql:"viewer"`
 47}
 48
 49type issueQuery struct {
 50	RateLimit  rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
 51	Repository struct {
 52		Issues issueConnection `graphql:"issues(first: $issueFirst, after: $issueAfter, orderBy: {field: CREATED_AT, direction: ASC}, filterBy: {since: $issueSince})"`
 53	} `graphql:"repository(owner: $owner, name: $name)"`
 54}
 55
 56func (q *issueQuery) rateLimit() rateLimit {
 57	return q.RateLimit
 58}
 59
 60type issueEditQuery struct {
 61	RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
 62	Node      struct {
 63		Typename githubv4.String `graphql:"__typename"`
 64		Issue    struct {
 65			UserContentEdits userContentEditConnection `graphql:"userContentEdits(last: $issueEditLast, before: $issueEditBefore)"`
 66		} `graphql:"... on Issue"`
 67	} `graphql:"node(id: $gqlNodeId)"`
 68}
 69
 70func (q *issueEditQuery) rateLimit() rateLimit {
 71	return q.RateLimit
 72}
 73
 74type timelineQuery struct {
 75	RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
 76	Node      struct {
 77		Typename githubv4.String `graphql:"__typename"`
 78		Issue    struct {
 79			TimelineItems timelineItemsConnection `graphql:"timelineItems(first: $timelineFirst, after: $timelineAfter)"`
 80		} `graphql:"... on Issue"`
 81	} `graphql:"node(id: $gqlNodeId)"`
 82}
 83
 84func (q *timelineQuery) rateLimit() rateLimit {
 85	return q.RateLimit
 86}
 87
 88type commentEditQuery struct {
 89	RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
 90	Node      struct {
 91		Typename     githubv4.String `graphql:"__typename"`
 92		IssueComment struct {
 93			UserContentEdits userContentEditConnection `graphql:"userContentEdits(last: $commentEditLast, before: $commentEditBefore)"`
 94		} `graphql:"... on IssueComment"`
 95	} `graphql:"node(id: $gqlNodeId)"`
 96}
 97
 98func (q *commentEditQuery) rateLimit() rateLimit {
 99	return q.RateLimit
100}
101
102type user struct {
103	Login     githubv4.String
104	AvatarUrl githubv4.String
105	Name      *githubv4.String
106}
107
108type issueConnection struct {
109	Nodes    []issueNode
110	PageInfo pageInfo
111}
112
113type issueNode struct {
114	issue
115	UserContentEdits userContentEditConnection `graphql:"userContentEdits(last: $issueEditLast, before: $issueEditBefore)"`
116	TimelineItems    timelineItemsConnection   `graphql:"timelineItems(first: $timelineFirst, after: $timelineAfter)"`
117}
118
119type issue struct {
120	authorEvent
121	Title  githubv4.String
122	Number githubv4.Int
123	Body   githubv4.String
124	Url    githubv4.URI
125}
126
127type timelineItemsConnection struct {
128	Nodes    []timelineItem
129	PageInfo pageInfo
130}
131
132type userContentEditConnection struct {
133	Nodes    []userContentEdit
134	PageInfo pageInfo
135}
136
137type userContentEdit struct {
138	Id        githubv4.ID
139	CreatedAt githubv4.DateTime
140	UpdatedAt githubv4.DateTime
141	EditedAt  githubv4.DateTime
142	Editor    *actor
143	DeletedAt *githubv4.DateTime
144	DeletedBy *actor
145	Diff      *githubv4.String
146}
147
148type timelineItem struct {
149	Typename githubv4.String `graphql:"__typename"`
150
151	// issue
152	IssueComment issueComment `graphql:"... on IssueComment"`
153
154	// Label
155	LabeledEvent struct {
156		actorEvent
157		Label struct {
158			// Color githubv4.String
159			Name githubv4.String
160		}
161	} `graphql:"... on LabeledEvent"`
162	UnlabeledEvent struct {
163		actorEvent
164		Label struct {
165			// Color githubv4.String
166			Name githubv4.String
167		}
168	} `graphql:"... on UnlabeledEvent"`
169
170	// Status
171	ClosedEvent struct {
172		actorEvent
173		// Url githubv4.URI
174	} `graphql:"... on  ClosedEvent"`
175	ReopenedEvent struct {
176		actorEvent
177	} `graphql:"... on  ReopenedEvent"`
178
179	// Title
180	RenamedTitleEvent struct {
181		actorEvent
182		CurrentTitle  githubv4.String
183		PreviousTitle githubv4.String
184	} `graphql:"... on RenamedTitleEvent"`
185}
186
187type issueComment struct {
188	authorEvent // NOTE: contains Id
189	Body        githubv4.String
190	Url         githubv4.URI
191
192	UserContentEdits userContentEditConnection `graphql:"userContentEdits(last: $commentEditLast, before: $commentEditBefore)"`
193}
194
195type actor struct {
196	Typename  githubv4.String `graphql:"__typename"`
197	Login     githubv4.String
198	AvatarUrl githubv4.String
199	User      struct {
200		Name  *githubv4.String
201		Email githubv4.String
202	} `graphql:"... on User"`
203	Organization struct {
204		Name  *githubv4.String
205		Email *githubv4.String
206	} `graphql:"... on Organization"`
207}
208
209type actorEvent struct {
210	Id        githubv4.ID
211	CreatedAt githubv4.DateTime
212	Actor     *actor
213}
214
215type authorEvent struct {
216	Id        githubv4.ID
217	CreatedAt githubv4.DateTime
218	Author    *actor
219}
220
221type pageInfo struct {
222	EndCursor       githubv4.String
223	HasNextPage     bool
224	StartCursor     githubv4.String
225	HasPreviousPage bool
226}