...

Source file src/google.golang.org/api/youtubeanalytics/v2/youtubeanalytics-gen.go

Documentation: google.golang.org/api/youtubeanalytics/v2

     1  // Copyright 2024 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 youtubeanalytics provides access to the YouTube Analytics API.
     8  //
     9  // For product documentation, see: https://developers.google.com/youtube/analytics
    10  //
    11  // # Library status
    12  //
    13  // These client libraries are officially supported by Google. However, this
    14  // library is considered complete and is in maintenance mode. This means
    15  // that we will address critical bugs and security issues but will not add
    16  // any new features.
    17  //
    18  // When possible, we recommend using our newer
    19  // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
    20  // that are still actively being worked and iterated on.
    21  //
    22  // # Creating a client
    23  //
    24  // Usage example:
    25  //
    26  //	import "google.golang.org/api/youtubeanalytics/v2"
    27  //	...
    28  //	ctx := context.Background()
    29  //	youtubeanalyticsService, err := youtubeanalytics.NewService(ctx)
    30  //
    31  // In this example, Google Application Default Credentials are used for
    32  // authentication. For information on how to create and obtain Application
    33  // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    34  //
    35  // # Other authentication options
    36  //
    37  // By default, all available scopes (see "Constants") are used to authenticate.
    38  // To restrict scopes, use [google.golang.org/api/option.WithScopes]:
    39  //
    40  //	youtubeanalyticsService, err := youtubeanalytics.NewService(ctx, option.WithScopes(youtubeanalytics.YtAnalyticsReadonlyScope))
    41  //
    42  // To use an API key for authentication (note: some APIs do not support API
    43  // keys), use [google.golang.org/api/option.WithAPIKey]:
    44  //
    45  //	youtubeanalyticsService, err := youtubeanalytics.NewService(ctx, option.WithAPIKey("AIza..."))
    46  //
    47  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    48  // flow, use [google.golang.org/api/option.WithTokenSource]:
    49  //
    50  //	config := &oauth2.Config{...}
    51  //	// ...
    52  //	token, err := config.Exchange(ctx, ...)
    53  //	youtubeanalyticsService, err := youtubeanalytics.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    54  //
    55  // See [google.golang.org/api/option.ClientOption] for details on options.
    56  package youtubeanalytics // import "google.golang.org/api/youtubeanalytics/v2"
    57  
    58  import (
    59  	"bytes"
    60  	"context"
    61  	"encoding/json"
    62  	"errors"
    63  	"fmt"
    64  	"io"
    65  	"net/http"
    66  	"net/url"
    67  	"strconv"
    68  	"strings"
    69  
    70  	googleapi "google.golang.org/api/googleapi"
    71  	internal "google.golang.org/api/internal"
    72  	gensupport "google.golang.org/api/internal/gensupport"
    73  	option "google.golang.org/api/option"
    74  	internaloption "google.golang.org/api/option/internaloption"
    75  	htransport "google.golang.org/api/transport/http"
    76  )
    77  
    78  // Always reference these packages, just in case the auto-generated code
    79  // below doesn't.
    80  var _ = bytes.NewBuffer
    81  var _ = strconv.Itoa
    82  var _ = fmt.Sprintf
    83  var _ = json.NewDecoder
    84  var _ = io.Copy
    85  var _ = url.Parse
    86  var _ = gensupport.MarshalJSON
    87  var _ = googleapi.Version
    88  var _ = errors.New
    89  var _ = strings.Replace
    90  var _ = context.Canceled
    91  var _ = internaloption.WithDefaultEndpoint
    92  var _ = internal.Version
    93  
    94  const apiId = "youtubeAnalytics:v2"
    95  const apiName = "youtubeAnalytics"
    96  const apiVersion = "v2"
    97  const basePath = "https://youtubeanalytics.googleapis.com/"
    98  const basePathTemplate = "https://youtubeanalytics.UNIVERSE_DOMAIN/"
    99  const mtlsBasePath = "https://youtubeanalytics.mtls.googleapis.com/"
   100  
   101  // OAuth2 scopes used by this API.
   102  const (
   103  	// Manage your YouTube account
   104  	YoutubeScope = "https://www.googleapis.com/auth/youtube"
   105  
   106  	// View your YouTube account
   107  	YoutubeReadonlyScope = "https://www.googleapis.com/auth/youtube.readonly"
   108  
   109  	// View and manage your assets and associated content on YouTube
   110  	YoutubepartnerScope = "https://www.googleapis.com/auth/youtubepartner"
   111  
   112  	// View monetary and non-monetary YouTube Analytics reports for your YouTube
   113  	// content
   114  	YtAnalyticsMonetaryReadonlyScope = "https://www.googleapis.com/auth/yt-analytics-monetary.readonly"
   115  
   116  	// View YouTube Analytics reports for your YouTube content
   117  	YtAnalyticsReadonlyScope = "https://www.googleapis.com/auth/yt-analytics.readonly"
   118  )
   119  
   120  // NewService creates a new Service.
   121  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   122  	scopesOption := internaloption.WithDefaultScopes(
   123  		"https://www.googleapis.com/auth/youtube",
   124  		"https://www.googleapis.com/auth/youtube.readonly",
   125  		"https://www.googleapis.com/auth/youtubepartner",
   126  		"https://www.googleapis.com/auth/yt-analytics-monetary.readonly",
   127  		"https://www.googleapis.com/auth/yt-analytics.readonly",
   128  	)
   129  	// NOTE: prepend, so we don't override user-specified scopes.
   130  	opts = append([]option.ClientOption{scopesOption}, opts...)
   131  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   132  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   133  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   134  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   135  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   136  	if err != nil {
   137  		return nil, err
   138  	}
   139  	s, err := New(client)
   140  	if err != nil {
   141  		return nil, err
   142  	}
   143  	if endpoint != "" {
   144  		s.BasePath = endpoint
   145  	}
   146  	return s, nil
   147  }
   148  
   149  // New creates a new Service. It uses the provided http.Client for requests.
   150  //
   151  // Deprecated: please use NewService instead.
   152  // To provide a custom HTTP client, use option.WithHTTPClient.
   153  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   154  func New(client *http.Client) (*Service, error) {
   155  	if client == nil {
   156  		return nil, errors.New("client is nil")
   157  	}
   158  	s := &Service{client: client, BasePath: basePath}
   159  	s.GroupItems = NewGroupItemsService(s)
   160  	s.Groups = NewGroupsService(s)
   161  	s.Reports = NewReportsService(s)
   162  	return s, nil
   163  }
   164  
   165  type Service struct {
   166  	client    *http.Client
   167  	BasePath  string // API endpoint base URL
   168  	UserAgent string // optional additional User-Agent fragment
   169  
   170  	GroupItems *GroupItemsService
   171  
   172  	Groups *GroupsService
   173  
   174  	Reports *ReportsService
   175  }
   176  
   177  func (s *Service) userAgent() string {
   178  	if s.UserAgent == "" {
   179  		return googleapi.UserAgent
   180  	}
   181  	return googleapi.UserAgent + " " + s.UserAgent
   182  }
   183  
   184  func NewGroupItemsService(s *Service) *GroupItemsService {
   185  	rs := &GroupItemsService{s: s}
   186  	return rs
   187  }
   188  
   189  type GroupItemsService struct {
   190  	s *Service
   191  }
   192  
   193  func NewGroupsService(s *Service) *GroupsService {
   194  	rs := &GroupsService{s: s}
   195  	return rs
   196  }
   197  
   198  type GroupsService struct {
   199  	s *Service
   200  }
   201  
   202  func NewReportsService(s *Service) *ReportsService {
   203  	rs := &ReportsService{s: s}
   204  	return rs
   205  }
   206  
   207  type ReportsService struct {
   208  	s *Service
   209  }
   210  
   211  // EmptyResponse: Empty response.
   212  type EmptyResponse struct {
   213  	// Errors: Apiary error details
   214  	Errors *Errors `json:"errors,omitempty"`
   215  
   216  	// ServerResponse contains the HTTP response code and headers from the server.
   217  	googleapi.ServerResponse `json:"-"`
   218  	// ForceSendFields is a list of field names (e.g. "Errors") to unconditionally
   219  	// include in API requests. By default, fields with empty or default values are
   220  	// omitted from API requests. See
   221  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   222  	// details.
   223  	ForceSendFields []string `json:"-"`
   224  	// NullFields is a list of field names (e.g. "Errors") to include in API
   225  	// requests with the JSON null value. By default, fields with empty values are
   226  	// omitted from API requests. See
   227  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   228  	NullFields []string `json:"-"`
   229  }
   230  
   231  func (s *EmptyResponse) MarshalJSON() ([]byte, error) {
   232  	type NoMethod EmptyResponse
   233  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   234  }
   235  
   236  // ErrorProto: Describes one specific error.
   237  type ErrorProto struct {
   238  	// Argument: Error arguments, to be used when building user-friendly error
   239  	// messages given the error domain and code. Different error codes require
   240  	// different arguments.
   241  	Argument []string `json:"argument,omitempty"`
   242  	// Code: Error code in the error domain. This should correspond to a value of
   243  	// the enum type whose name is in domain. See the core error domain in
   244  	// error_domain.proto.
   245  	Code string `json:"code,omitempty"`
   246  	// DebugInfo: Debugging information, which should not be shared externally.
   247  	DebugInfo string `json:"debugInfo,omitempty"`
   248  	// Domain: Error domain. RoSy services can define their own domain and error
   249  	// codes. This should normally be the name of an enum type, such as:
   250  	// gdata.CoreErrorDomain
   251  	Domain string `json:"domain,omitempty"`
   252  	// ExternalErrorMessage: A short explanation for the error, which can be shared
   253  	// outside Google. Please set domain, code and arguments whenever possible
   254  	// instead of this error message so that external APIs can build safe error
   255  	// messages themselves. External messages built in a RoSy interface will most
   256  	// likely refer to information and concepts that are not available externally
   257  	// and should not be exposed. It is safer if external APIs can understand the
   258  	// errors and decide what the error message should look like.
   259  	ExternalErrorMessage string `json:"externalErrorMessage,omitempty"`
   260  	// Location: Location of the error, as specified by the location type. If
   261  	// location_type is PATH, this should be a path to a field that's relative to
   262  	// the request, using FieldPath notation (net/proto2/util/public/field_path.h).
   263  	// Examples: authenticated_user.gaia_id resource.address[2].country
   264  	Location string `json:"location,omitempty"`
   265  	// Possible values:
   266  	//   "PATH" - location is an xpath-like path pointing to the request field that
   267  	// caused the error.
   268  	//   "OTHER" - other location type which can safely be shared externally.
   269  	//   "PARAMETER" - Location is request parameter. This maps to the {@link
   270  	// PARAMETERS} in {@link MessageLocation}.
   271  	LocationType string `json:"locationType,omitempty"`
   272  	// ForceSendFields is a list of field names (e.g. "Argument") to
   273  	// unconditionally include in API requests. By default, fields with empty or
   274  	// default values are omitted from API requests. See
   275  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   276  	// details.
   277  	ForceSendFields []string `json:"-"`
   278  	// NullFields is a list of field names (e.g. "Argument") to include in API
   279  	// requests with the JSON null value. By default, fields with empty values are
   280  	// omitted from API requests. See
   281  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   282  	NullFields []string `json:"-"`
   283  }
   284  
   285  func (s *ErrorProto) MarshalJSON() ([]byte, error) {
   286  	type NoMethod ErrorProto
   287  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   288  }
   289  
   290  // Errors: Request Error information. The presence of an error field signals
   291  // that the operation has failed.
   292  type Errors struct {
   293  	// Code: Global error code. Deprecated and ignored. Set custom error codes in
   294  	// ErrorProto.domain and ErrorProto.code instead.
   295  	//
   296  	// Possible values:
   297  	//   "BAD_REQUEST"
   298  	//   "FORBIDDEN"
   299  	//   "NOT_FOUND"
   300  	//   "CONFLICT"
   301  	//   "GONE"
   302  	//   "PRECONDITION_FAILED"
   303  	//   "INTERNAL_ERROR"
   304  	//   "SERVICE_UNAVAILABLE"
   305  	Code string `json:"code,omitempty"`
   306  	// Error: Specific error description and codes
   307  	Error []*ErrorProto `json:"error,omitempty"`
   308  	// RequestId: Request identifier generated by the service, which can be used to
   309  	// identify the error in the logs
   310  	RequestId string `json:"requestId,omitempty"`
   311  	// ForceSendFields is a list of field names (e.g. "Code") to unconditionally
   312  	// include in API requests. By default, fields with empty or default values are
   313  	// omitted from API requests. See
   314  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   315  	// details.
   316  	ForceSendFields []string `json:"-"`
   317  	// NullFields is a list of field names (e.g. "Code") to include in API requests
   318  	// with the JSON null value. By default, fields with empty values are omitted
   319  	// from API requests. See
   320  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   321  	NullFields []string `json:"-"`
   322  }
   323  
   324  func (s *Errors) MarshalJSON() ([]byte, error) {
   325  	type NoMethod Errors
   326  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   327  }
   328  
   329  // Group: A group.
   330  type Group struct {
   331  	// ContentDetails: The `contentDetails` object contains additional information
   332  	// about the group, such as the number and type of items that it contains.
   333  	ContentDetails *GroupContentDetails `json:"contentDetails,omitempty"`
   334  	// Errors: Apiary error details
   335  	Errors *Errors `json:"errors,omitempty"`
   336  	// Etag: The Etag of this resource.
   337  	Etag string `json:"etag,omitempty"`
   338  	// Id: The ID that YouTube uses to uniquely identify the group.
   339  	Id string `json:"id,omitempty"`
   340  	// Kind: Identifies the API resource's type. The value will be `youtube#group`.
   341  	Kind string `json:"kind,omitempty"`
   342  	// Snippet: The `snippet` object contains basic information about the group,
   343  	// including its creation date and name.
   344  	Snippet *GroupSnippet `json:"snippet,omitempty"`
   345  
   346  	// ServerResponse contains the HTTP response code and headers from the server.
   347  	googleapi.ServerResponse `json:"-"`
   348  	// ForceSendFields is a list of field names (e.g. "ContentDetails") to
   349  	// unconditionally include in API requests. By default, fields with empty or
   350  	// default values are omitted from API requests. See
   351  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   352  	// details.
   353  	ForceSendFields []string `json:"-"`
   354  	// NullFields is a list of field names (e.g. "ContentDetails") to include in
   355  	// API requests with the JSON null value. By default, fields with empty values
   356  	// are omitted from API requests. See
   357  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   358  	NullFields []string `json:"-"`
   359  }
   360  
   361  func (s *Group) MarshalJSON() ([]byte, error) {
   362  	type NoMethod Group
   363  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   364  }
   365  
   366  // GroupContentDetails: A group's content details.
   367  type GroupContentDetails struct {
   368  	// ItemCount: The number of items in the group.
   369  	ItemCount uint64 `json:"itemCount,omitempty,string"`
   370  	// ItemType: The type of resources that the group contains. Valid values for
   371  	// this property are: * `youtube#channel` * `youtube#playlist` *
   372  	// `youtube#video` * `youtubePartner#asset`
   373  	ItemType string `json:"itemType,omitempty"`
   374  	// ForceSendFields is a list of field names (e.g. "ItemCount") to
   375  	// unconditionally include in API requests. By default, fields with empty or
   376  	// default values are omitted from API requests. See
   377  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   378  	// details.
   379  	ForceSendFields []string `json:"-"`
   380  	// NullFields is a list of field names (e.g. "ItemCount") to include in API
   381  	// requests with the JSON null value. By default, fields with empty values are
   382  	// omitted from API requests. See
   383  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   384  	NullFields []string `json:"-"`
   385  }
   386  
   387  func (s *GroupContentDetails) MarshalJSON() ([]byte, error) {
   388  	type NoMethod GroupContentDetails
   389  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   390  }
   391  
   392  // GroupItem: A group item.
   393  type GroupItem struct {
   394  	// Errors: Apiary error details
   395  	Errors *Errors `json:"errors,omitempty"`
   396  	// Etag: The Etag of this resource.
   397  	Etag string `json:"etag,omitempty"`
   398  	// GroupId: The ID that YouTube uses to uniquely identify the group that
   399  	// contains the item.
   400  	GroupId string `json:"groupId,omitempty"`
   401  	// Id: The ID that YouTube uses to uniquely identify the `channel`, `video`,
   402  	// `playlist`, or `asset` resource that is included in the group. Note that
   403  	// this ID refers specifically to the inclusion of that resource in a
   404  	// particular group and is different than the channel ID, video ID, playlist
   405  	// ID, or asset ID that uniquely identifies the resource itself. The
   406  	// `resource.id` property's value specifies the unique channel, video,
   407  	// playlist, or asset ID.
   408  	Id string `json:"id,omitempty"`
   409  	// Kind: Identifies the API resource's type. The value will be
   410  	// `youtube#groupItem`.
   411  	Kind string `json:"kind,omitempty"`
   412  	// Resource: The `resource` object contains information that identifies the
   413  	// item being added to the group.
   414  	Resource *GroupItemResource `json:"resource,omitempty"`
   415  
   416  	// ServerResponse contains the HTTP response code and headers from the server.
   417  	googleapi.ServerResponse `json:"-"`
   418  	// ForceSendFields is a list of field names (e.g. "Errors") to unconditionally
   419  	// include in API requests. By default, fields with empty or default values are
   420  	// omitted from API requests. See
   421  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   422  	// details.
   423  	ForceSendFields []string `json:"-"`
   424  	// NullFields is a list of field names (e.g. "Errors") to include in API
   425  	// requests with the JSON null value. By default, fields with empty values are
   426  	// omitted from API requests. See
   427  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   428  	NullFields []string `json:"-"`
   429  }
   430  
   431  func (s *GroupItem) MarshalJSON() ([]byte, error) {
   432  	type NoMethod GroupItem
   433  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   434  }
   435  
   436  type GroupItemResource struct {
   437  	// Id: The channel, video, playlist, or asset ID that YouTube uses to uniquely
   438  	// identify the item that is being added to the group.
   439  	Id string `json:"id,omitempty"`
   440  	// Kind: Identifies the type of resource being added to the group. Valid values
   441  	// for this property are: * `youtube#channel` * `youtube#playlist` *
   442  	// `youtube#video` * `youtubePartner#asset`
   443  	Kind string `json:"kind,omitempty"`
   444  	// ForceSendFields is a list of field names (e.g. "Id") to unconditionally
   445  	// include in API requests. By default, fields with empty or default values are
   446  	// omitted from API requests. See
   447  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   448  	// details.
   449  	ForceSendFields []string `json:"-"`
   450  	// NullFields is a list of field names (e.g. "Id") to include in API requests
   451  	// with the JSON null value. By default, fields with empty values are omitted
   452  	// from API requests. See
   453  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   454  	NullFields []string `json:"-"`
   455  }
   456  
   457  func (s *GroupItemResource) MarshalJSON() ([]byte, error) {
   458  	type NoMethod GroupItemResource
   459  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   460  }
   461  
   462  // GroupSnippet: A group snippet.
   463  type GroupSnippet struct {
   464  	// PublishedAt: The date and time that the group was created. The value is
   465  	// specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
   466  	PublishedAt string `json:"publishedAt,omitempty"`
   467  	// Title: The group name. The value must be a non-empty string.
   468  	Title string `json:"title,omitempty"`
   469  	// ForceSendFields is a list of field names (e.g. "PublishedAt") to
   470  	// unconditionally include in API requests. By default, fields with empty or
   471  	// default values are omitted from API requests. See
   472  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   473  	// details.
   474  	ForceSendFields []string `json:"-"`
   475  	// NullFields is a list of field names (e.g. "PublishedAt") to include in API
   476  	// requests with the JSON null value. By default, fields with empty values are
   477  	// omitted from API requests. See
   478  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   479  	NullFields []string `json:"-"`
   480  }
   481  
   482  func (s *GroupSnippet) MarshalJSON() ([]byte, error) {
   483  	type NoMethod GroupSnippet
   484  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   485  }
   486  
   487  // ListGroupItemsResponse: Response message for GroupsService.ListGroupItems.
   488  type ListGroupItemsResponse struct {
   489  	// Errors: Apiary error details
   490  	Errors *Errors `json:"errors,omitempty"`
   491  	// Etag: The Etag of this resource.
   492  	Etag string `json:"etag,omitempty"`
   493  	// Items: A list of groups that match the API request parameters. Each item in
   494  	// the list represents a `groupItem` resource.
   495  	Items []*GroupItem `json:"items,omitempty"`
   496  	// Kind: Identifies the API resource's type. The value will be
   497  	// `youtube#groupItemListResponse`.
   498  	Kind string `json:"kind,omitempty"`
   499  
   500  	// ServerResponse contains the HTTP response code and headers from the server.
   501  	googleapi.ServerResponse `json:"-"`
   502  	// ForceSendFields is a list of field names (e.g. "Errors") to unconditionally
   503  	// include in API requests. By default, fields with empty or default values are
   504  	// omitted from API requests. See
   505  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   506  	// details.
   507  	ForceSendFields []string `json:"-"`
   508  	// NullFields is a list of field names (e.g. "Errors") to include in API
   509  	// requests with the JSON null value. By default, fields with empty values are
   510  	// omitted from API requests. See
   511  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   512  	NullFields []string `json:"-"`
   513  }
   514  
   515  func (s *ListGroupItemsResponse) MarshalJSON() ([]byte, error) {
   516  	type NoMethod ListGroupItemsResponse
   517  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   518  }
   519  
   520  // ListGroupsResponse: Response message for GroupsService.ListGroups.
   521  type ListGroupsResponse struct {
   522  	// Errors: Apiary error details
   523  	Errors *Errors `json:"errors,omitempty"`
   524  	// Etag: The Etag of this resource.
   525  	Etag string `json:"etag,omitempty"`
   526  	// Items: A list of groups that match the API request parameters. Each item in
   527  	// the list represents a `group` resource.
   528  	Items []*Group `json:"items,omitempty"`
   529  	// Kind: Identifies the API resource's type. The value will be
   530  	// `youtube#groupListResponse`.
   531  	Kind string `json:"kind,omitempty"`
   532  	// NextPageToken: The token that can be used as the value of the `pageToken`
   533  	// parameter to retrieve the next page in the result set.
   534  	NextPageToken string `json:"nextPageToken,omitempty"`
   535  
   536  	// ServerResponse contains the HTTP response code and headers from the server.
   537  	googleapi.ServerResponse `json:"-"`
   538  	// ForceSendFields is a list of field names (e.g. "Errors") to unconditionally
   539  	// include in API requests. By default, fields with empty or default values are
   540  	// omitted from API requests. See
   541  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   542  	// details.
   543  	ForceSendFields []string `json:"-"`
   544  	// NullFields is a list of field names (e.g. "Errors") to include in API
   545  	// requests with the JSON null value. By default, fields with empty values are
   546  	// omitted from API requests. See
   547  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   548  	NullFields []string `json:"-"`
   549  }
   550  
   551  func (s *ListGroupsResponse) MarshalJSON() ([]byte, error) {
   552  	type NoMethod ListGroupsResponse
   553  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   554  }
   555  
   556  // QueryResponse: Response message for TargetedQueriesService.Query.
   557  type QueryResponse struct {
   558  	// ColumnHeaders: This value specifies information about the data returned in
   559  	// the `rows` fields. Each item in the `columnHeaders` list identifies a field
   560  	// returned in the `rows` value, which contains a list of comma-delimited data.
   561  	// The `columnHeaders` list will begin with the dimensions specified in the API
   562  	// request, which will be followed by the metrics specified in the API request.
   563  	// The order of both dimensions and metrics will match the ordering in the API
   564  	// request. For example, if the API request contains the parameters
   565  	// `dimensions=ageGroup,gender&metrics=viewerPercentage`, the API response will
   566  	// return columns in this order: `ageGroup`, `gender`, `viewerPercentage`.
   567  	ColumnHeaders []*ResultTableColumnHeader `json:"columnHeaders,omitempty"`
   568  	// Errors: When set, indicates that the operation failed.
   569  	Errors *Errors `json:"errors,omitempty"`
   570  	// Kind: This value specifies the type of data included in the API response.
   571  	// For the query method, the kind property value will be
   572  	// `youtubeAnalytics#resultTable`.
   573  	Kind string `json:"kind,omitempty"`
   574  	// Rows: The list contains all rows of the result table. Each item in the list
   575  	// is an array that contains comma-delimited data corresponding to a single row
   576  	// of data. The order of the comma-delimited data fields will match the order
   577  	// of the columns listed in the `columnHeaders` field. If no data is available
   578  	// for the given query, the `rows` element will be omitted from the response.
   579  	// The response for a query with the `day` dimension will not contain rows for
   580  	// the most recent days.
   581  	Rows [][]interface{} `json:"rows,omitempty"`
   582  
   583  	// ServerResponse contains the HTTP response code and headers from the server.
   584  	googleapi.ServerResponse `json:"-"`
   585  	// ForceSendFields is a list of field names (e.g. "ColumnHeaders") to
   586  	// unconditionally include in API requests. By default, fields with empty or
   587  	// default values are omitted from API requests. See
   588  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   589  	// details.
   590  	ForceSendFields []string `json:"-"`
   591  	// NullFields is a list of field names (e.g. "ColumnHeaders") to include in API
   592  	// requests with the JSON null value. By default, fields with empty values are
   593  	// omitted from API requests. See
   594  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   595  	NullFields []string `json:"-"`
   596  }
   597  
   598  func (s *QueryResponse) MarshalJSON() ([]byte, error) {
   599  	type NoMethod QueryResponse
   600  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   601  }
   602  
   603  // ResultTableColumnHeader: The description of a column of the result table.
   604  type ResultTableColumnHeader struct {
   605  	// ColumnType: The type of the column (`DIMENSION` or `METRIC`).
   606  	ColumnType string `json:"columnType,omitempty"`
   607  	// DataType: The type of the data in the column (`STRING`, `INTEGER`, `FLOAT`,
   608  	// etc.).
   609  	DataType string `json:"dataType,omitempty"`
   610  	// Name: The name of the dimension or metric.
   611  	Name string `json:"name,omitempty"`
   612  	// ForceSendFields is a list of field names (e.g. "ColumnType") to
   613  	// unconditionally include in API requests. By default, fields with empty or
   614  	// default values are omitted from API requests. See
   615  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   616  	// details.
   617  	ForceSendFields []string `json:"-"`
   618  	// NullFields is a list of field names (e.g. "ColumnType") to include in API
   619  	// requests with the JSON null value. By default, fields with empty values are
   620  	// omitted from API requests. See
   621  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   622  	NullFields []string `json:"-"`
   623  }
   624  
   625  func (s *ResultTableColumnHeader) MarshalJSON() ([]byte, error) {
   626  	type NoMethod ResultTableColumnHeader
   627  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   628  }
   629  
   630  type GroupItemsDeleteCall struct {
   631  	s          *Service
   632  	urlParams_ gensupport.URLParams
   633  	ctx_       context.Context
   634  	header_    http.Header
   635  }
   636  
   637  // Delete: Removes an item from a group.
   638  func (r *GroupItemsService) Delete() *GroupItemsDeleteCall {
   639  	c := &GroupItemsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   640  	return c
   641  }
   642  
   643  // Id sets the optional parameter "id": The `id` parameter specifies the
   644  // YouTube group item ID of the group item that is being deleted.
   645  func (c *GroupItemsDeleteCall) Id(id string) *GroupItemsDeleteCall {
   646  	c.urlParams_.Set("id", id)
   647  	return c
   648  }
   649  
   650  // OnBehalfOfContentOwner sets the optional parameter "onBehalfOfContentOwner":
   651  // This parameter can only be used in a properly authorized request. **Note:**
   652  // This parameter is intended exclusively for YouTube content partners that own
   653  // and manage many different YouTube channels. The `onBehalfOfContentOwner`
   654  // parameter indicates that the request's authorization credentials identify a
   655  // YouTube user who is acting on behalf of the content owner specified in the
   656  // parameter value. It allows content owners to authenticate once and get
   657  // access to all their video and channel data, without having to provide
   658  // authentication credentials for each individual channel. The account that the
   659  // user authenticates with must be linked to the specified YouTube content
   660  // owner.
   661  func (c *GroupItemsDeleteCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupItemsDeleteCall {
   662  	c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
   663  	return c
   664  }
   665  
   666  // Fields allows partial responses to be retrieved. See
   667  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   668  // details.
   669  func (c *GroupItemsDeleteCall) Fields(s ...googleapi.Field) *GroupItemsDeleteCall {
   670  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   671  	return c
   672  }
   673  
   674  // Context sets the context to be used in this call's Do method.
   675  func (c *GroupItemsDeleteCall) Context(ctx context.Context) *GroupItemsDeleteCall {
   676  	c.ctx_ = ctx
   677  	return c
   678  }
   679  
   680  // Header returns a http.Header that can be modified by the caller to add
   681  // headers to the request.
   682  func (c *GroupItemsDeleteCall) Header() http.Header {
   683  	if c.header_ == nil {
   684  		c.header_ = make(http.Header)
   685  	}
   686  	return c.header_
   687  }
   688  
   689  func (c *GroupItemsDeleteCall) doRequest(alt string) (*http.Response, error) {
   690  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   691  	var body io.Reader = nil
   692  	c.urlParams_.Set("alt", alt)
   693  	c.urlParams_.Set("prettyPrint", "false")
   694  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groupItems")
   695  	urls += "?" + c.urlParams_.Encode()
   696  	req, err := http.NewRequest("DELETE", urls, body)
   697  	if err != nil {
   698  		return nil, err
   699  	}
   700  	req.Header = reqHeaders
   701  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   702  }
   703  
   704  // Do executes the "youtubeAnalytics.groupItems.delete" call.
   705  // Any non-2xx status code is an error. Response headers are in either
   706  // *EmptyResponse.ServerResponse.Header or (if a response was returned at all)
   707  // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   708  // whether the returned error was because http.StatusNotModified was returned.
   709  func (c *GroupItemsDeleteCall) Do(opts ...googleapi.CallOption) (*EmptyResponse, error) {
   710  	gensupport.SetOptions(c.urlParams_, opts...)
   711  	res, err := c.doRequest("json")
   712  	if res != nil && res.StatusCode == http.StatusNotModified {
   713  		if res.Body != nil {
   714  			res.Body.Close()
   715  		}
   716  		return nil, gensupport.WrapError(&googleapi.Error{
   717  			Code:   res.StatusCode,
   718  			Header: res.Header,
   719  		})
   720  	}
   721  	if err != nil {
   722  		return nil, err
   723  	}
   724  	defer googleapi.CloseBody(res)
   725  	if err := googleapi.CheckResponse(res); err != nil {
   726  		return nil, gensupport.WrapError(err)
   727  	}
   728  	ret := &EmptyResponse{
   729  		ServerResponse: googleapi.ServerResponse{
   730  			Header:         res.Header,
   731  			HTTPStatusCode: res.StatusCode,
   732  		},
   733  	}
   734  	target := &ret
   735  	if err := gensupport.DecodeResponse(target, res); err != nil {
   736  		return nil, err
   737  	}
   738  	return ret, nil
   739  }
   740  
   741  type GroupItemsInsertCall struct {
   742  	s          *Service
   743  	groupitem  *GroupItem
   744  	urlParams_ gensupport.URLParams
   745  	ctx_       context.Context
   746  	header_    http.Header
   747  }
   748  
   749  // Insert: Creates a group item.
   750  func (r *GroupItemsService) Insert(groupitem *GroupItem) *GroupItemsInsertCall {
   751  	c := &GroupItemsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   752  	c.groupitem = groupitem
   753  	return c
   754  }
   755  
   756  // OnBehalfOfContentOwner sets the optional parameter "onBehalfOfContentOwner":
   757  // This parameter can only be used in a properly authorized request. **Note:**
   758  // This parameter is intended exclusively for YouTube content partners that own
   759  // and manage many different YouTube channels. The `onBehalfOfContentOwner`
   760  // parameter indicates that the request's authorization credentials identify a
   761  // YouTube user who is acting on behalf of the content owner specified in the
   762  // parameter value. It allows content owners to authenticate once and get
   763  // access to all their video and channel data, without having to provide
   764  // authentication credentials for each individual channel. The account that the
   765  // user authenticates with must be linked to the specified YouTube content
   766  // owner.
   767  func (c *GroupItemsInsertCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupItemsInsertCall {
   768  	c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
   769  	return c
   770  }
   771  
   772  // Fields allows partial responses to be retrieved. See
   773  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   774  // details.
   775  func (c *GroupItemsInsertCall) Fields(s ...googleapi.Field) *GroupItemsInsertCall {
   776  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   777  	return c
   778  }
   779  
   780  // Context sets the context to be used in this call's Do method.
   781  func (c *GroupItemsInsertCall) Context(ctx context.Context) *GroupItemsInsertCall {
   782  	c.ctx_ = ctx
   783  	return c
   784  }
   785  
   786  // Header returns a http.Header that can be modified by the caller to add
   787  // headers to the request.
   788  func (c *GroupItemsInsertCall) Header() http.Header {
   789  	if c.header_ == nil {
   790  		c.header_ = make(http.Header)
   791  	}
   792  	return c.header_
   793  }
   794  
   795  func (c *GroupItemsInsertCall) doRequest(alt string) (*http.Response, error) {
   796  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   797  	var body io.Reader = nil
   798  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.groupitem)
   799  	if err != nil {
   800  		return nil, err
   801  	}
   802  	c.urlParams_.Set("alt", alt)
   803  	c.urlParams_.Set("prettyPrint", "false")
   804  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groupItems")
   805  	urls += "?" + c.urlParams_.Encode()
   806  	req, err := http.NewRequest("POST", urls, body)
   807  	if err != nil {
   808  		return nil, err
   809  	}
   810  	req.Header = reqHeaders
   811  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   812  }
   813  
   814  // Do executes the "youtubeAnalytics.groupItems.insert" call.
   815  // Any non-2xx status code is an error. Response headers are in either
   816  // *GroupItem.ServerResponse.Header or (if a response was returned at all) in
   817  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   818  // whether the returned error was because http.StatusNotModified was returned.
   819  func (c *GroupItemsInsertCall) Do(opts ...googleapi.CallOption) (*GroupItem, error) {
   820  	gensupport.SetOptions(c.urlParams_, opts...)
   821  	res, err := c.doRequest("json")
   822  	if res != nil && res.StatusCode == http.StatusNotModified {
   823  		if res.Body != nil {
   824  			res.Body.Close()
   825  		}
   826  		return nil, gensupport.WrapError(&googleapi.Error{
   827  			Code:   res.StatusCode,
   828  			Header: res.Header,
   829  		})
   830  	}
   831  	if err != nil {
   832  		return nil, err
   833  	}
   834  	defer googleapi.CloseBody(res)
   835  	if err := googleapi.CheckResponse(res); err != nil {
   836  		return nil, gensupport.WrapError(err)
   837  	}
   838  	ret := &GroupItem{
   839  		ServerResponse: googleapi.ServerResponse{
   840  			Header:         res.Header,
   841  			HTTPStatusCode: res.StatusCode,
   842  		},
   843  	}
   844  	target := &ret
   845  	if err := gensupport.DecodeResponse(target, res); err != nil {
   846  		return nil, err
   847  	}
   848  	return ret, nil
   849  }
   850  
   851  type GroupItemsListCall struct {
   852  	s            *Service
   853  	urlParams_   gensupport.URLParams
   854  	ifNoneMatch_ string
   855  	ctx_         context.Context
   856  	header_      http.Header
   857  }
   858  
   859  // List: Returns a collection of group items that match the API request
   860  // parameters.
   861  func (r *GroupItemsService) List() *GroupItemsListCall {
   862  	c := &GroupItemsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   863  	return c
   864  }
   865  
   866  // GroupId sets the optional parameter "groupId": The `groupId` parameter
   867  // specifies the unique ID of the group for which you want to retrieve group
   868  // items.
   869  func (c *GroupItemsListCall) GroupId(groupId string) *GroupItemsListCall {
   870  	c.urlParams_.Set("groupId", groupId)
   871  	return c
   872  }
   873  
   874  // OnBehalfOfContentOwner sets the optional parameter "onBehalfOfContentOwner":
   875  // This parameter can only be used in a properly authorized request. **Note:**
   876  // This parameter is intended exclusively for YouTube content partners that own
   877  // and manage many different YouTube channels. The `onBehalfOfContentOwner`
   878  // parameter indicates that the request's authorization credentials identify a
   879  // YouTube user who is acting on behalf of the content owner specified in the
   880  // parameter value. It allows content owners to authenticate once and get
   881  // access to all their video and channel data, without having to provide
   882  // authentication credentials for each individual channel. The account that the
   883  // user authenticates with must be linked to the specified YouTube content
   884  // owner.
   885  func (c *GroupItemsListCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupItemsListCall {
   886  	c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
   887  	return c
   888  }
   889  
   890  // Fields allows partial responses to be retrieved. See
   891  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   892  // details.
   893  func (c *GroupItemsListCall) Fields(s ...googleapi.Field) *GroupItemsListCall {
   894  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   895  	return c
   896  }
   897  
   898  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   899  // object's ETag matches the given value. This is useful for getting updates
   900  // only after the object has changed since the last request.
   901  func (c *GroupItemsListCall) IfNoneMatch(entityTag string) *GroupItemsListCall {
   902  	c.ifNoneMatch_ = entityTag
   903  	return c
   904  }
   905  
   906  // Context sets the context to be used in this call's Do method.
   907  func (c *GroupItemsListCall) Context(ctx context.Context) *GroupItemsListCall {
   908  	c.ctx_ = ctx
   909  	return c
   910  }
   911  
   912  // Header returns a http.Header that can be modified by the caller to add
   913  // headers to the request.
   914  func (c *GroupItemsListCall) Header() http.Header {
   915  	if c.header_ == nil {
   916  		c.header_ = make(http.Header)
   917  	}
   918  	return c.header_
   919  }
   920  
   921  func (c *GroupItemsListCall) doRequest(alt string) (*http.Response, error) {
   922  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   923  	if c.ifNoneMatch_ != "" {
   924  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   925  	}
   926  	var body io.Reader = nil
   927  	c.urlParams_.Set("alt", alt)
   928  	c.urlParams_.Set("prettyPrint", "false")
   929  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groupItems")
   930  	urls += "?" + c.urlParams_.Encode()
   931  	req, err := http.NewRequest("GET", urls, body)
   932  	if err != nil {
   933  		return nil, err
   934  	}
   935  	req.Header = reqHeaders
   936  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   937  }
   938  
   939  // Do executes the "youtubeAnalytics.groupItems.list" call.
   940  // Any non-2xx status code is an error. Response headers are in either
   941  // *ListGroupItemsResponse.ServerResponse.Header or (if a response was returned
   942  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   943  // check whether the returned error was because http.StatusNotModified was
   944  // returned.
   945  func (c *GroupItemsListCall) Do(opts ...googleapi.CallOption) (*ListGroupItemsResponse, error) {
   946  	gensupport.SetOptions(c.urlParams_, opts...)
   947  	res, err := c.doRequest("json")
   948  	if res != nil && res.StatusCode == http.StatusNotModified {
   949  		if res.Body != nil {
   950  			res.Body.Close()
   951  		}
   952  		return nil, gensupport.WrapError(&googleapi.Error{
   953  			Code:   res.StatusCode,
   954  			Header: res.Header,
   955  		})
   956  	}
   957  	if err != nil {
   958  		return nil, err
   959  	}
   960  	defer googleapi.CloseBody(res)
   961  	if err := googleapi.CheckResponse(res); err != nil {
   962  		return nil, gensupport.WrapError(err)
   963  	}
   964  	ret := &ListGroupItemsResponse{
   965  		ServerResponse: googleapi.ServerResponse{
   966  			Header:         res.Header,
   967  			HTTPStatusCode: res.StatusCode,
   968  		},
   969  	}
   970  	target := &ret
   971  	if err := gensupport.DecodeResponse(target, res); err != nil {
   972  		return nil, err
   973  	}
   974  	return ret, nil
   975  }
   976  
   977  type GroupsDeleteCall struct {
   978  	s          *Service
   979  	urlParams_ gensupport.URLParams
   980  	ctx_       context.Context
   981  	header_    http.Header
   982  }
   983  
   984  // Delete: Deletes a group.
   985  func (r *GroupsService) Delete() *GroupsDeleteCall {
   986  	c := &GroupsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   987  	return c
   988  }
   989  
   990  // Id sets the optional parameter "id": The `id` parameter specifies the
   991  // YouTube group ID of the group that is being deleted.
   992  func (c *GroupsDeleteCall) Id(id string) *GroupsDeleteCall {
   993  	c.urlParams_.Set("id", id)
   994  	return c
   995  }
   996  
   997  // OnBehalfOfContentOwner sets the optional parameter "onBehalfOfContentOwner":
   998  // This parameter can only be used in a properly authorized request. **Note:**
   999  // This parameter is intended exclusively for YouTube content partners that own
  1000  // and manage many different YouTube channels. The `onBehalfOfContentOwner`
  1001  // parameter indicates that the request's authorization credentials identify a
  1002  // YouTube user who is acting on behalf of the content owner specified in the
  1003  // parameter value. It allows content owners to authenticate once and get
  1004  // access to all their video and channel data, without having to provide
  1005  // authentication credentials for each individual channel. The account that the
  1006  // user authenticates with must be linked to the specified YouTube content
  1007  // owner.
  1008  func (c *GroupsDeleteCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupsDeleteCall {
  1009  	c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
  1010  	return c
  1011  }
  1012  
  1013  // Fields allows partial responses to be retrieved. See
  1014  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1015  // details.
  1016  func (c *GroupsDeleteCall) Fields(s ...googleapi.Field) *GroupsDeleteCall {
  1017  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1018  	return c
  1019  }
  1020  
  1021  // Context sets the context to be used in this call's Do method.
  1022  func (c *GroupsDeleteCall) Context(ctx context.Context) *GroupsDeleteCall {
  1023  	c.ctx_ = ctx
  1024  	return c
  1025  }
  1026  
  1027  // Header returns a http.Header that can be modified by the caller to add
  1028  // headers to the request.
  1029  func (c *GroupsDeleteCall) Header() http.Header {
  1030  	if c.header_ == nil {
  1031  		c.header_ = make(http.Header)
  1032  	}
  1033  	return c.header_
  1034  }
  1035  
  1036  func (c *GroupsDeleteCall) doRequest(alt string) (*http.Response, error) {
  1037  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
  1038  	var body io.Reader = nil
  1039  	c.urlParams_.Set("alt", alt)
  1040  	c.urlParams_.Set("prettyPrint", "false")
  1041  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groups")
  1042  	urls += "?" + c.urlParams_.Encode()
  1043  	req, err := http.NewRequest("DELETE", urls, body)
  1044  	if err != nil {
  1045  		return nil, err
  1046  	}
  1047  	req.Header = reqHeaders
  1048  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1049  }
  1050  
  1051  // Do executes the "youtubeAnalytics.groups.delete" call.
  1052  // Any non-2xx status code is an error. Response headers are in either
  1053  // *EmptyResponse.ServerResponse.Header or (if a response was returned at all)
  1054  // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1055  // whether the returned error was because http.StatusNotModified was returned.
  1056  func (c *GroupsDeleteCall) Do(opts ...googleapi.CallOption) (*EmptyResponse, error) {
  1057  	gensupport.SetOptions(c.urlParams_, opts...)
  1058  	res, err := c.doRequest("json")
  1059  	if res != nil && res.StatusCode == http.StatusNotModified {
  1060  		if res.Body != nil {
  1061  			res.Body.Close()
  1062  		}
  1063  		return nil, gensupport.WrapError(&googleapi.Error{
  1064  			Code:   res.StatusCode,
  1065  			Header: res.Header,
  1066  		})
  1067  	}
  1068  	if err != nil {
  1069  		return nil, err
  1070  	}
  1071  	defer googleapi.CloseBody(res)
  1072  	if err := googleapi.CheckResponse(res); err != nil {
  1073  		return nil, gensupport.WrapError(err)
  1074  	}
  1075  	ret := &EmptyResponse{
  1076  		ServerResponse: googleapi.ServerResponse{
  1077  			Header:         res.Header,
  1078  			HTTPStatusCode: res.StatusCode,
  1079  		},
  1080  	}
  1081  	target := &ret
  1082  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1083  		return nil, err
  1084  	}
  1085  	return ret, nil
  1086  }
  1087  
  1088  type GroupsInsertCall struct {
  1089  	s          *Service
  1090  	group      *Group
  1091  	urlParams_ gensupport.URLParams
  1092  	ctx_       context.Context
  1093  	header_    http.Header
  1094  }
  1095  
  1096  // Insert: Creates a group.
  1097  func (r *GroupsService) Insert(group *Group) *GroupsInsertCall {
  1098  	c := &GroupsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1099  	c.group = group
  1100  	return c
  1101  }
  1102  
  1103  // OnBehalfOfContentOwner sets the optional parameter "onBehalfOfContentOwner":
  1104  // This parameter can only be used in a properly authorized request. **Note:**
  1105  // This parameter is intended exclusively for YouTube content partners that own
  1106  // and manage many different YouTube channels. The `onBehalfOfContentOwner`
  1107  // parameter indicates that the request's authorization credentials identify a
  1108  // YouTube user who is acting on behalf of the content owner specified in the
  1109  // parameter value. It allows content owners to authenticate once and get
  1110  // access to all their video and channel data, without having to provide
  1111  // authentication credentials for each individual channel. The account that the
  1112  // user authenticates with must be linked to the specified YouTube content
  1113  // owner.
  1114  func (c *GroupsInsertCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupsInsertCall {
  1115  	c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
  1116  	return c
  1117  }
  1118  
  1119  // Fields allows partial responses to be retrieved. See
  1120  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1121  // details.
  1122  func (c *GroupsInsertCall) Fields(s ...googleapi.Field) *GroupsInsertCall {
  1123  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1124  	return c
  1125  }
  1126  
  1127  // Context sets the context to be used in this call's Do method.
  1128  func (c *GroupsInsertCall) Context(ctx context.Context) *GroupsInsertCall {
  1129  	c.ctx_ = ctx
  1130  	return c
  1131  }
  1132  
  1133  // Header returns a http.Header that can be modified by the caller to add
  1134  // headers to the request.
  1135  func (c *GroupsInsertCall) Header() http.Header {
  1136  	if c.header_ == nil {
  1137  		c.header_ = make(http.Header)
  1138  	}
  1139  	return c.header_
  1140  }
  1141  
  1142  func (c *GroupsInsertCall) doRequest(alt string) (*http.Response, error) {
  1143  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
  1144  	var body io.Reader = nil
  1145  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.group)
  1146  	if err != nil {
  1147  		return nil, err
  1148  	}
  1149  	c.urlParams_.Set("alt", alt)
  1150  	c.urlParams_.Set("prettyPrint", "false")
  1151  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groups")
  1152  	urls += "?" + c.urlParams_.Encode()
  1153  	req, err := http.NewRequest("POST", urls, body)
  1154  	if err != nil {
  1155  		return nil, err
  1156  	}
  1157  	req.Header = reqHeaders
  1158  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1159  }
  1160  
  1161  // Do executes the "youtubeAnalytics.groups.insert" call.
  1162  // Any non-2xx status code is an error. Response headers are in either
  1163  // *Group.ServerResponse.Header or (if a response was returned at all) in
  1164  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1165  // whether the returned error was because http.StatusNotModified was returned.
  1166  func (c *GroupsInsertCall) Do(opts ...googleapi.CallOption) (*Group, error) {
  1167  	gensupport.SetOptions(c.urlParams_, opts...)
  1168  	res, err := c.doRequest("json")
  1169  	if res != nil && res.StatusCode == http.StatusNotModified {
  1170  		if res.Body != nil {
  1171  			res.Body.Close()
  1172  		}
  1173  		return nil, gensupport.WrapError(&googleapi.Error{
  1174  			Code:   res.StatusCode,
  1175  			Header: res.Header,
  1176  		})
  1177  	}
  1178  	if err != nil {
  1179  		return nil, err
  1180  	}
  1181  	defer googleapi.CloseBody(res)
  1182  	if err := googleapi.CheckResponse(res); err != nil {
  1183  		return nil, gensupport.WrapError(err)
  1184  	}
  1185  	ret := &Group{
  1186  		ServerResponse: googleapi.ServerResponse{
  1187  			Header:         res.Header,
  1188  			HTTPStatusCode: res.StatusCode,
  1189  		},
  1190  	}
  1191  	target := &ret
  1192  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1193  		return nil, err
  1194  	}
  1195  	return ret, nil
  1196  }
  1197  
  1198  type GroupsListCall struct {
  1199  	s            *Service
  1200  	urlParams_   gensupport.URLParams
  1201  	ifNoneMatch_ string
  1202  	ctx_         context.Context
  1203  	header_      http.Header
  1204  }
  1205  
  1206  // List: Returns a collection of groups that match the API request parameters.
  1207  // For example, you can retrieve all groups that the authenticated user owns,
  1208  // or you can retrieve one or more groups by their unique IDs.
  1209  func (r *GroupsService) List() *GroupsListCall {
  1210  	c := &GroupsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1211  	return c
  1212  }
  1213  
  1214  // Id sets the optional parameter "id": The `id` parameter specifies a
  1215  // comma-separated list of the YouTube group ID(s) for the resource(s) that are
  1216  // being retrieved. Each group must be owned by the authenticated user. In a
  1217  // `group` resource, the `id` property specifies the group's YouTube group ID.
  1218  // Note that if you do not specify a value for the `id` parameter, then you
  1219  // must set the `mine` parameter to `true`.
  1220  func (c *GroupsListCall) Id(id string) *GroupsListCall {
  1221  	c.urlParams_.Set("id", id)
  1222  	return c
  1223  }
  1224  
  1225  // Mine sets the optional parameter "mine": This parameter can only be used in
  1226  // a properly authorized request. Set this parameter's value to true to
  1227  // retrieve all groups owned by the authenticated user.
  1228  func (c *GroupsListCall) Mine(mine bool) *GroupsListCall {
  1229  	c.urlParams_.Set("mine", fmt.Sprint(mine))
  1230  	return c
  1231  }
  1232  
  1233  // OnBehalfOfContentOwner sets the optional parameter "onBehalfOfContentOwner":
  1234  // This parameter can only be used in a properly authorized request. **Note:**
  1235  // This parameter is intended exclusively for YouTube content partners that own
  1236  // and manage many different YouTube channels. The `onBehalfOfContentOwner`
  1237  // parameter indicates that the request's authorization credentials identify a
  1238  // YouTube user who is acting on behalf of the content owner specified in the
  1239  // parameter value. It allows content owners to authenticate once and get
  1240  // access to all their video and channel data, without having to provide
  1241  // authentication credentials for each individual channel. The account that the
  1242  // user authenticates with must be linked to the specified YouTube content
  1243  // owner.
  1244  func (c *GroupsListCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupsListCall {
  1245  	c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
  1246  	return c
  1247  }
  1248  
  1249  // PageToken sets the optional parameter "pageToken": The `pageToken` parameter
  1250  // identifies a specific page in the result set that should be returned. In an
  1251  // API response, the `nextPageToken` property identifies the next page that can
  1252  // be retrieved.
  1253  func (c *GroupsListCall) PageToken(pageToken string) *GroupsListCall {
  1254  	c.urlParams_.Set("pageToken", pageToken)
  1255  	return c
  1256  }
  1257  
  1258  // Fields allows partial responses to be retrieved. See
  1259  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1260  // details.
  1261  func (c *GroupsListCall) Fields(s ...googleapi.Field) *GroupsListCall {
  1262  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1263  	return c
  1264  }
  1265  
  1266  // IfNoneMatch sets an optional parameter which makes the operation fail if the
  1267  // object's ETag matches the given value. This is useful for getting updates
  1268  // only after the object has changed since the last request.
  1269  func (c *GroupsListCall) IfNoneMatch(entityTag string) *GroupsListCall {
  1270  	c.ifNoneMatch_ = entityTag
  1271  	return c
  1272  }
  1273  
  1274  // Context sets the context to be used in this call's Do method.
  1275  func (c *GroupsListCall) Context(ctx context.Context) *GroupsListCall {
  1276  	c.ctx_ = ctx
  1277  	return c
  1278  }
  1279  
  1280  // Header returns a http.Header that can be modified by the caller to add
  1281  // headers to the request.
  1282  func (c *GroupsListCall) Header() http.Header {
  1283  	if c.header_ == nil {
  1284  		c.header_ = make(http.Header)
  1285  	}
  1286  	return c.header_
  1287  }
  1288  
  1289  func (c *GroupsListCall) doRequest(alt string) (*http.Response, error) {
  1290  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
  1291  	if c.ifNoneMatch_ != "" {
  1292  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1293  	}
  1294  	var body io.Reader = nil
  1295  	c.urlParams_.Set("alt", alt)
  1296  	c.urlParams_.Set("prettyPrint", "false")
  1297  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groups")
  1298  	urls += "?" + c.urlParams_.Encode()
  1299  	req, err := http.NewRequest("GET", urls, body)
  1300  	if err != nil {
  1301  		return nil, err
  1302  	}
  1303  	req.Header = reqHeaders
  1304  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1305  }
  1306  
  1307  // Do executes the "youtubeAnalytics.groups.list" call.
  1308  // Any non-2xx status code is an error. Response headers are in either
  1309  // *ListGroupsResponse.ServerResponse.Header or (if a response was returned at
  1310  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1311  // check whether the returned error was because http.StatusNotModified was
  1312  // returned.
  1313  func (c *GroupsListCall) Do(opts ...googleapi.CallOption) (*ListGroupsResponse, error) {
  1314  	gensupport.SetOptions(c.urlParams_, opts...)
  1315  	res, err := c.doRequest("json")
  1316  	if res != nil && res.StatusCode == http.StatusNotModified {
  1317  		if res.Body != nil {
  1318  			res.Body.Close()
  1319  		}
  1320  		return nil, gensupport.WrapError(&googleapi.Error{
  1321  			Code:   res.StatusCode,
  1322  			Header: res.Header,
  1323  		})
  1324  	}
  1325  	if err != nil {
  1326  		return nil, err
  1327  	}
  1328  	defer googleapi.CloseBody(res)
  1329  	if err := googleapi.CheckResponse(res); err != nil {
  1330  		return nil, gensupport.WrapError(err)
  1331  	}
  1332  	ret := &ListGroupsResponse{
  1333  		ServerResponse: googleapi.ServerResponse{
  1334  			Header:         res.Header,
  1335  			HTTPStatusCode: res.StatusCode,
  1336  		},
  1337  	}
  1338  	target := &ret
  1339  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1340  		return nil, err
  1341  	}
  1342  	return ret, nil
  1343  }
  1344  
  1345  // Pages invokes f for each page of results.
  1346  // A non-nil error returned from f will halt the iteration.
  1347  // The provided context supersedes any context provided to the Context method.
  1348  func (c *GroupsListCall) Pages(ctx context.Context, f func(*ListGroupsResponse) error) error {
  1349  	c.ctx_ = ctx
  1350  	defer c.PageToken(c.urlParams_.Get("pageToken"))
  1351  	for {
  1352  		x, err := c.Do()
  1353  		if err != nil {
  1354  			return err
  1355  		}
  1356  		if err := f(x); err != nil {
  1357  			return err
  1358  		}
  1359  		if x.NextPageToken == "" {
  1360  			return nil
  1361  		}
  1362  		c.PageToken(x.NextPageToken)
  1363  	}
  1364  }
  1365  
  1366  type GroupsUpdateCall struct {
  1367  	s          *Service
  1368  	group      *Group
  1369  	urlParams_ gensupport.URLParams
  1370  	ctx_       context.Context
  1371  	header_    http.Header
  1372  }
  1373  
  1374  // Update: Modifies a group. For example, you could change a group's title.
  1375  func (r *GroupsService) Update(group *Group) *GroupsUpdateCall {
  1376  	c := &GroupsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1377  	c.group = group
  1378  	return c
  1379  }
  1380  
  1381  // OnBehalfOfContentOwner sets the optional parameter "onBehalfOfContentOwner":
  1382  // This parameter can only be used in a properly authorized request. **Note:**
  1383  // This parameter is intended exclusively for YouTube content partners that own
  1384  // and manage many different YouTube channels. The `onBehalfOfContentOwner`
  1385  // parameter indicates that the request's authorization credentials identify a
  1386  // YouTube user who is acting on behalf of the content owner specified in the
  1387  // parameter value. It allows content owners to authenticate once and get
  1388  // access to all their video and channel data, without having to provide
  1389  // authentication credentials for each individual channel. The account that the
  1390  // user authenticates with must be linked to the specified YouTube content
  1391  // owner.
  1392  func (c *GroupsUpdateCall) OnBehalfOfContentOwner(onBehalfOfContentOwner string) *GroupsUpdateCall {
  1393  	c.urlParams_.Set("onBehalfOfContentOwner", onBehalfOfContentOwner)
  1394  	return c
  1395  }
  1396  
  1397  // Fields allows partial responses to be retrieved. See
  1398  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1399  // details.
  1400  func (c *GroupsUpdateCall) Fields(s ...googleapi.Field) *GroupsUpdateCall {
  1401  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1402  	return c
  1403  }
  1404  
  1405  // Context sets the context to be used in this call's Do method.
  1406  func (c *GroupsUpdateCall) Context(ctx context.Context) *GroupsUpdateCall {
  1407  	c.ctx_ = ctx
  1408  	return c
  1409  }
  1410  
  1411  // Header returns a http.Header that can be modified by the caller to add
  1412  // headers to the request.
  1413  func (c *GroupsUpdateCall) Header() http.Header {
  1414  	if c.header_ == nil {
  1415  		c.header_ = make(http.Header)
  1416  	}
  1417  	return c.header_
  1418  }
  1419  
  1420  func (c *GroupsUpdateCall) doRequest(alt string) (*http.Response, error) {
  1421  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
  1422  	var body io.Reader = nil
  1423  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.group)
  1424  	if err != nil {
  1425  		return nil, err
  1426  	}
  1427  	c.urlParams_.Set("alt", alt)
  1428  	c.urlParams_.Set("prettyPrint", "false")
  1429  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/groups")
  1430  	urls += "?" + c.urlParams_.Encode()
  1431  	req, err := http.NewRequest("PUT", urls, body)
  1432  	if err != nil {
  1433  		return nil, err
  1434  	}
  1435  	req.Header = reqHeaders
  1436  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1437  }
  1438  
  1439  // Do executes the "youtubeAnalytics.groups.update" call.
  1440  // Any non-2xx status code is an error. Response headers are in either
  1441  // *Group.ServerResponse.Header or (if a response was returned at all) in
  1442  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1443  // whether the returned error was because http.StatusNotModified was returned.
  1444  func (c *GroupsUpdateCall) Do(opts ...googleapi.CallOption) (*Group, error) {
  1445  	gensupport.SetOptions(c.urlParams_, opts...)
  1446  	res, err := c.doRequest("json")
  1447  	if res != nil && res.StatusCode == http.StatusNotModified {
  1448  		if res.Body != nil {
  1449  			res.Body.Close()
  1450  		}
  1451  		return nil, gensupport.WrapError(&googleapi.Error{
  1452  			Code:   res.StatusCode,
  1453  			Header: res.Header,
  1454  		})
  1455  	}
  1456  	if err != nil {
  1457  		return nil, err
  1458  	}
  1459  	defer googleapi.CloseBody(res)
  1460  	if err := googleapi.CheckResponse(res); err != nil {
  1461  		return nil, gensupport.WrapError(err)
  1462  	}
  1463  	ret := &Group{
  1464  		ServerResponse: googleapi.ServerResponse{
  1465  			Header:         res.Header,
  1466  			HTTPStatusCode: res.StatusCode,
  1467  		},
  1468  	}
  1469  	target := &ret
  1470  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1471  		return nil, err
  1472  	}
  1473  	return ret, nil
  1474  }
  1475  
  1476  type ReportsQueryCall struct {
  1477  	s            *Service
  1478  	urlParams_   gensupport.URLParams
  1479  	ifNoneMatch_ string
  1480  	ctx_         context.Context
  1481  	header_      http.Header
  1482  }
  1483  
  1484  // Query: Retrieve your YouTube Analytics reports.
  1485  func (r *ReportsService) Query() *ReportsQueryCall {
  1486  	c := &ReportsQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1487  	return c
  1488  }
  1489  
  1490  // Currency sets the optional parameter "currency": The currency to which
  1491  // financial metrics should be converted. The default is US Dollar (USD). If
  1492  // the result contains no financial metrics, this flag will be ignored.
  1493  // Responds with an error if the specified currency is not recognized.",
  1494  // pattern: [A-Z]{3}
  1495  func (c *ReportsQueryCall) Currency(currency string) *ReportsQueryCall {
  1496  	c.urlParams_.Set("currency", currency)
  1497  	return c
  1498  }
  1499  
  1500  // Dimensions sets the optional parameter "dimensions": A comma-separated list
  1501  // of YouTube Analytics dimensions, such as `views` or `ageGroup,gender`. See
  1502  // the Available Reports (/youtube/analytics/v2/available_reports) document for
  1503  // a list of the reports that you can retrieve and the dimensions used for
  1504  // those reports. Also see the Dimensions (/youtube/analytics/v2/dimsmets/dims)
  1505  // document for definitions of those dimensions." pattern: [0-9a-zA-Z,]+
  1506  func (c *ReportsQueryCall) Dimensions(dimensions string) *ReportsQueryCall {
  1507  	c.urlParams_.Set("dimensions", dimensions)
  1508  	return c
  1509  }
  1510  
  1511  // EndDate sets the optional parameter "endDate": The end date for fetching
  1512  // YouTube Analytics data. The value should be in `YYYY-MM-DD` format.
  1513  // required: true, pattern: [0-9]{4}-[0-9]{2}-[0-9]{2}
  1514  func (c *ReportsQueryCall) EndDate(endDate string) *ReportsQueryCall {
  1515  	c.urlParams_.Set("endDate", endDate)
  1516  	return c
  1517  }
  1518  
  1519  // Filters sets the optional parameter "filters": A list of filters that should
  1520  // be applied when retrieving YouTube Analytics data. The Available Reports
  1521  // (/youtube/analytics/v2/available_reports) document identifies the dimensions
  1522  // that can be used to filter each report, and the Dimensions
  1523  // (/youtube/analytics/v2/dimsmets/dims) document defines those dimensions. If
  1524  // a request uses multiple filters, join them together with a semicolon (`;`),
  1525  // and the returned result table will satisfy both filters. For example, a
  1526  // filters parameter value of `video==dMH0bHeiRNg;country==IT` restricts the
  1527  // result set to include data for the given video in Italy.",
  1528  func (c *ReportsQueryCall) Filters(filters string) *ReportsQueryCall {
  1529  	c.urlParams_.Set("filters", filters)
  1530  	return c
  1531  }
  1532  
  1533  // Ids sets the optional parameter "ids": Identifies the YouTube channel or
  1534  // content owner for which you are retrieving YouTube Analytics data. - To
  1535  // request data for a YouTube user, set the `ids` parameter value to
  1536  // `channel==CHANNEL_ID`, where `CHANNEL_ID` specifies the unique YouTube
  1537  // channel ID. - To request data for a YouTube CMS content owner, set the `ids`
  1538  // parameter value to `contentOwner==OWNER_NAME`, where `OWNER_NAME` is the CMS
  1539  // name of the content owner. required: true, pattern:
  1540  // [a-zA-Z]+==[a-zA-Z0-9_+-]+
  1541  func (c *ReportsQueryCall) Ids(ids string) *ReportsQueryCall {
  1542  	c.urlParams_.Set("ids", ids)
  1543  	return c
  1544  }
  1545  
  1546  // IncludeHistoricalChannelData sets the optional parameter
  1547  // "includeHistoricalChannelData": If set to true historical data (i.e. channel
  1548  // data from before the linking of the channel to the content owner) will be
  1549  // retrieved.",
  1550  func (c *ReportsQueryCall) IncludeHistoricalChannelData(includeHistoricalChannelData bool) *ReportsQueryCall {
  1551  	c.urlParams_.Set("includeHistoricalChannelData", fmt.Sprint(includeHistoricalChannelData))
  1552  	return c
  1553  }
  1554  
  1555  // MaxResults sets the optional parameter "maxResults": The maximum number of
  1556  // rows to include in the response.", minValue: 1
  1557  func (c *ReportsQueryCall) MaxResults(maxResults int64) *ReportsQueryCall {
  1558  	c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  1559  	return c
  1560  }
  1561  
  1562  // Metrics sets the optional parameter "metrics": A comma-separated list of
  1563  // YouTube Analytics metrics, such as `views` or `likes,dislikes`. See the
  1564  // Available Reports (/youtube/analytics/v2/available_reports) document for a
  1565  // list of the reports that you can retrieve and the metrics available in each
  1566  // report, and see the Metrics (/youtube/analytics/v2/dimsmets/mets) document
  1567  // for definitions of those metrics. required: true, pattern: [0-9a-zA-Z,]+
  1568  func (c *ReportsQueryCall) Metrics(metrics string) *ReportsQueryCall {
  1569  	c.urlParams_.Set("metrics", metrics)
  1570  	return c
  1571  }
  1572  
  1573  // Sort sets the optional parameter "sort": A comma-separated list of
  1574  // dimensions or metrics that determine the sort order for YouTube Analytics
  1575  // data. By default the sort order is ascending. The '`-`' prefix causes
  1576  // descending sort order.", pattern: [-0-9a-zA-Z,]+
  1577  func (c *ReportsQueryCall) Sort(sort string) *ReportsQueryCall {
  1578  	c.urlParams_.Set("sort", sort)
  1579  	return c
  1580  }
  1581  
  1582  // StartDate sets the optional parameter "startDate": The start date for
  1583  // fetching YouTube Analytics data. The value should be in `YYYY-MM-DD` format.
  1584  // required: true, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}
  1585  func (c *ReportsQueryCall) StartDate(startDate string) *ReportsQueryCall {
  1586  	c.urlParams_.Set("startDate", startDate)
  1587  	return c
  1588  }
  1589  
  1590  // StartIndex sets the optional parameter "startIndex": An index of the first
  1591  // entity to retrieve. Use this parameter as a pagination mechanism along with
  1592  // the max-results parameter (one-based, inclusive).", minValue: 1
  1593  func (c *ReportsQueryCall) StartIndex(startIndex int64) *ReportsQueryCall {
  1594  	c.urlParams_.Set("startIndex", fmt.Sprint(startIndex))
  1595  	return c
  1596  }
  1597  
  1598  // Fields allows partial responses to be retrieved. See
  1599  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1600  // details.
  1601  func (c *ReportsQueryCall) Fields(s ...googleapi.Field) *ReportsQueryCall {
  1602  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1603  	return c
  1604  }
  1605  
  1606  // IfNoneMatch sets an optional parameter which makes the operation fail if the
  1607  // object's ETag matches the given value. This is useful for getting updates
  1608  // only after the object has changed since the last request.
  1609  func (c *ReportsQueryCall) IfNoneMatch(entityTag string) *ReportsQueryCall {
  1610  	c.ifNoneMatch_ = entityTag
  1611  	return c
  1612  }
  1613  
  1614  // Context sets the context to be used in this call's Do method.
  1615  func (c *ReportsQueryCall) Context(ctx context.Context) *ReportsQueryCall {
  1616  	c.ctx_ = ctx
  1617  	return c
  1618  }
  1619  
  1620  // Header returns a http.Header that can be modified by the caller to add
  1621  // headers to the request.
  1622  func (c *ReportsQueryCall) Header() http.Header {
  1623  	if c.header_ == nil {
  1624  		c.header_ = make(http.Header)
  1625  	}
  1626  	return c.header_
  1627  }
  1628  
  1629  func (c *ReportsQueryCall) doRequest(alt string) (*http.Response, error) {
  1630  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
  1631  	if c.ifNoneMatch_ != "" {
  1632  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1633  	}
  1634  	var body io.Reader = nil
  1635  	c.urlParams_.Set("alt", alt)
  1636  	c.urlParams_.Set("prettyPrint", "false")
  1637  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2/reports")
  1638  	urls += "?" + c.urlParams_.Encode()
  1639  	req, err := http.NewRequest("GET", urls, body)
  1640  	if err != nil {
  1641  		return nil, err
  1642  	}
  1643  	req.Header = reqHeaders
  1644  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1645  }
  1646  
  1647  // Do executes the "youtubeAnalytics.reports.query" call.
  1648  // Any non-2xx status code is an error. Response headers are in either
  1649  // *QueryResponse.ServerResponse.Header or (if a response was returned at all)
  1650  // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1651  // whether the returned error was because http.StatusNotModified was returned.
  1652  func (c *ReportsQueryCall) Do(opts ...googleapi.CallOption) (*QueryResponse, error) {
  1653  	gensupport.SetOptions(c.urlParams_, opts...)
  1654  	res, err := c.doRequest("json")
  1655  	if res != nil && res.StatusCode == http.StatusNotModified {
  1656  		if res.Body != nil {
  1657  			res.Body.Close()
  1658  		}
  1659  		return nil, gensupport.WrapError(&googleapi.Error{
  1660  			Code:   res.StatusCode,
  1661  			Header: res.Header,
  1662  		})
  1663  	}
  1664  	if err != nil {
  1665  		return nil, err
  1666  	}
  1667  	defer googleapi.CloseBody(res)
  1668  	if err := googleapi.CheckResponse(res); err != nil {
  1669  		return nil, gensupport.WrapError(err)
  1670  	}
  1671  	ret := &QueryResponse{
  1672  		ServerResponse: googleapi.ServerResponse{
  1673  			Header:         res.Header,
  1674  			HTTPStatusCode: res.StatusCode,
  1675  		},
  1676  	}
  1677  	target := &ret
  1678  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1679  		return nil, err
  1680  	}
  1681  	return ret, nil
  1682  }
  1683  

View as plain text