...

Source file src/google.golang.org/api/readerrevenuesubscriptionlinking/v1/readerrevenuesubscriptionlinking-gen.go

Documentation: google.golang.org/api/readerrevenuesubscriptionlinking/v1

     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 readerrevenuesubscriptionlinking provides access to the Reader Revenue Subscription Linking API.
     8  //
     9  // For product documentation, see: https://developers.google.com/news/subscribe/subscription-linking/overview
    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/readerrevenuesubscriptionlinking/v1"
    27  //	...
    28  //	ctx := context.Background()
    29  //	readerrevenuesubscriptionlinkingService, err := readerrevenuesubscriptionlinking.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  // To use an API key for authentication (note: some APIs do not support API
    38  // keys), use [google.golang.org/api/option.WithAPIKey]:
    39  //
    40  //	readerrevenuesubscriptionlinkingService, err := readerrevenuesubscriptionlinking.NewService(ctx, option.WithAPIKey("AIza..."))
    41  //
    42  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    43  // flow, use [google.golang.org/api/option.WithTokenSource]:
    44  //
    45  //	config := &oauth2.Config{...}
    46  //	// ...
    47  //	token, err := config.Exchange(ctx, ...)
    48  //	readerrevenuesubscriptionlinkingService, err := readerrevenuesubscriptionlinking.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    49  //
    50  // See [google.golang.org/api/option.ClientOption] for details on options.
    51  package readerrevenuesubscriptionlinking // import "google.golang.org/api/readerrevenuesubscriptionlinking/v1"
    52  
    53  import (
    54  	"bytes"
    55  	"context"
    56  	"encoding/json"
    57  	"errors"
    58  	"fmt"
    59  	"io"
    60  	"net/http"
    61  	"net/url"
    62  	"strconv"
    63  	"strings"
    64  
    65  	googleapi "google.golang.org/api/googleapi"
    66  	internal "google.golang.org/api/internal"
    67  	gensupport "google.golang.org/api/internal/gensupport"
    68  	option "google.golang.org/api/option"
    69  	internaloption "google.golang.org/api/option/internaloption"
    70  	htransport "google.golang.org/api/transport/http"
    71  )
    72  
    73  // Always reference these packages, just in case the auto-generated code
    74  // below doesn't.
    75  var _ = bytes.NewBuffer
    76  var _ = strconv.Itoa
    77  var _ = fmt.Sprintf
    78  var _ = json.NewDecoder
    79  var _ = io.Copy
    80  var _ = url.Parse
    81  var _ = gensupport.MarshalJSON
    82  var _ = googleapi.Version
    83  var _ = errors.New
    84  var _ = strings.Replace
    85  var _ = context.Canceled
    86  var _ = internaloption.WithDefaultEndpoint
    87  var _ = internal.Version
    88  
    89  const apiId = "readerrevenuesubscriptionlinking:v1"
    90  const apiName = "readerrevenuesubscriptionlinking"
    91  const apiVersion = "v1"
    92  const basePath = "https://readerrevenuesubscriptionlinking.googleapis.com/"
    93  const basePathTemplate = "https://readerrevenuesubscriptionlinking.UNIVERSE_DOMAIN/"
    94  const mtlsBasePath = "https://readerrevenuesubscriptionlinking.mtls.googleapis.com/"
    95  
    96  // NewService creates a new Service.
    97  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
    98  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
    99  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   100  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   101  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   102  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   103  	if err != nil {
   104  		return nil, err
   105  	}
   106  	s, err := New(client)
   107  	if err != nil {
   108  		return nil, err
   109  	}
   110  	if endpoint != "" {
   111  		s.BasePath = endpoint
   112  	}
   113  	return s, nil
   114  }
   115  
   116  // New creates a new Service. It uses the provided http.Client for requests.
   117  //
   118  // Deprecated: please use NewService instead.
   119  // To provide a custom HTTP client, use option.WithHTTPClient.
   120  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   121  func New(client *http.Client) (*Service, error) {
   122  	if client == nil {
   123  		return nil, errors.New("client is nil")
   124  	}
   125  	s := &Service{client: client, BasePath: basePath}
   126  	s.Publications = NewPublicationsService(s)
   127  	return s, nil
   128  }
   129  
   130  type Service struct {
   131  	client    *http.Client
   132  	BasePath  string // API endpoint base URL
   133  	UserAgent string // optional additional User-Agent fragment
   134  
   135  	Publications *PublicationsService
   136  }
   137  
   138  func (s *Service) userAgent() string {
   139  	if s.UserAgent == "" {
   140  		return googleapi.UserAgent
   141  	}
   142  	return googleapi.UserAgent + " " + s.UserAgent
   143  }
   144  
   145  func NewPublicationsService(s *Service) *PublicationsService {
   146  	rs := &PublicationsService{s: s}
   147  	rs.Readers = NewPublicationsReadersService(s)
   148  	return rs
   149  }
   150  
   151  type PublicationsService struct {
   152  	s *Service
   153  
   154  	Readers *PublicationsReadersService
   155  }
   156  
   157  func NewPublicationsReadersService(s *Service) *PublicationsReadersService {
   158  	rs := &PublicationsReadersService{s: s}
   159  	return rs
   160  }
   161  
   162  type PublicationsReadersService struct {
   163  	s *Service
   164  }
   165  
   166  // DeleteReaderResponse: Response to deleting a reader of a publication.
   167  type DeleteReaderResponse struct {
   168  	// ServerResponse contains the HTTP response code and headers from the server.
   169  	googleapi.ServerResponse `json:"-"`
   170  }
   171  
   172  // Entitlement: A single entitlement for a publication reader
   173  type Entitlement struct {
   174  	// Detail: The detail field can carry a description of the SKU that corresponds
   175  	// to what the user has been granted access to. This description, which is
   176  	// opaque to Google, can be displayed in the Google user subscription console
   177  	// for users who linked the subscription to a Google Account. Max 80 character
   178  	// limit.
   179  	Detail string `json:"detail,omitempty"`
   180  	// ExpireTime: Required. Expiration time of the entitlement. Entitlements that
   181  	// have expired over 30 days will be purged. Required.
   182  	// LINT.IfChange(expire_time) The max expire_time is 398 days from now().
   183  	// LINT.ThenChange(//depot/google3/java/com/google/subscribewithgoogle/accountli
   184  	// nking/subscriptionlink/service/config/protoconf.pi:max_expiry_age)
   185  	ExpireTime string `json:"expireTime,omitempty"`
   186  	// ProductId: Required. The publication's product ID that the user has access
   187  	// to. This is the same product ID as can be found in Schema.org markup
   188  	// (http://schema.org/productID). E.g. "dailybugle.com:basic"
   189  	ProductId string `json:"productId,omitempty"`
   190  	// SubscriptionToken: A source-specific subscription token. This is an opaque
   191  	// string that the publisher provides to Google. This token is opaque and has
   192  	// no meaning to Google.
   193  	SubscriptionToken string `json:"subscriptionToken,omitempty"`
   194  	// ForceSendFields is a list of field names (e.g. "Detail") to unconditionally
   195  	// include in API requests. By default, fields with empty or default values are
   196  	// omitted from API requests. See
   197  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   198  	// details.
   199  	ForceSendFields []string `json:"-"`
   200  	// NullFields is a list of field names (e.g. "Detail") to include in API
   201  	// requests with the JSON null value. By default, fields with empty values are
   202  	// omitted from API requests. See
   203  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   204  	NullFields []string `json:"-"`
   205  }
   206  
   207  func (s *Entitlement) MarshalJSON() ([]byte, error) {
   208  	type NoMethod Entitlement
   209  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   210  }
   211  
   212  // Reader: A reader of a publication.
   213  type Reader struct {
   214  	// CreateTime: Output only. Time the publication reader was created and
   215  	// associated with a Google user.
   216  	CreateTime string `json:"createTime,omitempty"`
   217  	// Name: Output only. The resource name of the reader. The last part of ppid in
   218  	// the resource name is the publisher provided id.
   219  	Name string `json:"name,omitempty"`
   220  
   221  	// ServerResponse contains the HTTP response code and headers from the server.
   222  	googleapi.ServerResponse `json:"-"`
   223  	// ForceSendFields is a list of field names (e.g. "CreateTime") to
   224  	// unconditionally include in API requests. By default, fields with empty or
   225  	// default values are omitted from API requests. See
   226  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   227  	// details.
   228  	ForceSendFields []string `json:"-"`
   229  	// NullFields is a list of field names (e.g. "CreateTime") to include in API
   230  	// requests with the JSON null value. By default, fields with empty values are
   231  	// omitted from API requests. See
   232  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   233  	NullFields []string `json:"-"`
   234  }
   235  
   236  func (s *Reader) MarshalJSON() ([]byte, error) {
   237  	type NoMethod Reader
   238  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   239  }
   240  
   241  // ReaderEntitlements: A singleton containing all of a reader's entitlements
   242  // for a publication.
   243  type ReaderEntitlements struct {
   244  	// Entitlements: All of the entitlements for a publication reader.
   245  	Entitlements []*Entitlement `json:"entitlements,omitempty"`
   246  	// Name: Output only. The resource name of the singleton.
   247  	Name string `json:"name,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. "Entitlements") 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. "Entitlements") to include in API
   258  	// requests with the JSON null value. By default, fields with empty values are
   259  	// 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 *ReaderEntitlements) MarshalJSON() ([]byte, error) {
   265  	type NoMethod ReaderEntitlements
   266  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   267  }
   268  
   269  type PublicationsReadersDeleteCall struct {
   270  	s          *Service
   271  	name       string
   272  	urlParams_ gensupport.URLParams
   273  	ctx_       context.Context
   274  	header_    http.Header
   275  }
   276  
   277  // Delete: Removes a publication reader, effectively severing the association
   278  // with a Google user. If `force` is set to true, any entitlements for this
   279  // reader will also be deleted. (Otherwise, the request will only work if the
   280  // reader has no entitlements.) - If the reader does not exist, return
   281  // NOT_FOUND. - Return FAILED_PRECONDITION if the force field is false (or
   282  // unset) and entitlements are present.
   283  //
   284  //   - name: The resource name of the reader. Format:
   285  //     publications/{publication_id}/readers/{ppid}.
   286  func (r *PublicationsReadersService) Delete(name string) *PublicationsReadersDeleteCall {
   287  	c := &PublicationsReadersDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   288  	c.name = name
   289  	return c
   290  }
   291  
   292  // Force sets the optional parameter "force": If set to true, any entitlements
   293  // under the reader will also be purged.
   294  func (c *PublicationsReadersDeleteCall) Force(force bool) *PublicationsReadersDeleteCall {
   295  	c.urlParams_.Set("force", fmt.Sprint(force))
   296  	return c
   297  }
   298  
   299  // Fields allows partial responses to be retrieved. See
   300  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   301  // details.
   302  func (c *PublicationsReadersDeleteCall) Fields(s ...googleapi.Field) *PublicationsReadersDeleteCall {
   303  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   304  	return c
   305  }
   306  
   307  // Context sets the context to be used in this call's Do method.
   308  func (c *PublicationsReadersDeleteCall) Context(ctx context.Context) *PublicationsReadersDeleteCall {
   309  	c.ctx_ = ctx
   310  	return c
   311  }
   312  
   313  // Header returns a http.Header that can be modified by the caller to add
   314  // headers to the request.
   315  func (c *PublicationsReadersDeleteCall) Header() http.Header {
   316  	if c.header_ == nil {
   317  		c.header_ = make(http.Header)
   318  	}
   319  	return c.header_
   320  }
   321  
   322  func (c *PublicationsReadersDeleteCall) doRequest(alt string) (*http.Response, error) {
   323  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   324  	var body io.Reader = nil
   325  	c.urlParams_.Set("alt", alt)
   326  	c.urlParams_.Set("prettyPrint", "false")
   327  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   328  	urls += "?" + c.urlParams_.Encode()
   329  	req, err := http.NewRequest("DELETE", urls, body)
   330  	if err != nil {
   331  		return nil, err
   332  	}
   333  	req.Header = reqHeaders
   334  	googleapi.Expand(req.URL, map[string]string{
   335  		"name": c.name,
   336  	})
   337  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   338  }
   339  
   340  // Do executes the "readerrevenuesubscriptionlinking.publications.readers.delete" call.
   341  // Any non-2xx status code is an error. Response headers are in either
   342  // *DeleteReaderResponse.ServerResponse.Header or (if a response was returned
   343  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   344  // check whether the returned error was because http.StatusNotModified was
   345  // returned.
   346  func (c *PublicationsReadersDeleteCall) Do(opts ...googleapi.CallOption) (*DeleteReaderResponse, error) {
   347  	gensupport.SetOptions(c.urlParams_, opts...)
   348  	res, err := c.doRequest("json")
   349  	if res != nil && res.StatusCode == http.StatusNotModified {
   350  		if res.Body != nil {
   351  			res.Body.Close()
   352  		}
   353  		return nil, gensupport.WrapError(&googleapi.Error{
   354  			Code:   res.StatusCode,
   355  			Header: res.Header,
   356  		})
   357  	}
   358  	if err != nil {
   359  		return nil, err
   360  	}
   361  	defer googleapi.CloseBody(res)
   362  	if err := googleapi.CheckResponse(res); err != nil {
   363  		return nil, gensupport.WrapError(err)
   364  	}
   365  	ret := &DeleteReaderResponse{
   366  		ServerResponse: googleapi.ServerResponse{
   367  			Header:         res.Header,
   368  			HTTPStatusCode: res.StatusCode,
   369  		},
   370  	}
   371  	target := &ret
   372  	if err := gensupport.DecodeResponse(target, res); err != nil {
   373  		return nil, err
   374  	}
   375  	return ret, nil
   376  }
   377  
   378  type PublicationsReadersGetCall struct {
   379  	s            *Service
   380  	name         string
   381  	urlParams_   gensupport.URLParams
   382  	ifNoneMatch_ string
   383  	ctx_         context.Context
   384  	header_      http.Header
   385  }
   386  
   387  // Get: Gets a reader of a publication. Returns NOT_FOUND if the reader does
   388  // not exist.
   389  //
   390  //   - name: The resource name of the reader. Format:
   391  //     publications/{publication_id}/readers/{ppid}.
   392  func (r *PublicationsReadersService) Get(name string) *PublicationsReadersGetCall {
   393  	c := &PublicationsReadersGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   394  	c.name = name
   395  	return c
   396  }
   397  
   398  // Fields allows partial responses to be retrieved. See
   399  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   400  // details.
   401  func (c *PublicationsReadersGetCall) Fields(s ...googleapi.Field) *PublicationsReadersGetCall {
   402  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   403  	return c
   404  }
   405  
   406  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   407  // object's ETag matches the given value. This is useful for getting updates
   408  // only after the object has changed since the last request.
   409  func (c *PublicationsReadersGetCall) IfNoneMatch(entityTag string) *PublicationsReadersGetCall {
   410  	c.ifNoneMatch_ = entityTag
   411  	return c
   412  }
   413  
   414  // Context sets the context to be used in this call's Do method.
   415  func (c *PublicationsReadersGetCall) Context(ctx context.Context) *PublicationsReadersGetCall {
   416  	c.ctx_ = ctx
   417  	return c
   418  }
   419  
   420  // Header returns a http.Header that can be modified by the caller to add
   421  // headers to the request.
   422  func (c *PublicationsReadersGetCall) Header() http.Header {
   423  	if c.header_ == nil {
   424  		c.header_ = make(http.Header)
   425  	}
   426  	return c.header_
   427  }
   428  
   429  func (c *PublicationsReadersGetCall) doRequest(alt string) (*http.Response, error) {
   430  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   431  	if c.ifNoneMatch_ != "" {
   432  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   433  	}
   434  	var body io.Reader = nil
   435  	c.urlParams_.Set("alt", alt)
   436  	c.urlParams_.Set("prettyPrint", "false")
   437  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   438  	urls += "?" + c.urlParams_.Encode()
   439  	req, err := http.NewRequest("GET", urls, body)
   440  	if err != nil {
   441  		return nil, err
   442  	}
   443  	req.Header = reqHeaders
   444  	googleapi.Expand(req.URL, map[string]string{
   445  		"name": c.name,
   446  	})
   447  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   448  }
   449  
   450  // Do executes the "readerrevenuesubscriptionlinking.publications.readers.get" call.
   451  // Any non-2xx status code is an error. Response headers are in either
   452  // *Reader.ServerResponse.Header or (if a response was returned at all) in
   453  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   454  // whether the returned error was because http.StatusNotModified was returned.
   455  func (c *PublicationsReadersGetCall) Do(opts ...googleapi.CallOption) (*Reader, error) {
   456  	gensupport.SetOptions(c.urlParams_, opts...)
   457  	res, err := c.doRequest("json")
   458  	if res != nil && res.StatusCode == http.StatusNotModified {
   459  		if res.Body != nil {
   460  			res.Body.Close()
   461  		}
   462  		return nil, gensupport.WrapError(&googleapi.Error{
   463  			Code:   res.StatusCode,
   464  			Header: res.Header,
   465  		})
   466  	}
   467  	if err != nil {
   468  		return nil, err
   469  	}
   470  	defer googleapi.CloseBody(res)
   471  	if err := googleapi.CheckResponse(res); err != nil {
   472  		return nil, gensupport.WrapError(err)
   473  	}
   474  	ret := &Reader{
   475  		ServerResponse: googleapi.ServerResponse{
   476  			Header:         res.Header,
   477  			HTTPStatusCode: res.StatusCode,
   478  		},
   479  	}
   480  	target := &ret
   481  	if err := gensupport.DecodeResponse(target, res); err != nil {
   482  		return nil, err
   483  	}
   484  	return ret, nil
   485  }
   486  
   487  type PublicationsReadersGetEntitlementsCall struct {
   488  	s            *Service
   489  	name         string
   490  	urlParams_   gensupport.URLParams
   491  	ifNoneMatch_ string
   492  	ctx_         context.Context
   493  	header_      http.Header
   494  }
   495  
   496  // GetEntitlements: Gets the reader entitlements for a publication reader. -
   497  // Returns PERMISSION_DENIED if the caller does not have access. - Returns
   498  // NOT_FOUND if the reader does not exist.
   499  //
   500  //   - name: The name of the reader entitlements to retrieve. Format:
   501  //     publications/{publication_id}/readers/{reader_id}/entitlements.
   502  func (r *PublicationsReadersService) GetEntitlements(name string) *PublicationsReadersGetEntitlementsCall {
   503  	c := &PublicationsReadersGetEntitlementsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   504  	c.name = name
   505  	return c
   506  }
   507  
   508  // Fields allows partial responses to be retrieved. See
   509  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   510  // details.
   511  func (c *PublicationsReadersGetEntitlementsCall) Fields(s ...googleapi.Field) *PublicationsReadersGetEntitlementsCall {
   512  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   513  	return c
   514  }
   515  
   516  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   517  // object's ETag matches the given value. This is useful for getting updates
   518  // only after the object has changed since the last request.
   519  func (c *PublicationsReadersGetEntitlementsCall) IfNoneMatch(entityTag string) *PublicationsReadersGetEntitlementsCall {
   520  	c.ifNoneMatch_ = entityTag
   521  	return c
   522  }
   523  
   524  // Context sets the context to be used in this call's Do method.
   525  func (c *PublicationsReadersGetEntitlementsCall) Context(ctx context.Context) *PublicationsReadersGetEntitlementsCall {
   526  	c.ctx_ = ctx
   527  	return c
   528  }
   529  
   530  // Header returns a http.Header that can be modified by the caller to add
   531  // headers to the request.
   532  func (c *PublicationsReadersGetEntitlementsCall) Header() http.Header {
   533  	if c.header_ == nil {
   534  		c.header_ = make(http.Header)
   535  	}
   536  	return c.header_
   537  }
   538  
   539  func (c *PublicationsReadersGetEntitlementsCall) doRequest(alt string) (*http.Response, error) {
   540  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   541  	if c.ifNoneMatch_ != "" {
   542  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   543  	}
   544  	var body io.Reader = nil
   545  	c.urlParams_.Set("alt", alt)
   546  	c.urlParams_.Set("prettyPrint", "false")
   547  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   548  	urls += "?" + c.urlParams_.Encode()
   549  	req, err := http.NewRequest("GET", urls, body)
   550  	if err != nil {
   551  		return nil, err
   552  	}
   553  	req.Header = reqHeaders
   554  	googleapi.Expand(req.URL, map[string]string{
   555  		"name": c.name,
   556  	})
   557  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   558  }
   559  
   560  // Do executes the "readerrevenuesubscriptionlinking.publications.readers.getEntitlements" call.
   561  // Any non-2xx status code is an error. Response headers are in either
   562  // *ReaderEntitlements.ServerResponse.Header or (if a response was returned at
   563  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   564  // check whether the returned error was because http.StatusNotModified was
   565  // returned.
   566  func (c *PublicationsReadersGetEntitlementsCall) Do(opts ...googleapi.CallOption) (*ReaderEntitlements, error) {
   567  	gensupport.SetOptions(c.urlParams_, opts...)
   568  	res, err := c.doRequest("json")
   569  	if res != nil && res.StatusCode == http.StatusNotModified {
   570  		if res.Body != nil {
   571  			res.Body.Close()
   572  		}
   573  		return nil, gensupport.WrapError(&googleapi.Error{
   574  			Code:   res.StatusCode,
   575  			Header: res.Header,
   576  		})
   577  	}
   578  	if err != nil {
   579  		return nil, err
   580  	}
   581  	defer googleapi.CloseBody(res)
   582  	if err := googleapi.CheckResponse(res); err != nil {
   583  		return nil, gensupport.WrapError(err)
   584  	}
   585  	ret := &ReaderEntitlements{
   586  		ServerResponse: googleapi.ServerResponse{
   587  			Header:         res.Header,
   588  			HTTPStatusCode: res.StatusCode,
   589  		},
   590  	}
   591  	target := &ret
   592  	if err := gensupport.DecodeResponse(target, res); err != nil {
   593  		return nil, err
   594  	}
   595  	return ret, nil
   596  }
   597  
   598  type PublicationsReadersUpdateEntitlementsCall struct {
   599  	s                  *Service
   600  	name               string
   601  	readerentitlements *ReaderEntitlements
   602  	urlParams_         gensupport.URLParams
   603  	ctx_               context.Context
   604  	header_            http.Header
   605  }
   606  
   607  // UpdateEntitlements: Updates the reader entitlements for a publication
   608  // reader. The entire reader entitlements will be overwritten by the new reader
   609  // entitlements in the payload, like a PUT. - Returns PERMISSION_DENIED if the
   610  // caller does not have access. - Returns NOT_FOUND if the reader does not
   611  // exist.
   612  //
   613  // - name: Output only. The resource name of the singleton.
   614  func (r *PublicationsReadersService) UpdateEntitlements(name string, readerentitlements *ReaderEntitlements) *PublicationsReadersUpdateEntitlementsCall {
   615  	c := &PublicationsReadersUpdateEntitlementsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   616  	c.name = name
   617  	c.readerentitlements = readerentitlements
   618  	return c
   619  }
   620  
   621  // UpdateMask sets the optional parameter "updateMask": The list of fields to
   622  // update. Defaults to all fields.
   623  func (c *PublicationsReadersUpdateEntitlementsCall) UpdateMask(updateMask string) *PublicationsReadersUpdateEntitlementsCall {
   624  	c.urlParams_.Set("updateMask", updateMask)
   625  	return c
   626  }
   627  
   628  // Fields allows partial responses to be retrieved. See
   629  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   630  // details.
   631  func (c *PublicationsReadersUpdateEntitlementsCall) Fields(s ...googleapi.Field) *PublicationsReadersUpdateEntitlementsCall {
   632  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   633  	return c
   634  }
   635  
   636  // Context sets the context to be used in this call's Do method.
   637  func (c *PublicationsReadersUpdateEntitlementsCall) Context(ctx context.Context) *PublicationsReadersUpdateEntitlementsCall {
   638  	c.ctx_ = ctx
   639  	return c
   640  }
   641  
   642  // Header returns a http.Header that can be modified by the caller to add
   643  // headers to the request.
   644  func (c *PublicationsReadersUpdateEntitlementsCall) Header() http.Header {
   645  	if c.header_ == nil {
   646  		c.header_ = make(http.Header)
   647  	}
   648  	return c.header_
   649  }
   650  
   651  func (c *PublicationsReadersUpdateEntitlementsCall) doRequest(alt string) (*http.Response, error) {
   652  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   653  	var body io.Reader = nil
   654  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.readerentitlements)
   655  	if err != nil {
   656  		return nil, err
   657  	}
   658  	c.urlParams_.Set("alt", alt)
   659  	c.urlParams_.Set("prettyPrint", "false")
   660  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   661  	urls += "?" + c.urlParams_.Encode()
   662  	req, err := http.NewRequest("PATCH", urls, body)
   663  	if err != nil {
   664  		return nil, err
   665  	}
   666  	req.Header = reqHeaders
   667  	googleapi.Expand(req.URL, map[string]string{
   668  		"name": c.name,
   669  	})
   670  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   671  }
   672  
   673  // Do executes the "readerrevenuesubscriptionlinking.publications.readers.updateEntitlements" call.
   674  // Any non-2xx status code is an error. Response headers are in either
   675  // *ReaderEntitlements.ServerResponse.Header or (if a response was returned at
   676  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   677  // check whether the returned error was because http.StatusNotModified was
   678  // returned.
   679  func (c *PublicationsReadersUpdateEntitlementsCall) Do(opts ...googleapi.CallOption) (*ReaderEntitlements, error) {
   680  	gensupport.SetOptions(c.urlParams_, opts...)
   681  	res, err := c.doRequest("json")
   682  	if res != nil && res.StatusCode == http.StatusNotModified {
   683  		if res.Body != nil {
   684  			res.Body.Close()
   685  		}
   686  		return nil, gensupport.WrapError(&googleapi.Error{
   687  			Code:   res.StatusCode,
   688  			Header: res.Header,
   689  		})
   690  	}
   691  	if err != nil {
   692  		return nil, err
   693  	}
   694  	defer googleapi.CloseBody(res)
   695  	if err := googleapi.CheckResponse(res); err != nil {
   696  		return nil, gensupport.WrapError(err)
   697  	}
   698  	ret := &ReaderEntitlements{
   699  		ServerResponse: googleapi.ServerResponse{
   700  			Header:         res.Header,
   701  			HTTPStatusCode: res.StatusCode,
   702  		},
   703  	}
   704  	target := &ret
   705  	if err := gensupport.DecodeResponse(target, res); err != nil {
   706  		return nil, err
   707  	}
   708  	return ret, nil
   709  }
   710  

View as plain text