...

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

Documentation: google.golang.org/api/analytics/v2.4

     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 analytics provides access to the Google Analytics API.
     8  //
     9  // For product documentation, see: https://developers.google.com/analytics/
    10  //
    11  // # Creating a client
    12  //
    13  // Usage example:
    14  //
    15  //	import "google.golang.org/api/analytics/v2.4"
    16  //	...
    17  //	ctx := context.Background()
    18  //	analyticsService, err := analytics.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  // By default, all available scopes (see "Constants") are used to authenticate. To restrict scopes, use option.WithScopes:
    27  //
    28  //	analyticsService, err := analytics.NewService(ctx, option.WithScopes(analytics.AnalyticsReadonlyScope))
    29  //
    30  // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
    31  //
    32  //	analyticsService, err := analytics.NewService(ctx, option.WithAPIKey("AIza..."))
    33  //
    34  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
    35  //
    36  //	config := &oauth2.Config{...}
    37  //	// ...
    38  //	token, err := config.Exchange(ctx, ...)
    39  //	analyticsService, err := analytics.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    40  //
    41  // See https://godoc.org/google.golang.org/api/option/ for details on options.
    42  package analytics // import "google.golang.org/api/analytics/v2.4"
    43  
    44  import (
    45  	"bytes"
    46  	"context"
    47  	"encoding/json"
    48  	"errors"
    49  	"fmt"
    50  	"io"
    51  	"net/http"
    52  	"net/url"
    53  	"strconv"
    54  	"strings"
    55  
    56  	googleapi "google.golang.org/api/googleapi"
    57  	gensupport "google.golang.org/api/internal/gensupport"
    58  	option "google.golang.org/api/option"
    59  	htransport "google.golang.org/api/transport/http"
    60  )
    61  
    62  // Always reference these packages, just in case the auto-generated code
    63  // below doesn't.
    64  var _ = bytes.NewBuffer
    65  var _ = strconv.Itoa
    66  var _ = fmt.Sprintf
    67  var _ = json.NewDecoder
    68  var _ = io.Copy
    69  var _ = url.Parse
    70  var _ = gensupport.MarshalJSON
    71  var _ = googleapi.Version
    72  var _ = errors.New
    73  var _ = strings.Replace
    74  var _ = context.Canceled
    75  
    76  const apiId = "analytics:v2.4"
    77  const apiName = "analytics"
    78  const apiVersion = "v2.4"
    79  const basePath = "https://www.googleapis.com/analytics/v2.4/"
    80  
    81  // OAuth2 scopes used by this API.
    82  const (
    83  	// View and manage your Google Analytics data
    84  	AnalyticsScope = "https://www.googleapis.com/auth/analytics"
    85  
    86  	// View your Google Analytics data
    87  	AnalyticsReadonlyScope = "https://www.googleapis.com/auth/analytics.readonly"
    88  )
    89  
    90  // NewService creates a new Service.
    91  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
    92  	scopesOption := option.WithScopes(
    93  		"https://www.googleapis.com/auth/analytics",
    94  		"https://www.googleapis.com/auth/analytics.readonly",
    95  	)
    96  	// NOTE: prepend, so we don't override user-specified scopes.
    97  	opts = append([]option.ClientOption{scopesOption}, opts...)
    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.
   117  func 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.Data = NewDataService(s)
   123  	s.Management = NewManagementService(s)
   124  	return s, nil
   125  }
   126  
   127  type Service struct {
   128  	client    *http.Client
   129  	BasePath  string // API endpoint base URL
   130  	UserAgent string // optional additional User-Agent fragment
   131  
   132  	Data *DataService
   133  
   134  	Management *ManagementService
   135  }
   136  
   137  func (s *Service) userAgent() string {
   138  	if s.UserAgent == "" {
   139  		return googleapi.UserAgent
   140  	}
   141  	return googleapi.UserAgent + " " + s.UserAgent
   142  }
   143  
   144  func NewDataService(s *Service) *DataService {
   145  	rs := &DataService{s: s}
   146  	return rs
   147  }
   148  
   149  type DataService struct {
   150  	s *Service
   151  }
   152  
   153  func NewManagementService(s *Service) *ManagementService {
   154  	rs := &ManagementService{s: s}
   155  	rs.Accounts = NewManagementAccountsService(s)
   156  	rs.Goals = NewManagementGoalsService(s)
   157  	rs.Profiles = NewManagementProfilesService(s)
   158  	rs.Segments = NewManagementSegmentsService(s)
   159  	rs.Webproperties = NewManagementWebpropertiesService(s)
   160  	return rs
   161  }
   162  
   163  type ManagementService struct {
   164  	s *Service
   165  
   166  	Accounts *ManagementAccountsService
   167  
   168  	Goals *ManagementGoalsService
   169  
   170  	Profiles *ManagementProfilesService
   171  
   172  	Segments *ManagementSegmentsService
   173  
   174  	Webproperties *ManagementWebpropertiesService
   175  }
   176  
   177  func NewManagementAccountsService(s *Service) *ManagementAccountsService {
   178  	rs := &ManagementAccountsService{s: s}
   179  	return rs
   180  }
   181  
   182  type ManagementAccountsService struct {
   183  	s *Service
   184  }
   185  
   186  func NewManagementGoalsService(s *Service) *ManagementGoalsService {
   187  	rs := &ManagementGoalsService{s: s}
   188  	return rs
   189  }
   190  
   191  type ManagementGoalsService struct {
   192  	s *Service
   193  }
   194  
   195  func NewManagementProfilesService(s *Service) *ManagementProfilesService {
   196  	rs := &ManagementProfilesService{s: s}
   197  	return rs
   198  }
   199  
   200  type ManagementProfilesService struct {
   201  	s *Service
   202  }
   203  
   204  func NewManagementSegmentsService(s *Service) *ManagementSegmentsService {
   205  	rs := &ManagementSegmentsService{s: s}
   206  	return rs
   207  }
   208  
   209  type ManagementSegmentsService struct {
   210  	s *Service
   211  }
   212  
   213  func NewManagementWebpropertiesService(s *Service) *ManagementWebpropertiesService {
   214  	rs := &ManagementWebpropertiesService{s: s}
   215  	return rs
   216  }
   217  
   218  type ManagementWebpropertiesService struct {
   219  	s *Service
   220  }
   221  
   222  // method id "analytics.data.get":
   223  
   224  type DataGetCall struct {
   225  	s            *Service
   226  	urlParams_   gensupport.URLParams
   227  	ifNoneMatch_ string
   228  	ctx_         context.Context
   229  	header_      http.Header
   230  }
   231  
   232  // Get: Returns Analytics report data for a view (profile).
   233  func (r *DataService) Get(ids string, startDate string, endDate string, metrics string) *DataGetCall {
   234  	c := &DataGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   235  	c.urlParams_.Set("ids", ids)
   236  	c.urlParams_.Set("start-date", startDate)
   237  	c.urlParams_.Set("end-date", endDate)
   238  	c.urlParams_.Set("metrics", metrics)
   239  	return c
   240  }
   241  
   242  // Dimensions sets the optional parameter "dimensions": A
   243  // comma-separated list of Analytics dimensions. E.g.,
   244  // 'ga:browser,ga:city'.
   245  func (c *DataGetCall) Dimensions(dimensions string) *DataGetCall {
   246  	c.urlParams_.Set("dimensions", dimensions)
   247  	return c
   248  }
   249  
   250  // Filters sets the optional parameter "filters": A comma-separated list
   251  // of dimension or metric filters to be applied to the report data.
   252  func (c *DataGetCall) Filters(filters string) *DataGetCall {
   253  	c.urlParams_.Set("filters", filters)
   254  	return c
   255  }
   256  
   257  // MaxResults sets the optional parameter "max-results": The maximum
   258  // number of entries to include in this feed.
   259  func (c *DataGetCall) MaxResults(maxResults int64) *DataGetCall {
   260  	c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
   261  	return c
   262  }
   263  
   264  // Segment sets the optional parameter "segment": An Analytics advanced
   265  // segment to be applied to the report data.
   266  func (c *DataGetCall) Segment(segment string) *DataGetCall {
   267  	c.urlParams_.Set("segment", segment)
   268  	return c
   269  }
   270  
   271  // Sort sets the optional parameter "sort": A comma-separated list of
   272  // dimensions or metrics that determine the sort order for the report
   273  // data.
   274  func (c *DataGetCall) Sort(sort string) *DataGetCall {
   275  	c.urlParams_.Set("sort", sort)
   276  	return c
   277  }
   278  
   279  // StartIndex sets the optional parameter "start-index": An index of the
   280  // first entity to retrieve. Use this parameter as a pagination
   281  // mechanism along with the max-results parameter.
   282  func (c *DataGetCall) StartIndex(startIndex int64) *DataGetCall {
   283  	c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
   284  	return c
   285  }
   286  
   287  // Fields allows partial responses to be retrieved. See
   288  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   289  // for more information.
   290  func (c *DataGetCall) Fields(s ...googleapi.Field) *DataGetCall {
   291  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   292  	return c
   293  }
   294  
   295  // IfNoneMatch sets the optional parameter which makes the operation
   296  // fail if the object's ETag matches the given value. This is useful for
   297  // getting updates only after the object has changed since the last
   298  // request. Use googleapi.IsNotModified to check whether the response
   299  // error from Do is the result of In-None-Match.
   300  func (c *DataGetCall) IfNoneMatch(entityTag string) *DataGetCall {
   301  	c.ifNoneMatch_ = entityTag
   302  	return c
   303  }
   304  
   305  // Context sets the context to be used in this call's Do method. Any
   306  // pending HTTP request will be aborted if the provided context is
   307  // canceled.
   308  func (c *DataGetCall) Context(ctx context.Context) *DataGetCall {
   309  	c.ctx_ = ctx
   310  	return c
   311  }
   312  
   313  // Header returns an http.Header that can be modified by the caller to
   314  // add HTTP headers to the request.
   315  func (c *DataGetCall) Header() http.Header {
   316  	if c.header_ == nil {
   317  		c.header_ = make(http.Header)
   318  	}
   319  	return c.header_
   320  }
   321  
   322  func (c *DataGetCall) doRequest(alt string) (*http.Response, error) {
   323  	reqHeaders := make(http.Header)
   324  	reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20200206")
   325  	for k, v := range c.header_ {
   326  		reqHeaders[k] = v
   327  	}
   328  	reqHeaders.Set("User-Agent", c.s.userAgent())
   329  	if c.ifNoneMatch_ != "" {
   330  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   331  	}
   332  	var body io.Reader = nil
   333  	c.urlParams_.Set("alt", alt)
   334  	c.urlParams_.Set("prettyPrint", "false")
   335  	urls := googleapi.ResolveRelative(c.s.BasePath, "data")
   336  	urls += "?" + c.urlParams_.Encode()
   337  	req, err := http.NewRequest("GET", urls, body)
   338  	if err != nil {
   339  		return nil, err
   340  	}
   341  	req.Header = reqHeaders
   342  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   343  }
   344  
   345  // Do executes the "analytics.data.get" call.
   346  func (c *DataGetCall) Do(opts ...googleapi.CallOption) error {
   347  	gensupport.SetOptions(c.urlParams_, opts...)
   348  	res, err := c.doRequest("json")
   349  	if err != nil {
   350  		return err
   351  	}
   352  	defer googleapi.CloseBody(res)
   353  	if err := googleapi.CheckResponse(res); err != nil {
   354  		return err
   355  	}
   356  	return nil
   357  	// {
   358  	//   "description": "Returns Analytics report data for a view (profile).",
   359  	//   "httpMethod": "GET",
   360  	//   "id": "analytics.data.get",
   361  	//   "parameterOrder": [
   362  	//     "ids",
   363  	//     "start-date",
   364  	//     "end-date",
   365  	//     "metrics"
   366  	//   ],
   367  	//   "parameters": {
   368  	//     "dimensions": {
   369  	//       "description": "A comma-separated list of Analytics dimensions. E.g., 'ga:browser,ga:city'.",
   370  	//       "location": "query",
   371  	//       "pattern": "(ga:.+)?",
   372  	//       "type": "string"
   373  	//     },
   374  	//     "end-date": {
   375  	//       "description": "End date for fetching report data. All requests should specify an end date formatted as YYYY-MM-DD.",
   376  	//       "location": "query",
   377  	//       "pattern": "[0-9]{4}-[0-9]{2}-[0-9]{2}",
   378  	//       "required": true,
   379  	//       "type": "string"
   380  	//     },
   381  	//     "filters": {
   382  	//       "description": "A comma-separated list of dimension or metric filters to be applied to the report data.",
   383  	//       "location": "query",
   384  	//       "pattern": "ga:.+",
   385  	//       "type": "string"
   386  	//     },
   387  	//     "ids": {
   388  	//       "description": "Unique table ID for retrieving report data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.",
   389  	//       "location": "query",
   390  	//       "pattern": "ga:[0-9]+",
   391  	//       "required": true,
   392  	//       "type": "string"
   393  	//     },
   394  	//     "max-results": {
   395  	//       "description": "The maximum number of entries to include in this feed.",
   396  	//       "format": "int32",
   397  	//       "location": "query",
   398  	//       "type": "integer"
   399  	//     },
   400  	//     "metrics": {
   401  	//       "description": "A comma-separated list of Analytics metrics. E.g., 'ga:sessions,ga:pageviews'. At least one metric must be specified to retrieve a valid Analytics report.",
   402  	//       "location": "query",
   403  	//       "pattern": "ga:.+",
   404  	//       "required": true,
   405  	//       "type": "string"
   406  	//     },
   407  	//     "segment": {
   408  	//       "description": "An Analytics advanced segment to be applied to the report data.",
   409  	//       "location": "query",
   410  	//       "type": "string"
   411  	//     },
   412  	//     "sort": {
   413  	//       "description": "A comma-separated list of dimensions or metrics that determine the sort order for the report data.",
   414  	//       "location": "query",
   415  	//       "pattern": "(-)?ga:.+",
   416  	//       "type": "string"
   417  	//     },
   418  	//     "start-date": {
   419  	//       "description": "Start date for fetching report data. All requests should specify a start date formatted as YYYY-MM-DD.",
   420  	//       "location": "query",
   421  	//       "pattern": "[0-9]{4}-[0-9]{2}-[0-9]{2}",
   422  	//       "required": true,
   423  	//       "type": "string"
   424  	//     },
   425  	//     "start-index": {
   426  	//       "description": "An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
   427  	//       "format": "int32",
   428  	//       "location": "query",
   429  	//       "minimum": "1",
   430  	//       "type": "integer"
   431  	//     }
   432  	//   },
   433  	//   "path": "data",
   434  	//   "scopes": [
   435  	//     "https://www.googleapis.com/auth/analytics",
   436  	//     "https://www.googleapis.com/auth/analytics.readonly"
   437  	//   ]
   438  	// }
   439  
   440  }
   441  
   442  // method id "analytics.management.accounts.list":
   443  
   444  type ManagementAccountsListCall struct {
   445  	s            *Service
   446  	urlParams_   gensupport.URLParams
   447  	ifNoneMatch_ string
   448  	ctx_         context.Context
   449  	header_      http.Header
   450  }
   451  
   452  // List: Lists all accounts to which the user has access.
   453  func (r *ManagementAccountsService) List() *ManagementAccountsListCall {
   454  	c := &ManagementAccountsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   455  	return c
   456  }
   457  
   458  // MaxResults sets the optional parameter "max-results": The maximum
   459  // number of accounts to include in this response.
   460  func (c *ManagementAccountsListCall) MaxResults(maxResults int64) *ManagementAccountsListCall {
   461  	c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
   462  	return c
   463  }
   464  
   465  // StartIndex sets the optional parameter "start-index": An index of the
   466  // first account to retrieve. Use this parameter as a pagination
   467  // mechanism along with the max-results parameter.
   468  func (c *ManagementAccountsListCall) StartIndex(startIndex int64) *ManagementAccountsListCall {
   469  	c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
   470  	return c
   471  }
   472  
   473  // Fields allows partial responses to be retrieved. See
   474  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   475  // for more information.
   476  func (c *ManagementAccountsListCall) Fields(s ...googleapi.Field) *ManagementAccountsListCall {
   477  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   478  	return c
   479  }
   480  
   481  // IfNoneMatch sets the optional parameter which makes the operation
   482  // fail if the object's ETag matches the given value. This is useful for
   483  // getting updates only after the object has changed since the last
   484  // request. Use googleapi.IsNotModified to check whether the response
   485  // error from Do is the result of In-None-Match.
   486  func (c *ManagementAccountsListCall) IfNoneMatch(entityTag string) *ManagementAccountsListCall {
   487  	c.ifNoneMatch_ = entityTag
   488  	return c
   489  }
   490  
   491  // Context sets the context to be used in this call's Do method. Any
   492  // pending HTTP request will be aborted if the provided context is
   493  // canceled.
   494  func (c *ManagementAccountsListCall) Context(ctx context.Context) *ManagementAccountsListCall {
   495  	c.ctx_ = ctx
   496  	return c
   497  }
   498  
   499  // Header returns an http.Header that can be modified by the caller to
   500  // add HTTP headers to the request.
   501  func (c *ManagementAccountsListCall) Header() http.Header {
   502  	if c.header_ == nil {
   503  		c.header_ = make(http.Header)
   504  	}
   505  	return c.header_
   506  }
   507  
   508  func (c *ManagementAccountsListCall) doRequest(alt string) (*http.Response, error) {
   509  	reqHeaders := make(http.Header)
   510  	reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20200206")
   511  	for k, v := range c.header_ {
   512  		reqHeaders[k] = v
   513  	}
   514  	reqHeaders.Set("User-Agent", c.s.userAgent())
   515  	if c.ifNoneMatch_ != "" {
   516  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   517  	}
   518  	var body io.Reader = nil
   519  	c.urlParams_.Set("alt", alt)
   520  	c.urlParams_.Set("prettyPrint", "false")
   521  	urls := googleapi.ResolveRelative(c.s.BasePath, "management/accounts")
   522  	urls += "?" + c.urlParams_.Encode()
   523  	req, err := http.NewRequest("GET", urls, body)
   524  	if err != nil {
   525  		return nil, err
   526  	}
   527  	req.Header = reqHeaders
   528  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   529  }
   530  
   531  // Do executes the "analytics.management.accounts.list" call.
   532  func (c *ManagementAccountsListCall) Do(opts ...googleapi.CallOption) error {
   533  	gensupport.SetOptions(c.urlParams_, opts...)
   534  	res, err := c.doRequest("json")
   535  	if err != nil {
   536  		return err
   537  	}
   538  	defer googleapi.CloseBody(res)
   539  	if err := googleapi.CheckResponse(res); err != nil {
   540  		return err
   541  	}
   542  	return nil
   543  	// {
   544  	//   "description": "Lists all accounts to which the user has access.",
   545  	//   "httpMethod": "GET",
   546  	//   "id": "analytics.management.accounts.list",
   547  	//   "parameters": {
   548  	//     "max-results": {
   549  	//       "description": "The maximum number of accounts to include in this response.",
   550  	//       "format": "int32",
   551  	//       "location": "query",
   552  	//       "type": "integer"
   553  	//     },
   554  	//     "start-index": {
   555  	//       "description": "An index of the first account to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
   556  	//       "format": "int32",
   557  	//       "location": "query",
   558  	//       "minimum": "1",
   559  	//       "type": "integer"
   560  	//     }
   561  	//   },
   562  	//   "path": "management/accounts",
   563  	//   "scopes": [
   564  	//     "https://www.googleapis.com/auth/analytics",
   565  	//     "https://www.googleapis.com/auth/analytics.readonly"
   566  	//   ]
   567  	// }
   568  
   569  }
   570  
   571  // method id "analytics.management.goals.list":
   572  
   573  type ManagementGoalsListCall struct {
   574  	s             *Service
   575  	accountId     string
   576  	webPropertyId string
   577  	profileId     string
   578  	urlParams_    gensupport.URLParams
   579  	ifNoneMatch_  string
   580  	ctx_          context.Context
   581  	header_       http.Header
   582  }
   583  
   584  // List: Lists goals to which the user has access.
   585  func (r *ManagementGoalsService) List(accountId string, webPropertyId string, profileId string) *ManagementGoalsListCall {
   586  	c := &ManagementGoalsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   587  	c.accountId = accountId
   588  	c.webPropertyId = webPropertyId
   589  	c.profileId = profileId
   590  	return c
   591  }
   592  
   593  // MaxResults sets the optional parameter "max-results": The maximum
   594  // number of goals to include in this response.
   595  func (c *ManagementGoalsListCall) MaxResults(maxResults int64) *ManagementGoalsListCall {
   596  	c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
   597  	return c
   598  }
   599  
   600  // StartIndex sets the optional parameter "start-index": An index of the
   601  // first goal to retrieve. Use this parameter as a pagination mechanism
   602  // along with the max-results parameter.
   603  func (c *ManagementGoalsListCall) StartIndex(startIndex int64) *ManagementGoalsListCall {
   604  	c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
   605  	return c
   606  }
   607  
   608  // Fields allows partial responses to be retrieved. See
   609  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   610  // for more information.
   611  func (c *ManagementGoalsListCall) Fields(s ...googleapi.Field) *ManagementGoalsListCall {
   612  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   613  	return c
   614  }
   615  
   616  // IfNoneMatch sets the optional parameter which makes the operation
   617  // fail if the object's ETag matches the given value. This is useful for
   618  // getting updates only after the object has changed since the last
   619  // request. Use googleapi.IsNotModified to check whether the response
   620  // error from Do is the result of In-None-Match.
   621  func (c *ManagementGoalsListCall) IfNoneMatch(entityTag string) *ManagementGoalsListCall {
   622  	c.ifNoneMatch_ = entityTag
   623  	return c
   624  }
   625  
   626  // Context sets the context to be used in this call's Do method. Any
   627  // pending HTTP request will be aborted if the provided context is
   628  // canceled.
   629  func (c *ManagementGoalsListCall) Context(ctx context.Context) *ManagementGoalsListCall {
   630  	c.ctx_ = ctx
   631  	return c
   632  }
   633  
   634  // Header returns an http.Header that can be modified by the caller to
   635  // add HTTP headers to the request.
   636  func (c *ManagementGoalsListCall) Header() http.Header {
   637  	if c.header_ == nil {
   638  		c.header_ = make(http.Header)
   639  	}
   640  	return c.header_
   641  }
   642  
   643  func (c *ManagementGoalsListCall) doRequest(alt string) (*http.Response, error) {
   644  	reqHeaders := make(http.Header)
   645  	reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20200206")
   646  	for k, v := range c.header_ {
   647  		reqHeaders[k] = v
   648  	}
   649  	reqHeaders.Set("User-Agent", c.s.userAgent())
   650  	if c.ifNoneMatch_ != "" {
   651  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   652  	}
   653  	var body io.Reader = nil
   654  	c.urlParams_.Set("alt", alt)
   655  	c.urlParams_.Set("prettyPrint", "false")
   656  	urls := googleapi.ResolveRelative(c.s.BasePath, "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals")
   657  	urls += "?" + c.urlParams_.Encode()
   658  	req, err := http.NewRequest("GET", urls, body)
   659  	if err != nil {
   660  		return nil, err
   661  	}
   662  	req.Header = reqHeaders
   663  	googleapi.Expand(req.URL, map[string]string{
   664  		"accountId":     c.accountId,
   665  		"webPropertyId": c.webPropertyId,
   666  		"profileId":     c.profileId,
   667  	})
   668  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   669  }
   670  
   671  // Do executes the "analytics.management.goals.list" call.
   672  func (c *ManagementGoalsListCall) Do(opts ...googleapi.CallOption) error {
   673  	gensupport.SetOptions(c.urlParams_, opts...)
   674  	res, err := c.doRequest("json")
   675  	if err != nil {
   676  		return err
   677  	}
   678  	defer googleapi.CloseBody(res)
   679  	if err := googleapi.CheckResponse(res); err != nil {
   680  		return err
   681  	}
   682  	return nil
   683  	// {
   684  	//   "description": "Lists goals to which the user has access.",
   685  	//   "httpMethod": "GET",
   686  	//   "id": "analytics.management.goals.list",
   687  	//   "parameterOrder": [
   688  	//     "accountId",
   689  	//     "webPropertyId",
   690  	//     "profileId"
   691  	//   ],
   692  	//   "parameters": {
   693  	//     "accountId": {
   694  	//       "description": "Account ID to retrieve goals for. Can either be a specific account ID or '~all', which refers to all the accounts that user has access to.",
   695  	//       "location": "path",
   696  	//       "required": true,
   697  	//       "type": "string"
   698  	//     },
   699  	//     "max-results": {
   700  	//       "description": "The maximum number of goals to include in this response.",
   701  	//       "format": "int32",
   702  	//       "location": "query",
   703  	//       "type": "integer"
   704  	//     },
   705  	//     "profileId": {
   706  	//       "description": "View (Profile) ID to retrieve goals for. Can either be a specific view (profile) ID or '~all', which refers to all the views (profiles) that user has access to.",
   707  	//       "location": "path",
   708  	//       "required": true,
   709  	//       "type": "string"
   710  	//     },
   711  	//     "start-index": {
   712  	//       "description": "An index of the first goal to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
   713  	//       "format": "int32",
   714  	//       "location": "query",
   715  	//       "minimum": "1",
   716  	//       "type": "integer"
   717  	//     },
   718  	//     "webPropertyId": {
   719  	//       "description": "Web property ID to retrieve goals for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.",
   720  	//       "location": "path",
   721  	//       "required": true,
   722  	//       "type": "string"
   723  	//     }
   724  	//   },
   725  	//   "path": "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals",
   726  	//   "scopes": [
   727  	//     "https://www.googleapis.com/auth/analytics",
   728  	//     "https://www.googleapis.com/auth/analytics.readonly"
   729  	//   ]
   730  	// }
   731  
   732  }
   733  
   734  // method id "analytics.management.profiles.list":
   735  
   736  type ManagementProfilesListCall struct {
   737  	s             *Service
   738  	accountId     string
   739  	webPropertyId string
   740  	urlParams_    gensupport.URLParams
   741  	ifNoneMatch_  string
   742  	ctx_          context.Context
   743  	header_       http.Header
   744  }
   745  
   746  // List: Lists views (profiles) to which the user has access.
   747  func (r *ManagementProfilesService) List(accountId string, webPropertyId string) *ManagementProfilesListCall {
   748  	c := &ManagementProfilesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   749  	c.accountId = accountId
   750  	c.webPropertyId = webPropertyId
   751  	return c
   752  }
   753  
   754  // MaxResults sets the optional parameter "max-results": The maximum
   755  // number of views (profiles) to include in this response.
   756  func (c *ManagementProfilesListCall) MaxResults(maxResults int64) *ManagementProfilesListCall {
   757  	c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
   758  	return c
   759  }
   760  
   761  // StartIndex sets the optional parameter "start-index": An index of the
   762  // first entity to retrieve. Use this parameter as a pagination
   763  // mechanism along with the max-results parameter.
   764  func (c *ManagementProfilesListCall) StartIndex(startIndex int64) *ManagementProfilesListCall {
   765  	c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
   766  	return c
   767  }
   768  
   769  // Fields allows partial responses to be retrieved. See
   770  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   771  // for more information.
   772  func (c *ManagementProfilesListCall) Fields(s ...googleapi.Field) *ManagementProfilesListCall {
   773  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   774  	return c
   775  }
   776  
   777  // IfNoneMatch sets the optional parameter which makes the operation
   778  // fail if the object's ETag matches the given value. This is useful for
   779  // getting updates only after the object has changed since the last
   780  // request. Use googleapi.IsNotModified to check whether the response
   781  // error from Do is the result of In-None-Match.
   782  func (c *ManagementProfilesListCall) IfNoneMatch(entityTag string) *ManagementProfilesListCall {
   783  	c.ifNoneMatch_ = entityTag
   784  	return c
   785  }
   786  
   787  // Context sets the context to be used in this call's Do method. Any
   788  // pending HTTP request will be aborted if the provided context is
   789  // canceled.
   790  func (c *ManagementProfilesListCall) Context(ctx context.Context) *ManagementProfilesListCall {
   791  	c.ctx_ = ctx
   792  	return c
   793  }
   794  
   795  // Header returns an http.Header that can be modified by the caller to
   796  // add HTTP headers to the request.
   797  func (c *ManagementProfilesListCall) Header() http.Header {
   798  	if c.header_ == nil {
   799  		c.header_ = make(http.Header)
   800  	}
   801  	return c.header_
   802  }
   803  
   804  func (c *ManagementProfilesListCall) doRequest(alt string) (*http.Response, error) {
   805  	reqHeaders := make(http.Header)
   806  	reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20200206")
   807  	for k, v := range c.header_ {
   808  		reqHeaders[k] = v
   809  	}
   810  	reqHeaders.Set("User-Agent", c.s.userAgent())
   811  	if c.ifNoneMatch_ != "" {
   812  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   813  	}
   814  	var body io.Reader = nil
   815  	c.urlParams_.Set("alt", alt)
   816  	c.urlParams_.Set("prettyPrint", "false")
   817  	urls := googleapi.ResolveRelative(c.s.BasePath, "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles")
   818  	urls += "?" + c.urlParams_.Encode()
   819  	req, err := http.NewRequest("GET", urls, body)
   820  	if err != nil {
   821  		return nil, err
   822  	}
   823  	req.Header = reqHeaders
   824  	googleapi.Expand(req.URL, map[string]string{
   825  		"accountId":     c.accountId,
   826  		"webPropertyId": c.webPropertyId,
   827  	})
   828  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   829  }
   830  
   831  // Do executes the "analytics.management.profiles.list" call.
   832  func (c *ManagementProfilesListCall) Do(opts ...googleapi.CallOption) error {
   833  	gensupport.SetOptions(c.urlParams_, opts...)
   834  	res, err := c.doRequest("json")
   835  	if err != nil {
   836  		return err
   837  	}
   838  	defer googleapi.CloseBody(res)
   839  	if err := googleapi.CheckResponse(res); err != nil {
   840  		return err
   841  	}
   842  	return nil
   843  	// {
   844  	//   "description": "Lists views (profiles) to which the user has access.",
   845  	//   "httpMethod": "GET",
   846  	//   "id": "analytics.management.profiles.list",
   847  	//   "parameterOrder": [
   848  	//     "accountId",
   849  	//     "webPropertyId"
   850  	//   ],
   851  	//   "parameters": {
   852  	//     "accountId": {
   853  	//       "description": "Account ID for the views (profiles) to retrieve. Can either be a specific account ID or '~all', which refers to all the accounts to which the user has access.",
   854  	//       "location": "path",
   855  	//       "required": true,
   856  	//       "type": "string"
   857  	//     },
   858  	//     "max-results": {
   859  	//       "description": "The maximum number of views (profiles) to include in this response.",
   860  	//       "format": "int32",
   861  	//       "location": "query",
   862  	//       "type": "integer"
   863  	//     },
   864  	//     "start-index": {
   865  	//       "description": "An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
   866  	//       "format": "int32",
   867  	//       "location": "query",
   868  	//       "minimum": "1",
   869  	//       "type": "integer"
   870  	//     },
   871  	//     "webPropertyId": {
   872  	//       "description": "Web property ID for the views (profiles) to retrieve. Can either be a specific web property ID or '~all', which refers to all the web properties to which the user has access.",
   873  	//       "location": "path",
   874  	//       "required": true,
   875  	//       "type": "string"
   876  	//     }
   877  	//   },
   878  	//   "path": "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles",
   879  	//   "scopes": [
   880  	//     "https://www.googleapis.com/auth/analytics",
   881  	//     "https://www.googleapis.com/auth/analytics.readonly"
   882  	//   ]
   883  	// }
   884  
   885  }
   886  
   887  // method id "analytics.management.segments.list":
   888  
   889  type ManagementSegmentsListCall struct {
   890  	s            *Service
   891  	urlParams_   gensupport.URLParams
   892  	ifNoneMatch_ string
   893  	ctx_         context.Context
   894  	header_      http.Header
   895  }
   896  
   897  // List: Lists advanced segments to which the user has access.
   898  func (r *ManagementSegmentsService) List() *ManagementSegmentsListCall {
   899  	c := &ManagementSegmentsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   900  	return c
   901  }
   902  
   903  // MaxResults sets the optional parameter "max-results": The maximum
   904  // number of advanced segments to include in this response.
   905  func (c *ManagementSegmentsListCall) MaxResults(maxResults int64) *ManagementSegmentsListCall {
   906  	c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
   907  	return c
   908  }
   909  
   910  // StartIndex sets the optional parameter "start-index": An index of the
   911  // first advanced segment to retrieve. Use this parameter as a
   912  // pagination mechanism along with the max-results parameter.
   913  func (c *ManagementSegmentsListCall) StartIndex(startIndex int64) *ManagementSegmentsListCall {
   914  	c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
   915  	return c
   916  }
   917  
   918  // Fields allows partial responses to be retrieved. See
   919  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
   920  // for more information.
   921  func (c *ManagementSegmentsListCall) Fields(s ...googleapi.Field) *ManagementSegmentsListCall {
   922  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   923  	return c
   924  }
   925  
   926  // IfNoneMatch sets the optional parameter which makes the operation
   927  // fail if the object's ETag matches the given value. This is useful for
   928  // getting updates only after the object has changed since the last
   929  // request. Use googleapi.IsNotModified to check whether the response
   930  // error from Do is the result of In-None-Match.
   931  func (c *ManagementSegmentsListCall) IfNoneMatch(entityTag string) *ManagementSegmentsListCall {
   932  	c.ifNoneMatch_ = entityTag
   933  	return c
   934  }
   935  
   936  // Context sets the context to be used in this call's Do method. Any
   937  // pending HTTP request will be aborted if the provided context is
   938  // canceled.
   939  func (c *ManagementSegmentsListCall) Context(ctx context.Context) *ManagementSegmentsListCall {
   940  	c.ctx_ = ctx
   941  	return c
   942  }
   943  
   944  // Header returns an http.Header that can be modified by the caller to
   945  // add HTTP headers to the request.
   946  func (c *ManagementSegmentsListCall) Header() http.Header {
   947  	if c.header_ == nil {
   948  		c.header_ = make(http.Header)
   949  	}
   950  	return c.header_
   951  }
   952  
   953  func (c *ManagementSegmentsListCall) doRequest(alt string) (*http.Response, error) {
   954  	reqHeaders := make(http.Header)
   955  	reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20200206")
   956  	for k, v := range c.header_ {
   957  		reqHeaders[k] = v
   958  	}
   959  	reqHeaders.Set("User-Agent", c.s.userAgent())
   960  	if c.ifNoneMatch_ != "" {
   961  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   962  	}
   963  	var body io.Reader = nil
   964  	c.urlParams_.Set("alt", alt)
   965  	c.urlParams_.Set("prettyPrint", "false")
   966  	urls := googleapi.ResolveRelative(c.s.BasePath, "management/segments")
   967  	urls += "?" + c.urlParams_.Encode()
   968  	req, err := http.NewRequest("GET", urls, body)
   969  	if err != nil {
   970  		return nil, err
   971  	}
   972  	req.Header = reqHeaders
   973  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   974  }
   975  
   976  // Do executes the "analytics.management.segments.list" call.
   977  func (c *ManagementSegmentsListCall) Do(opts ...googleapi.CallOption) error {
   978  	gensupport.SetOptions(c.urlParams_, opts...)
   979  	res, err := c.doRequest("json")
   980  	if err != nil {
   981  		return err
   982  	}
   983  	defer googleapi.CloseBody(res)
   984  	if err := googleapi.CheckResponse(res); err != nil {
   985  		return err
   986  	}
   987  	return nil
   988  	// {
   989  	//   "description": "Lists advanced segments to which the user has access.",
   990  	//   "httpMethod": "GET",
   991  	//   "id": "analytics.management.segments.list",
   992  	//   "parameters": {
   993  	//     "max-results": {
   994  	//       "description": "The maximum number of advanced segments to include in this response.",
   995  	//       "format": "int32",
   996  	//       "location": "query",
   997  	//       "type": "integer"
   998  	//     },
   999  	//     "start-index": {
  1000  	//       "description": "An index of the first advanced segment to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
  1001  	//       "format": "int32",
  1002  	//       "location": "query",
  1003  	//       "minimum": "1",
  1004  	//       "type": "integer"
  1005  	//     }
  1006  	//   },
  1007  	//   "path": "management/segments",
  1008  	//   "scopes": [
  1009  	//     "https://www.googleapis.com/auth/analytics",
  1010  	//     "https://www.googleapis.com/auth/analytics.readonly"
  1011  	//   ]
  1012  	// }
  1013  
  1014  }
  1015  
  1016  // method id "analytics.management.webproperties.list":
  1017  
  1018  type ManagementWebpropertiesListCall struct {
  1019  	s            *Service
  1020  	accountId    string
  1021  	urlParams_   gensupport.URLParams
  1022  	ifNoneMatch_ string
  1023  	ctx_         context.Context
  1024  	header_      http.Header
  1025  }
  1026  
  1027  // List: Lists web properties to which the user has access.
  1028  func (r *ManagementWebpropertiesService) List(accountId string) *ManagementWebpropertiesListCall {
  1029  	c := &ManagementWebpropertiesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1030  	c.accountId = accountId
  1031  	return c
  1032  }
  1033  
  1034  // MaxResults sets the optional parameter "max-results": The maximum
  1035  // number of web properties to include in this response.
  1036  func (c *ManagementWebpropertiesListCall) MaxResults(maxResults int64) *ManagementWebpropertiesListCall {
  1037  	c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
  1038  	return c
  1039  }
  1040  
  1041  // StartIndex sets the optional parameter "start-index": An index of the
  1042  // first entity to retrieve. Use this parameter as a pagination
  1043  // mechanism along with the max-results parameter.
  1044  func (c *ManagementWebpropertiesListCall) StartIndex(startIndex int64) *ManagementWebpropertiesListCall {
  1045  	c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
  1046  	return c
  1047  }
  1048  
  1049  // Fields allows partial responses to be retrieved. See
  1050  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1051  // for more information.
  1052  func (c *ManagementWebpropertiesListCall) Fields(s ...googleapi.Field) *ManagementWebpropertiesListCall {
  1053  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1054  	return c
  1055  }
  1056  
  1057  // IfNoneMatch sets the optional parameter which makes the operation
  1058  // fail if the object's ETag matches the given value. This is useful for
  1059  // getting updates only after the object has changed since the last
  1060  // request. Use googleapi.IsNotModified to check whether the response
  1061  // error from Do is the result of In-None-Match.
  1062  func (c *ManagementWebpropertiesListCall) IfNoneMatch(entityTag string) *ManagementWebpropertiesListCall {
  1063  	c.ifNoneMatch_ = entityTag
  1064  	return c
  1065  }
  1066  
  1067  // Context sets the context to be used in this call's Do method. Any
  1068  // pending HTTP request will be aborted if the provided context is
  1069  // canceled.
  1070  func (c *ManagementWebpropertiesListCall) Context(ctx context.Context) *ManagementWebpropertiesListCall {
  1071  	c.ctx_ = ctx
  1072  	return c
  1073  }
  1074  
  1075  // Header returns an http.Header that can be modified by the caller to
  1076  // add HTTP headers to the request.
  1077  func (c *ManagementWebpropertiesListCall) Header() http.Header {
  1078  	if c.header_ == nil {
  1079  		c.header_ = make(http.Header)
  1080  	}
  1081  	return c.header_
  1082  }
  1083  
  1084  func (c *ManagementWebpropertiesListCall) doRequest(alt string) (*http.Response, error) {
  1085  	reqHeaders := make(http.Header)
  1086  	reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20200206")
  1087  	for k, v := range c.header_ {
  1088  		reqHeaders[k] = v
  1089  	}
  1090  	reqHeaders.Set("User-Agent", c.s.userAgent())
  1091  	if c.ifNoneMatch_ != "" {
  1092  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1093  	}
  1094  	var body io.Reader = nil
  1095  	c.urlParams_.Set("alt", alt)
  1096  	c.urlParams_.Set("prettyPrint", "false")
  1097  	urls := googleapi.ResolveRelative(c.s.BasePath, "management/accounts/{accountId}/webproperties")
  1098  	urls += "?" + c.urlParams_.Encode()
  1099  	req, err := http.NewRequest("GET", urls, body)
  1100  	if err != nil {
  1101  		return nil, err
  1102  	}
  1103  	req.Header = reqHeaders
  1104  	googleapi.Expand(req.URL, map[string]string{
  1105  		"accountId": c.accountId,
  1106  	})
  1107  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1108  }
  1109  
  1110  // Do executes the "analytics.management.webproperties.list" call.
  1111  func (c *ManagementWebpropertiesListCall) Do(opts ...googleapi.CallOption) error {
  1112  	gensupport.SetOptions(c.urlParams_, opts...)
  1113  	res, err := c.doRequest("json")
  1114  	if err != nil {
  1115  		return err
  1116  	}
  1117  	defer googleapi.CloseBody(res)
  1118  	if err := googleapi.CheckResponse(res); err != nil {
  1119  		return err
  1120  	}
  1121  	return nil
  1122  	// {
  1123  	//   "description": "Lists web properties to which the user has access.",
  1124  	//   "httpMethod": "GET",
  1125  	//   "id": "analytics.management.webproperties.list",
  1126  	//   "parameterOrder": [
  1127  	//     "accountId"
  1128  	//   ],
  1129  	//   "parameters": {
  1130  	//     "accountId": {
  1131  	//       "description": "Account ID to retrieve web properties for. Can either be a specific account ID or '~all', which refers to all the accounts that user has access to.",
  1132  	//       "location": "path",
  1133  	//       "required": true,
  1134  	//       "type": "string"
  1135  	//     },
  1136  	//     "max-results": {
  1137  	//       "description": "The maximum number of web properties to include in this response.",
  1138  	//       "format": "int32",
  1139  	//       "location": "query",
  1140  	//       "type": "integer"
  1141  	//     },
  1142  	//     "start-index": {
  1143  	//       "description": "An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
  1144  	//       "format": "int32",
  1145  	//       "location": "query",
  1146  	//       "minimum": "1",
  1147  	//       "type": "integer"
  1148  	//     }
  1149  	//   },
  1150  	//   "path": "management/accounts/{accountId}/webproperties",
  1151  	//   "scopes": [
  1152  	//     "https://www.googleapis.com/auth/analytics",
  1153  	//     "https://www.googleapis.com/auth/analytics.readonly"
  1154  	//   ]
  1155  	// }
  1156  
  1157  }
  1158  

View as plain text