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