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