...

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

Documentation: google.golang.org/api/acmedns/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 acmedns provides access to the ACME DNS API.
     8  //
     9  // For product documentation, see: https://developers.google.com/domains/acme-dns/
    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/acmedns/v1"
    27  //	...
    28  //	ctx := context.Background()
    29  //	acmednsService, err := acmedns.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  //	acmednsService, err := acmedns.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  //	acmednsService, err := acmedns.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    49  //
    50  // See [google.golang.org/api/option.ClientOption] for details on options.
    51  package acmedns // import "google.golang.org/api/acmedns/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 = "acmedns:v1"
    90  const apiName = "acmedns"
    91  const apiVersion = "v1"
    92  const basePath = "https://acmedns.googleapis.com/"
    93  const basePathTemplate = "https://acmedns.UNIVERSE_DOMAIN/"
    94  const mtlsBasePath = "https://acmedns.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.AcmeChallengeSets = NewAcmeChallengeSetsService(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  	AcmeChallengeSets *AcmeChallengeSetsService
   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 NewAcmeChallengeSetsService(s *Service) *AcmeChallengeSetsService {
   146  	rs := &AcmeChallengeSetsService{s: s}
   147  	return rs
   148  }
   149  
   150  type AcmeChallengeSetsService struct {
   151  	s *Service
   152  }
   153  
   154  // AcmeChallengeSet: The up-to-date ACME challenge set on a domain for an RPC.
   155  // This contains all of the ACME TXT records that exist on the domain.
   156  type AcmeChallengeSet struct {
   157  	// Record: The ACME challenges on the requested domain represented as
   158  	// individual TXT records.
   159  	Record []*AcmeTxtRecord `json:"record,omitempty"`
   160  
   161  	// ServerResponse contains the HTTP response code and headers from the server.
   162  	googleapi.ServerResponse `json:"-"`
   163  	// ForceSendFields is a list of field names (e.g. "Record") to unconditionally
   164  	// include in API requests. By default, fields with empty or default values are
   165  	// omitted from API requests. See
   166  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   167  	// details.
   168  	ForceSendFields []string `json:"-"`
   169  	// NullFields is a list of field names (e.g. "Record") to include in API
   170  	// requests with the JSON null value. By default, fields with empty values are
   171  	// omitted from API requests. See
   172  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   173  	NullFields []string `json:"-"`
   174  }
   175  
   176  func (s *AcmeChallengeSet) MarshalJSON() ([]byte, error) {
   177  	type NoMethod AcmeChallengeSet
   178  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   179  }
   180  
   181  // AcmeTxtRecord: The TXT record message that represents an ACME DNS-01
   182  // challenge.
   183  type AcmeTxtRecord struct {
   184  	// Digest: Holds the ACME challenge data put in the TXT record. This will be
   185  	// checked to be a valid TXT record data entry.
   186  	Digest string `json:"digest,omitempty"`
   187  	// Fqdn: The domain/subdomain for the record. In a request, this MAY be Unicode
   188  	// or Punycode. In a response, this will be in Unicode. The fqdn MUST contain
   189  	// the root_domain field on the request.
   190  	Fqdn string `json:"fqdn,omitempty"`
   191  	// UpdateTime: Output only. The time when this record was last updated. This
   192  	// will be in UTC time.
   193  	UpdateTime string `json:"updateTime,omitempty"`
   194  	// ForceSendFields is a list of field names (e.g. "Digest") 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. "Digest") 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 *AcmeTxtRecord) MarshalJSON() ([]byte, error) {
   208  	type NoMethod AcmeTxtRecord
   209  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   210  }
   211  
   212  // RotateChallengesRequest: The request message for the RotateChallenges RPC.
   213  // Requires an access token, a root domain, and either records_to_add or
   214  // records_to_remove to be populated. Records may be set for multiple
   215  // subdomains at once to support SAN requests for multiple subdomains in a
   216  // single domain. By default, ACME TXT record challenges that are older than 30
   217  // days will be removed. Set `keep_expired_records` to false if this behavior
   218  // is undesired. There is a record maximum of 100 records per domain including
   219  // expired records. Any request sent that would exceed this maximum will result
   220  // in a FAILED_PRECONDITION error. NEXT ID: 6
   221  type RotateChallengesRequest struct {
   222  	// AccessToken: Required. ACME DNS access token. This is a base64 token secret
   223  	// that is procured from the Google Domains website. It authorizes ACME TXT
   224  	// record updates for a domain.
   225  	AccessToken string `json:"accessToken,omitempty"`
   226  	// KeepExpiredRecords: Keep records older than 30 days that were used for
   227  	// previous requests.
   228  	KeepExpiredRecords bool `json:"keepExpiredRecords,omitempty"`
   229  	// RecordsToAdd: ACME TXT record challenges to add. Supports multiple
   230  	// challenges on the same FQDN.
   231  	RecordsToAdd []*AcmeTxtRecord `json:"recordsToAdd,omitempty"`
   232  	// RecordsToRemove: ACME TXT record challenges to remove.
   233  	RecordsToRemove []*AcmeTxtRecord `json:"recordsToRemove,omitempty"`
   234  	// ForceSendFields is a list of field names (e.g. "AccessToken") to
   235  	// unconditionally include in API requests. By default, fields with empty or
   236  	// default values are omitted from API requests. See
   237  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   238  	// details.
   239  	ForceSendFields []string `json:"-"`
   240  	// NullFields is a list of field names (e.g. "AccessToken") to include in API
   241  	// requests with the JSON null value. By default, fields with empty values are
   242  	// omitted from API requests. See
   243  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   244  	NullFields []string `json:"-"`
   245  }
   246  
   247  func (s *RotateChallengesRequest) MarshalJSON() ([]byte, error) {
   248  	type NoMethod RotateChallengesRequest
   249  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   250  }
   251  
   252  type AcmeChallengeSetsGetCall struct {
   253  	s            *Service
   254  	rootDomain   string
   255  	urlParams_   gensupport.URLParams
   256  	ifNoneMatch_ string
   257  	ctx_         context.Context
   258  	header_      http.Header
   259  }
   260  
   261  // Get: Gets the ACME challenge set for a given domain name. Domain names must
   262  // be provided in Punycode.
   263  //
   264  //   - rootDomain: SLD + TLD domain name to list challenges. For example, this
   265  //     would be "google.com" for any FQDN under "google.com". That includes
   266  //     challenges for "subdomain.google.com". This MAY be Unicode or Punycode.
   267  func (r *AcmeChallengeSetsService) Get(rootDomain string) *AcmeChallengeSetsGetCall {
   268  	c := &AcmeChallengeSetsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   269  	c.rootDomain = rootDomain
   270  	return c
   271  }
   272  
   273  // Fields allows partial responses to be retrieved. See
   274  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   275  // details.
   276  func (c *AcmeChallengeSetsGetCall) Fields(s ...googleapi.Field) *AcmeChallengeSetsGetCall {
   277  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   278  	return c
   279  }
   280  
   281  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   282  // object's ETag matches the given value. This is useful for getting updates
   283  // only after the object has changed since the last request.
   284  func (c *AcmeChallengeSetsGetCall) IfNoneMatch(entityTag string) *AcmeChallengeSetsGetCall {
   285  	c.ifNoneMatch_ = entityTag
   286  	return c
   287  }
   288  
   289  // Context sets the context to be used in this call's Do method.
   290  func (c *AcmeChallengeSetsGetCall) Context(ctx context.Context) *AcmeChallengeSetsGetCall {
   291  	c.ctx_ = ctx
   292  	return c
   293  }
   294  
   295  // Header returns a http.Header that can be modified by the caller to add
   296  // headers to the request.
   297  func (c *AcmeChallengeSetsGetCall) Header() http.Header {
   298  	if c.header_ == nil {
   299  		c.header_ = make(http.Header)
   300  	}
   301  	return c.header_
   302  }
   303  
   304  func (c *AcmeChallengeSetsGetCall) doRequest(alt string) (*http.Response, error) {
   305  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   306  	if c.ifNoneMatch_ != "" {
   307  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   308  	}
   309  	var body io.Reader = nil
   310  	c.urlParams_.Set("alt", alt)
   311  	c.urlParams_.Set("prettyPrint", "false")
   312  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/acmeChallengeSets/{rootDomain}")
   313  	urls += "?" + c.urlParams_.Encode()
   314  	req, err := http.NewRequest("GET", urls, body)
   315  	if err != nil {
   316  		return nil, err
   317  	}
   318  	req.Header = reqHeaders
   319  	googleapi.Expand(req.URL, map[string]string{
   320  		"rootDomain": c.rootDomain,
   321  	})
   322  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   323  }
   324  
   325  // Do executes the "acmedns.acmeChallengeSets.get" call.
   326  // Any non-2xx status code is an error. Response headers are in either
   327  // *AcmeChallengeSet.ServerResponse.Header or (if a response was returned at
   328  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   329  // check whether the returned error was because http.StatusNotModified was
   330  // returned.
   331  func (c *AcmeChallengeSetsGetCall) Do(opts ...googleapi.CallOption) (*AcmeChallengeSet, error) {
   332  	gensupport.SetOptions(c.urlParams_, opts...)
   333  	res, err := c.doRequest("json")
   334  	if res != nil && res.StatusCode == http.StatusNotModified {
   335  		if res.Body != nil {
   336  			res.Body.Close()
   337  		}
   338  		return nil, gensupport.WrapError(&googleapi.Error{
   339  			Code:   res.StatusCode,
   340  			Header: res.Header,
   341  		})
   342  	}
   343  	if err != nil {
   344  		return nil, err
   345  	}
   346  	defer googleapi.CloseBody(res)
   347  	if err := googleapi.CheckResponse(res); err != nil {
   348  		return nil, gensupport.WrapError(err)
   349  	}
   350  	ret := &AcmeChallengeSet{
   351  		ServerResponse: googleapi.ServerResponse{
   352  			Header:         res.Header,
   353  			HTTPStatusCode: res.StatusCode,
   354  		},
   355  	}
   356  	target := &ret
   357  	if err := gensupport.DecodeResponse(target, res); err != nil {
   358  		return nil, err
   359  	}
   360  	return ret, nil
   361  }
   362  
   363  type AcmeChallengeSetsRotateChallengesCall struct {
   364  	s                       *Service
   365  	rootDomain              string
   366  	rotatechallengesrequest *RotateChallengesRequest
   367  	urlParams_              gensupport.URLParams
   368  	ctx_                    context.Context
   369  	header_                 http.Header
   370  }
   371  
   372  // RotateChallenges: Rotate the ACME challenges for a given domain name. By
   373  // default, removes any challenges that are older than 30 days. Domain names
   374  // must be provided in Punycode.
   375  //
   376  //   - rootDomain: SLD + TLD domain name to update records for. For example, this
   377  //     would be "google.com" for any FQDN under "google.com". That includes
   378  //     challenges for "subdomain.google.com". This MAY be Unicode or Punycode.
   379  func (r *AcmeChallengeSetsService) RotateChallenges(rootDomain string, rotatechallengesrequest *RotateChallengesRequest) *AcmeChallengeSetsRotateChallengesCall {
   380  	c := &AcmeChallengeSetsRotateChallengesCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   381  	c.rootDomain = rootDomain
   382  	c.rotatechallengesrequest = rotatechallengesrequest
   383  	return c
   384  }
   385  
   386  // Fields allows partial responses to be retrieved. See
   387  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   388  // details.
   389  func (c *AcmeChallengeSetsRotateChallengesCall) Fields(s ...googleapi.Field) *AcmeChallengeSetsRotateChallengesCall {
   390  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   391  	return c
   392  }
   393  
   394  // Context sets the context to be used in this call's Do method.
   395  func (c *AcmeChallengeSetsRotateChallengesCall) Context(ctx context.Context) *AcmeChallengeSetsRotateChallengesCall {
   396  	c.ctx_ = ctx
   397  	return c
   398  }
   399  
   400  // Header returns a http.Header that can be modified by the caller to add
   401  // headers to the request.
   402  func (c *AcmeChallengeSetsRotateChallengesCall) Header() http.Header {
   403  	if c.header_ == nil {
   404  		c.header_ = make(http.Header)
   405  	}
   406  	return c.header_
   407  }
   408  
   409  func (c *AcmeChallengeSetsRotateChallengesCall) doRequest(alt string) (*http.Response, error) {
   410  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   411  	var body io.Reader = nil
   412  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.rotatechallengesrequest)
   413  	if err != nil {
   414  		return nil, err
   415  	}
   416  	c.urlParams_.Set("alt", alt)
   417  	c.urlParams_.Set("prettyPrint", "false")
   418  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/acmeChallengeSets/{rootDomain}:rotateChallenges")
   419  	urls += "?" + c.urlParams_.Encode()
   420  	req, err := http.NewRequest("POST", urls, body)
   421  	if err != nil {
   422  		return nil, err
   423  	}
   424  	req.Header = reqHeaders
   425  	googleapi.Expand(req.URL, map[string]string{
   426  		"rootDomain": c.rootDomain,
   427  	})
   428  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   429  }
   430  
   431  // Do executes the "acmedns.acmeChallengeSets.rotateChallenges" call.
   432  // Any non-2xx status code is an error. Response headers are in either
   433  // *AcmeChallengeSet.ServerResponse.Header or (if a response was returned at
   434  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   435  // check whether the returned error was because http.StatusNotModified was
   436  // returned.
   437  func (c *AcmeChallengeSetsRotateChallengesCall) Do(opts ...googleapi.CallOption) (*AcmeChallengeSet, error) {
   438  	gensupport.SetOptions(c.urlParams_, opts...)
   439  	res, err := c.doRequest("json")
   440  	if res != nil && res.StatusCode == http.StatusNotModified {
   441  		if res.Body != nil {
   442  			res.Body.Close()
   443  		}
   444  		return nil, gensupport.WrapError(&googleapi.Error{
   445  			Code:   res.StatusCode,
   446  			Header: res.Header,
   447  		})
   448  	}
   449  	if err != nil {
   450  		return nil, err
   451  	}
   452  	defer googleapi.CloseBody(res)
   453  	if err := googleapi.CheckResponse(res); err != nil {
   454  		return nil, gensupport.WrapError(err)
   455  	}
   456  	ret := &AcmeChallengeSet{
   457  		ServerResponse: googleapi.ServerResponse{
   458  			Header:         res.Header,
   459  			HTTPStatusCode: res.StatusCode,
   460  		},
   461  	}
   462  	target := &ret
   463  	if err := gensupport.DecodeResponse(target, res); err != nil {
   464  		return nil, err
   465  	}
   466  	return ret, nil
   467  }
   468  

View as plain text