1 // Copyright 2023 Google LLC. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated file. DO NOT EDIT. 6 7 // Package baremetalsolution provides access to the Bare Metal Solution API. 8 // 9 // For product documentation, see: https://cloud.google.com/bare-metal 10 // 11 // # Creating a client 12 // 13 // Usage example: 14 // 15 // import "google.golang.org/api/baremetalsolution/v1" 16 // ... 17 // ctx := context.Background() 18 // baremetalsolutionService, err := baremetalsolution.NewService(ctx) 19 // 20 // In this example, Google Application Default Credentials are used for authentication. 21 // 22 // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 23 // 24 // # Other authentication options 25 // 26 // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey: 27 // 28 // baremetalsolutionService, err := baremetalsolution.NewService(ctx, option.WithAPIKey("AIza...")) 29 // 30 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource: 31 // 32 // config := &oauth2.Config{...} 33 // // ... 34 // token, err := config.Exchange(ctx, ...) 35 // baremetalsolutionService, err := baremetalsolution.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 36 // 37 // See https://godoc.org/google.golang.org/api/option/ for details on options. 38 package baremetalsolution // import "google.golang.org/api/baremetalsolution/v1" 39 40 import ( 41 "bytes" 42 "context" 43 "encoding/json" 44 "errors" 45 "fmt" 46 "io" 47 "net/http" 48 "net/url" 49 "strconv" 50 "strings" 51 52 googleapi "google.golang.org/api/googleapi" 53 internal "google.golang.org/api/internal" 54 gensupport "google.golang.org/api/internal/gensupport" 55 option "google.golang.org/api/option" 56 internaloption "google.golang.org/api/option/internaloption" 57 htransport "google.golang.org/api/transport/http" 58 ) 59 60 // Always reference these packages, just in case the auto-generated code 61 // below doesn't. 62 var _ = bytes.NewBuffer 63 var _ = strconv.Itoa 64 var _ = fmt.Sprintf 65 var _ = json.NewDecoder 66 var _ = io.Copy 67 var _ = url.Parse 68 var _ = gensupport.MarshalJSON 69 var _ = googleapi.Version 70 var _ = errors.New 71 var _ = strings.Replace 72 var _ = context.Canceled 73 var _ = internaloption.WithDefaultEndpoint 74 75 const apiId = "baremetalsolution:v1" 76 const apiName = "baremetalsolution" 77 const apiVersion = "v1" 78 const basePath = "https://baremetalsolution.googleapis.com/" 79 const mtlsBasePath = "https://baremetalsolution.mtls.googleapis.com/" 80 81 // OAuth2 scopes used by this API. 82 const ( 83 // See, edit, configure, and delete your Google Cloud data and see the 84 // email address for your Google Account. 85 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" 86 ) 87 88 // NewService creates a new Service. 89 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 90 scopesOption := internaloption.WithDefaultScopes( 91 "https://www.googleapis.com/auth/cloud-platform", 92 ) 93 // NOTE: prepend, so we don't override user-specified scopes. 94 opts = append([]option.ClientOption{scopesOption}, opts...) 95 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 96 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 97 client, endpoint, err := htransport.NewClient(ctx, opts...) 98 if err != nil { 99 return nil, err 100 } 101 s, err := New(client) 102 if err != nil { 103 return nil, err 104 } 105 if endpoint != "" { 106 s.BasePath = endpoint 107 } 108 return s, nil 109 } 110 111 // New creates a new Service. It uses the provided http.Client for requests. 112 // 113 // Deprecated: please use NewService instead. 114 // To provide a custom HTTP client, use option.WithHTTPClient. 115 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 116 func New(client *http.Client) (*Service, error) { 117 if client == nil { 118 return nil, errors.New("client is nil") 119 } 120 s := &Service{client: client, BasePath: basePath} 121 s.Operations = NewOperationsService(s) 122 return s, nil 123 } 124 125 type Service struct { 126 client *http.Client 127 BasePath string // API endpoint base URL 128 UserAgent string // optional additional User-Agent fragment 129 130 Operations *OperationsService 131 } 132 133 func (s *Service) userAgent() string { 134 if s.UserAgent == "" { 135 return googleapi.UserAgent 136 } 137 return googleapi.UserAgent + " " + s.UserAgent 138 } 139 140 func NewOperationsService(s *Service) *OperationsService { 141 rs := &OperationsService{s: s} 142 return rs 143 } 144 145 type OperationsService struct { 146 s *Service 147 } 148 149 // CancelOperationRequest: The request message for 150 // Operations.CancelOperation. 151 type CancelOperationRequest struct { 152 } 153 154 // Empty: A generic empty message that you can re-use to avoid defining 155 // duplicated empty messages in your APIs. A typical example is to use 156 // it as the request or the response type of an API method. For 157 // instance: service Foo { rpc Bar(google.protobuf.Empty) returns 158 // (google.protobuf.Empty); } 159 type Empty struct { 160 // ServerResponse contains the HTTP response code and headers from the 161 // server. 162 googleapi.ServerResponse `json:"-"` 163 } 164 165 // ListOperationsResponse: The response message for 166 // Operations.ListOperations. 167 type ListOperationsResponse struct { 168 // NextPageToken: The standard List next-page token. 169 NextPageToken string `json:"nextPageToken,omitempty"` 170 171 // Operations: A list of operations that matches the specified filter in 172 // the request. 173 Operations []*Operation `json:"operations,omitempty"` 174 175 // ServerResponse contains the HTTP response code and headers from the 176 // server. 177 googleapi.ServerResponse `json:"-"` 178 179 // ForceSendFields is a list of field names (e.g. "NextPageToken") to 180 // unconditionally include in API requests. By default, fields with 181 // empty or default values are omitted from API requests. However, any 182 // non-pointer, non-interface field appearing in ForceSendFields will be 183 // sent to the server regardless of whether the field is empty or not. 184 // This may be used to include empty fields in Patch requests. 185 ForceSendFields []string `json:"-"` 186 187 // NullFields is a list of field names (e.g. "NextPageToken") to include 188 // in API requests with the JSON null value. By default, fields with 189 // empty values are omitted from API requests. However, any field with 190 // an empty value appearing in NullFields will be sent to the server as 191 // null. It is an error if a field in this list has a non-empty value. 192 // This may be used to include null fields in Patch requests. 193 NullFields []string `json:"-"` 194 } 195 196 func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) { 197 type NoMethod ListOperationsResponse 198 raw := NoMethod(*s) 199 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 200 } 201 202 // Operation: This resource represents a long-running operation that is 203 // the result of a network API call. 204 type Operation struct { 205 // Done: If the value is `false`, it means the operation is still in 206 // progress. If `true`, the operation is completed, and either `error` 207 // or `response` is available. 208 Done bool `json:"done,omitempty"` 209 210 // Error: The error result of the operation in case of failure or 211 // cancellation. 212 Error *Status `json:"error,omitempty"` 213 214 // Metadata: Service-specific metadata associated with the operation. It 215 // typically contains progress information and common metadata such as 216 // create time. Some services might not provide such metadata. Any 217 // method that returns a long-running operation should document the 218 // metadata type, if any. 219 Metadata googleapi.RawMessage `json:"metadata,omitempty"` 220 221 // Name: The server-assigned name, which is only unique within the same 222 // service that originally returns it. If you use the default HTTP 223 // mapping, the `name` should be a resource name ending with 224 // `operations/{unique_id}`. 225 Name string `json:"name,omitempty"` 226 227 // Response: The normal response of the operation in case of success. If 228 // the original method returns no data on success, such as `Delete`, the 229 // response is `google.protobuf.Empty`. If the original method is 230 // standard `Get`/`Create`/`Update`, the response should be the 231 // resource. For other methods, the response should have the type 232 // `XxxResponse`, where `Xxx` is the original method name. For example, 233 // if the original method name is `TakeSnapshot()`, the inferred 234 // response type is `TakeSnapshotResponse`. 235 Response googleapi.RawMessage `json:"response,omitempty"` 236 237 // ServerResponse contains the HTTP response code and headers from the 238 // server. 239 googleapi.ServerResponse `json:"-"` 240 241 // ForceSendFields is a list of field names (e.g. "Done") to 242 // unconditionally include in API requests. By default, fields with 243 // empty or default values are omitted from API requests. However, any 244 // non-pointer, non-interface field appearing in ForceSendFields will be 245 // sent to the server regardless of whether the field is empty or not. 246 // This may be used to include empty fields in Patch requests. 247 ForceSendFields []string `json:"-"` 248 249 // NullFields is a list of field names (e.g. "Done") to include in API 250 // requests with the JSON null value. By default, fields with empty 251 // values are omitted from API requests. However, any field with an 252 // empty value appearing in NullFields will be sent to the server as 253 // null. It is an error if a field in this list has a non-empty value. 254 // This may be used to include null fields in Patch requests. 255 NullFields []string `json:"-"` 256 } 257 258 func (s *Operation) MarshalJSON() ([]byte, error) { 259 type NoMethod Operation 260 raw := NoMethod(*s) 261 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 262 } 263 264 // Status: The `Status` type defines a logical error model that is 265 // suitable for different programming environments, including REST APIs 266 // and RPC APIs. It is used by gRPC (https://github.com/grpc). Each 267 // `Status` message contains three pieces of data: error code, error 268 // message, and error details. You can find out more about this error 269 // model and how to work with it in the API Design Guide 270 // (https://cloud.google.com/apis/design/errors). 271 type Status struct { 272 // Code: The status code, which should be an enum value of 273 // google.rpc.Code. 274 Code int64 `json:"code,omitempty"` 275 276 // Details: A list of messages that carry the error details. There is a 277 // common set of message types for APIs to use. 278 Details []googleapi.RawMessage `json:"details,omitempty"` 279 280 // Message: A developer-facing error message, which should be in 281 // English. Any user-facing error message should be localized and sent 282 // in the google.rpc.Status.details field, or localized by the client. 283 Message string `json:"message,omitempty"` 284 285 // ForceSendFields is a list of field names (e.g. "Code") to 286 // unconditionally include in API requests. By default, fields with 287 // empty or default values are omitted from API requests. However, any 288 // non-pointer, non-interface field appearing in ForceSendFields will be 289 // sent to the server regardless of whether the field is empty or not. 290 // This may be used to include empty fields in Patch requests. 291 ForceSendFields []string `json:"-"` 292 293 // NullFields is a list of field names (e.g. "Code") to include in API 294 // requests with the JSON null value. By default, fields with empty 295 // values are omitted from API requests. However, any field with an 296 // empty value appearing in NullFields will be sent to the server as 297 // null. It is an error if a field in this list has a non-empty value. 298 // This may be used to include null fields in Patch requests. 299 NullFields []string `json:"-"` 300 } 301 302 func (s *Status) MarshalJSON() ([]byte, error) { 303 type NoMethod Status 304 raw := NoMethod(*s) 305 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 306 } 307 308 // method id "baremetalsolution.operations.cancel": 309 310 type OperationsCancelCall struct { 311 s *Service 312 name string 313 canceloperationrequest *CancelOperationRequest 314 urlParams_ gensupport.URLParams 315 ctx_ context.Context 316 header_ http.Header 317 } 318 319 // Cancel: Starts asynchronous cancellation on a long-running operation. 320 // The server makes a best effort to cancel the operation, but success 321 // is not guaranteed. If the server doesn't support this method, it 322 // returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use 323 // Operations.GetOperation or other methods to check whether the 324 // cancellation succeeded or whether the operation completed despite 325 // cancellation. On successful cancellation, the operation is not 326 // deleted; instead, it becomes an operation with an Operation.error 327 // value with a google.rpc.Status.code of 1, corresponding to 328 // `Code.CANCELLED`. 329 // 330 // - name: The name of the operation resource to be cancelled. 331 func (r *OperationsService) Cancel(name string, canceloperationrequest *CancelOperationRequest) *OperationsCancelCall { 332 c := &OperationsCancelCall{s: r.s, urlParams_: make(gensupport.URLParams)} 333 c.name = name 334 c.canceloperationrequest = canceloperationrequest 335 return c 336 } 337 338 // Fields allows partial responses to be retrieved. See 339 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 340 // for more information. 341 func (c *OperationsCancelCall) Fields(s ...googleapi.Field) *OperationsCancelCall { 342 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 343 return c 344 } 345 346 // Context sets the context to be used in this call's Do method. Any 347 // pending HTTP request will be aborted if the provided context is 348 // canceled. 349 func (c *OperationsCancelCall) Context(ctx context.Context) *OperationsCancelCall { 350 c.ctx_ = ctx 351 return c 352 } 353 354 // Header returns an http.Header that can be modified by the caller to 355 // add HTTP headers to the request. 356 func (c *OperationsCancelCall) Header() http.Header { 357 if c.header_ == nil { 358 c.header_ = make(http.Header) 359 } 360 return c.header_ 361 } 362 363 func (c *OperationsCancelCall) doRequest(alt string) (*http.Response, error) { 364 reqHeaders := make(http.Header) 365 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version) 366 for k, v := range c.header_ { 367 reqHeaders[k] = v 368 } 369 reqHeaders.Set("User-Agent", c.s.userAgent()) 370 var body io.Reader = nil 371 body, err := googleapi.WithoutDataWrapper.JSONReader(c.canceloperationrequest) 372 if err != nil { 373 return nil, err 374 } 375 reqHeaders.Set("Content-Type", "application/json") 376 c.urlParams_.Set("alt", alt) 377 c.urlParams_.Set("prettyPrint", "false") 378 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:cancel") 379 urls += "?" + c.urlParams_.Encode() 380 req, err := http.NewRequest("POST", urls, body) 381 if err != nil { 382 return nil, err 383 } 384 req.Header = reqHeaders 385 googleapi.Expand(req.URL, map[string]string{ 386 "name": c.name, 387 }) 388 return gensupport.SendRequest(c.ctx_, c.s.client, req) 389 } 390 391 // Do executes the "baremetalsolution.operations.cancel" call. 392 // Exactly one of *Empty or error will be non-nil. Any non-2xx status 393 // code is an error. Response headers are in either 394 // *Empty.ServerResponse.Header or (if a response was returned at all) 395 // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 396 // check whether the returned error was because http.StatusNotModified 397 // was returned. 398 func (c *OperationsCancelCall) Do(opts ...googleapi.CallOption) (*Empty, error) { 399 gensupport.SetOptions(c.urlParams_, opts...) 400 res, err := c.doRequest("json") 401 if res != nil && res.StatusCode == http.StatusNotModified { 402 if res.Body != nil { 403 res.Body.Close() 404 } 405 return nil, gensupport.WrapError(&googleapi.Error{ 406 Code: res.StatusCode, 407 Header: res.Header, 408 }) 409 } 410 if err != nil { 411 return nil, err 412 } 413 defer googleapi.CloseBody(res) 414 if err := googleapi.CheckResponse(res); err != nil { 415 return nil, gensupport.WrapError(err) 416 } 417 ret := &Empty{ 418 ServerResponse: googleapi.ServerResponse{ 419 Header: res.Header, 420 HTTPStatusCode: res.StatusCode, 421 }, 422 } 423 target := &ret 424 if err := gensupport.DecodeResponse(target, res); err != nil { 425 return nil, err 426 } 427 return ret, nil 428 // { 429 // "description": "Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.", 430 // "flatPath": "v1/operations/{operationsId}:cancel", 431 // "httpMethod": "POST", 432 // "id": "baremetalsolution.operations.cancel", 433 // "parameterOrder": [ 434 // "name" 435 // ], 436 // "parameters": { 437 // "name": { 438 // "description": "The name of the operation resource to be cancelled.", 439 // "location": "path", 440 // "pattern": "^operations/.*$", 441 // "required": true, 442 // "type": "string" 443 // } 444 // }, 445 // "path": "v1/{+name}:cancel", 446 // "request": { 447 // "$ref": "CancelOperationRequest" 448 // }, 449 // "response": { 450 // "$ref": "Empty" 451 // }, 452 // "scopes": [ 453 // "https://www.googleapis.com/auth/cloud-platform" 454 // ] 455 // } 456 457 } 458 459 // method id "baremetalsolution.operations.delete": 460 461 type OperationsDeleteCall struct { 462 s *Service 463 name string 464 urlParams_ gensupport.URLParams 465 ctx_ context.Context 466 header_ http.Header 467 } 468 469 // Delete: Deletes a long-running operation. This method indicates that 470 // the client is no longer interested in the operation result. It does 471 // not cancel the operation. If the server doesn't support this method, 472 // it returns `google.rpc.Code.UNIMPLEMENTED`. 473 // 474 // - name: The name of the operation resource to be deleted. 475 func (r *OperationsService) Delete(name string) *OperationsDeleteCall { 476 c := &OperationsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} 477 c.name = name 478 return c 479 } 480 481 // Fields allows partial responses to be retrieved. See 482 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 483 // for more information. 484 func (c *OperationsDeleteCall) Fields(s ...googleapi.Field) *OperationsDeleteCall { 485 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 486 return c 487 } 488 489 // Context sets the context to be used in this call's Do method. Any 490 // pending HTTP request will be aborted if the provided context is 491 // canceled. 492 func (c *OperationsDeleteCall) Context(ctx context.Context) *OperationsDeleteCall { 493 c.ctx_ = ctx 494 return c 495 } 496 497 // Header returns an http.Header that can be modified by the caller to 498 // add HTTP headers to the request. 499 func (c *OperationsDeleteCall) Header() http.Header { 500 if c.header_ == nil { 501 c.header_ = make(http.Header) 502 } 503 return c.header_ 504 } 505 506 func (c *OperationsDeleteCall) doRequest(alt string) (*http.Response, error) { 507 reqHeaders := make(http.Header) 508 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version) 509 for k, v := range c.header_ { 510 reqHeaders[k] = v 511 } 512 reqHeaders.Set("User-Agent", c.s.userAgent()) 513 var body io.Reader = nil 514 c.urlParams_.Set("alt", alt) 515 c.urlParams_.Set("prettyPrint", "false") 516 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") 517 urls += "?" + c.urlParams_.Encode() 518 req, err := http.NewRequest("DELETE", urls, body) 519 if err != nil { 520 return nil, err 521 } 522 req.Header = reqHeaders 523 googleapi.Expand(req.URL, map[string]string{ 524 "name": c.name, 525 }) 526 return gensupport.SendRequest(c.ctx_, c.s.client, req) 527 } 528 529 // Do executes the "baremetalsolution.operations.delete" call. 530 // Exactly one of *Empty or error will be non-nil. Any non-2xx status 531 // code is an error. Response headers are in either 532 // *Empty.ServerResponse.Header or (if a response was returned at all) 533 // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 534 // check whether the returned error was because http.StatusNotModified 535 // was returned. 536 func (c *OperationsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { 537 gensupport.SetOptions(c.urlParams_, opts...) 538 res, err := c.doRequest("json") 539 if res != nil && res.StatusCode == http.StatusNotModified { 540 if res.Body != nil { 541 res.Body.Close() 542 } 543 return nil, gensupport.WrapError(&googleapi.Error{ 544 Code: res.StatusCode, 545 Header: res.Header, 546 }) 547 } 548 if err != nil { 549 return nil, err 550 } 551 defer googleapi.CloseBody(res) 552 if err := googleapi.CheckResponse(res); err != nil { 553 return nil, gensupport.WrapError(err) 554 } 555 ret := &Empty{ 556 ServerResponse: googleapi.ServerResponse{ 557 Header: res.Header, 558 HTTPStatusCode: res.StatusCode, 559 }, 560 } 561 target := &ret 562 if err := gensupport.DecodeResponse(target, res); err != nil { 563 return nil, err 564 } 565 return ret, nil 566 // { 567 // "description": "Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.", 568 // "flatPath": "v1/operations/{operationsId}", 569 // "httpMethod": "DELETE", 570 // "id": "baremetalsolution.operations.delete", 571 // "parameterOrder": [ 572 // "name" 573 // ], 574 // "parameters": { 575 // "name": { 576 // "description": "The name of the operation resource to be deleted.", 577 // "location": "path", 578 // "pattern": "^operations/.*$", 579 // "required": true, 580 // "type": "string" 581 // } 582 // }, 583 // "path": "v1/{+name}", 584 // "response": { 585 // "$ref": "Empty" 586 // }, 587 // "scopes": [ 588 // "https://www.googleapis.com/auth/cloud-platform" 589 // ] 590 // } 591 592 } 593 594 // method id "baremetalsolution.operations.get": 595 596 type OperationsGetCall struct { 597 s *Service 598 name string 599 urlParams_ gensupport.URLParams 600 ifNoneMatch_ string 601 ctx_ context.Context 602 header_ http.Header 603 } 604 605 // Get: Gets the latest state of a long-running operation. Clients can 606 // use this method to poll the operation result at intervals as 607 // recommended by the API service. 608 // 609 // - name: The name of the operation resource. 610 func (r *OperationsService) Get(name string) *OperationsGetCall { 611 c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 612 c.name = name 613 return c 614 } 615 616 // Fields allows partial responses to be retrieved. See 617 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 618 // for more information. 619 func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall { 620 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 621 return c 622 } 623 624 // IfNoneMatch sets the optional parameter which makes the operation 625 // fail if the object's ETag matches the given value. This is useful for 626 // getting updates only after the object has changed since the last 627 // request. Use googleapi.IsNotModified to check whether the response 628 // error from Do is the result of In-None-Match. 629 func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall { 630 c.ifNoneMatch_ = entityTag 631 return c 632 } 633 634 // Context sets the context to be used in this call's Do method. Any 635 // pending HTTP request will be aborted if the provided context is 636 // canceled. 637 func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall { 638 c.ctx_ = ctx 639 return c 640 } 641 642 // Header returns an http.Header that can be modified by the caller to 643 // add HTTP headers to the request. 644 func (c *OperationsGetCall) Header() http.Header { 645 if c.header_ == nil { 646 c.header_ = make(http.Header) 647 } 648 return c.header_ 649 } 650 651 func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) { 652 reqHeaders := make(http.Header) 653 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version) 654 for k, v := range c.header_ { 655 reqHeaders[k] = v 656 } 657 reqHeaders.Set("User-Agent", c.s.userAgent()) 658 if c.ifNoneMatch_ != "" { 659 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 660 } 661 var body io.Reader = nil 662 c.urlParams_.Set("alt", alt) 663 c.urlParams_.Set("prettyPrint", "false") 664 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") 665 urls += "?" + c.urlParams_.Encode() 666 req, err := http.NewRequest("GET", urls, body) 667 if err != nil { 668 return nil, err 669 } 670 req.Header = reqHeaders 671 googleapi.Expand(req.URL, map[string]string{ 672 "name": c.name, 673 }) 674 return gensupport.SendRequest(c.ctx_, c.s.client, req) 675 } 676 677 // Do executes the "baremetalsolution.operations.get" call. 678 // Exactly one of *Operation or error will be non-nil. Any non-2xx 679 // status code is an error. Response headers are in either 680 // *Operation.ServerResponse.Header or (if a response was returned at 681 // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 682 // to check whether the returned error was because 683 // http.StatusNotModified was returned. 684 func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 685 gensupport.SetOptions(c.urlParams_, opts...) 686 res, err := c.doRequest("json") 687 if res != nil && res.StatusCode == http.StatusNotModified { 688 if res.Body != nil { 689 res.Body.Close() 690 } 691 return nil, gensupport.WrapError(&googleapi.Error{ 692 Code: res.StatusCode, 693 Header: res.Header, 694 }) 695 } 696 if err != nil { 697 return nil, err 698 } 699 defer googleapi.CloseBody(res) 700 if err := googleapi.CheckResponse(res); err != nil { 701 return nil, gensupport.WrapError(err) 702 } 703 ret := &Operation{ 704 ServerResponse: googleapi.ServerResponse{ 705 Header: res.Header, 706 HTTPStatusCode: res.StatusCode, 707 }, 708 } 709 target := &ret 710 if err := gensupport.DecodeResponse(target, res); err != nil { 711 return nil, err 712 } 713 return ret, nil 714 // { 715 // "description": "Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.", 716 // "flatPath": "v1/operations/{operationsId}", 717 // "httpMethod": "GET", 718 // "id": "baremetalsolution.operations.get", 719 // "parameterOrder": [ 720 // "name" 721 // ], 722 // "parameters": { 723 // "name": { 724 // "description": "The name of the operation resource.", 725 // "location": "path", 726 // "pattern": "^operations/.*$", 727 // "required": true, 728 // "type": "string" 729 // } 730 // }, 731 // "path": "v1/{+name}", 732 // "response": { 733 // "$ref": "Operation" 734 // }, 735 // "scopes": [ 736 // "https://www.googleapis.com/auth/cloud-platform" 737 // ] 738 // } 739 740 } 741 742 // method id "baremetalsolution.operations.list": 743 744 type OperationsListCall struct { 745 s *Service 746 name string 747 urlParams_ gensupport.URLParams 748 ifNoneMatch_ string 749 ctx_ context.Context 750 header_ http.Header 751 } 752 753 // List: Lists operations that match the specified filter in the 754 // request. If the server doesn't support this method, it returns 755 // `UNIMPLEMENTED`. NOTE: the `name` binding allows API services to 756 // override the binding to use different resource name schemes, such as 757 // `users/*/operations`. To override the binding, API services can add a 758 // binding such as "/v1/{name=users/*}/operations" to their service 759 // configuration. For backwards compatibility, the default name includes 760 // the operations collection id, however overriding users must ensure 761 // the name binding is the parent resource, without the operations 762 // collection id. 763 // 764 // - name: The name of the operation's parent resource. 765 func (r *OperationsService) List(name string) *OperationsListCall { 766 c := &OperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 767 c.name = name 768 return c 769 } 770 771 // Filter sets the optional parameter "filter": The standard list 772 // filter. 773 func (c *OperationsListCall) Filter(filter string) *OperationsListCall { 774 c.urlParams_.Set("filter", filter) 775 return c 776 } 777 778 // PageSize sets the optional parameter "pageSize": The standard list 779 // page size. 780 func (c *OperationsListCall) PageSize(pageSize int64) *OperationsListCall { 781 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) 782 return c 783 } 784 785 // PageToken sets the optional parameter "pageToken": The standard list 786 // page token. 787 func (c *OperationsListCall) PageToken(pageToken string) *OperationsListCall { 788 c.urlParams_.Set("pageToken", pageToken) 789 return c 790 } 791 792 // Fields allows partial responses to be retrieved. See 793 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 794 // for more information. 795 func (c *OperationsListCall) Fields(s ...googleapi.Field) *OperationsListCall { 796 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 797 return c 798 } 799 800 // IfNoneMatch sets the optional parameter which makes the operation 801 // fail if the object's ETag matches the given value. This is useful for 802 // getting updates only after the object has changed since the last 803 // request. Use googleapi.IsNotModified to check whether the response 804 // error from Do is the result of In-None-Match. 805 func (c *OperationsListCall) IfNoneMatch(entityTag string) *OperationsListCall { 806 c.ifNoneMatch_ = entityTag 807 return c 808 } 809 810 // Context sets the context to be used in this call's Do method. Any 811 // pending HTTP request will be aborted if the provided context is 812 // canceled. 813 func (c *OperationsListCall) Context(ctx context.Context) *OperationsListCall { 814 c.ctx_ = ctx 815 return c 816 } 817 818 // Header returns an http.Header that can be modified by the caller to 819 // add HTTP headers to the request. 820 func (c *OperationsListCall) Header() http.Header { 821 if c.header_ == nil { 822 c.header_ = make(http.Header) 823 } 824 return c.header_ 825 } 826 827 func (c *OperationsListCall) doRequest(alt string) (*http.Response, error) { 828 reqHeaders := make(http.Header) 829 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version) 830 for k, v := range c.header_ { 831 reqHeaders[k] = v 832 } 833 reqHeaders.Set("User-Agent", c.s.userAgent()) 834 if c.ifNoneMatch_ != "" { 835 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 836 } 837 var body io.Reader = nil 838 c.urlParams_.Set("alt", alt) 839 c.urlParams_.Set("prettyPrint", "false") 840 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") 841 urls += "?" + c.urlParams_.Encode() 842 req, err := http.NewRequest("GET", urls, body) 843 if err != nil { 844 return nil, err 845 } 846 req.Header = reqHeaders 847 googleapi.Expand(req.URL, map[string]string{ 848 "name": c.name, 849 }) 850 return gensupport.SendRequest(c.ctx_, c.s.client, req) 851 } 852 853 // Do executes the "baremetalsolution.operations.list" call. 854 // Exactly one of *ListOperationsResponse or error will be non-nil. Any 855 // non-2xx status code is an error. Response headers are in either 856 // *ListOperationsResponse.ServerResponse.Header or (if a response was 857 // returned at all) in error.(*googleapi.Error).Header. Use 858 // googleapi.IsNotModified to check whether the returned error was 859 // because http.StatusNotModified was returned. 860 func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) { 861 gensupport.SetOptions(c.urlParams_, opts...) 862 res, err := c.doRequest("json") 863 if res != nil && res.StatusCode == http.StatusNotModified { 864 if res.Body != nil { 865 res.Body.Close() 866 } 867 return nil, gensupport.WrapError(&googleapi.Error{ 868 Code: res.StatusCode, 869 Header: res.Header, 870 }) 871 } 872 if err != nil { 873 return nil, err 874 } 875 defer googleapi.CloseBody(res) 876 if err := googleapi.CheckResponse(res); err != nil { 877 return nil, gensupport.WrapError(err) 878 } 879 ret := &ListOperationsResponse{ 880 ServerResponse: googleapi.ServerResponse{ 881 Header: res.Header, 882 HTTPStatusCode: res.StatusCode, 883 }, 884 } 885 target := &ret 886 if err := gensupport.DecodeResponse(target, res); err != nil { 887 return nil, err 888 } 889 return ret, nil 890 // { 891 // "description": "Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. To override the binding, API services can add a binding such as `\"/v1/{name=users/*}/operations\"` to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must ensure the name binding is the parent resource, without the operations collection id.", 892 // "flatPath": "v1/operations", 893 // "httpMethod": "GET", 894 // "id": "baremetalsolution.operations.list", 895 // "parameterOrder": [ 896 // "name" 897 // ], 898 // "parameters": { 899 // "filter": { 900 // "description": "The standard list filter.", 901 // "location": "query", 902 // "type": "string" 903 // }, 904 // "name": { 905 // "description": "The name of the operation's parent resource.", 906 // "location": "path", 907 // "pattern": "^operations$", 908 // "required": true, 909 // "type": "string" 910 // }, 911 // "pageSize": { 912 // "description": "The standard list page size.", 913 // "format": "int32", 914 // "location": "query", 915 // "type": "integer" 916 // }, 917 // "pageToken": { 918 // "description": "The standard list page token.", 919 // "location": "query", 920 // "type": "string" 921 // } 922 // }, 923 // "path": "v1/{+name}", 924 // "response": { 925 // "$ref": "ListOperationsResponse" 926 // }, 927 // "scopes": [ 928 // "https://www.googleapis.com/auth/cloud-platform" 929 // ] 930 // } 931 932 } 933 934 // Pages invokes f for each page of results. 935 // A non-nil error returned from f will halt the iteration. 936 // The provided context supersedes any context provided to the Context method. 937 func (c *OperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error { 938 c.ctx_ = ctx 939 defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point 940 for { 941 x, err := c.Do() 942 if err != nil { 943 return err 944 } 945 if err := f(x); err != nil { 946 return err 947 } 948 if x.NextPageToken == "" { 949 return nil 950 } 951 c.PageToken(x.NextPageToken) 952 } 953 } 954