// Copyright 2024 Google LLC. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Code generated file. DO NOT EDIT. // Package displayvideo provides access to the Display & Video 360 API. // // For product documentation, see: https://developers.google.com/display-video/ // // # Library status // // These client libraries are officially supported by Google. However, this // library is considered complete and is in maintenance mode. This means // that we will address critical bugs and security issues but will not add // any new features. // // When possible, we recommend using our newer // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) // that are still actively being worked and iterated on. // // # Creating a client // // Usage example: // // import "google.golang.org/api/displayvideo/v4" // ... // ctx := context.Background() // displayvideoService, err := displayvideo.NewService(ctx) // // In this example, Google Application Default Credentials are used for // authentication. For information on how to create and obtain Application // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. // // # Other authentication options // // By default, all available scopes (see "Constants") are used to authenticate. // To restrict scopes, use [google.golang.org/api/option.WithScopes]: // // displayvideoService, err := displayvideo.NewService(ctx, option.WithScopes(displayvideo.DoubleclickbidmanagerScope)) // // To use an API key for authentication (note: some APIs do not support API // keys), use [google.golang.org/api/option.WithAPIKey]: // // displayvideoService, err := displayvideo.NewService(ctx, option.WithAPIKey("AIza...")) // // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth // flow, use [google.golang.org/api/option.WithTokenSource]: // // config := &oauth2.Config{...} // // ... // token, err := config.Exchange(ctx, ...) // displayvideoService, err := displayvideo.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) // // See [google.golang.org/api/option.ClientOption] for details on options. package displayvideo // import "google.golang.org/api/displayvideo/v4" import ( "bytes" "context" "encoding/json" "errors" "fmt" "io" "net/http" "net/url" "strconv" "strings" googleapi "google.golang.org/api/googleapi" internal "google.golang.org/api/internal" gensupport "google.golang.org/api/internal/gensupport" option "google.golang.org/api/option" internaloption "google.golang.org/api/option/internaloption" htransport "google.golang.org/api/transport/http" ) // Always reference these packages, just in case the auto-generated code // below doesn't. var _ = bytes.NewBuffer var _ = strconv.Itoa var _ = fmt.Sprintf var _ = json.NewDecoder var _ = io.Copy var _ = url.Parse var _ = gensupport.MarshalJSON var _ = googleapi.Version var _ = errors.New var _ = strings.Replace var _ = context.Canceled var _ = internaloption.WithDefaultEndpoint var _ = internal.Version const apiId = "displayvideo:v4" const apiName = "displayvideo" const apiVersion = "v4" const basePath = "https://displayvideo.googleapis.com/" const basePathTemplate = "https://displayvideo.UNIVERSE_DOMAIN/" const mtlsBasePath = "https://displayvideo.mtls.googleapis.com/" const defaultUniverseDomain = "googleapis.com" // OAuth2 scopes used by this API. const ( // Create, see, edit, and permanently delete your Display & Video 360 // entities and reports DisplayVideoScope = "https://www.googleapis.com/auth/display-video" // View and manage your reports in DoubleClick Bid Manager DoubleclickbidmanagerScope = "https://www.googleapis.com/auth/doubleclickbidmanager" ) // NewService creates a new Service. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { scopesOption := internaloption.WithDefaultScopes( "https://www.googleapis.com/auth/display-video", "https://www.googleapis.com/auth/doubleclickbidmanager", ) // NOTE: prepend, so we don't override user-specified scopes. opts = append([]option.ClientOption{scopesOption}, opts...) opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) opts = append(opts, internaloption.WithDefaultUniverseDomain(defaultUniverseDomain)) client, endpoint, err := htransport.NewClient(ctx, opts...) if err != nil { return nil, err } s, err := New(client) if err != nil { return nil, err } if endpoint != "" { s.BasePath = endpoint } return s, nil } // New creates a new Service. It uses the provided http.Client for requests. // // Deprecated: please use NewService instead. // To provide a custom HTTP client, use option.WithHTTPClient. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. func New(client *http.Client) (*Service, error) { if client == nil { return nil, errors.New("client is nil") } s := &Service{client: client, BasePath: basePath} s.Media = NewMediaService(s) s.Sdfdownloadtasks = NewSdfdownloadtasksService(s) return s, nil } type Service struct { client *http.Client BasePath string // API endpoint base URL UserAgent string // optional additional User-Agent fragment Media *MediaService Sdfdownloadtasks *SdfdownloadtasksService } func (s *Service) userAgent() string { if s.UserAgent == "" { return googleapi.UserAgent } return googleapi.UserAgent + " " + s.UserAgent } func NewMediaService(s *Service) *MediaService { rs := &MediaService{s: s} return rs } type MediaService struct { s *Service } func NewSdfdownloadtasksService(s *Service) *SdfdownloadtasksService { rs := &SdfdownloadtasksService{s: s} rs.Operations = NewSdfdownloadtasksOperationsService(s) return rs } type SdfdownloadtasksService struct { s *Service Operations *SdfdownloadtasksOperationsService } func NewSdfdownloadtasksOperationsService(s *Service) *SdfdownloadtasksOperationsService { rs := &SdfdownloadtasksOperationsService{s: s} return rs } type SdfdownloadtasksOperationsService struct { s *Service } // GoogleBytestreamMedia: Media resource. type GoogleBytestreamMedia struct { // ResourceName: Name of the media resource. ResourceName string `json:"resourceName,omitempty"` // ServerResponse contains the HTTP response code and headers from the // server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "ResourceName") to // unconditionally include in API requests. By default, fields with // empty or default values are omitted from API requests. However, any // non-pointer, non-interface field appearing in ForceSendFields will be // sent to the server regardless of whether the field is empty or not. // This may be used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "ResourceName") to include // in API requests with the JSON null value. By default, fields with // empty values are omitted from API requests. However, any field with // an empty value appearing in NullFields will be sent to the server as // null. It is an error if a field in this list has a non-empty value. // This may be used to include null fields in Patch requests. NullFields []string `json:"-"` } func (s *GoogleBytestreamMedia) MarshalJSON() ([]byte, error) { type NoMethod GoogleBytestreamMedia raw := NoMethod(*s) return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // Operation: This resource represents a long-running operation that is // the result of a network API call. type Operation struct { // Done: If the value is `false`, it means the operation is still in // progress. If `true`, the operation is completed, and either `error` // or `response` is available. Done bool `json:"done,omitempty"` // Error: The error result of the operation in case of failure or // cancellation. Error *Status `json:"error,omitempty"` // Metadata: Service-specific metadata associated with the operation. It // typically contains progress information and common metadata such as // create time. Some services might not provide such metadata. Any // method that returns a long-running operation should document the // metadata type, if any. Metadata googleapi.RawMessage `json:"metadata,omitempty"` // Name: The server-assigned name, which is only unique within the same // service that originally returns it. If you use the default HTTP // mapping, the `name` should be a resource name ending with // `operations/{unique_id}`. Name string `json:"name,omitempty"` // Response: The normal, successful response of the operation. If the // original method returns no data on success, such as `Delete`, the // response is `google.protobuf.Empty`. If the original method is // standard `Get`/`Create`/`Update`, the response should be the // resource. For other methods, the response should have the type // `XxxResponse`, where `Xxx` is the original method name. For example, // if the original method name is `TakeSnapshot()`, the inferred // response type is `TakeSnapshotResponse`. Response googleapi.RawMessage `json:"response,omitempty"` // ServerResponse contains the HTTP response code and headers from the // server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "Done") to // unconditionally include in API requests. By default, fields with // empty or default values are omitted from API requests. However, any // non-pointer, non-interface field appearing in ForceSendFields will be // sent to the server regardless of whether the field is empty or not. // This may be used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Done") to include in API // requests with the JSON null value. By default, fields with empty // values are omitted from API requests. However, any field with an // empty value appearing in NullFields will be sent to the server as // null. It is an error if a field in this list has a non-empty value. // This may be used to include null fields in Patch requests. NullFields []string `json:"-"` } func (s *Operation) MarshalJSON() ([]byte, error) { type NoMethod Operation raw := NoMethod(*s) return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // Status: The `Status` type defines a logical error model that is // suitable for different programming environments, including REST APIs // and RPC APIs. It is used by gRPC (https://github.com/grpc). Each // `Status` message contains three pieces of data: error code, error // message, and error details. You can find out more about this error // model and how to work with it in the API Design Guide // (https://cloud.google.com/apis/design/errors). type Status struct { // Code: The status code, which should be an enum value of // google.rpc.Code. Code int64 `json:"code,omitempty"` // Details: A list of messages that carry the error details. There is a // common set of message types for APIs to use. Details []googleapi.RawMessage `json:"details,omitempty"` // Message: A developer-facing error message, which should be in // English. Any user-facing error message should be localized and sent // in the google.rpc.Status.details field, or localized by the client. Message string `json:"message,omitempty"` // ForceSendFields is a list of field names (e.g. "Code") to // unconditionally include in API requests. By default, fields with // empty or default values are omitted from API requests. However, any // non-pointer, non-interface field appearing in ForceSendFields will be // sent to the server regardless of whether the field is empty or not. // This may be used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Code") to include in API // requests with the JSON null value. By default, fields with empty // values are omitted from API requests. However, any field with an // empty value appearing in NullFields will be sent to the server as // null. It is an error if a field in this list has a non-empty value. // This may be used to include null fields in Patch requests. NullFields []string `json:"-"` } func (s *Status) MarshalJSON() ([]byte, error) { type NoMethod Status raw := NoMethod(*s) return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) } // method id "displayvideo.media.download": type MediaDownloadCall struct { s *Service resourceName string urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context header_ http.Header } // Download: 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. // // - resourceName: Name of the media that is being downloaded. See // ReadRequest.resource_name. func (r *MediaService) Download(resourceName string) *MediaDownloadCall { c := &MediaDownloadCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.resourceName = resourceName return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. func (c *MediaDownloadCall) Fields(s ...googleapi.Field) *MediaDownloadCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // IfNoneMatch sets the optional parameter which makes the operation // fail if the object's ETag matches the given value. This is useful for // getting updates only after the object has changed since the last // request. Use googleapi.IsNotModified to check whether the response // error from Do is the result of In-None-Match. func (c *MediaDownloadCall) IfNoneMatch(entityTag string) *MediaDownloadCall { c.ifNoneMatch_ = entityTag return c } // Context sets the context to be used in this call's Do and Download // methods. Any pending HTTP request will be aborted if the provided // context is canceled. func (c *MediaDownloadCall) Context(ctx context.Context) *MediaDownloadCall { c.ctx_ = ctx return c } // Header returns an http.Header that can be modified by the caller to // add HTTP headers to the request. func (c *MediaDownloadCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *MediaDownloadCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version) for k, v := range c.header_ { reqHeaders[k] = v } reqHeaders.Set("User-Agent", c.s.userAgent()) if c.ifNoneMatch_ != "" { reqHeaders.Set("If-None-Match", c.ifNoneMatch_) } var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "download/{+resourceName}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "resourceName": c.resourceName, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Download fetches the API endpoint's "media" value, instead of the normal // API response value. If the returned error is nil, the Response is guaranteed to // have a 2xx status code. Callers must close the Response.Body as usual. func (c *MediaDownloadCall) Download(opts ...googleapi.CallOption) (*http.Response, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("media") if err != nil { return nil, err } if err := googleapi.CheckResponse(res); err != nil { res.Body.Close() return nil, gensupport.WrapError(err) } return res, nil } // Do executes the "displayvideo.media.download" call. // Exactly one of *GoogleBytestreamMedia or error will be non-nil. Any // non-2xx status code is an error. Response headers are in either // *GoogleBytestreamMedia.ServerResponse.Header or (if a response was // returned at all) in error.(*googleapi.Error).Header. Use // googleapi.IsNotModified to check whether the returned error was // because http.StatusNotModified was returned. func (c *MediaDownloadCall) Do(opts ...googleapi.CallOption) (*GoogleBytestreamMedia, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &GoogleBytestreamMedia{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil // { // "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.", // "flatPath": "download/{downloadId}", // "httpMethod": "GET", // "id": "displayvideo.media.download", // "parameterOrder": [ // "resourceName" // ], // "parameters": { // "resourceName": { // "description": "Name of the media that is being downloaded. See ReadRequest.resource_name.", // "location": "path", // "pattern": "^.*$", // "required": true, // "type": "string" // } // }, // "path": "download/{+resourceName}", // "response": { // "$ref": "GoogleBytestreamMedia" // }, // "scopes": [ // "https://www.googleapis.com/auth/display-video", // "https://www.googleapis.com/auth/doubleclickbidmanager" // ], // "supportsMediaDownload": true // } } // method id "displayvideo.media.upload": type MediaUploadCall struct { s *Service resourceName string googlebytestreammedia *GoogleBytestreamMedia urlParams_ gensupport.URLParams mediaInfo_ *gensupport.MediaInfo ctx_ context.Context header_ http.Header } // Upload: Uploads media. Upload is supported on the URI // `/upload/media/{resource_name=**}?upload_type=media.` **Note**: // Upload requests will not be successful without including // `upload_type=media` query string. // // - resourceName: Name of the media that is being downloaded. See // ReadRequest.resource_name. func (r *MediaService) Upload(resourceName string, googlebytestreammedia *GoogleBytestreamMedia) *MediaUploadCall { c := &MediaUploadCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.resourceName = resourceName c.googlebytestreammedia = googlebytestreammedia return c } // Media specifies the media to upload in one or more chunks. The chunk // size may be controlled by supplying a MediaOption generated by // googleapi.ChunkSize. The chunk size defaults to // googleapi.DefaultUploadChunkSize.The Content-Type header used in the // upload request will be determined by sniffing the contents of r, // unless a MediaOption generated by googleapi.ContentType is // supplied. // At most one of Media and ResumableMedia may be set. func (c *MediaUploadCall) Media(r io.Reader, options ...googleapi.MediaOption) *MediaUploadCall { c.mediaInfo_ = gensupport.NewInfoFromMedia(r, options) return c } // ResumableMedia specifies the media to upload in chunks and can be // canceled with ctx. // // Deprecated: use Media instead. // // At most one of Media and ResumableMedia may be set. mediaType // identifies the MIME media type of the upload, such as "image/png". If // mediaType is "", it will be auto-detected. The provided ctx will // supersede any context previously provided to the Context method. func (c *MediaUploadCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *MediaUploadCall { c.ctx_ = ctx c.mediaInfo_ = gensupport.NewInfoFromResumableMedia(r, size, mediaType) return c } // ProgressUpdater provides a callback function that will be called // after every chunk. It should be a low-latency function in order to // not slow down the upload operation. This should only be called when // using ResumableMedia (as opposed to Media). func (c *MediaUploadCall) ProgressUpdater(pu googleapi.ProgressUpdater) *MediaUploadCall { c.mediaInfo_.SetProgressUpdater(pu) return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. func (c *MediaUploadCall) Fields(s ...googleapi.Field) *MediaUploadCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // Context sets the context to be used in this call's Do method. Any // pending HTTP request will be aborted if the provided context is // canceled. // This context will supersede any context previously provided to the // ResumableMedia method. func (c *MediaUploadCall) Context(ctx context.Context) *MediaUploadCall { c.ctx_ = ctx return c } // Header returns an http.Header that can be modified by the caller to // add HTTP headers to the request. func (c *MediaUploadCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *MediaUploadCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version) for k, v := range c.header_ { reqHeaders[k] = v } reqHeaders.Set("User-Agent", c.s.userAgent()) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.googlebytestreammedia) if err != nil { return nil, err } reqHeaders.Set("Content-Type", "application/json") c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "media/{+resourceName}") if c.mediaInfo_ != nil { urls = googleapi.ResolveRelative(c.s.BasePath, "/upload/media/{+resourceName}") c.urlParams_.Set("uploadType", c.mediaInfo_.UploadType()) } if body == nil { body = new(bytes.Buffer) reqHeaders.Set("Content-Type", "application/json") } body, getBody, cleanup := c.mediaInfo_.UploadRequest(reqHeaders, body) defer cleanup() urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("POST", urls, body) if err != nil { return nil, err } req.Header = reqHeaders req.GetBody = getBody googleapi.Expand(req.URL, map[string]string{ "resourceName": c.resourceName, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "displayvideo.media.upload" call. // Exactly one of *GoogleBytestreamMedia or error will be non-nil. Any // non-2xx status code is an error. Response headers are in either // *GoogleBytestreamMedia.ServerResponse.Header or (if a response was // returned at all) in error.(*googleapi.Error).Header. Use // googleapi.IsNotModified to check whether the returned error was // because http.StatusNotModified was returned. func (c *MediaUploadCall) Do(opts ...googleapi.CallOption) (*GoogleBytestreamMedia, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } rx := c.mediaInfo_.ResumableUpload(res.Header.Get("Location")) if rx != nil { rx.Client = c.s.client rx.UserAgent = c.s.userAgent() ctx := c.ctx_ if ctx == nil { ctx = context.TODO() } res, err = rx.Upload(ctx) if err != nil { return nil, err } defer res.Body.Close() if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } } ret := &GoogleBytestreamMedia{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil // { // "description": "Uploads media. Upload is supported on the URI `/upload/media/{resource_name=**}?upload_type=media.` **Note**: Upload requests will not be successful without including `upload_type=media` query string.", // "flatPath": "media/{mediaId}", // "httpMethod": "POST", // "id": "displayvideo.media.upload", // "mediaUpload": { // "accept": [ // "*/*" // ], // "protocols": { // "simple": { // "multipart": true, // "path": "/upload/media/{+resourceName}" // } // } // }, // "parameterOrder": [ // "resourceName" // ], // "parameters": { // "resourceName": { // "description": "Name of the media that is being downloaded. See ReadRequest.resource_name.", // "location": "path", // "pattern": "^.*$", // "required": true, // "type": "string" // } // }, // "path": "media/{+resourceName}", // "request": { // "$ref": "GoogleBytestreamMedia" // }, // "response": { // "$ref": "GoogleBytestreamMedia" // }, // "scopes": [ // "https://www.googleapis.com/auth/display-video", // "https://www.googleapis.com/auth/doubleclickbidmanager" // ], // "supportsMediaUpload": true // } } // method id "displayvideo.sdfdownloadtasks.operations.get": type SdfdownloadtasksOperationsGetCall struct { s *Service name string urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context header_ http.Header } // Get: Gets the latest state of an asynchronous SDF download task // operation. Clients should poll this method at intervals of 30 // seconds. // // - name: The name of the operation resource. func (r *SdfdownloadtasksOperationsService) Get(name string) *SdfdownloadtasksOperationsGetCall { c := &SdfdownloadtasksOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse // for more information. func (c *SdfdownloadtasksOperationsGetCall) Fields(s ...googleapi.Field) *SdfdownloadtasksOperationsGetCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // IfNoneMatch sets the optional parameter which makes the operation // fail if the object's ETag matches the given value. This is useful for // getting updates only after the object has changed since the last // request. Use googleapi.IsNotModified to check whether the response // error from Do is the result of In-None-Match. func (c *SdfdownloadtasksOperationsGetCall) IfNoneMatch(entityTag string) *SdfdownloadtasksOperationsGetCall { c.ifNoneMatch_ = entityTag return c } // Context sets the context to be used in this call's Do method. Any // pending HTTP request will be aborted if the provided context is // canceled. func (c *SdfdownloadtasksOperationsGetCall) Context(ctx context.Context) *SdfdownloadtasksOperationsGetCall { c.ctx_ = ctx return c } // Header returns an http.Header that can be modified by the caller to // add HTTP headers to the request. func (c *SdfdownloadtasksOperationsGetCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *SdfdownloadtasksOperationsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version) for k, v := range c.header_ { reqHeaders[k] = v } reqHeaders.Set("User-Agent", c.s.userAgent()) if c.ifNoneMatch_ != "" { reqHeaders.Set("If-None-Match", c.ifNoneMatch_) } var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v4/{+name}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "name": c.name, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "displayvideo.sdfdownloadtasks.operations.get" call. // Exactly one of *Operation or error will be non-nil. Any non-2xx // status code is an error. Response headers are in either // *Operation.ServerResponse.Header or (if a response was returned at // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified // to check whether the returned error was because // http.StatusNotModified was returned. func (c *SdfdownloadtasksOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Operation{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil // { // "description": "Gets the latest state of an asynchronous SDF download task operation. Clients should poll this method at intervals of 30 seconds.", // "flatPath": "v4/sdfdownloadtasks/operations/{operationsId}", // "httpMethod": "GET", // "id": "displayvideo.sdfdownloadtasks.operations.get", // "parameterOrder": [ // "name" // ], // "parameters": { // "name": { // "description": "The name of the operation resource.", // "location": "path", // "pattern": "^sdfdownloadtasks/operations/[^/]+$", // "required": true, // "type": "string" // } // }, // "path": "v4/{+name}", // "response": { // "$ref": "Operation" // }, // "scopes": [ // "https://www.googleapis.com/auth/display-video", // "https://www.googleapis.com/auth/doubleclickbidmanager" // ] // } }