You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2251 lines
82 KiB

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