1// Copyright 2020 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 urlshortener provides access to the URL Shortener API.
8//
9// For product documentation, see: https://developers.google.com/url-shortener/v1/getting_started
10//
11// Creating a client
12//
13// Usage example:
14//
15//   import "google.golang.org/api/urlshortener/v1"
16//   ...
17//   ctx := context.Background()
18//   urlshortenerService, err := urlshortener.NewService(ctx)
19//
20// In this example, Google Application Default Credentials are used for authentication.
21//
22// For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
23//
24// Other authentication options
25//
26// To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
27//
28//   urlshortenerService, err := urlshortener.NewService(ctx, option.WithAPIKey("AIza..."))
29//
30// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
31//
32//   config := &oauth2.Config{...}
33//   // ...
34//   token, err := config.Exchange(ctx, ...)
35//   urlshortenerService, err := urlshortener.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
36//
37// See https://godoc.org/google.golang.org/api/option/ for details on options.
38package urlshortener // import "google.golang.org/api/urlshortener/v1"
39
40import (
41	"bytes"
42	"context"
43	"encoding/json"
44	"errors"
45	"fmt"
46	"io"
47	"net/http"
48	"net/url"
49	"strconv"
50	"strings"
51
52	googleapi "google.golang.org/api/googleapi"
53	gensupport "google.golang.org/api/internal/gensupport"
54	option "google.golang.org/api/option"
55	htransport "google.golang.org/api/transport/http"
56)
57
58// Always reference these packages, just in case the auto-generated code
59// below doesn't.
60var _ = bytes.NewBuffer
61var _ = strconv.Itoa
62var _ = fmt.Sprintf
63var _ = json.NewDecoder
64var _ = io.Copy
65var _ = url.Parse
66var _ = gensupport.MarshalJSON
67var _ = googleapi.Version
68var _ = errors.New
69var _ = strings.Replace
70var _ = context.Canceled
71
72const apiId = "urlshortener:v1"
73const apiName = "urlshortener"
74const apiVersion = "v1"
75const basePath = "https://www.googleapis.com/urlshortener/v1/"
76
77// OAuth2 scopes used by this API.
78const (
79	// Manage your goo.gl short URLs
80	UrlshortenerScope = "https://www.googleapis.com/auth/urlshortener"
81)
82
83// NewService creates a new Service.
84func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
85	scopesOption := option.WithScopes(
86		"https://www.googleapis.com/auth/urlshortener",
87	)
88	// NOTE: prepend, so we don't override user-specified scopes.
89	opts = append([]option.ClientOption{scopesOption}, opts...)
90	client, endpoint, err := htransport.NewClient(ctx, opts...)
91	if err != nil {
92		return nil, err
93	}
94	s, err := New(client)
95	if err != nil {
96		return nil, err
97	}
98	if endpoint != "" {
99		s.BasePath = endpoint
100	}
101	return s, nil
102}
103
104// New creates a new Service. It uses the provided http.Client for requests.
105//
106// Deprecated: please use NewService instead.
107// To provide a custom HTTP client, use option.WithHTTPClient.
108// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
109func New(client *http.Client) (*Service, error) {
110	if client == nil {
111		return nil, errors.New("client is nil")
112	}
113	s := &Service{client: client, BasePath: basePath}
114	s.Url = NewUrlService(s)
115	return s, nil
116}
117
118type Service struct {
119	client    *http.Client
120	BasePath  string // API endpoint base URL
121	UserAgent string // optional additional User-Agent fragment
122
123	Url *UrlService
124}
125
126func (s *Service) userAgent() string {
127	if s.UserAgent == "" {
128		return googleapi.UserAgent
129	}
130	return googleapi.UserAgent + " " + s.UserAgent
131}
132
133func NewUrlService(s *Service) *UrlService {
134	rs := &UrlService{s: s}
135	return rs
136}
137
138type UrlService struct {
139	s *Service
140}
141
142type AnalyticsSnapshot struct {
143	// Browsers: Top browsers, e.g. "Chrome"; sorted by (descending) click
144	// counts. Only present if this data is available.
145	Browsers []*StringCount `json:"browsers,omitempty"`
146
147	// Countries: Top countries (expressed as country codes), e.g. "US" or
148	// "DE"; sorted by (descending) click counts. Only present if this data
149	// is available.
150	Countries []*StringCount `json:"countries,omitempty"`
151
152	// LongUrlClicks: Number of clicks on all goo.gl short URLs pointing to
153	// this long URL.
154	LongUrlClicks int64 `json:"longUrlClicks,omitempty,string"`
155
156	// Platforms: Top platforms or OSes, e.g. "Windows"; sorted by
157	// (descending) click counts. Only present if this data is available.
158	Platforms []*StringCount `json:"platforms,omitempty"`
159
160	// Referrers: Top referring hosts, e.g. "www.google.com"; sorted by
161	// (descending) click counts. Only present if this data is available.
162	Referrers []*StringCount `json:"referrers,omitempty"`
163
164	// ShortUrlClicks: Number of clicks on this short URL.
165	ShortUrlClicks int64 `json:"shortUrlClicks,omitempty,string"`
166
167	// ForceSendFields is a list of field names (e.g. "Browsers") to
168	// unconditionally include in API requests. By default, fields with
169	// empty values are omitted from API requests. However, any non-pointer,
170	// non-interface field appearing in ForceSendFields will be sent to the
171	// server regardless of whether the field is empty or not. This may be
172	// used to include empty fields in Patch requests.
173	ForceSendFields []string `json:"-"`
174
175	// NullFields is a list of field names (e.g. "Browsers") to include in
176	// API requests with the JSON null value. By default, fields with empty
177	// values are omitted from API requests. However, any field with an
178	// empty value appearing in NullFields will be sent to the server as
179	// null. It is an error if a field in this list has a non-empty value.
180	// This may be used to include null fields in Patch requests.
181	NullFields []string `json:"-"`
182}
183
184func (s *AnalyticsSnapshot) MarshalJSON() ([]byte, error) {
185	type NoMethod AnalyticsSnapshot
186	raw := NoMethod(*s)
187	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
188}
189
190type AnalyticsSummary struct {
191	// AllTime: Click analytics over all time.
192	AllTime *AnalyticsSnapshot `json:"allTime,omitempty"`
193
194	// Day: Click analytics over the last day.
195	Day *AnalyticsSnapshot `json:"day,omitempty"`
196
197	// Month: Click analytics over the last month.
198	Month *AnalyticsSnapshot `json:"month,omitempty"`
199
200	// TwoHours: Click analytics over the last two hours.
201	TwoHours *AnalyticsSnapshot `json:"twoHours,omitempty"`
202
203	// Week: Click analytics over the last week.
204	Week *AnalyticsSnapshot `json:"week,omitempty"`
205
206	// ForceSendFields is a list of field names (e.g. "AllTime") to
207	// unconditionally include in API requests. By default, fields with
208	// empty values are omitted from API requests. However, any non-pointer,
209	// non-interface field appearing in ForceSendFields will be sent to the
210	// server regardless of whether the field is empty or not. This may be
211	// used to include empty fields in Patch requests.
212	ForceSendFields []string `json:"-"`
213
214	// NullFields is a list of field names (e.g. "AllTime") to include in
215	// API requests with the JSON null value. By default, fields with empty
216	// values are omitted from API requests. However, any field with an
217	// empty value appearing in NullFields will be sent to the server as
218	// null. It is an error if a field in this list has a non-empty value.
219	// This may be used to include null fields in Patch requests.
220	NullFields []string `json:"-"`
221}
222
223func (s *AnalyticsSummary) MarshalJSON() ([]byte, error) {
224	type NoMethod AnalyticsSummary
225	raw := NoMethod(*s)
226	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
227}
228
229type StringCount struct {
230	// Count: Number of clicks for this top entry, e.g. for this particular
231	// country or browser.
232	Count int64 `json:"count,omitempty,string"`
233
234	// Id: Label assigned to this top entry, e.g. "US" or "Chrome".
235	Id string `json:"id,omitempty"`
236
237	// ForceSendFields is a list of field names (e.g. "Count") to
238	// unconditionally include in API requests. By default, fields with
239	// empty values are omitted from API requests. However, any non-pointer,
240	// non-interface field appearing in ForceSendFields will be sent to the
241	// server regardless of whether the field is empty or not. This may be
242	// used to include empty fields in Patch requests.
243	ForceSendFields []string `json:"-"`
244
245	// NullFields is a list of field names (e.g. "Count") to include in API
246	// requests with the JSON null value. By default, fields with empty
247	// values are omitted from API requests. However, any field with an
248	// empty value appearing in NullFields will be sent to the server as
249	// null. It is an error if a field in this list has a non-empty value.
250	// This may be used to include null fields in Patch requests.
251	NullFields []string `json:"-"`
252}
253
254func (s *StringCount) MarshalJSON() ([]byte, error) {
255	type NoMethod StringCount
256	raw := NoMethod(*s)
257	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
258}
259
260type Url struct {
261	// Analytics: A summary of the click analytics for the short and long
262	// URL. Might not be present if not requested or currently unavailable.
263	Analytics *AnalyticsSummary `json:"analytics,omitempty"`
264
265	// Created: Time the short URL was created; ISO 8601 representation
266	// using the yyyy-MM-dd'T'HH:mm:ss.SSSZZ format, e.g.
267	// "2010-10-14T19:01:24.944+00:00".
268	Created string `json:"created,omitempty"`
269
270	// Id: Short URL, e.g. "http://goo.gl/l6MS".
271	Id string `json:"id,omitempty"`
272
273	// Kind: The fixed string "urlshortener#url".
274	Kind string `json:"kind,omitempty"`
275
276	// LongUrl: Long URL, e.g. "http://www.google.com/". Might not be
277	// present if the status is "REMOVED".
278	LongUrl string `json:"longUrl,omitempty"`
279
280	// Status: Status of the target URL. Possible values: "OK", "MALWARE",
281	// "PHISHING", or "REMOVED". A URL might be marked "REMOVED" if it was
282	// flagged as spam, for example.
283	Status string `json:"status,omitempty"`
284
285	// ServerResponse contains the HTTP response code and headers from the
286	// server.
287	googleapi.ServerResponse `json:"-"`
288
289	// ForceSendFields is a list of field names (e.g. "Analytics") to
290	// unconditionally include in API requests. By default, fields with
291	// empty values are omitted from API requests. However, any non-pointer,
292	// non-interface field appearing in ForceSendFields will be sent to the
293	// server regardless of whether the field is empty or not. This may be
294	// used to include empty fields in Patch requests.
295	ForceSendFields []string `json:"-"`
296
297	// NullFields is a list of field names (e.g. "Analytics") to include in
298	// API requests with the JSON null value. By default, fields with empty
299	// values are omitted from API requests. However, any field with an
300	// empty value appearing in NullFields will be sent to the server as
301	// null. It is an error if a field in this list has a non-empty value.
302	// This may be used to include null fields in Patch requests.
303	NullFields []string `json:"-"`
304}
305
306func (s *Url) MarshalJSON() ([]byte, error) {
307	type NoMethod Url
308	raw := NoMethod(*s)
309	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
310}
311
312type UrlHistory struct {
313	// Items: A list of URL resources.
314	Items []*Url `json:"items,omitempty"`
315
316	// ItemsPerPage: Number of items returned with each full "page" of
317	// results. Note that the last page could have fewer items than the
318	// "itemsPerPage" value.
319	ItemsPerPage int64 `json:"itemsPerPage,omitempty"`
320
321	// Kind: The fixed string "urlshortener#urlHistory".
322	Kind string `json:"kind,omitempty"`
323
324	// NextPageToken: A token to provide to get the next page of results.
325	NextPageToken string `json:"nextPageToken,omitempty"`
326
327	// TotalItems: Total number of short URLs associated with this user (may
328	// be approximate).
329	TotalItems int64 `json:"totalItems,omitempty"`
330
331	// ServerResponse contains the HTTP response code and headers from the
332	// server.
333	googleapi.ServerResponse `json:"-"`
334
335	// ForceSendFields is a list of field names (e.g. "Items") to
336	// unconditionally include in API requests. By default, fields with
337	// empty values are omitted from API requests. However, any non-pointer,
338	// non-interface field appearing in ForceSendFields will be sent to the
339	// server regardless of whether the field is empty or not. This may be
340	// used to include empty fields in Patch requests.
341	ForceSendFields []string `json:"-"`
342
343	// NullFields is a list of field names (e.g. "Items") to include in API
344	// requests with the JSON null value. By default, fields with empty
345	// values are omitted from API requests. However, any field with an
346	// empty value appearing in NullFields will be sent to the server as
347	// null. It is an error if a field in this list has a non-empty value.
348	// This may be used to include null fields in Patch requests.
349	NullFields []string `json:"-"`
350}
351
352func (s *UrlHistory) MarshalJSON() ([]byte, error) {
353	type NoMethod UrlHistory
354	raw := NoMethod(*s)
355	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
356}
357
358// method id "urlshortener.url.get":
359
360type UrlGetCall struct {
361	s            *Service
362	urlParams_   gensupport.URLParams
363	ifNoneMatch_ string
364	ctx_         context.Context
365	header_      http.Header
366}
367
368// Get: Expands a short URL or gets creation time and analytics.
369func (r *UrlService) Get(shortUrl string) *UrlGetCall {
370	c := &UrlGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
371	c.urlParams_.Set("shortUrl", shortUrl)
372	return c
373}
374
375// Projection sets the optional parameter "projection": Additional
376// information to return.
377//
378// Possible values:
379//   "ANALYTICS_CLICKS" - Returns only click counts.
380//   "ANALYTICS_TOP_STRINGS" - Returns only top string counts.
381//   "FULL" - Returns the creation timestamp and all available
382// analytics.
383func (c *UrlGetCall) Projection(projection string) *UrlGetCall {
384	c.urlParams_.Set("projection", projection)
385	return c
386}
387
388// Fields allows partial responses to be retrieved. See
389// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
390// for more information.
391func (c *UrlGetCall) Fields(s ...googleapi.Field) *UrlGetCall {
392	c.urlParams_.Set("fields", googleapi.CombineFields(s))
393	return c
394}
395
396// IfNoneMatch sets the optional parameter which makes the operation
397// fail if the object's ETag matches the given value. This is useful for
398// getting updates only after the object has changed since the last
399// request. Use googleapi.IsNotModified to check whether the response
400// error from Do is the result of In-None-Match.
401func (c *UrlGetCall) IfNoneMatch(entityTag string) *UrlGetCall {
402	c.ifNoneMatch_ = entityTag
403	return c
404}
405
406// Context sets the context to be used in this call's Do method. Any
407// pending HTTP request will be aborted if the provided context is
408// canceled.
409func (c *UrlGetCall) Context(ctx context.Context) *UrlGetCall {
410	c.ctx_ = ctx
411	return c
412}
413
414// Header returns an http.Header that can be modified by the caller to
415// add HTTP headers to the request.
416func (c *UrlGetCall) Header() http.Header {
417	if c.header_ == nil {
418		c.header_ = make(http.Header)
419	}
420	return c.header_
421}
422
423func (c *UrlGetCall) doRequest(alt string) (*http.Response, error) {
424	reqHeaders := make(http.Header)
425	reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
426	for k, v := range c.header_ {
427		reqHeaders[k] = v
428	}
429	reqHeaders.Set("User-Agent", c.s.userAgent())
430	if c.ifNoneMatch_ != "" {
431		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
432	}
433	var body io.Reader = nil
434	c.urlParams_.Set("alt", alt)
435	c.urlParams_.Set("prettyPrint", "false")
436	urls := googleapi.ResolveRelative(c.s.BasePath, "url")
437	urls += "?" + c.urlParams_.Encode()
438	req, err := http.NewRequest("GET", urls, body)
439	if err != nil {
440		return nil, err
441	}
442	req.Header = reqHeaders
443	return gensupport.SendRequest(c.ctx_, c.s.client, req)
444}
445
446// Do executes the "urlshortener.url.get" call.
447// Exactly one of *Url or error will be non-nil. Any non-2xx status code
448// is an error. Response headers are in either
449// *Url.ServerResponse.Header or (if a response was returned at all) in
450// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
451// whether the returned error was because http.StatusNotModified was
452// returned.
453func (c *UrlGetCall) Do(opts ...googleapi.CallOption) (*Url, error) {
454	gensupport.SetOptions(c.urlParams_, opts...)
455	res, err := c.doRequest("json")
456	if res != nil && res.StatusCode == http.StatusNotModified {
457		if res.Body != nil {
458			res.Body.Close()
459		}
460		return nil, &googleapi.Error{
461			Code:   res.StatusCode,
462			Header: res.Header,
463		}
464	}
465	if err != nil {
466		return nil, err
467	}
468	defer googleapi.CloseBody(res)
469	if err := googleapi.CheckResponse(res); err != nil {
470		return nil, err
471	}
472	ret := &Url{
473		ServerResponse: googleapi.ServerResponse{
474			Header:         res.Header,
475			HTTPStatusCode: res.StatusCode,
476		},
477	}
478	target := &ret
479	if err := gensupport.DecodeResponse(target, res); err != nil {
480		return nil, err
481	}
482	return ret, nil
483	// {
484	//   "description": "Expands a short URL or gets creation time and analytics.",
485	//   "httpMethod": "GET",
486	//   "id": "urlshortener.url.get",
487	//   "parameterOrder": [
488	//     "shortUrl"
489	//   ],
490	//   "parameters": {
491	//     "projection": {
492	//       "description": "Additional information to return.",
493	//       "enum": [
494	//         "ANALYTICS_CLICKS",
495	//         "ANALYTICS_TOP_STRINGS",
496	//         "FULL"
497	//       ],
498	//       "enumDescriptions": [
499	//         "Returns only click counts.",
500	//         "Returns only top string counts.",
501	//         "Returns the creation timestamp and all available analytics."
502	//       ],
503	//       "location": "query",
504	//       "type": "string"
505	//     },
506	//     "shortUrl": {
507	//       "description": "The short URL, including the protocol.",
508	//       "location": "query",
509	//       "required": true,
510	//       "type": "string"
511	//     }
512	//   },
513	//   "path": "url",
514	//   "response": {
515	//     "$ref": "Url"
516	//   },
517	//   "scopes": [
518	//     "https://www.googleapis.com/auth/urlshortener"
519	//   ]
520	// }
521
522}
523
524// method id "urlshortener.url.insert":
525
526type UrlInsertCall struct {
527	s          *Service
528	url        *Url
529	urlParams_ gensupport.URLParams
530	ctx_       context.Context
531	header_    http.Header
532}
533
534// Insert: Creates a new short URL.
535func (r *UrlService) Insert(url *Url) *UrlInsertCall {
536	c := &UrlInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
537	c.url = url
538	return c
539}
540
541// Fields allows partial responses to be retrieved. See
542// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
543// for more information.
544func (c *UrlInsertCall) Fields(s ...googleapi.Field) *UrlInsertCall {
545	c.urlParams_.Set("fields", googleapi.CombineFields(s))
546	return c
547}
548
549// Context sets the context to be used in this call's Do method. Any
550// pending HTTP request will be aborted if the provided context is
551// canceled.
552func (c *UrlInsertCall) Context(ctx context.Context) *UrlInsertCall {
553	c.ctx_ = ctx
554	return c
555}
556
557// Header returns an http.Header that can be modified by the caller to
558// add HTTP headers to the request.
559func (c *UrlInsertCall) Header() http.Header {
560	if c.header_ == nil {
561		c.header_ = make(http.Header)
562	}
563	return c.header_
564}
565
566func (c *UrlInsertCall) doRequest(alt string) (*http.Response, error) {
567	reqHeaders := make(http.Header)
568	reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
569	for k, v := range c.header_ {
570		reqHeaders[k] = v
571	}
572	reqHeaders.Set("User-Agent", c.s.userAgent())
573	var body io.Reader = nil
574	body, err := googleapi.WithoutDataWrapper.JSONReader(c.url)
575	if err != nil {
576		return nil, err
577	}
578	reqHeaders.Set("Content-Type", "application/json")
579	c.urlParams_.Set("alt", alt)
580	c.urlParams_.Set("prettyPrint", "false")
581	urls := googleapi.ResolveRelative(c.s.BasePath, "url")
582	urls += "?" + c.urlParams_.Encode()
583	req, err := http.NewRequest("POST", urls, body)
584	if err != nil {
585		return nil, err
586	}
587	req.Header = reqHeaders
588	return gensupport.SendRequest(c.ctx_, c.s.client, req)
589}
590
591// Do executes the "urlshortener.url.insert" call.
592// Exactly one of *Url or error will be non-nil. Any non-2xx status code
593// is an error. Response headers are in either
594// *Url.ServerResponse.Header or (if a response was returned at all) in
595// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
596// whether the returned error was because http.StatusNotModified was
597// returned.
598func (c *UrlInsertCall) Do(opts ...googleapi.CallOption) (*Url, error) {
599	gensupport.SetOptions(c.urlParams_, opts...)
600	res, err := c.doRequest("json")
601	if res != nil && res.StatusCode == http.StatusNotModified {
602		if res.Body != nil {
603			res.Body.Close()
604		}
605		return nil, &googleapi.Error{
606			Code:   res.StatusCode,
607			Header: res.Header,
608		}
609	}
610	if err != nil {
611		return nil, err
612	}
613	defer googleapi.CloseBody(res)
614	if err := googleapi.CheckResponse(res); err != nil {
615		return nil, err
616	}
617	ret := &Url{
618		ServerResponse: googleapi.ServerResponse{
619			Header:         res.Header,
620			HTTPStatusCode: res.StatusCode,
621		},
622	}
623	target := &ret
624	if err := gensupport.DecodeResponse(target, res); err != nil {
625		return nil, err
626	}
627	return ret, nil
628	// {
629	//   "description": "Creates a new short URL.",
630	//   "httpMethod": "POST",
631	//   "id": "urlshortener.url.insert",
632	//   "path": "url",
633	//   "request": {
634	//     "$ref": "Url"
635	//   },
636	//   "response": {
637	//     "$ref": "Url"
638	//   },
639	//   "scopes": [
640	//     "https://www.googleapis.com/auth/urlshortener"
641	//   ]
642	// }
643
644}
645
646// method id "urlshortener.url.list":
647
648type UrlListCall struct {
649	s            *Service
650	urlParams_   gensupport.URLParams
651	ifNoneMatch_ string
652	ctx_         context.Context
653	header_      http.Header
654}
655
656// List: Retrieves a list of URLs shortened by a user.
657func (r *UrlService) List() *UrlListCall {
658	c := &UrlListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
659	return c
660}
661
662// Projection sets the optional parameter "projection": Additional
663// information to return.
664//
665// Possible values:
666//   "ANALYTICS_CLICKS" - Returns short URL click counts.
667//   "FULL" - Returns short URL click counts.
668func (c *UrlListCall) Projection(projection string) *UrlListCall {
669	c.urlParams_.Set("projection", projection)
670	return c
671}
672
673// StartToken sets the optional parameter "start-token": Token for
674// requesting successive pages of results.
675func (c *UrlListCall) StartToken(startToken string) *UrlListCall {
676	c.urlParams_.Set("start-token", startToken)
677	return c
678}
679
680// Fields allows partial responses to be retrieved. See
681// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
682// for more information.
683func (c *UrlListCall) Fields(s ...googleapi.Field) *UrlListCall {
684	c.urlParams_.Set("fields", googleapi.CombineFields(s))
685	return c
686}
687
688// IfNoneMatch sets the optional parameter which makes the operation
689// fail if the object's ETag matches the given value. This is useful for
690// getting updates only after the object has changed since the last
691// request. Use googleapi.IsNotModified to check whether the response
692// error from Do is the result of In-None-Match.
693func (c *UrlListCall) IfNoneMatch(entityTag string) *UrlListCall {
694	c.ifNoneMatch_ = entityTag
695	return c
696}
697
698// Context sets the context to be used in this call's Do method. Any
699// pending HTTP request will be aborted if the provided context is
700// canceled.
701func (c *UrlListCall) Context(ctx context.Context) *UrlListCall {
702	c.ctx_ = ctx
703	return c
704}
705
706// Header returns an http.Header that can be modified by the caller to
707// add HTTP headers to the request.
708func (c *UrlListCall) Header() http.Header {
709	if c.header_ == nil {
710		c.header_ = make(http.Header)
711	}
712	return c.header_
713}
714
715func (c *UrlListCall) doRequest(alt string) (*http.Response, error) {
716	reqHeaders := make(http.Header)
717	reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
718	for k, v := range c.header_ {
719		reqHeaders[k] = v
720	}
721	reqHeaders.Set("User-Agent", c.s.userAgent())
722	if c.ifNoneMatch_ != "" {
723		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
724	}
725	var body io.Reader = nil
726	c.urlParams_.Set("alt", alt)
727	c.urlParams_.Set("prettyPrint", "false")
728	urls := googleapi.ResolveRelative(c.s.BasePath, "url/history")
729	urls += "?" + c.urlParams_.Encode()
730	req, err := http.NewRequest("GET", urls, body)
731	if err != nil {
732		return nil, err
733	}
734	req.Header = reqHeaders
735	return gensupport.SendRequest(c.ctx_, c.s.client, req)
736}
737
738// Do executes the "urlshortener.url.list" call.
739// Exactly one of *UrlHistory or error will be non-nil. Any non-2xx
740// status code is an error. Response headers are in either
741// *UrlHistory.ServerResponse.Header or (if a response was returned at
742// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
743// to check whether the returned error was because
744// http.StatusNotModified was returned.
745func (c *UrlListCall) Do(opts ...googleapi.CallOption) (*UrlHistory, error) {
746	gensupport.SetOptions(c.urlParams_, opts...)
747	res, err := c.doRequest("json")
748	if res != nil && res.StatusCode == http.StatusNotModified {
749		if res.Body != nil {
750			res.Body.Close()
751		}
752		return nil, &googleapi.Error{
753			Code:   res.StatusCode,
754			Header: res.Header,
755		}
756	}
757	if err != nil {
758		return nil, err
759	}
760	defer googleapi.CloseBody(res)
761	if err := googleapi.CheckResponse(res); err != nil {
762		return nil, err
763	}
764	ret := &UrlHistory{
765		ServerResponse: googleapi.ServerResponse{
766			Header:         res.Header,
767			HTTPStatusCode: res.StatusCode,
768		},
769	}
770	target := &ret
771	if err := gensupport.DecodeResponse(target, res); err != nil {
772		return nil, err
773	}
774	return ret, nil
775	// {
776	//   "description": "Retrieves a list of URLs shortened by a user.",
777	//   "httpMethod": "GET",
778	//   "id": "urlshortener.url.list",
779	//   "parameters": {
780	//     "projection": {
781	//       "description": "Additional information to return.",
782	//       "enum": [
783	//         "ANALYTICS_CLICKS",
784	//         "FULL"
785	//       ],
786	//       "enumDescriptions": [
787	//         "Returns short URL click counts.",
788	//         "Returns short URL click counts."
789	//       ],
790	//       "location": "query",
791	//       "type": "string"
792	//     },
793	//     "start-token": {
794	//       "description": "Token for requesting successive pages of results.",
795	//       "location": "query",
796	//       "type": "string"
797	//     }
798	//   },
799	//   "path": "url/history",
800	//   "response": {
801	//     "$ref": "UrlHistory"
802	//   },
803	//   "scopes": [
804	//     "https://www.googleapis.com/auth/urlshortener"
805	//   ]
806	// }
807
808}
809