...

Source file src/google.golang.org/api/speech/v2beta/speech-gen.go

Documentation: google.golang.org/api/speech/v2beta

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

View as plain text