...

Source file src/google.golang.org/api/marketingplatformadmin/v1alpha/marketingplatformadmin-gen.go

Documentation: google.golang.org/api/marketingplatformadmin/v1alpha

     1  // Copyright 2024 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 marketingplatformadmin provides access to the Google Marketing Platform Admin API.
     8  //
     9  // For product documentation, see: https://developers.google.com/analytics/devguides/config/gmp/v1
    10  //
    11  // # Library status
    12  //
    13  // These client libraries are officially supported by Google. However, this
    14  // library is considered complete and is in maintenance mode. This means
    15  // that we will address critical bugs and security issues but will not add
    16  // any new features.
    17  //
    18  // When possible, we recommend using our newer
    19  // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
    20  // that are still actively being worked and iterated on.
    21  //
    22  // # Creating a client
    23  //
    24  // Usage example:
    25  //
    26  //	import "google.golang.org/api/marketingplatformadmin/v1alpha"
    27  //	...
    28  //	ctx := context.Background()
    29  //	marketingplatformadminService, err := marketingplatformadmin.NewService(ctx)
    30  //
    31  // In this example, Google Application Default Credentials are used for
    32  // authentication. For information on how to create and obtain Application
    33  // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    34  //
    35  // # Other authentication options
    36  //
    37  // By default, all available scopes (see "Constants") are used to authenticate.
    38  // To restrict scopes, use [google.golang.org/api/option.WithScopes]:
    39  //
    40  //	marketingplatformadminService, err := marketingplatformadmin.NewService(ctx, option.WithScopes(marketingplatformadmin.MarketingplatformadminAnalyticsUpdateScope))
    41  //
    42  // To use an API key for authentication (note: some APIs do not support API
    43  // keys), use [google.golang.org/api/option.WithAPIKey]:
    44  //
    45  //	marketingplatformadminService, err := marketingplatformadmin.NewService(ctx, option.WithAPIKey("AIza..."))
    46  //
    47  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    48  // flow, use [google.golang.org/api/option.WithTokenSource]:
    49  //
    50  //	config := &oauth2.Config{...}
    51  //	// ...
    52  //	token, err := config.Exchange(ctx, ...)
    53  //	marketingplatformadminService, err := marketingplatformadmin.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    54  //
    55  // See [google.golang.org/api/option.ClientOption] for details on options.
    56  package marketingplatformadmin // import "google.golang.org/api/marketingplatformadmin/v1alpha"
    57  
    58  import (
    59  	"bytes"
    60  	"context"
    61  	"encoding/json"
    62  	"errors"
    63  	"fmt"
    64  	"io"
    65  	"net/http"
    66  	"net/url"
    67  	"strconv"
    68  	"strings"
    69  
    70  	googleapi "google.golang.org/api/googleapi"
    71  	internal "google.golang.org/api/internal"
    72  	gensupport "google.golang.org/api/internal/gensupport"
    73  	option "google.golang.org/api/option"
    74  	internaloption "google.golang.org/api/option/internaloption"
    75  	htransport "google.golang.org/api/transport/http"
    76  )
    77  
    78  // Always reference these packages, just in case the auto-generated code
    79  // below doesn't.
    80  var _ = bytes.NewBuffer
    81  var _ = strconv.Itoa
    82  var _ = fmt.Sprintf
    83  var _ = json.NewDecoder
    84  var _ = io.Copy
    85  var _ = url.Parse
    86  var _ = gensupport.MarshalJSON
    87  var _ = googleapi.Version
    88  var _ = errors.New
    89  var _ = strings.Replace
    90  var _ = context.Canceled
    91  var _ = internaloption.WithDefaultEndpoint
    92  var _ = internal.Version
    93  
    94  const apiId = "marketingplatformadmin:v1alpha"
    95  const apiName = "marketingplatformadmin"
    96  const apiVersion = "v1alpha"
    97  const basePath = "https://marketingplatformadmin.googleapis.com/"
    98  const basePathTemplate = "https://marketingplatformadmin.UNIVERSE_DOMAIN/"
    99  const mtlsBasePath = "https://marketingplatformadmin.mtls.googleapis.com/"
   100  
   101  // OAuth2 scopes used by this API.
   102  const (
   103  	// View your Google Analytics product account data in GMP home
   104  	MarketingplatformadminAnalyticsReadScope = "https://www.googleapis.com/auth/marketingplatformadmin.analytics.read"
   105  
   106  	// Manage your Google Analytics product account data in GMP home
   107  	MarketingplatformadminAnalyticsUpdateScope = "https://www.googleapis.com/auth/marketingplatformadmin.analytics.update"
   108  )
   109  
   110  // NewService creates a new Service.
   111  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   112  	scopesOption := internaloption.WithDefaultScopes(
   113  		"https://www.googleapis.com/auth/marketingplatformadmin.analytics.read",
   114  		"https://www.googleapis.com/auth/marketingplatformadmin.analytics.update",
   115  	)
   116  	// NOTE: prepend, so we don't override user-specified scopes.
   117  	opts = append([]option.ClientOption{scopesOption}, opts...)
   118  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   119  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   120  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   121  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   122  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   123  	if err != nil {
   124  		return nil, err
   125  	}
   126  	s, err := New(client)
   127  	if err != nil {
   128  		return nil, err
   129  	}
   130  	if endpoint != "" {
   131  		s.BasePath = endpoint
   132  	}
   133  	return s, nil
   134  }
   135  
   136  // New creates a new Service. It uses the provided http.Client for requests.
   137  //
   138  // Deprecated: please use NewService instead.
   139  // To provide a custom HTTP client, use option.WithHTTPClient.
   140  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   141  func New(client *http.Client) (*Service, error) {
   142  	if client == nil {
   143  		return nil, errors.New("client is nil")
   144  	}
   145  	s := &Service{client: client, BasePath: basePath}
   146  	s.Organizations = NewOrganizationsService(s)
   147  	return s, nil
   148  }
   149  
   150  type Service struct {
   151  	client    *http.Client
   152  	BasePath  string // API endpoint base URL
   153  	UserAgent string // optional additional User-Agent fragment
   154  
   155  	Organizations *OrganizationsService
   156  }
   157  
   158  func (s *Service) userAgent() string {
   159  	if s.UserAgent == "" {
   160  		return googleapi.UserAgent
   161  	}
   162  	return googleapi.UserAgent + " " + s.UserAgent
   163  }
   164  
   165  func NewOrganizationsService(s *Service) *OrganizationsService {
   166  	rs := &OrganizationsService{s: s}
   167  	rs.AnalyticsAccountLinks = NewOrganizationsAnalyticsAccountLinksService(s)
   168  	return rs
   169  }
   170  
   171  type OrganizationsService struct {
   172  	s *Service
   173  
   174  	AnalyticsAccountLinks *OrganizationsAnalyticsAccountLinksService
   175  }
   176  
   177  func NewOrganizationsAnalyticsAccountLinksService(s *Service) *OrganizationsAnalyticsAccountLinksService {
   178  	rs := &OrganizationsAnalyticsAccountLinksService{s: s}
   179  	return rs
   180  }
   181  
   182  type OrganizationsAnalyticsAccountLinksService struct {
   183  	s *Service
   184  }
   185  
   186  // AnalyticsAccountLink: A resource message representing the link between a
   187  // Google Analytics account and a Google Marketing Platform organization.
   188  type AnalyticsAccountLink struct {
   189  	// AnalyticsAccount: Required. Immutable. The resource name of the
   190  	// AnalyticsAdmin API account. The account ID will be used as the ID of this
   191  	// AnalyticsAccountLink resource, which will become the final component of the
   192  	// resource name. Format: analyticsadmin.googleapis.com/accounts/{account_id}
   193  	AnalyticsAccount string `json:"analyticsAccount,omitempty"`
   194  	// DisplayName: Output only. The human-readable name for the Analytics account.
   195  	DisplayName string `json:"displayName,omitempty"`
   196  	// LinkVerificationState: Output only. The verification state of the link
   197  	// between the Analytics account and the parent organization.
   198  	//
   199  	// Possible values:
   200  	//   "LINK_VERIFICATION_STATE_UNSPECIFIED" - The link state is unknown.
   201  	//   "LINK_VERIFICATION_STATE_VERIFIED" - The link is established.
   202  	//   "LINK_VERIFICATION_STATE_NOT_VERIFIED" - The link is requested, but hasn't
   203  	// been approved by the product account admin.
   204  	LinkVerificationState string `json:"linkVerificationState,omitempty"`
   205  	// Name: Identifier. Resource name of this AnalyticsAccountLink. Note the
   206  	// resource ID is the same as the ID of the Analtyics account. Format:
   207  	// organizations/{org_id}/analyticsAccountLinks/{analytics_account_link_id}
   208  	// Example: "organizations/xyz/analyticsAccountLinks/1234"
   209  	Name string `json:"name,omitempty"`
   210  
   211  	// ServerResponse contains the HTTP response code and headers from the server.
   212  	googleapi.ServerResponse `json:"-"`
   213  	// ForceSendFields is a list of field names (e.g. "AnalyticsAccount") to
   214  	// unconditionally include in API requests. By default, fields with empty or
   215  	// default values are omitted from API requests. See
   216  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   217  	// details.
   218  	ForceSendFields []string `json:"-"`
   219  	// NullFields is a list of field names (e.g. "AnalyticsAccount") to include in
   220  	// API requests with the JSON null value. By default, fields with empty values
   221  	// are omitted from API requests. See
   222  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   223  	NullFields []string `json:"-"`
   224  }
   225  
   226  func (s *AnalyticsAccountLink) MarshalJSON() ([]byte, error) {
   227  	type NoMethod AnalyticsAccountLink
   228  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   229  }
   230  
   231  // Empty: A generic empty message that you can re-use to avoid defining
   232  // duplicated empty messages in your APIs. A typical example is to use it as
   233  // the request or the response type of an API method. For instance: service Foo
   234  // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
   235  type Empty struct {
   236  	// ServerResponse contains the HTTP response code and headers from the server.
   237  	googleapi.ServerResponse `json:"-"`
   238  }
   239  
   240  // ListAnalyticsAccountLinksResponse: Response message for
   241  // ListAnalyticsAccountLinks RPC.
   242  type ListAnalyticsAccountLinksResponse struct {
   243  	// AnalyticsAccountLinks: Analytics account links in this organization.
   244  	AnalyticsAccountLinks []*AnalyticsAccountLink `json:"analyticsAccountLinks,omitempty"`
   245  	// NextPageToken: A token, which can be sent as `page_token` to retrieve the
   246  	// next page. If this field is omitted, there are no subsequent pages.
   247  	NextPageToken string `json:"nextPageToken,omitempty"`
   248  
   249  	// ServerResponse contains the HTTP response code and headers from the server.
   250  	googleapi.ServerResponse `json:"-"`
   251  	// ForceSendFields is a list of field names (e.g. "AnalyticsAccountLinks") to
   252  	// unconditionally include in API requests. By default, fields with empty or
   253  	// default values are omitted from API requests. See
   254  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   255  	// details.
   256  	ForceSendFields []string `json:"-"`
   257  	// NullFields is a list of field names (e.g. "AnalyticsAccountLinks") to
   258  	// include in API requests with the JSON null value. By default, fields with
   259  	// empty values are omitted from API requests. See
   260  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   261  	NullFields []string `json:"-"`
   262  }
   263  
   264  func (s *ListAnalyticsAccountLinksResponse) MarshalJSON() ([]byte, error) {
   265  	type NoMethod ListAnalyticsAccountLinksResponse
   266  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   267  }
   268  
   269  // Organization: A resource message representing a Google Marketing Platform
   270  // organization.
   271  type Organization struct {
   272  	// DisplayName: The human-readable name for the organization.
   273  	DisplayName string `json:"displayName,omitempty"`
   274  	// Name: Identifier. The resource name of the GMP organization. Format:
   275  	// organizations/{org_id}
   276  	Name string `json:"name,omitempty"`
   277  
   278  	// ServerResponse contains the HTTP response code and headers from the server.
   279  	googleapi.ServerResponse `json:"-"`
   280  	// ForceSendFields is a list of field names (e.g. "DisplayName") to
   281  	// unconditionally include in API requests. By default, fields with empty or
   282  	// default values are omitted from API requests. See
   283  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   284  	// details.
   285  	ForceSendFields []string `json:"-"`
   286  	// NullFields is a list of field names (e.g. "DisplayName") to include in API
   287  	// requests with the JSON null value. By default, fields with empty values are
   288  	// omitted from API requests. See
   289  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   290  	NullFields []string `json:"-"`
   291  }
   292  
   293  func (s *Organization) MarshalJSON() ([]byte, error) {
   294  	type NoMethod Organization
   295  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   296  }
   297  
   298  // SetPropertyServiceLevelRequest: Request message for SetPropertyServiceLevel
   299  // RPC.
   300  type SetPropertyServiceLevelRequest struct {
   301  	// AnalyticsProperty: Required. The Analytics property to change the
   302  	// ServiceLevel setting. This field is the name of the Google Analytics Admin
   303  	// API property resource. Format:
   304  	// analyticsadmin.googleapis.com/properties/{property_id}
   305  	AnalyticsProperty string `json:"analyticsProperty,omitempty"`
   306  	// ServiceLevel: Required. The service level to set for this property.
   307  	//
   308  	// Possible values:
   309  	//   "ANALYTICS_SERVICE_LEVEL_UNSPECIFIED" - Service level unspecified.
   310  	//   "ANALYTICS_SERVICE_LEVEL_STANDARD" - The standard version of Google
   311  	// Analytics.
   312  	//   "ANALYTICS_SERVICE_LEVEL_360" - The premium version of Google Analytics.
   313  	ServiceLevel string `json:"serviceLevel,omitempty"`
   314  	// ForceSendFields is a list of field names (e.g. "AnalyticsProperty") to
   315  	// unconditionally include in API requests. By default, fields with empty or
   316  	// default values are omitted from API requests. See
   317  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   318  	// details.
   319  	ForceSendFields []string `json:"-"`
   320  	// NullFields is a list of field names (e.g. "AnalyticsProperty") to include in
   321  	// API requests with the JSON null value. By default, fields with empty values
   322  	// are omitted from API requests. See
   323  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   324  	NullFields []string `json:"-"`
   325  }
   326  
   327  func (s *SetPropertyServiceLevelRequest) MarshalJSON() ([]byte, error) {
   328  	type NoMethod SetPropertyServiceLevelRequest
   329  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   330  }
   331  
   332  // SetPropertyServiceLevelResponse: Response message for
   333  // SetPropertyServiceLevel RPC.
   334  type SetPropertyServiceLevelResponse struct {
   335  	// ServerResponse contains the HTTP response code and headers from the server.
   336  	googleapi.ServerResponse `json:"-"`
   337  }
   338  
   339  type OrganizationsGetCall struct {
   340  	s            *Service
   341  	name         string
   342  	urlParams_   gensupport.URLParams
   343  	ifNoneMatch_ string
   344  	ctx_         context.Context
   345  	header_      http.Header
   346  }
   347  
   348  // Get: Lookup for a single organization.
   349  //
   350  //   - name: The name of the Organization to retrieve. Format:
   351  //     organizations/{org_id}.
   352  func (r *OrganizationsService) Get(name string) *OrganizationsGetCall {
   353  	c := &OrganizationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   354  	c.name = name
   355  	return c
   356  }
   357  
   358  // Fields allows partial responses to be retrieved. See
   359  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   360  // details.
   361  func (c *OrganizationsGetCall) Fields(s ...googleapi.Field) *OrganizationsGetCall {
   362  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   363  	return c
   364  }
   365  
   366  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   367  // object's ETag matches the given value. This is useful for getting updates
   368  // only after the object has changed since the last request.
   369  func (c *OrganizationsGetCall) IfNoneMatch(entityTag string) *OrganizationsGetCall {
   370  	c.ifNoneMatch_ = entityTag
   371  	return c
   372  }
   373  
   374  // Context sets the context to be used in this call's Do method.
   375  func (c *OrganizationsGetCall) Context(ctx context.Context) *OrganizationsGetCall {
   376  	c.ctx_ = ctx
   377  	return c
   378  }
   379  
   380  // Header returns a http.Header that can be modified by the caller to add
   381  // headers to the request.
   382  func (c *OrganizationsGetCall) Header() http.Header {
   383  	if c.header_ == nil {
   384  		c.header_ = make(http.Header)
   385  	}
   386  	return c.header_
   387  }
   388  
   389  func (c *OrganizationsGetCall) doRequest(alt string) (*http.Response, error) {
   390  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   391  	if c.ifNoneMatch_ != "" {
   392  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   393  	}
   394  	var body io.Reader = nil
   395  	c.urlParams_.Set("alt", alt)
   396  	c.urlParams_.Set("prettyPrint", "false")
   397  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+name}")
   398  	urls += "?" + c.urlParams_.Encode()
   399  	req, err := http.NewRequest("GET", urls, body)
   400  	if err != nil {
   401  		return nil, err
   402  	}
   403  	req.Header = reqHeaders
   404  	googleapi.Expand(req.URL, map[string]string{
   405  		"name": c.name,
   406  	})
   407  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   408  }
   409  
   410  // Do executes the "marketingplatformadmin.organizations.get" call.
   411  // Any non-2xx status code is an error. Response headers are in either
   412  // *Organization.ServerResponse.Header or (if a response was returned at all)
   413  // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   414  // whether the returned error was because http.StatusNotModified was returned.
   415  func (c *OrganizationsGetCall) Do(opts ...googleapi.CallOption) (*Organization, error) {
   416  	gensupport.SetOptions(c.urlParams_, opts...)
   417  	res, err := c.doRequest("json")
   418  	if res != nil && res.StatusCode == http.StatusNotModified {
   419  		if res.Body != nil {
   420  			res.Body.Close()
   421  		}
   422  		return nil, gensupport.WrapError(&googleapi.Error{
   423  			Code:   res.StatusCode,
   424  			Header: res.Header,
   425  		})
   426  	}
   427  	if err != nil {
   428  		return nil, err
   429  	}
   430  	defer googleapi.CloseBody(res)
   431  	if err := googleapi.CheckResponse(res); err != nil {
   432  		return nil, gensupport.WrapError(err)
   433  	}
   434  	ret := &Organization{
   435  		ServerResponse: googleapi.ServerResponse{
   436  			Header:         res.Header,
   437  			HTTPStatusCode: res.StatusCode,
   438  		},
   439  	}
   440  	target := &ret
   441  	if err := gensupport.DecodeResponse(target, res); err != nil {
   442  		return nil, err
   443  	}
   444  	return ret, nil
   445  }
   446  
   447  type OrganizationsAnalyticsAccountLinksCreateCall struct {
   448  	s                    *Service
   449  	parent               string
   450  	analyticsaccountlink *AnalyticsAccountLink
   451  	urlParams_           gensupport.URLParams
   452  	ctx_                 context.Context
   453  	header_              http.Header
   454  }
   455  
   456  // Create: Creates the link between the Analytics account and the Google
   457  // Marketing Platform organization. User needs to be an org user, and admin on
   458  // the Analytics account to create the link. If the account is already linked
   459  // to an organization, user needs to unlink the account from the current
   460  // organization, then try link again.
   461  //
   462  //   - parent: The parent resource where this Analytics account link will be
   463  //     created. Format: organizations/{org_id}.
   464  func (r *OrganizationsAnalyticsAccountLinksService) Create(parent string, analyticsaccountlink *AnalyticsAccountLink) *OrganizationsAnalyticsAccountLinksCreateCall {
   465  	c := &OrganizationsAnalyticsAccountLinksCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   466  	c.parent = parent
   467  	c.analyticsaccountlink = analyticsaccountlink
   468  	return c
   469  }
   470  
   471  // Fields allows partial responses to be retrieved. See
   472  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   473  // details.
   474  func (c *OrganizationsAnalyticsAccountLinksCreateCall) Fields(s ...googleapi.Field) *OrganizationsAnalyticsAccountLinksCreateCall {
   475  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   476  	return c
   477  }
   478  
   479  // Context sets the context to be used in this call's Do method.
   480  func (c *OrganizationsAnalyticsAccountLinksCreateCall) Context(ctx context.Context) *OrganizationsAnalyticsAccountLinksCreateCall {
   481  	c.ctx_ = ctx
   482  	return c
   483  }
   484  
   485  // Header returns a http.Header that can be modified by the caller to add
   486  // headers to the request.
   487  func (c *OrganizationsAnalyticsAccountLinksCreateCall) Header() http.Header {
   488  	if c.header_ == nil {
   489  		c.header_ = make(http.Header)
   490  	}
   491  	return c.header_
   492  }
   493  
   494  func (c *OrganizationsAnalyticsAccountLinksCreateCall) doRequest(alt string) (*http.Response, error) {
   495  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   496  	var body io.Reader = nil
   497  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.analyticsaccountlink)
   498  	if err != nil {
   499  		return nil, err
   500  	}
   501  	c.urlParams_.Set("alt", alt)
   502  	c.urlParams_.Set("prettyPrint", "false")
   503  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+parent}/analyticsAccountLinks")
   504  	urls += "?" + c.urlParams_.Encode()
   505  	req, err := http.NewRequest("POST", urls, body)
   506  	if err != nil {
   507  		return nil, err
   508  	}
   509  	req.Header = reqHeaders
   510  	googleapi.Expand(req.URL, map[string]string{
   511  		"parent": c.parent,
   512  	})
   513  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   514  }
   515  
   516  // Do executes the "marketingplatformadmin.organizations.analyticsAccountLinks.create" call.
   517  // Any non-2xx status code is an error. Response headers are in either
   518  // *AnalyticsAccountLink.ServerResponse.Header or (if a response was returned
   519  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   520  // check whether the returned error was because http.StatusNotModified was
   521  // returned.
   522  func (c *OrganizationsAnalyticsAccountLinksCreateCall) Do(opts ...googleapi.CallOption) (*AnalyticsAccountLink, error) {
   523  	gensupport.SetOptions(c.urlParams_, opts...)
   524  	res, err := c.doRequest("json")
   525  	if res != nil && res.StatusCode == http.StatusNotModified {
   526  		if res.Body != nil {
   527  			res.Body.Close()
   528  		}
   529  		return nil, gensupport.WrapError(&googleapi.Error{
   530  			Code:   res.StatusCode,
   531  			Header: res.Header,
   532  		})
   533  	}
   534  	if err != nil {
   535  		return nil, err
   536  	}
   537  	defer googleapi.CloseBody(res)
   538  	if err := googleapi.CheckResponse(res); err != nil {
   539  		return nil, gensupport.WrapError(err)
   540  	}
   541  	ret := &AnalyticsAccountLink{
   542  		ServerResponse: googleapi.ServerResponse{
   543  			Header:         res.Header,
   544  			HTTPStatusCode: res.StatusCode,
   545  		},
   546  	}
   547  	target := &ret
   548  	if err := gensupport.DecodeResponse(target, res); err != nil {
   549  		return nil, err
   550  	}
   551  	return ret, nil
   552  }
   553  
   554  type OrganizationsAnalyticsAccountLinksDeleteCall struct {
   555  	s          *Service
   556  	name       string
   557  	urlParams_ gensupport.URLParams
   558  	ctx_       context.Context
   559  	header_    http.Header
   560  }
   561  
   562  // Delete: Deletes the AnalyticsAccountLink, which detaches the Analytics
   563  // account from the Google Marketing Platform organization. User needs to be an
   564  // org user, and admin on the Analytics account in order to delete the link.
   565  //
   566  //   - name: The name of the Analytics account link to delete. Format:
   567  //     organizations/{org_id}/analyticsAccountLinks/{analytics_account_link_id}.
   568  func (r *OrganizationsAnalyticsAccountLinksService) Delete(name string) *OrganizationsAnalyticsAccountLinksDeleteCall {
   569  	c := &OrganizationsAnalyticsAccountLinksDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   570  	c.name = name
   571  	return c
   572  }
   573  
   574  // Fields allows partial responses to be retrieved. See
   575  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   576  // details.
   577  func (c *OrganizationsAnalyticsAccountLinksDeleteCall) Fields(s ...googleapi.Field) *OrganizationsAnalyticsAccountLinksDeleteCall {
   578  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   579  	return c
   580  }
   581  
   582  // Context sets the context to be used in this call's Do method.
   583  func (c *OrganizationsAnalyticsAccountLinksDeleteCall) Context(ctx context.Context) *OrganizationsAnalyticsAccountLinksDeleteCall {
   584  	c.ctx_ = ctx
   585  	return c
   586  }
   587  
   588  // Header returns a http.Header that can be modified by the caller to add
   589  // headers to the request.
   590  func (c *OrganizationsAnalyticsAccountLinksDeleteCall) Header() http.Header {
   591  	if c.header_ == nil {
   592  		c.header_ = make(http.Header)
   593  	}
   594  	return c.header_
   595  }
   596  
   597  func (c *OrganizationsAnalyticsAccountLinksDeleteCall) doRequest(alt string) (*http.Response, error) {
   598  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   599  	var body io.Reader = nil
   600  	c.urlParams_.Set("alt", alt)
   601  	c.urlParams_.Set("prettyPrint", "false")
   602  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+name}")
   603  	urls += "?" + c.urlParams_.Encode()
   604  	req, err := http.NewRequest("DELETE", urls, body)
   605  	if err != nil {
   606  		return nil, err
   607  	}
   608  	req.Header = reqHeaders
   609  	googleapi.Expand(req.URL, map[string]string{
   610  		"name": c.name,
   611  	})
   612  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   613  }
   614  
   615  // Do executes the "marketingplatformadmin.organizations.analyticsAccountLinks.delete" call.
   616  // Any non-2xx status code is an error. Response headers are in either
   617  // *Empty.ServerResponse.Header or (if a response was returned at all) in
   618  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   619  // whether the returned error was because http.StatusNotModified was returned.
   620  func (c *OrganizationsAnalyticsAccountLinksDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
   621  	gensupport.SetOptions(c.urlParams_, opts...)
   622  	res, err := c.doRequest("json")
   623  	if res != nil && res.StatusCode == http.StatusNotModified {
   624  		if res.Body != nil {
   625  			res.Body.Close()
   626  		}
   627  		return nil, gensupport.WrapError(&googleapi.Error{
   628  			Code:   res.StatusCode,
   629  			Header: res.Header,
   630  		})
   631  	}
   632  	if err != nil {
   633  		return nil, err
   634  	}
   635  	defer googleapi.CloseBody(res)
   636  	if err := googleapi.CheckResponse(res); err != nil {
   637  		return nil, gensupport.WrapError(err)
   638  	}
   639  	ret := &Empty{
   640  		ServerResponse: googleapi.ServerResponse{
   641  			Header:         res.Header,
   642  			HTTPStatusCode: res.StatusCode,
   643  		},
   644  	}
   645  	target := &ret
   646  	if err := gensupport.DecodeResponse(target, res); err != nil {
   647  		return nil, err
   648  	}
   649  	return ret, nil
   650  }
   651  
   652  type OrganizationsAnalyticsAccountLinksListCall struct {
   653  	s            *Service
   654  	parent       string
   655  	urlParams_   gensupport.URLParams
   656  	ifNoneMatch_ string
   657  	ctx_         context.Context
   658  	header_      http.Header
   659  }
   660  
   661  // List: Lists the Google Analytics accounts link to the specified Google
   662  // Marketing Platform organization.
   663  //
   664  //   - parent: The parent organization, which owns this collection of Analytics
   665  //     account links. Format: organizations/{org_id}.
   666  func (r *OrganizationsAnalyticsAccountLinksService) List(parent string) *OrganizationsAnalyticsAccountLinksListCall {
   667  	c := &OrganizationsAnalyticsAccountLinksListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   668  	c.parent = parent
   669  	return c
   670  }
   671  
   672  // PageSize sets the optional parameter "pageSize": The maximum number of
   673  // Analytics account links to return in one call. The service may return fewer
   674  // than this value. If unspecified, at most 50 Analytics account links will be
   675  // returned. The maximum value is 1000; values above 1000 will be coerced to
   676  // 1000.
   677  func (c *OrganizationsAnalyticsAccountLinksListCall) PageSize(pageSize int64) *OrganizationsAnalyticsAccountLinksListCall {
   678  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   679  	return c
   680  }
   681  
   682  // PageToken sets the optional parameter "pageToken": A page token, received
   683  // from a previous ListAnalyticsAccountLinks call. Provide this to retrieve the
   684  // subsequent page. When paginating, all other parameters provided to
   685  // `ListAnalyticsAccountLinks` must match the call that provided the page
   686  // token.
   687  func (c *OrganizationsAnalyticsAccountLinksListCall) PageToken(pageToken string) *OrganizationsAnalyticsAccountLinksListCall {
   688  	c.urlParams_.Set("pageToken", pageToken)
   689  	return c
   690  }
   691  
   692  // Fields allows partial responses to be retrieved. See
   693  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   694  // details.
   695  func (c *OrganizationsAnalyticsAccountLinksListCall) Fields(s ...googleapi.Field) *OrganizationsAnalyticsAccountLinksListCall {
   696  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   697  	return c
   698  }
   699  
   700  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   701  // object's ETag matches the given value. This is useful for getting updates
   702  // only after the object has changed since the last request.
   703  func (c *OrganizationsAnalyticsAccountLinksListCall) IfNoneMatch(entityTag string) *OrganizationsAnalyticsAccountLinksListCall {
   704  	c.ifNoneMatch_ = entityTag
   705  	return c
   706  }
   707  
   708  // Context sets the context to be used in this call's Do method.
   709  func (c *OrganizationsAnalyticsAccountLinksListCall) Context(ctx context.Context) *OrganizationsAnalyticsAccountLinksListCall {
   710  	c.ctx_ = ctx
   711  	return c
   712  }
   713  
   714  // Header returns a http.Header that can be modified by the caller to add
   715  // headers to the request.
   716  func (c *OrganizationsAnalyticsAccountLinksListCall) Header() http.Header {
   717  	if c.header_ == nil {
   718  		c.header_ = make(http.Header)
   719  	}
   720  	return c.header_
   721  }
   722  
   723  func (c *OrganizationsAnalyticsAccountLinksListCall) doRequest(alt string) (*http.Response, error) {
   724  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   725  	if c.ifNoneMatch_ != "" {
   726  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   727  	}
   728  	var body io.Reader = nil
   729  	c.urlParams_.Set("alt", alt)
   730  	c.urlParams_.Set("prettyPrint", "false")
   731  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+parent}/analyticsAccountLinks")
   732  	urls += "?" + c.urlParams_.Encode()
   733  	req, err := http.NewRequest("GET", urls, body)
   734  	if err != nil {
   735  		return nil, err
   736  	}
   737  	req.Header = reqHeaders
   738  	googleapi.Expand(req.URL, map[string]string{
   739  		"parent": c.parent,
   740  	})
   741  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   742  }
   743  
   744  // Do executes the "marketingplatformadmin.organizations.analyticsAccountLinks.list" call.
   745  // Any non-2xx status code is an error. Response headers are in either
   746  // *ListAnalyticsAccountLinksResponse.ServerResponse.Header or (if a response
   747  // was returned at all) in error.(*googleapi.Error).Header. Use
   748  // googleapi.IsNotModified to check whether the returned error was because
   749  // http.StatusNotModified was returned.
   750  func (c *OrganizationsAnalyticsAccountLinksListCall) Do(opts ...googleapi.CallOption) (*ListAnalyticsAccountLinksResponse, error) {
   751  	gensupport.SetOptions(c.urlParams_, opts...)
   752  	res, err := c.doRequest("json")
   753  	if res != nil && res.StatusCode == http.StatusNotModified {
   754  		if res.Body != nil {
   755  			res.Body.Close()
   756  		}
   757  		return nil, gensupport.WrapError(&googleapi.Error{
   758  			Code:   res.StatusCode,
   759  			Header: res.Header,
   760  		})
   761  	}
   762  	if err != nil {
   763  		return nil, err
   764  	}
   765  	defer googleapi.CloseBody(res)
   766  	if err := googleapi.CheckResponse(res); err != nil {
   767  		return nil, gensupport.WrapError(err)
   768  	}
   769  	ret := &ListAnalyticsAccountLinksResponse{
   770  		ServerResponse: googleapi.ServerResponse{
   771  			Header:         res.Header,
   772  			HTTPStatusCode: res.StatusCode,
   773  		},
   774  	}
   775  	target := &ret
   776  	if err := gensupport.DecodeResponse(target, res); err != nil {
   777  		return nil, err
   778  	}
   779  	return ret, nil
   780  }
   781  
   782  // Pages invokes f for each page of results.
   783  // A non-nil error returned from f will halt the iteration.
   784  // The provided context supersedes any context provided to the Context method.
   785  func (c *OrganizationsAnalyticsAccountLinksListCall) Pages(ctx context.Context, f func(*ListAnalyticsAccountLinksResponse) error) error {
   786  	c.ctx_ = ctx
   787  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   788  	for {
   789  		x, err := c.Do()
   790  		if err != nil {
   791  			return err
   792  		}
   793  		if err := f(x); err != nil {
   794  			return err
   795  		}
   796  		if x.NextPageToken == "" {
   797  			return nil
   798  		}
   799  		c.PageToken(x.NextPageToken)
   800  	}
   801  }
   802  
   803  type OrganizationsAnalyticsAccountLinksSetPropertyServiceLevelCall struct {
   804  	s                              *Service
   805  	analyticsAccountLink           string
   806  	setpropertyservicelevelrequest *SetPropertyServiceLevelRequest
   807  	urlParams_                     gensupport.URLParams
   808  	ctx_                           context.Context
   809  	header_                        http.Header
   810  }
   811  
   812  // SetPropertyServiceLevel: Updates the service level for an Analytics
   813  // property.
   814  //
   815  //   - analyticsAccountLink: The parent AnalyticsAccountLink scope where this
   816  //     property is in. Format:
   817  //     organizations/{org_id}/analyticsAccountLinks/{analytics_account_link_id}.
   818  func (r *OrganizationsAnalyticsAccountLinksService) SetPropertyServiceLevel(analyticsAccountLink string, setpropertyservicelevelrequest *SetPropertyServiceLevelRequest) *OrganizationsAnalyticsAccountLinksSetPropertyServiceLevelCall {
   819  	c := &OrganizationsAnalyticsAccountLinksSetPropertyServiceLevelCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   820  	c.analyticsAccountLink = analyticsAccountLink
   821  	c.setpropertyservicelevelrequest = setpropertyservicelevelrequest
   822  	return c
   823  }
   824  
   825  // Fields allows partial responses to be retrieved. See
   826  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   827  // details.
   828  func (c *OrganizationsAnalyticsAccountLinksSetPropertyServiceLevelCall) Fields(s ...googleapi.Field) *OrganizationsAnalyticsAccountLinksSetPropertyServiceLevelCall {
   829  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   830  	return c
   831  }
   832  
   833  // Context sets the context to be used in this call's Do method.
   834  func (c *OrganizationsAnalyticsAccountLinksSetPropertyServiceLevelCall) Context(ctx context.Context) *OrganizationsAnalyticsAccountLinksSetPropertyServiceLevelCall {
   835  	c.ctx_ = ctx
   836  	return c
   837  }
   838  
   839  // Header returns a http.Header that can be modified by the caller to add
   840  // headers to the request.
   841  func (c *OrganizationsAnalyticsAccountLinksSetPropertyServiceLevelCall) Header() http.Header {
   842  	if c.header_ == nil {
   843  		c.header_ = make(http.Header)
   844  	}
   845  	return c.header_
   846  }
   847  
   848  func (c *OrganizationsAnalyticsAccountLinksSetPropertyServiceLevelCall) doRequest(alt string) (*http.Response, error) {
   849  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   850  	var body io.Reader = nil
   851  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.setpropertyservicelevelrequest)
   852  	if err != nil {
   853  		return nil, err
   854  	}
   855  	c.urlParams_.Set("alt", alt)
   856  	c.urlParams_.Set("prettyPrint", "false")
   857  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+analyticsAccountLink}:setPropertyServiceLevel")
   858  	urls += "?" + c.urlParams_.Encode()
   859  	req, err := http.NewRequest("POST", urls, body)
   860  	if err != nil {
   861  		return nil, err
   862  	}
   863  	req.Header = reqHeaders
   864  	googleapi.Expand(req.URL, map[string]string{
   865  		"analyticsAccountLink": c.analyticsAccountLink,
   866  	})
   867  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   868  }
   869  
   870  // Do executes the "marketingplatformadmin.organizations.analyticsAccountLinks.setPropertyServiceLevel" call.
   871  // Any non-2xx status code is an error. Response headers are in either
   872  // *SetPropertyServiceLevelResponse.ServerResponse.Header or (if a response was
   873  // returned at all) in error.(*googleapi.Error).Header. Use
   874  // googleapi.IsNotModified to check whether the returned error was because
   875  // http.StatusNotModified was returned.
   876  func (c *OrganizationsAnalyticsAccountLinksSetPropertyServiceLevelCall) Do(opts ...googleapi.CallOption) (*SetPropertyServiceLevelResponse, error) {
   877  	gensupport.SetOptions(c.urlParams_, opts...)
   878  	res, err := c.doRequest("json")
   879  	if res != nil && res.StatusCode == http.StatusNotModified {
   880  		if res.Body != nil {
   881  			res.Body.Close()
   882  		}
   883  		return nil, gensupport.WrapError(&googleapi.Error{
   884  			Code:   res.StatusCode,
   885  			Header: res.Header,
   886  		})
   887  	}
   888  	if err != nil {
   889  		return nil, err
   890  	}
   891  	defer googleapi.CloseBody(res)
   892  	if err := googleapi.CheckResponse(res); err != nil {
   893  		return nil, gensupport.WrapError(err)
   894  	}
   895  	ret := &SetPropertyServiceLevelResponse{
   896  		ServerResponse: googleapi.ServerResponse{
   897  			Header:         res.Header,
   898  			HTTPStatusCode: res.StatusCode,
   899  		},
   900  	}
   901  	target := &ret
   902  	if err := gensupport.DecodeResponse(target, res); err != nil {
   903  		return nil, err
   904  	}
   905  	return ret, nil
   906  }
   907  

View as plain text