...

Source file src/google.golang.org/api/displayvideo/v1beta/displayvideo-gen.go

Documentation: google.golang.org/api/displayvideo/v1beta

     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 displayvideo provides access to the Display & Video 360 API.
     8  //
     9  // For product documentation, see: https://developers.google.com/display-video/
    10  //
    11  // # Creating a client
    12  //
    13  // Usage example:
    14  //
    15  //	import "google.golang.org/api/displayvideo/v1beta"
    16  //	...
    17  //	ctx := context.Background()
    18  //	displayvideoService, err := displayvideo.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  // By default, all available scopes (see "Constants") are used to authenticate. To restrict scopes, use option.WithScopes:
    27  //
    28  //	displayvideoService, err := displayvideo.NewService(ctx, option.WithScopes(displayvideo.DoubleclickbidmanagerScope))
    29  //
    30  // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
    31  //
    32  //	displayvideoService, err := displayvideo.NewService(ctx, option.WithAPIKey("AIza..."))
    33  //
    34  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
    35  //
    36  //	config := &oauth2.Config{...}
    37  //	// ...
    38  //	token, err := config.Exchange(ctx, ...)
    39  //	displayvideoService, err := displayvideo.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    40  //
    41  // See https://godoc.org/google.golang.org/api/option/ for details on options.
    42  package displayvideo // import "google.golang.org/api/displayvideo/v1beta"
    43  
    44  import (
    45  	"bytes"
    46  	"context"
    47  	"encoding/json"
    48  	"errors"
    49  	"fmt"
    50  	"io"
    51  	"net/http"
    52  	"net/url"
    53  	"strconv"
    54  	"strings"
    55  
    56  	googleapi "google.golang.org/api/googleapi"
    57  	gensupport "google.golang.org/api/internal/gensupport"
    58  	option "google.golang.org/api/option"
    59  	internaloption "google.golang.org/api/option/internaloption"
    60  	htransport "google.golang.org/api/transport/http"
    61  )
    62  
    63  // Always reference these packages, just in case the auto-generated code
    64  // below doesn't.
    65  var _ = bytes.NewBuffer
    66  var _ = strconv.Itoa
    67  var _ = fmt.Sprintf
    68  var _ = json.NewDecoder
    69  var _ = io.Copy
    70  var _ = url.Parse
    71  var _ = gensupport.MarshalJSON
    72  var _ = googleapi.Version
    73  var _ = errors.New
    74  var _ = strings.Replace
    75  var _ = context.Canceled
    76  var _ = internaloption.WithDefaultEndpoint
    77  
    78  const apiId = "displayvideo:v1beta"
    79  const apiName = "displayvideo"
    80  const apiVersion = "v1beta"
    81  const basePath = "https://displayvideo.googleapis.com/"
    82  const mtlsBasePath = "https://displayvideo.mtls.googleapis.com/"
    83  
    84  // OAuth2 scopes used by this API.
    85  const (
    86  	// Create, see, edit, and permanently delete your Display & Video 360
    87  	// entities and reports
    88  	DisplayVideoScope = "https://www.googleapis.com/auth/display-video"
    89  
    90  	// View and manage your reports in DoubleClick Bid Manager
    91  	DoubleclickbidmanagerScope = "https://www.googleapis.com/auth/doubleclickbidmanager"
    92  )
    93  
    94  // NewService creates a new Service.
    95  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
    96  	scopesOption := option.WithScopes(
    97  		"https://www.googleapis.com/auth/display-video",
    98  		"https://www.googleapis.com/auth/doubleclickbidmanager",
    99  	)
   100  	// NOTE: prepend, so we don't override user-specified scopes.
   101  	opts = append([]option.ClientOption{scopesOption}, opts...)
   102  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   103  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   104  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   105  	if err != nil {
   106  		return nil, err
   107  	}
   108  	s, err := New(client)
   109  	if err != nil {
   110  		return nil, err
   111  	}
   112  	if endpoint != "" {
   113  		s.BasePath = endpoint
   114  	}
   115  	return s, nil
   116  }
   117  
   118  // New creates a new Service. It uses the provided http.Client for requests.
   119  //
   120  // Deprecated: please use NewService instead.
   121  // To provide a custom HTTP client, use option.WithHTTPClient.
   122  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   123  func New(client *http.Client) (*Service, error) {
   124  	if client == nil {
   125  		return nil, errors.New("client is nil")
   126  	}
   127  	s := &Service{client: client, BasePath: basePath}
   128  	s.Media = NewMediaService(s)
   129  	s.Sdfdownloadtask = NewSdfdownloadtaskService(s)
   130  	s.Sdfdownloadtasks = NewSdfdownloadtasksService(s)
   131  	return s, nil
   132  }
   133  
   134  type Service struct {
   135  	client    *http.Client
   136  	BasePath  string // API endpoint base URL
   137  	UserAgent string // optional additional User-Agent fragment
   138  
   139  	Media *MediaService
   140  
   141  	Sdfdownloadtask *SdfdownloadtaskService
   142  
   143  	Sdfdownloadtasks *SdfdownloadtasksService
   144  }
   145  
   146  func (s *Service) userAgent() string {
   147  	if s.UserAgent == "" {
   148  		return googleapi.UserAgent
   149  	}
   150  	return googleapi.UserAgent + " " + s.UserAgent
   151  }
   152  
   153  func NewMediaService(s *Service) *MediaService {
   154  	rs := &MediaService{s: s}
   155  	return rs
   156  }
   157  
   158  type MediaService struct {
   159  	s *Service
   160  }
   161  
   162  func NewSdfdownloadtaskService(s *Service) *SdfdownloadtaskService {
   163  	rs := &SdfdownloadtaskService{s: s}
   164  	rs.Operations = NewSdfdownloadtaskOperationsService(s)
   165  	return rs
   166  }
   167  
   168  type SdfdownloadtaskService struct {
   169  	s *Service
   170  
   171  	Operations *SdfdownloadtaskOperationsService
   172  }
   173  
   174  func NewSdfdownloadtaskOperationsService(s *Service) *SdfdownloadtaskOperationsService {
   175  	rs := &SdfdownloadtaskOperationsService{s: s}
   176  	return rs
   177  }
   178  
   179  type SdfdownloadtaskOperationsService struct {
   180  	s *Service
   181  }
   182  
   183  func NewSdfdownloadtasksService(s *Service) *SdfdownloadtasksService {
   184  	rs := &SdfdownloadtasksService{s: s}
   185  	rs.Operations = NewSdfdownloadtasksOperationsService(s)
   186  	return rs
   187  }
   188  
   189  type SdfdownloadtasksService struct {
   190  	s *Service
   191  
   192  	Operations *SdfdownloadtasksOperationsService
   193  }
   194  
   195  func NewSdfdownloadtasksOperationsService(s *Service) *SdfdownloadtasksOperationsService {
   196  	rs := &SdfdownloadtasksOperationsService{s: s}
   197  	return rs
   198  }
   199  
   200  type SdfdownloadtasksOperationsService struct {
   201  	s *Service
   202  }
   203  
   204  // GoogleBytestreamMedia: Media resource.
   205  type GoogleBytestreamMedia struct {
   206  	// ResourceName: Name of the media resource.
   207  	ResourceName string `json:"resourceName,omitempty"`
   208  
   209  	// ServerResponse contains the HTTP response code and headers from the
   210  	// server.
   211  	googleapi.ServerResponse `json:"-"`
   212  
   213  	// ForceSendFields is a list of field names (e.g. "ResourceName") to
   214  	// unconditionally include in API requests. By default, fields with
   215  	// empty values are omitted from API requests. However, any non-pointer,
   216  	// non-interface field appearing in ForceSendFields will be sent to the
   217  	// server regardless of whether the field is empty or not. This may be
   218  	// used to include empty fields in Patch requests.
   219  	ForceSendFields []string `json:"-"`
   220  
   221  	// NullFields is a list of field names (e.g. "ResourceName") to include
   222  	// in API requests with the JSON null value. By default, fields with
   223  	// empty values are omitted from API requests. However, any field with
   224  	// an empty value appearing in NullFields will be sent to the server as
   225  	// null. It is an error if a field in this list has a non-empty value.
   226  	// This may be used to include null fields in Patch requests.
   227  	NullFields []string `json:"-"`
   228  }
   229  
   230  func (s *GoogleBytestreamMedia) MarshalJSON() ([]byte, error) {
   231  	type NoMethod GoogleBytestreamMedia
   232  	raw := NoMethod(*s)
   233  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   234  }
   235  
   236  // Operation: This resource represents a long-running operation that is
   237  // the result of a network API call.
   238  type Operation struct {
   239  	// Done: If the value is `false`, it means the operation is still in
   240  	// progress. If `true`, the operation is completed, and either `error`
   241  	// or `response` is available.
   242  	Done bool `json:"done,omitempty"`
   243  
   244  	// Error: The error result of the operation in case of failure or
   245  	// cancellation.
   246  	Error *Status `json:"error,omitempty"`
   247  
   248  	// Metadata: Service-specific metadata associated with the operation. It
   249  	// typically contains progress information and common metadata such as
   250  	// create time. Some services might not provide such metadata. Any
   251  	// method that returns a long-running operation should document the
   252  	// metadata type, if any.
   253  	Metadata googleapi.RawMessage `json:"metadata,omitempty"`
   254  
   255  	// Name: The server-assigned name, which is only unique within the same
   256  	// service that originally returns it. If you use the default HTTP
   257  	// mapping, the `name` should be a resource name ending with
   258  	// `operations/{unique_id}`.
   259  	Name string `json:"name,omitempty"`
   260  
   261  	// Response: The normal response of the operation in case of success. If
   262  	// the original method returns no data on success, such as `Delete`, the
   263  	// response is `google.protobuf.Empty`. If the original method is
   264  	// standard `Get`/`Create`/`Update`, the response should be the
   265  	// resource. For other methods, the response should have the type
   266  	// `XxxResponse`, where `Xxx` is the original method name. For example,
   267  	// if the original method name is `TakeSnapshot()`, the inferred
   268  	// response type is `TakeSnapshotResponse`.
   269  	Response googleapi.RawMessage `json:"response,omitempty"`
   270  
   271  	// ServerResponse contains the HTTP response code and headers from the
   272  	// server.
   273  	googleapi.ServerResponse `json:"-"`
   274  
   275  	// ForceSendFields is a list of field names (e.g. "Done") to
   276  	// unconditionally include in API requests. By default, fields with
   277  	// empty values are omitted from API requests. However, any non-pointer,
   278  	// non-interface field appearing in ForceSendFields will be sent to the
   279  	// server regardless of whether the field is empty or not. This may be
   280  	// used to include empty fields in Patch requests.
   281  	ForceSendFields []string `json:"-"`
   282  
   283  	// NullFields is a list of field names (e.g. "Done") to include in API
   284  	// requests with the JSON null value. By default, fields with empty
   285  	// values are omitted from API requests. However, any field with an
   286  	// empty value appearing in NullFields will be sent to the server as
   287  	// null. It is an error if a field in this list has a non-empty value.
   288  	// This may be used to include null fields in Patch requests.
   289  	NullFields []string `json:"-"`
   290  }
   291  
   292  func (s *Operation) MarshalJSON() ([]byte, error) {
   293  	type NoMethod Operation
   294  	raw := NoMethod(*s)
   295  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   296  }
   297  
   298  // Status: The `Status` type defines a logical error model that is
   299  // suitable for different programming environments, including REST APIs
   300  // and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each
   301  // `Status` message contains three pieces of data: error code, error
   302  // message, and error details. You can find out more about this error
   303  // model and how to work with it in the [API Design
   304  // Guide](https://cloud.google.com/apis/design/errors).
   305  type Status struct {
   306  	// Code: The status code, which should be an enum value of
   307  	// google.rpc.Code.
   308  	Code int64 `json:"code,omitempty"`
   309  
   310  	// Details: A list of messages that carry the error details. There is a
   311  	// common set of message types for APIs to use.
   312  	Details []googleapi.RawMessage `json:"details,omitempty"`
   313  
   314  	// Message: A developer-facing error message, which should be in
   315  	// English. Any user-facing error message should be localized and sent
   316  	// in the google.rpc.Status.details field, or localized by the client.
   317  	Message string `json:"message,omitempty"`
   318  
   319  	// ForceSendFields is a list of field names (e.g. "Code") to
   320  	// unconditionally include in API requests. By default, fields with
   321  	// empty values are omitted from API requests. However, any non-pointer,
   322  	// non-interface field appearing in ForceSendFields will be sent to the
   323  	// server regardless of whether the field is empty or not. This may be
   324  	// used to include empty fields in Patch requests.
   325  	ForceSendFields []string `json:"-"`
   326  
   327  	// NullFields is a list of field names (e.g. "Code") to include in API
   328  	// requests with the JSON null value. By default, fields with empty
   329  	// values are omitted from API requests. However, any field with an
   330  	// empty value appearing in NullFields will be sent to the server as
   331  	// null. It is an error if a field in this list has a non-empty value.
   332  	// This may be used to include null fields in Patch requests.
   333  	NullFields []string `json:"-"`
   334  }
   335  
   336  func (s *Status) MarshalJSON() ([]byte, error) {
   337  	type NoMethod Status
   338  	raw := NoMethod(*s)
   339  	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
   340  }
   341  
   342  // method id "displayvideo.media.download":
   343  
   344  type MediaDownloadCall struct {
   345  	s            *Service
   346  	resourceName string
   347  	urlParams_   gensupport.URLParams
   348  	ifNoneMatch_ string
   349  	ctx_         context.Context
   350  	header_      http.Header
   351  }
   352  
   353  // Download: Downloads media. Download is supported on the URI
   354  // `/download/{resource_name=**}?alt=media.` **Note**: Download requests
   355  // will not be successful without including `alt=media` query string.
   356  func (r *MediaService) Download(resourceName string) *MediaDownloadCall {
   357  	c := &MediaDownloadCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   358  	c.resourceName = resourceName
   359  	return c
   360  }
   361  
   362  // Fields allows partial responses to be retrieved. See
   363  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   364  // for more information.
   365  func (c *MediaDownloadCall) Fields(s ...googleapi.Field) *MediaDownloadCall {
   366  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   367  	return c
   368  }
   369  
   370  // IfNoneMatch sets the optional parameter which makes the operation
   371  // fail if the object's ETag matches the given value. This is useful for
   372  // getting updates only after the object has changed since the last
   373  // request. Use googleapi.IsNotModified to check whether the response
   374  // error from Do is the result of In-None-Match.
   375  func (c *MediaDownloadCall) IfNoneMatch(entityTag string) *MediaDownloadCall {
   376  	c.ifNoneMatch_ = entityTag
   377  	return c
   378  }
   379  
   380  // Context sets the context to be used in this call's Do and Download
   381  // methods. Any pending HTTP request will be aborted if the provided
   382  // context is canceled.
   383  func (c *MediaDownloadCall) Context(ctx context.Context) *MediaDownloadCall {
   384  	c.ctx_ = ctx
   385  	return c
   386  }
   387  
   388  // Header returns an http.Header that can be modified by the caller to
   389  // add HTTP headers to the request.
   390  func (c *MediaDownloadCall) Header() http.Header {
   391  	if c.header_ == nil {
   392  		c.header_ = make(http.Header)
   393  	}
   394  	return c.header_
   395  }
   396  
   397  func (c *MediaDownloadCall) doRequest(alt string) (*http.Response, error) {
   398  	reqHeaders := make(http.Header)
   399  	reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20201104")
   400  	for k, v := range c.header_ {
   401  		reqHeaders[k] = v
   402  	}
   403  	reqHeaders.Set("User-Agent", c.s.userAgent())
   404  	if c.ifNoneMatch_ != "" {
   405  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   406  	}
   407  	var body io.Reader = nil
   408  	c.urlParams_.Set("alt", alt)
   409  	c.urlParams_.Set("prettyPrint", "false")
   410  	urls := googleapi.ResolveRelative(c.s.BasePath, "download/{+resourceName}")
   411  	urls += "?" + c.urlParams_.Encode()
   412  	req, err := http.NewRequest("GET", urls, body)
   413  	if err != nil {
   414  		return nil, err
   415  	}
   416  	req.Header = reqHeaders
   417  	googleapi.Expand(req.URL, map[string]string{
   418  		"resourceName": c.resourceName,
   419  	})
   420  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   421  }
   422  
   423  // Download fetches the API endpoint's "media" value, instead of the normal
   424  // API response value. If the returned error is nil, the Response is guaranteed to
   425  // have a 2xx status code. Callers must close the Response.Body as usual.
   426  func (c *MediaDownloadCall) Download(opts ...googleapi.CallOption) (*http.Response, error) {
   427  	gensupport.SetOptions(c.urlParams_, opts...)
   428  	res, err := c.doRequest("media")
   429  	if err != nil {
   430  		return nil, err
   431  	}
   432  	if err := googleapi.CheckMediaResponse(res); err != nil {
   433  		res.Body.Close()
   434  		return nil, err
   435  	}
   436  	return res, nil
   437  }
   438  
   439  // Do executes the "displayvideo.media.download" call.
   440  // Exactly one of *GoogleBytestreamMedia or error will be non-nil. Any
   441  // non-2xx status code is an error. Response headers are in either
   442  // *GoogleBytestreamMedia.ServerResponse.Header or (if a response was
   443  // returned at all) in error.(*googleapi.Error).Header. Use
   444  // googleapi.IsNotModified to check whether the returned error was
   445  // because http.StatusNotModified was returned.
   446  func (c *MediaDownloadCall) Do(opts ...googleapi.CallOption) (*GoogleBytestreamMedia, error) {
   447  	gensupport.SetOptions(c.urlParams_, opts...)
   448  	res, err := c.doRequest("json")
   449  	if res != nil && res.StatusCode == http.StatusNotModified {
   450  		if res.Body != nil {
   451  			res.Body.Close()
   452  		}
   453  		return nil, &googleapi.Error{
   454  			Code:   res.StatusCode,
   455  			Header: res.Header,
   456  		}
   457  	}
   458  	if err != nil {
   459  		return nil, err
   460  	}
   461  	defer googleapi.CloseBody(res)
   462  	if err := googleapi.CheckResponse(res); err != nil {
   463  		return nil, err
   464  	}
   465  	ret := &GoogleBytestreamMedia{
   466  		ServerResponse: googleapi.ServerResponse{
   467  			Header:         res.Header,
   468  			HTTPStatusCode: res.StatusCode,
   469  		},
   470  	}
   471  	target := &ret
   472  	if err := gensupport.DecodeResponse(target, res); err != nil {
   473  		return nil, err
   474  	}
   475  	return ret, nil
   476  	// {
   477  	//   "description": "Downloads media. Download is supported on the URI `/download/{resource_name=**}?alt=media.` **Note**: Download requests will not be successful without including `alt=media` query string.",
   478  	//   "flatPath": "download/{downloadId}",
   479  	//   "httpMethod": "GET",
   480  	//   "id": "displayvideo.media.download",
   481  	//   "parameterOrder": [
   482  	//     "resourceName"
   483  	//   ],
   484  	//   "parameters": {
   485  	//     "resourceName": {
   486  	//       "description": "Name of the media that is being downloaded. See ReadRequest.resource_name.",
   487  	//       "location": "path",
   488  	//       "pattern": "^.*$",
   489  	//       "required": true,
   490  	//       "type": "string"
   491  	//     }
   492  	//   },
   493  	//   "path": "download/{+resourceName}",
   494  	//   "response": {
   495  	//     "$ref": "GoogleBytestreamMedia"
   496  	//   },
   497  	//   "scopes": [
   498  	//     "https://www.googleapis.com/auth/display-video",
   499  	//     "https://www.googleapis.com/auth/doubleclickbidmanager"
   500  	//   ],
   501  	//   "supportsMediaDownload": true
   502  	// }
   503  
   504  }
   505  
   506  // method id "displayvideo.sdfdownloadtask.operations.get":
   507  
   508  type SdfdownloadtaskOperationsGetCall struct {
   509  	s            *Service
   510  	name         string
   511  	urlParams_   gensupport.URLParams
   512  	ifNoneMatch_ string
   513  	ctx_         context.Context
   514  	header_      http.Header
   515  }
   516  
   517  // Get: Gets the latest state of an asynchronous SDF download task
   518  // operation. Clients should poll this method at intervals of 30
   519  // seconds.
   520  func (r *SdfdownloadtaskOperationsService) Get(name string) *SdfdownloadtaskOperationsGetCall {
   521  	c := &SdfdownloadtaskOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   522  	c.name = name
   523  	return c
   524  }
   525  
   526  // Fields allows partial responses to be retrieved. See
   527  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   528  // for more information.
   529  func (c *SdfdownloadtaskOperationsGetCall) Fields(s ...googleapi.Field) *SdfdownloadtaskOperationsGetCall {
   530  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   531  	return c
   532  }
   533  
   534  // IfNoneMatch sets the optional parameter which makes the operation
   535  // fail if the object's ETag matches the given value. This is useful for
   536  // getting updates only after the object has changed since the last
   537  // request. Use googleapi.IsNotModified to check whether the response
   538  // error from Do is the result of In-None-Match.
   539  func (c *SdfdownloadtaskOperationsGetCall) IfNoneMatch(entityTag string) *SdfdownloadtaskOperationsGetCall {
   540  	c.ifNoneMatch_ = entityTag
   541  	return c
   542  }
   543  
   544  // Context sets the context to be used in this call's Do method. Any
   545  // pending HTTP request will be aborted if the provided context is
   546  // canceled.
   547  func (c *SdfdownloadtaskOperationsGetCall) Context(ctx context.Context) *SdfdownloadtaskOperationsGetCall {
   548  	c.ctx_ = ctx
   549  	return c
   550  }
   551  
   552  // Header returns an http.Header that can be modified by the caller to
   553  // add HTTP headers to the request.
   554  func (c *SdfdownloadtaskOperationsGetCall) Header() http.Header {
   555  	if c.header_ == nil {
   556  		c.header_ = make(http.Header)
   557  	}
   558  	return c.header_
   559  }
   560  
   561  func (c *SdfdownloadtaskOperationsGetCall) doRequest(alt string) (*http.Response, error) {
   562  	reqHeaders := make(http.Header)
   563  	reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20201104")
   564  	for k, v := range c.header_ {
   565  		reqHeaders[k] = v
   566  	}
   567  	reqHeaders.Set("User-Agent", c.s.userAgent())
   568  	if c.ifNoneMatch_ != "" {
   569  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   570  	}
   571  	var body io.Reader = nil
   572  	c.urlParams_.Set("alt", alt)
   573  	c.urlParams_.Set("prettyPrint", "false")
   574  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}")
   575  	urls += "?" + c.urlParams_.Encode()
   576  	req, err := http.NewRequest("GET", urls, body)
   577  	if err != nil {
   578  		return nil, err
   579  	}
   580  	req.Header = reqHeaders
   581  	googleapi.Expand(req.URL, map[string]string{
   582  		"name": c.name,
   583  	})
   584  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   585  }
   586  
   587  // Do executes the "displayvideo.sdfdownloadtask.operations.get" call.
   588  // Exactly one of *Operation or error will be non-nil. Any non-2xx
   589  // status code is an error. Response headers are in either
   590  // *Operation.ServerResponse.Header or (if a response was returned at
   591  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
   592  // to check whether the returned error was because
   593  // http.StatusNotModified was returned.
   594  func (c *SdfdownloadtaskOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
   595  	gensupport.SetOptions(c.urlParams_, opts...)
   596  	res, err := c.doRequest("json")
   597  	if res != nil && res.StatusCode == http.StatusNotModified {
   598  		if res.Body != nil {
   599  			res.Body.Close()
   600  		}
   601  		return nil, &googleapi.Error{
   602  			Code:   res.StatusCode,
   603  			Header: res.Header,
   604  		}
   605  	}
   606  	if err != nil {
   607  		return nil, err
   608  	}
   609  	defer googleapi.CloseBody(res)
   610  	if err := googleapi.CheckResponse(res); err != nil {
   611  		return nil, err
   612  	}
   613  	ret := &Operation{
   614  		ServerResponse: googleapi.ServerResponse{
   615  			Header:         res.Header,
   616  			HTTPStatusCode: res.StatusCode,
   617  		},
   618  	}
   619  	target := &ret
   620  	if err := gensupport.DecodeResponse(target, res); err != nil {
   621  		return nil, err
   622  	}
   623  	return ret, nil
   624  	// {
   625  	//   "description": "Gets the latest state of an asynchronous SDF download task operation. Clients should poll this method at intervals of 30 seconds.",
   626  	//   "flatPath": "v1beta/sdfdownloadtask/operations/{operationsId}",
   627  	//   "httpMethod": "GET",
   628  	//   "id": "displayvideo.sdfdownloadtask.operations.get",
   629  	//   "parameterOrder": [
   630  	//     "name"
   631  	//   ],
   632  	//   "parameters": {
   633  	//     "name": {
   634  	//       "description": "The name of the operation resource.",
   635  	//       "location": "path",
   636  	//       "pattern": "^sdfdownloadtask/operations/[^/]+$",
   637  	//       "required": true,
   638  	//       "type": "string"
   639  	//     }
   640  	//   },
   641  	//   "path": "v1beta/{+name}",
   642  	//   "response": {
   643  	//     "$ref": "Operation"
   644  	//   },
   645  	//   "scopes": [
   646  	//     "https://www.googleapis.com/auth/display-video",
   647  	//     "https://www.googleapis.com/auth/doubleclickbidmanager"
   648  	//   ]
   649  	// }
   650  
   651  }
   652  
   653  // method id "displayvideo.sdfdownloadtasks.operations.get":
   654  
   655  type SdfdownloadtasksOperationsGetCall struct {
   656  	s            *Service
   657  	name         string
   658  	urlParams_   gensupport.URLParams
   659  	ifNoneMatch_ string
   660  	ctx_         context.Context
   661  	header_      http.Header
   662  }
   663  
   664  // Get: Gets the latest state of an asynchronous SDF download task
   665  // operation. Clients should poll this method at intervals of 30
   666  // seconds.
   667  func (r *SdfdownloadtasksOperationsService) Get(name string) *SdfdownloadtasksOperationsGetCall {
   668  	c := &SdfdownloadtasksOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   669  	c.name = name
   670  	return c
   671  }
   672  
   673  // Fields allows partial responses to be retrieved. See
   674  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   675  // for more information.
   676  func (c *SdfdownloadtasksOperationsGetCall) Fields(s ...googleapi.Field) *SdfdownloadtasksOperationsGetCall {
   677  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   678  	return c
   679  }
   680  
   681  // IfNoneMatch sets the optional parameter which makes the operation
   682  // fail if the object's ETag matches the given value. This is useful for
   683  // getting updates only after the object has changed since the last
   684  // request. Use googleapi.IsNotModified to check whether the response
   685  // error from Do is the result of In-None-Match.
   686  func (c *SdfdownloadtasksOperationsGetCall) IfNoneMatch(entityTag string) *SdfdownloadtasksOperationsGetCall {
   687  	c.ifNoneMatch_ = entityTag
   688  	return c
   689  }
   690  
   691  // Context sets the context to be used in this call's Do method. Any
   692  // pending HTTP request will be aborted if the provided context is
   693  // canceled.
   694  func (c *SdfdownloadtasksOperationsGetCall) Context(ctx context.Context) *SdfdownloadtasksOperationsGetCall {
   695  	c.ctx_ = ctx
   696  	return c
   697  }
   698  
   699  // Header returns an http.Header that can be modified by the caller to
   700  // add HTTP headers to the request.
   701  func (c *SdfdownloadtasksOperationsGetCall) Header() http.Header {
   702  	if c.header_ == nil {
   703  		c.header_ = make(http.Header)
   704  	}
   705  	return c.header_
   706  }
   707  
   708  func (c *SdfdownloadtasksOperationsGetCall) doRequest(alt string) (*http.Response, error) {
   709  	reqHeaders := make(http.Header)
   710  	reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20201104")
   711  	for k, v := range c.header_ {
   712  		reqHeaders[k] = v
   713  	}
   714  	reqHeaders.Set("User-Agent", c.s.userAgent())
   715  	if c.ifNoneMatch_ != "" {
   716  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   717  	}
   718  	var body io.Reader = nil
   719  	c.urlParams_.Set("alt", alt)
   720  	c.urlParams_.Set("prettyPrint", "false")
   721  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta/{+name}")
   722  	urls += "?" + c.urlParams_.Encode()
   723  	req, err := http.NewRequest("GET", urls, body)
   724  	if err != nil {
   725  		return nil, err
   726  	}
   727  	req.Header = reqHeaders
   728  	googleapi.Expand(req.URL, map[string]string{
   729  		"name": c.name,
   730  	})
   731  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   732  }
   733  
   734  // Do executes the "displayvideo.sdfdownloadtasks.operations.get" call.
   735  // Exactly one of *Operation or error will be non-nil. Any non-2xx
   736  // status code is an error. Response headers are in either
   737  // *Operation.ServerResponse.Header or (if a response was returned at
   738  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
   739  // to check whether the returned error was because
   740  // http.StatusNotModified was returned.
   741  func (c *SdfdownloadtasksOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
   742  	gensupport.SetOptions(c.urlParams_, opts...)
   743  	res, err := c.doRequest("json")
   744  	if res != nil && res.StatusCode == http.StatusNotModified {
   745  		if res.Body != nil {
   746  			res.Body.Close()
   747  		}
   748  		return nil, &googleapi.Error{
   749  			Code:   res.StatusCode,
   750  			Header: res.Header,
   751  		}
   752  	}
   753  	if err != nil {
   754  		return nil, err
   755  	}
   756  	defer googleapi.CloseBody(res)
   757  	if err := googleapi.CheckResponse(res); err != nil {
   758  		return nil, err
   759  	}
   760  	ret := &Operation{
   761  		ServerResponse: googleapi.ServerResponse{
   762  			Header:         res.Header,
   763  			HTTPStatusCode: res.StatusCode,
   764  		},
   765  	}
   766  	target := &ret
   767  	if err := gensupport.DecodeResponse(target, res); err != nil {
   768  		return nil, err
   769  	}
   770  	return ret, nil
   771  	// {
   772  	//   "description": "Gets the latest state of an asynchronous SDF download task operation. Clients should poll this method at intervals of 30 seconds.",
   773  	//   "flatPath": "v1beta/sdfdownloadtasks/operations/{operationsId}",
   774  	//   "httpMethod": "GET",
   775  	//   "id": "displayvideo.sdfdownloadtasks.operations.get",
   776  	//   "parameterOrder": [
   777  	//     "name"
   778  	//   ],
   779  	//   "parameters": {
   780  	//     "name": {
   781  	//       "description": "The name of the operation resource.",
   782  	//       "location": "path",
   783  	//       "pattern": "^sdfdownloadtasks/operations/[^/]+$",
   784  	//       "required": true,
   785  	//       "type": "string"
   786  	//     }
   787  	//   },
   788  	//   "path": "v1beta/{+name}",
   789  	//   "response": {
   790  	//     "$ref": "Operation"
   791  	//   },
   792  	//   "scopes": [
   793  	//     "https://www.googleapis.com/auth/display-video",
   794  	//     "https://www.googleapis.com/auth/doubleclickbidmanager"
   795  	//   ]
   796  	// }
   797  
   798  }
   799  

View as plain text