OLD | NEW |
1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 // Package swarmbucket provides access to the Buildbucket-Swarming integration. | 5 // Package swarmbucket provides access to the Buildbucket-Swarming integration. |
6 // | 6 // |
7 // Usage example: | 7 // Usage example: |
8 // | 8 // |
9 // import "github.com/luci/luci-go/common/api/buildbucket/swarmbucket/v1" | 9 // import "github.com/luci/luci-go/common/api/buildbucket/swarmbucket/v1" |
10 // ... | 10 // ... |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 UserAgent string // optional additional User-Agent fragment | 67 UserAgent string // optional additional User-Agent fragment |
68 } | 68 } |
69 | 69 |
70 func (s *Service) userAgent() string { | 70 func (s *Service) userAgent() string { |
71 if s.UserAgent == "" { | 71 if s.UserAgent == "" { |
72 return googleapi.UserAgent | 72 return googleapi.UserAgent |
73 } | 73 } |
74 return googleapi.UserAgent + " " + s.UserAgent | 74 return googleapi.UserAgent + " " + s.UserAgent |
75 } | 75 } |
76 | 76 |
| 77 type ApiPubSubCallbackMessage struct { |
| 78 AuthToken string `json:"auth_token,omitempty"` |
| 79 |
| 80 Topic string `json:"topic,omitempty"` |
| 81 |
| 82 UserData string `json:"user_data,omitempty"` |
| 83 |
| 84 // ForceSendFields is a list of field names (e.g. "AuthToken") to |
| 85 // unconditionally include in API requests. By default, fields with |
| 86 // empty values are omitted from API requests. However, any non-pointer, |
| 87 // non-interface field appearing in ForceSendFields will be sent to the |
| 88 // server regardless of whether the field is empty or not. This may be |
| 89 // used to include empty fields in Patch requests. |
| 90 ForceSendFields []string `json:"-"` |
| 91 |
| 92 // NullFields is a list of field names (e.g. "AuthToken") to include in |
| 93 // API requests with the JSON null value. By default, fields with empty |
| 94 // values are omitted from API requests. However, any field with an |
| 95 // empty value appearing in NullFields will be sent to the server as |
| 96 // null. It is an error if a field in this list has a non-empty value. |
| 97 // This may be used to include null fields in Patch requests. |
| 98 NullFields []string `json:"-"` |
| 99 } |
| 100 |
| 101 func (s *ApiPubSubCallbackMessage) MarshalJSON() ([]byte, error) { |
| 102 type noMethod ApiPubSubCallbackMessage |
| 103 raw := noMethod(*s) |
| 104 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) |
| 105 } |
| 106 |
| 107 type ApiPutRequestMessage struct { |
| 108 Bucket string `json:"bucket,omitempty"` |
| 109 |
| 110 ClientOperationId string `json:"client_operation_id,omitempty"` |
| 111 |
| 112 LeaseExpirationTs int64 `json:"lease_expiration_ts,omitempty,string"` |
| 113 |
| 114 ParametersJson string `json:"parameters_json,omitempty"` |
| 115 |
| 116 PubsubCallback *ApiPubSubCallbackMessage `json:"pubsub_callback,omitempt
y"` |
| 117 |
| 118 Tags []string `json:"tags,omitempty"` |
| 119 |
| 120 // ForceSendFields is a list of field names (e.g. "Bucket") to |
| 121 // unconditionally include in API requests. By default, fields with |
| 122 // empty values are omitted from API requests. However, any non-pointer, |
| 123 // non-interface field appearing in ForceSendFields will be sent to the |
| 124 // server regardless of whether the field is empty or not. This may be |
| 125 // used to include empty fields in Patch requests. |
| 126 ForceSendFields []string `json:"-"` |
| 127 |
| 128 // NullFields is a list of field names (e.g. "Bucket") to include in API |
| 129 // requests with the JSON null value. By default, fields with empty |
| 130 // values are omitted from API requests. However, any field with an |
| 131 // empty value appearing in NullFields will be sent to the server as |
| 132 // null. It is an error if a field in this list has a non-empty value. |
| 133 // This may be used to include null fields in Patch requests. |
| 134 NullFields []string `json:"-"` |
| 135 } |
| 136 |
| 137 func (s *ApiPutRequestMessage) MarshalJSON() ([]byte, error) { |
| 138 type noMethod ApiPutRequestMessage |
| 139 raw := noMethod(*s) |
| 140 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) |
| 141 } |
| 142 |
77 type SwarmingSwarmbucketApiBucketMessage struct { | 143 type SwarmingSwarmbucketApiBucketMessage struct { |
78 Builders []*SwarmingSwarmbucketApiBuilderMessage `json:"builders,omitemp
ty"` | 144 Builders []*SwarmingSwarmbucketApiBuilderMessage `json:"builders,omitemp
ty"` |
79 | 145 |
80 Name string `json:"name,omitempty"` | 146 Name string `json:"name,omitempty"` |
81 | 147 |
82 // ForceSendFields is a list of field names (e.g. "Builders") to | 148 // ForceSendFields is a list of field names (e.g. "Builders") to |
83 // unconditionally include in API requests. By default, fields with | 149 // unconditionally include in API requests. By default, fields with |
84 // empty values are omitted from API requests. However, any non-pointer, | 150 // empty values are omitted from API requests. However, any non-pointer, |
85 // non-interface field appearing in ForceSendFields will be sent to the | 151 // non-interface field appearing in ForceSendFields will be sent to the |
86 // server regardless of whether the field is empty or not. This may be | 152 // server regardless of whether the field is empty or not. This may be |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // This may be used to include null fields in Patch requests. | 219 // This may be used to include null fields in Patch requests. |
154 NullFields []string `json:"-"` | 220 NullFields []string `json:"-"` |
155 } | 221 } |
156 | 222 |
157 func (s *SwarmingSwarmbucketApiGetBuildersResponseMessage) MarshalJSON() ([]byte
, error) { | 223 func (s *SwarmingSwarmbucketApiGetBuildersResponseMessage) MarshalJSON() ([]byte
, error) { |
158 type noMethod SwarmingSwarmbucketApiGetBuildersResponseMessage | 224 type noMethod SwarmingSwarmbucketApiGetBuildersResponseMessage |
159 raw := noMethod(*s) | 225 raw := noMethod(*s) |
160 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) | 226 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) |
161 } | 227 } |
162 | 228 |
| 229 type SwarmingSwarmbucketApiGetTaskDefinitionRequestMessage struct { |
| 230 BuildRequest *ApiPutRequestMessage `json:"build_request,omitempty"` |
| 231 |
| 232 // ForceSendFields is a list of field names (e.g. "BuildRequest") to |
| 233 // unconditionally include in API requests. By default, fields with |
| 234 // empty values are omitted from API requests. However, any non-pointer, |
| 235 // non-interface field appearing in ForceSendFields will be sent to the |
| 236 // server regardless of whether the field is empty or not. This may be |
| 237 // used to include empty fields in Patch requests. |
| 238 ForceSendFields []string `json:"-"` |
| 239 |
| 240 // NullFields is a list of field names (e.g. "BuildRequest") to include |
| 241 // in API requests with the JSON null value. By default, fields with |
| 242 // empty values are omitted from API requests. However, any field with |
| 243 // an empty value appearing in NullFields will be sent to the server as |
| 244 // null. It is an error if a field in this list has a non-empty value. |
| 245 // This may be used to include null fields in Patch requests. |
| 246 NullFields []string `json:"-"` |
| 247 } |
| 248 |
| 249 func (s *SwarmingSwarmbucketApiGetTaskDefinitionRequestMessage) MarshalJSON() ([
]byte, error) { |
| 250 type noMethod SwarmingSwarmbucketApiGetTaskDefinitionRequestMessage |
| 251 raw := noMethod(*s) |
| 252 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) |
| 253 } |
| 254 |
| 255 type SwarmingSwarmbucketApiGetTaskDefinitionResponseMessage struct { |
| 256 ApiExplorerLink string `json:"api_explorer_link,omitempty"` |
| 257 |
| 258 TaskDefinition string `json:"task_definition,omitempty"` |
| 259 |
| 260 // ServerResponse contains the HTTP response code and headers from the |
| 261 // server. |
| 262 googleapi.ServerResponse `json:"-"` |
| 263 |
| 264 // ForceSendFields is a list of field names (e.g. "ApiExplorerLink") to |
| 265 // unconditionally include in API requests. By default, fields with |
| 266 // empty values are omitted from API requests. However, any non-pointer, |
| 267 // non-interface field appearing in ForceSendFields will be sent to the |
| 268 // server regardless of whether the field is empty or not. This may be |
| 269 // used to include empty fields in Patch requests. |
| 270 ForceSendFields []string `json:"-"` |
| 271 |
| 272 // NullFields is a list of field names (e.g. "ApiExplorerLink") to |
| 273 // include in API requests with the JSON null value. By default, fields |
| 274 // with empty values are omitted from API requests. However, any field |
| 275 // with an empty value appearing in NullFields will be sent to the |
| 276 // server as null. It is an error if a field in this list has a |
| 277 // non-empty value. This may be used to include null fields in Patch |
| 278 // requests. |
| 279 NullFields []string `json:"-"` |
| 280 } |
| 281 |
| 282 func (s *SwarmingSwarmbucketApiGetTaskDefinitionResponseMessage) MarshalJSON() (
[]byte, error) { |
| 283 type noMethod SwarmingSwarmbucketApiGetTaskDefinitionResponseMessage |
| 284 raw := noMethod(*s) |
| 285 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) |
| 286 } |
| 287 |
163 // method id "swarmbucket.get_builders": | 288 // method id "swarmbucket.get_builders": |
164 | 289 |
165 type GetBuildersCall struct { | 290 type GetBuildersCall struct { |
166 s *Service | 291 s *Service |
167 urlParams_ gensupport.URLParams | 292 urlParams_ gensupport.URLParams |
168 ifNoneMatch_ string | 293 ifNoneMatch_ string |
169 ctx_ context.Context | 294 ctx_ context.Context |
170 header_ http.Header | 295 header_ http.Header |
171 } | 296 } |
172 | 297 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // "path": "builders", | 401 // "path": "builders", |
277 // "response": { | 402 // "response": { |
278 // "$ref": "SwarmingSwarmbucketApiGetBuildersResponseMessage" | 403 // "$ref": "SwarmingSwarmbucketApiGetBuildersResponseMessage" |
279 // }, | 404 // }, |
280 // "scopes": [ | 405 // "scopes": [ |
281 // "https://www.googleapis.com/auth/userinfo.email" | 406 // "https://www.googleapis.com/auth/userinfo.email" |
282 // ] | 407 // ] |
283 // } | 408 // } |
284 | 409 |
285 } | 410 } |
| 411 |
| 412 // method id "swarmbucket.get_task_def": |
| 413 |
| 414 type GetTaskDefCall struct { |
| 415 s *Service |
| 416 swarmingswarmbucketapigettaskdefinitionrequestmessage *SwarmingSwarmbuck
etApiGetTaskDefinitionRequestMessage |
| 417 urlParams_ gensupport.URLPara
ms |
| 418 ctx_ context.Context |
| 419 header_ http.Header |
| 420 } |
| 421 |
| 422 // GetTaskDef: Returns a swarming task definition for a build request. |
| 423 func (s *Service) GetTaskDef(swarmingswarmbucketapigettaskdefinitionrequestmessa
ge *SwarmingSwarmbucketApiGetTaskDefinitionRequestMessage) *GetTaskDefCall { |
| 424 c := &GetTaskDefCall{s: s, urlParams_: make(gensupport.URLParams)} |
| 425 c.swarmingswarmbucketapigettaskdefinitionrequestmessage = swarmingswarmb
ucketapigettaskdefinitionrequestmessage |
| 426 return c |
| 427 } |
| 428 |
| 429 // Fields allows partial responses to be retrieved. See |
| 430 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse |
| 431 // for more information. |
| 432 func (c *GetTaskDefCall) Fields(s ...googleapi.Field) *GetTaskDefCall { |
| 433 c.urlParams_.Set("fields", googleapi.CombineFields(s)) |
| 434 return c |
| 435 } |
| 436 |
| 437 // Context sets the context to be used in this call's Do method. Any |
| 438 // pending HTTP request will be aborted if the provided context is |
| 439 // canceled. |
| 440 func (c *GetTaskDefCall) Context(ctx context.Context) *GetTaskDefCall { |
| 441 c.ctx_ = ctx |
| 442 return c |
| 443 } |
| 444 |
| 445 // Header returns an http.Header that can be modified by the caller to |
| 446 // add HTTP headers to the request. |
| 447 func (c *GetTaskDefCall) Header() http.Header { |
| 448 if c.header_ == nil { |
| 449 c.header_ = make(http.Header) |
| 450 } |
| 451 return c.header_ |
| 452 } |
| 453 |
| 454 func (c *GetTaskDefCall) doRequest(alt string) (*http.Response, error) { |
| 455 reqHeaders := make(http.Header) |
| 456 for k, v := range c.header_ { |
| 457 reqHeaders[k] = v |
| 458 } |
| 459 reqHeaders.Set("User-Agent", c.s.userAgent()) |
| 460 var body io.Reader = nil |
| 461 body, err := googleapi.WithoutDataWrapper.JSONReader(c.swarmingswarmbuck
etapigettaskdefinitionrequestmessage) |
| 462 if err != nil { |
| 463 return nil, err |
| 464 } |
| 465 reqHeaders.Set("Content-Type", "application/json") |
| 466 c.urlParams_.Set("alt", alt) |
| 467 urls := googleapi.ResolveRelative(c.s.BasePath, "get_task_def") |
| 468 urls += "?" + c.urlParams_.Encode() |
| 469 req, _ := http.NewRequest("POST", urls, body) |
| 470 req.Header = reqHeaders |
| 471 return gensupport.SendRequest(c.ctx_, c.s.client, req) |
| 472 } |
| 473 |
| 474 // Do executes the "swarmbucket.get_task_def" call. |
| 475 // Exactly one of |
| 476 // *SwarmingSwarmbucketApiGetTaskDefinitionResponseMessage or error will |
| 477 // be non-nil. Any non-2xx status code is an error. Response headers are |
| 478 // in either |
| 479 // *SwarmingSwarmbucketApiGetTaskDefinitionResponseMessage.ServerResponse |
| 480 // .Header or (if a response was returned at all) in |
| 481 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check |
| 482 // whether the returned error was because http.StatusNotModified was |
| 483 // returned. |
| 484 func (c *GetTaskDefCall) Do(opts ...googleapi.CallOption) (*SwarmingSwarmbucketA
piGetTaskDefinitionResponseMessage, error) { |
| 485 gensupport.SetOptions(c.urlParams_, opts...) |
| 486 res, err := c.doRequest("json") |
| 487 if res != nil && res.StatusCode == http.StatusNotModified { |
| 488 if res.Body != nil { |
| 489 res.Body.Close() |
| 490 } |
| 491 return nil, &googleapi.Error{ |
| 492 Code: res.StatusCode, |
| 493 Header: res.Header, |
| 494 } |
| 495 } |
| 496 if err != nil { |
| 497 return nil, err |
| 498 } |
| 499 defer googleapi.CloseBody(res) |
| 500 if err := googleapi.CheckResponse(res); err != nil { |
| 501 return nil, err |
| 502 } |
| 503 ret := &SwarmingSwarmbucketApiGetTaskDefinitionResponseMessage{ |
| 504 ServerResponse: googleapi.ServerResponse{ |
| 505 Header: res.Header, |
| 506 HTTPStatusCode: res.StatusCode, |
| 507 }, |
| 508 } |
| 509 target := &ret |
| 510 if err := json.NewDecoder(res.Body).Decode(target); err != nil { |
| 511 return nil, err |
| 512 } |
| 513 return ret, nil |
| 514 // { |
| 515 // "description": "Returns a swarming task definition for a build requ
est.", |
| 516 // "httpMethod": "POST", |
| 517 // "id": "swarmbucket.get_task_def", |
| 518 // "path": "get_task_def", |
| 519 // "request": { |
| 520 // "$ref": "SwarmingSwarmbucketApiGetTaskDefinitionRequestMessage", |
| 521 // "parameterName": "resource" |
| 522 // }, |
| 523 // "response": { |
| 524 // "$ref": "SwarmingSwarmbucketApiGetTaskDefinitionResponseMessage" |
| 525 // }, |
| 526 // "scopes": [ |
| 527 // "https://www.googleapis.com/auth/userinfo.email" |
| 528 // ] |
| 529 // } |
| 530 |
| 531 } |
OLD | NEW |