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.
 
 
 

432 lines
12 KiB

  1. // Copyright YEAR Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Code generated file. DO NOT EDIT.
  5. // Package paramrename provides access to the Example API.
  6. //
  7. // Creating a client
  8. //
  9. // Usage example:
  10. //
  11. // import "google.golang.org/api/paramrename/v1"
  12. // ...
  13. // ctx := context.Background()
  14. // paramrenameService, err := paramrename.NewService(ctx)
  15. //
  16. // In this example, Google Application Default Credentials are used for authentication.
  17. //
  18. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  19. //
  20. // Other authentication options
  21. //
  22. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  23. //
  24. // paramrenameService, err := paramrename.NewService(ctx, option.WithAPIKey("AIza..."))
  25. //
  26. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  27. //
  28. // config := &oauth2.Config{...}
  29. // // ...
  30. // token, err := config.Exchange(ctx, ...)
  31. // paramrenameService, err := paramrename.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  32. //
  33. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  34. package paramrename // import "google.golang.org/api/paramrename/v1"
  35. import (
  36. "bytes"
  37. "context"
  38. "encoding/json"
  39. "errors"
  40. "fmt"
  41. "io"
  42. "net/http"
  43. "net/url"
  44. "strconv"
  45. "strings"
  46. gensupport "google.golang.org/api/gensupport"
  47. googleapi "google.golang.org/api/googleapi"
  48. option "google.golang.org/api/option"
  49. htransport "google.golang.org/api/transport/http"
  50. )
  51. // Always reference these packages, just in case the auto-generated code
  52. // below doesn't.
  53. var _ = bytes.NewBuffer
  54. var _ = strconv.Itoa
  55. var _ = fmt.Sprintf
  56. var _ = json.NewDecoder
  57. var _ = io.Copy
  58. var _ = url.Parse
  59. var _ = gensupport.MarshalJSON
  60. var _ = googleapi.Version
  61. var _ = errors.New
  62. var _ = strings.Replace
  63. var _ = context.Canceled
  64. const apiId = "paramrename:v1"
  65. const apiName = "paramrename"
  66. const apiVersion = "v1"
  67. const basePath = "https://www.googleapis.com/discovery/v1/apis"
  68. // NewService creates a new Service.
  69. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  70. client, endpoint, err := htransport.NewClient(ctx, opts...)
  71. if err != nil {
  72. return nil, err
  73. }
  74. s, err := New(client)
  75. if err != nil {
  76. return nil, err
  77. }
  78. if endpoint != "" {
  79. s.BasePath = endpoint
  80. }
  81. return s, nil
  82. }
  83. // New creates a new Service. It uses the provided http.Client for requests.
  84. //
  85. // Deprecated: please use NewService instead.
  86. // To provide a custom HTTP client, use option.WithHTTPClient.
  87. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  88. func New(client *http.Client) (*Service, error) {
  89. if client == nil {
  90. return nil, errors.New("client is nil")
  91. }
  92. s := &Service{client: client, BasePath: basePath}
  93. s.Events = NewEventsService(s)
  94. s.Reports = NewReportsService(s)
  95. return s, nil
  96. }
  97. type Service struct {
  98. client *http.Client
  99. BasePath string // API endpoint base URL
  100. UserAgent string // optional additional User-Agent fragment
  101. Events *EventsService
  102. Reports *ReportsService
  103. }
  104. func (s *Service) userAgent() string {
  105. if s.UserAgent == "" {
  106. return googleapi.UserAgent
  107. }
  108. return googleapi.UserAgent + " " + s.UserAgent
  109. }
  110. func NewEventsService(s *Service) *EventsService {
  111. rs := &EventsService{s: s}
  112. return rs
  113. }
  114. type EventsService struct {
  115. s *Service
  116. }
  117. func NewReportsService(s *Service) *ReportsService {
  118. rs := &ReportsService{s: s}
  119. return rs
  120. }
  121. type ReportsService struct {
  122. s *Service
  123. }
  124. type Event string
  125. type ResultTable string
  126. // method id "calendar.events.move":
  127. type EventsMoveCall struct {
  128. s *Service
  129. rightString string
  130. urlParams_ gensupport.URLParams
  131. ctx_ context.Context
  132. header_ http.Header
  133. }
  134. // Move: Moves an event to another calendar, i.e. changes an event's
  135. // organizer.
  136. func (r *EventsService) Move(destinationid string, rightString string) *EventsMoveCall {
  137. c := &EventsMoveCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  138. c.urlParams_.Set("destination", destinationid)
  139. c.rightString = rightString
  140. return c
  141. }
  142. // SourceParam sets the optional parameter "source-param": Some
  143. // parameter.
  144. func (c *EventsMoveCall) SourceParam(sourceParam string) *EventsMoveCall {
  145. c.urlParams_.Set("source-param", sourceParam)
  146. return c
  147. }
  148. // Fields allows partial responses to be retrieved. See
  149. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  150. // for more information.
  151. func (c *EventsMoveCall) Fields(s ...googleapi.Field) *EventsMoveCall {
  152. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  153. return c
  154. }
  155. // Context sets the context to be used in this call's Do method. Any
  156. // pending HTTP request will be aborted if the provided context is
  157. // canceled.
  158. func (c *EventsMoveCall) Context(ctx context.Context) *EventsMoveCall {
  159. c.ctx_ = ctx
  160. return c
  161. }
  162. // Header returns an http.Header that can be modified by the caller to
  163. // add HTTP headers to the request.
  164. func (c *EventsMoveCall) Header() http.Header {
  165. if c.header_ == nil {
  166. c.header_ = make(http.Header)
  167. }
  168. return c.header_
  169. }
  170. func (c *EventsMoveCall) doRequest(alt string) (*http.Response, error) {
  171. reqHeaders := make(http.Header)
  172. for k, v := range c.header_ {
  173. reqHeaders[k] = v
  174. }
  175. reqHeaders.Set("User-Agent", c.s.userAgent())
  176. var body io.Reader = nil
  177. c.urlParams_.Set("alt", alt)
  178. c.urlParams_.Set("prettyPrint", "false")
  179. urls := googleapi.ResolveRelative(c.s.BasePath, "calendars/{calendarId}/events/{eventId}/move")
  180. urls += "?" + c.urlParams_.Encode()
  181. req, err := http.NewRequest("POST", urls, body)
  182. if err != nil {
  183. return nil, err
  184. }
  185. req.Header = reqHeaders
  186. googleapi.Expand(req.URL, map[string]string{
  187. "right-string": c.rightString,
  188. })
  189. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  190. }
  191. // Do executes the "calendar.events.move" call.
  192. // Exactly one of *Event or error will be non-nil. Any non-2xx status
  193. // code is an error. Response headers are in either
  194. // *Event.ServerResponse.Header or (if a response was returned at all)
  195. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  196. // check whether the returned error was because http.StatusNotModified
  197. // was returned.
  198. func (c *EventsMoveCall) Do(opts ...googleapi.CallOption) (*Event, error) {
  199. gensupport.SetOptions(c.urlParams_, opts...)
  200. res, err := c.doRequest("json")
  201. if res != nil && res.StatusCode == http.StatusNotModified {
  202. if res.Body != nil {
  203. res.Body.Close()
  204. }
  205. return nil, &googleapi.Error{
  206. Code: res.StatusCode,
  207. Header: res.Header,
  208. }
  209. }
  210. if err != nil {
  211. return nil, err
  212. }
  213. defer googleapi.CloseBody(res)
  214. if err := googleapi.CheckResponse(res); err != nil {
  215. return nil, err
  216. }
  217. ret := &Event{
  218. ServerResponse: googleapi.ServerResponse{
  219. Header: res.Header,
  220. HTTPStatusCode: res.StatusCode,
  221. },
  222. }
  223. target := &ret
  224. if err := gensupport.DecodeResponse(target, res); err != nil {
  225. return nil, err
  226. }
  227. return ret, nil
  228. // {
  229. // "description": "Moves an event to another calendar, i.e. changes an event's organizer.",
  230. // "httpMethod": "POST",
  231. // "id": "calendar.events.move",
  232. // "parameterOrder": [
  233. // "destination",
  234. // "right-string"
  235. // ],
  236. // "parameters": {
  237. // "destination": {
  238. // "description": "Calendar identifier of the target calendar where the event is to be moved to.",
  239. // "location": "query",
  240. // "required": true,
  241. // "type": "string"
  242. // },
  243. // "right-string": {
  244. // "description": "Yet another parameter.",
  245. // "location": "path",
  246. // "required": true,
  247. // "type": "string"
  248. // },
  249. // "source-param": {
  250. // "description": "Some parameter.",
  251. // "location": "query",
  252. // "required": false,
  253. // "type": "string"
  254. // }
  255. // },
  256. // "path": "calendars/{calendarId}/events/{eventId}/move",
  257. // "response": {
  258. // "$ref": "Event"
  259. // },
  260. // "scopes": [
  261. // "https://www.googleapis.com/auth/calendar"
  262. // ]
  263. // }
  264. }
  265. // method id "youtubeAnalytics.reports.query":
  266. type ReportsQueryCall struct {
  267. s *Service
  268. urlParams_ gensupport.URLParams
  269. ifNoneMatch_ string
  270. ctx_ context.Context
  271. header_ http.Header
  272. }
  273. // Query: Retrieve your YouTube Analytics reports.
  274. func (r *ReportsService) Query(startDate string) *ReportsQueryCall {
  275. c := &ReportsQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  276. c.urlParams_.Set("start-date", startDate)
  277. return c
  278. }
  279. // Fields allows partial responses to be retrieved. See
  280. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  281. // for more information.
  282. func (c *ReportsQueryCall) Fields(s ...googleapi.Field) *ReportsQueryCall {
  283. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  284. return c
  285. }
  286. // IfNoneMatch sets the optional parameter which makes the operation
  287. // fail if the object's ETag matches the given value. This is useful for
  288. // getting updates only after the object has changed since the last
  289. // request. Use googleapi.IsNotModified to check whether the response
  290. // error from Do is the result of In-None-Match.
  291. func (c *ReportsQueryCall) IfNoneMatch(entityTag string) *ReportsQueryCall {
  292. c.ifNoneMatch_ = entityTag
  293. return c
  294. }
  295. // Context sets the context to be used in this call's Do method. Any
  296. // pending HTTP request will be aborted if the provided context is
  297. // canceled.
  298. func (c *ReportsQueryCall) Context(ctx context.Context) *ReportsQueryCall {
  299. c.ctx_ = ctx
  300. return c
  301. }
  302. // Header returns an http.Header that can be modified by the caller to
  303. // add HTTP headers to the request.
  304. func (c *ReportsQueryCall) Header() http.Header {
  305. if c.header_ == nil {
  306. c.header_ = make(http.Header)
  307. }
  308. return c.header_
  309. }
  310. func (c *ReportsQueryCall) doRequest(alt string) (*http.Response, error) {
  311. reqHeaders := make(http.Header)
  312. for k, v := range c.header_ {
  313. reqHeaders[k] = v
  314. }
  315. reqHeaders.Set("User-Agent", c.s.userAgent())
  316. if c.ifNoneMatch_ != "" {
  317. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  318. }
  319. var body io.Reader = nil
  320. c.urlParams_.Set("alt", alt)
  321. c.urlParams_.Set("prettyPrint", "false")
  322. urls := googleapi.ResolveRelative(c.s.BasePath, "reports")
  323. urls += "?" + c.urlParams_.Encode()
  324. req, err := http.NewRequest("GET", urls, body)
  325. if err != nil {
  326. return nil, err
  327. }
  328. req.Header = reqHeaders
  329. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  330. }
  331. // Do executes the "youtubeAnalytics.reports.query" call.
  332. // Exactly one of *ResultTable or error will be non-nil. Any non-2xx
  333. // status code is an error. Response headers are in either
  334. // *ResultTable.ServerResponse.Header or (if a response was returned at
  335. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  336. // to check whether the returned error was because
  337. // http.StatusNotModified was returned.
  338. func (c *ReportsQueryCall) Do(opts ...googleapi.CallOption) (*ResultTable, error) {
  339. gensupport.SetOptions(c.urlParams_, opts...)
  340. res, err := c.doRequest("json")
  341. if res != nil && res.StatusCode == http.StatusNotModified {
  342. if res.Body != nil {
  343. res.Body.Close()
  344. }
  345. return nil, &googleapi.Error{
  346. Code: res.StatusCode,
  347. Header: res.Header,
  348. }
  349. }
  350. if err != nil {
  351. return nil, err
  352. }
  353. defer googleapi.CloseBody(res)
  354. if err := googleapi.CheckResponse(res); err != nil {
  355. return nil, err
  356. }
  357. ret := &ResultTable{
  358. ServerResponse: googleapi.ServerResponse{
  359. Header: res.Header,
  360. HTTPStatusCode: res.StatusCode,
  361. },
  362. }
  363. target := &ret
  364. if err := gensupport.DecodeResponse(target, res); err != nil {
  365. return nil, err
  366. }
  367. return ret, nil
  368. // {
  369. // "description": "Retrieve your YouTube Analytics reports.",
  370. // "httpMethod": "GET",
  371. // "id": "youtubeAnalytics.reports.query",
  372. // "parameterOrder": [
  373. // "start-date"
  374. // ],
  375. // "parameters": {
  376. // "start-date": {
  377. // "description": "The start date for fetching YouTube Analytics data. The value should be in YYYY-MM-DD format.",
  378. // "location": "query",
  379. // "pattern": "[0-9]{4}-[0-9]{2}-[0-9]{2}",
  380. // "required": true,
  381. // "type": "string"
  382. // }
  383. // },
  384. // "path": "reports",
  385. // "response": {
  386. // "$ref": "ResultTable"
  387. // },
  388. // "scopes": [
  389. // "https://www.googleapis.com/auth/yt-analytics-monetary.readonly",
  390. // "https://www.googleapis.com/auth/yt-analytics.readonly"
  391. // ]
  392. // }
  393. }