Debian Codegraph @

domains/apiv1beta1/domains_client.go

raw
1 // Copyright 2025 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17 package domains
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27
28 domainspb "cloud.google.com/go/domains/apiv1beta1/domainspb"
29 "cloud.google.com/go/longrunning"
30 lroauto "cloud.google.com/go/longrunning/autogen"
31 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
32 gax "github.com/googleapis/gax-go/v2"
33 "google.golang.org/api/iterator"
34 "google.golang.org/api/option"
35 "google.golang.org/api/option/internaloption"
36 gtransport "google.golang.org/api/transport/grpc"
37 httptransport "google.golang.org/api/transport/http"
38 "google.golang.org/grpc"
39 "google.golang.org/protobuf/encoding/protojson"
40 "google.golang.org/protobuf/proto"
41 )
42
43 var newClientHook clientHook
44
45 // CallOptions contains the retry settings for each method of Client.
46 type CallOptions struct {
47 SearchDomains []gax.CallOption
48 RetrieveRegisterParameters []gax.CallOption
49 RegisterDomain []gax.CallOption
50 RetrieveTransferParameters []gax.CallOption
51 TransferDomain []gax.CallOption
52 ListRegistrations []gax.CallOption
53 GetRegistration []gax.CallOption
54 UpdateRegistration []gax.CallOption
55 ConfigureManagementSettings []gax.CallOption
56 ConfigureDnsSettings []gax.CallOption
57 ConfigureContactSettings []gax.CallOption
58 ExportRegistration []gax.CallOption
59 DeleteRegistration []gax.CallOption
60 RetrieveAuthorizationCode []gax.CallOption
61 ResetAuthorizationCode []gax.CallOption
62 }
63
64 func defaultGRPCClientOptions() []option.ClientOption {
65 return []option.ClientOption{
66 internaloption.WithDefaultEndpoint("domains.googleapis.com:443"),
67 internaloption.WithDefaultEndpointTemplate("domains.UNIVERSE_DOMAIN:443"),
68 internaloption.WithDefaultMTLSEndpoint("domains.mtls.googleapis.com:443"),
69 internaloption.WithDefaultUniverseDomain("googleapis.com"),
70 internaloption.WithDefaultAudience("https://domains.googleapis.com/"),
71 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
72 internaloption.EnableJwtWithScope(),
73 internaloption.EnableNewAuthLibrary(),
74 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
75 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
76 }
77 }
78
79 func defaultCallOptions() *CallOptions {
80 return &CallOptions{
81 SearchDomains: []gax.CallOption{},
82 RetrieveRegisterParameters: []gax.CallOption{},
83 RegisterDomain: []gax.CallOption{},
84 RetrieveTransferParameters: []gax.CallOption{},
85 TransferDomain: []gax.CallOption{},
86 ListRegistrations: []gax.CallOption{},
87 GetRegistration: []gax.CallOption{},
88 UpdateRegistration: []gax.CallOption{},
89 ConfigureManagementSettings: []gax.CallOption{},
90 ConfigureDnsSettings: []gax.CallOption{},
91 ConfigureContactSettings: []gax.CallOption{},
92 ExportRegistration: []gax.CallOption{},
93 DeleteRegistration: []gax.CallOption{},
94 RetrieveAuthorizationCode: []gax.CallOption{},
95 ResetAuthorizationCode: []gax.CallOption{},
96 }
97 }
98
99 func defaultRESTCallOptions() *CallOptions {
100 return &CallOptions{
101 SearchDomains: []gax.CallOption{},
102 RetrieveRegisterParameters: []gax.CallOption{},
103 RegisterDomain: []gax.CallOption{},
104 RetrieveTransferParameters: []gax.CallOption{},
105 TransferDomain: []gax.CallOption{},
106 ListRegistrations: []gax.CallOption{},
107 GetRegistration: []gax.CallOption{},
108 UpdateRegistration: []gax.CallOption{},
109 ConfigureManagementSettings: []gax.CallOption{},
110 ConfigureDnsSettings: []gax.CallOption{},
111 ConfigureContactSettings: []gax.CallOption{},
112 ExportRegistration: []gax.CallOption{},
113 DeleteRegistration: []gax.CallOption{},
114 RetrieveAuthorizationCode: []gax.CallOption{},
115 ResetAuthorizationCode: []gax.CallOption{},
116 }
117 }
118
119 // internalClient is an interface that defines the methods available from Cloud Domains API.
120 type internalClient interface {
121 Close() error
122 setGoogleClientInfo(...string)
123 Connection() *grpc.ClientConn
124 SearchDomains(context.Context, *domainspb.SearchDomainsRequest, ...gax.CallOption) (*domainspb.SearchDomainsResponse, error)
125 RetrieveRegisterParameters(context.Context, *domainspb.RetrieveRegisterParametersRequest, ...gax.CallOption) (*domainspb.RetrieveRegisterParametersResponse, error)
126 RegisterDomain(context.Context, *domainspb.RegisterDomainRequest, ...gax.CallOption) (*RegisterDomainOperation, error)
127 RegisterDomainOperation(name string) *RegisterDomainOperation
128 RetrieveTransferParameters(context.Context, *domainspb.RetrieveTransferParametersRequest, ...gax.CallOption) (*domainspb.RetrieveTransferParametersResponse, error)
129 TransferDomain(context.Context, *domainspb.TransferDomainRequest, ...gax.CallOption) (*TransferDomainOperation, error)
130 TransferDomainOperation(name string) *TransferDomainOperation
131 ListRegistrations(context.Context, *domainspb.ListRegistrationsRequest, ...gax.CallOption) *RegistrationIterator
132 GetRegistration(context.Context, *domainspb.GetRegistrationRequest, ...gax.CallOption) (*domainspb.Registration, error)
133 UpdateRegistration(context.Context, *domainspb.UpdateRegistrationRequest, ...gax.CallOption) (*UpdateRegistrationOperation, error)
134 UpdateRegistrationOperation(name string) *UpdateRegistrationOperation
135 ConfigureManagementSettings(context.Context, *domainspb.ConfigureManagementSettingsRequest, ...gax.CallOption) (*ConfigureManagementSettingsOperation, error)
136 ConfigureManagementSettingsOperation(name string) *ConfigureManagementSettingsOperation
137 ConfigureDnsSettings(context.Context, *domainspb.ConfigureDnsSettingsRequest, ...gax.CallOption) (*ConfigureDnsSettingsOperation, error)
138 ConfigureDnsSettingsOperation(name string) *ConfigureDnsSettingsOperation
139 ConfigureContactSettings(context.Context, *domainspb.ConfigureContactSettingsRequest, ...gax.CallOption) (*ConfigureContactSettingsOperation, error)
140 ConfigureContactSettingsOperation(name string) *ConfigureContactSettingsOperation
141 ExportRegistration(context.Context, *domainspb.ExportRegistrationRequest, ...gax.CallOption) (*ExportRegistrationOperation, error)
142 ExportRegistrationOperation(name string) *ExportRegistrationOperation
143 DeleteRegistration(context.Context, *domainspb.DeleteRegistrationRequest, ...gax.CallOption) (*DeleteRegistrationOperation, error)
144 DeleteRegistrationOperation(name string) *DeleteRegistrationOperation
145 RetrieveAuthorizationCode(context.Context, *domainspb.RetrieveAuthorizationCodeRequest, ...gax.CallOption) (*domainspb.AuthorizationCode, error)
146 ResetAuthorizationCode(context.Context, *domainspb.ResetAuthorizationCodeRequest, ...gax.CallOption) (*domainspb.AuthorizationCode, error)
147 }
148
149 // Client is a client for interacting with Cloud Domains API.
150 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
151 //
152 // The Cloud Domains API enables management and configuration of domain names.
153 type Client struct {
154 // The internal transport-dependent client.
155 internalClient internalClient
156
157 // The call options for this service.
158 CallOptions *CallOptions
159
160 // LROClient is used internally to handle long-running operations.
161 // It is exposed so that its CallOptions can be modified if required.
162 // Users should not Close this client.
163 LROClient *lroauto.OperationsClient
164 }
165
166 // Wrapper methods routed to the internal client.
167
168 // Close closes the connection to the API service. The user should invoke this when
169 // the client is no longer required.
170 func (c *Client) Close() error {
171 return c.internalClient.Close()
172 }
173
174 // setGoogleClientInfo sets the name and version of the application in
175 // the `x-goog-api-client` header passed on each request. Intended for
176 // use by Google-written clients.
177 func (c *Client) setGoogleClientInfo(keyval ...string) {
178 c.internalClient.setGoogleClientInfo(keyval...)
179 }
180
181 // Connection returns a connection to the API service.
182 //
183 // Deprecated: Connections are now pooled so this method does not always
184 // return the same resource.
185 func (c *Client) Connection() *grpc.ClientConn {
186 return c.internalClient.Connection()
187 }
188
189 // SearchDomains searches for available domain names similar to the provided query.
190 //
191 // Availability results from this method are approximate; call
192 // RetrieveRegisterParameters on a domain before registering to confirm
193 // availability.
194 func (c *Client) SearchDomains(ctx context.Context, req *domainspb.SearchDomainsRequest, opts ...gax.CallOption) (*domainspb.SearchDomainsResponse, error) {
195 return c.internalClient.SearchDomains(ctx, req, opts...)
196 }
197
198 // RetrieveRegisterParameters gets parameters needed to register a new domain name, including price and
199 // up-to-date availability. Use the returned values to call RegisterDomain.
200 func (c *Client) RetrieveRegisterParameters(ctx context.Context, req *domainspb.RetrieveRegisterParametersRequest, opts ...gax.CallOption) (*domainspb.RetrieveRegisterParametersResponse, error) {
201 return c.internalClient.RetrieveRegisterParameters(ctx, req, opts...)
202 }
203
204 // RegisterDomain registers a new domain name and creates a corresponding Registration
205 // resource.
206 //
207 // Call RetrieveRegisterParameters first to check availability of the domain
208 // name and determine parameters like price that are needed to build a call to
209 // this method.
210 //
211 // A successful call creates a Registration resource in state
212 // REGISTRATION_PENDING, which resolves to ACTIVE within 1-2
213 // minutes, indicating that the domain was successfully registered. If the
214 // resource ends up in state REGISTRATION_FAILED, it indicates that the
215 // domain was not registered successfully, and you can safely delete the
216 // resource and retry registration.
217 func (c *Client) RegisterDomain(ctx context.Context, req *domainspb.RegisterDomainRequest, opts ...gax.CallOption) (*RegisterDomainOperation, error) {
218 return c.internalClient.RegisterDomain(ctx, req, opts...)
219 }
220
221 // RegisterDomainOperation returns a new RegisterDomainOperation from a given name.
222 // The name must be that of a previously created RegisterDomainOperation, possibly from a different process.
223 func (c *Client) RegisterDomainOperation(name string) *RegisterDomainOperation {
224 return c.internalClient.RegisterDomainOperation(name)
225 }
226
227 // RetrieveTransferParameters gets parameters needed to transfer a domain name from another registrar to
228 // Cloud Domains. For domains managed by Google Domains, transferring to Cloud
229 // Domains is not supported.
230 //
231 // Use the returned values to call TransferDomain.
232 func (c *Client) RetrieveTransferParameters(ctx context.Context, req *domainspb.RetrieveTransferParametersRequest, opts ...gax.CallOption) (*domainspb.RetrieveTransferParametersResponse, error) {
233 return c.internalClient.RetrieveTransferParameters(ctx, req, opts...)
234 }
235
236 // TransferDomain transfers a domain name from another registrar to Cloud Domains. For
237 // domains managed by Google Domains, transferring to Cloud Domains is not
238 // supported.
239 //
240 // Before calling this method, go to the domain’s current registrar to unlock
241 // the domain for transfer and retrieve the domain’s transfer authorization
242 // code. Then call RetrieveTransferParameters to confirm that the domain is
243 // unlocked and to get values needed to build a call to this method.
244 //
245 // A successful call creates a Registration resource in state
246 // TRANSFER_PENDING. It can take several days to complete the transfer
247 // process. The registrant can often speed up this process by approving the
248 // transfer through the current registrar, either by clicking a link in an
249 // email from the registrar or by visiting the registrar’s website.
250 //
251 // A few minutes after transfer approval, the resource transitions to state
252 // ACTIVE, indicating that the transfer was successful. If the transfer is
253 // rejected or the request expires without being approved, the resource can
254 // end up in state TRANSFER_FAILED. If transfer fails, you can safely delete
255 // the resource and retry the transfer.
256 func (c *Client) TransferDomain(ctx context.Context, req *domainspb.TransferDomainRequest, opts ...gax.CallOption) (*TransferDomainOperation, error) {
257 return c.internalClient.TransferDomain(ctx, req, opts...)
258 }
259
260 // TransferDomainOperation returns a new TransferDomainOperation from a given name.
261 // The name must be that of a previously created TransferDomainOperation, possibly from a different process.
262 func (c *Client) TransferDomainOperation(name string) *TransferDomainOperation {
263 return c.internalClient.TransferDomainOperation(name)
264 }
265
266 // ListRegistrations lists the Registration resources in a project.
267 func (c *Client) ListRegistrations(ctx context.Context, req *domainspb.ListRegistrationsRequest, opts ...gax.CallOption) *RegistrationIterator {
268 return c.internalClient.ListRegistrations(ctx, req, opts...)
269 }
270
271 // GetRegistration gets the details of a Registration resource.
272 func (c *Client) GetRegistration(ctx context.Context, req *domainspb.GetRegistrationRequest, opts ...gax.CallOption) (*domainspb.Registration, error) {
273 return c.internalClient.GetRegistration(ctx, req, opts...)
274 }
275
276 // UpdateRegistration updates select fields of a Registration resource, notably labels. To
277 // update other fields, use the appropriate custom update method:
278 //
279 // To update management settings, see ConfigureManagementSettings
280 //
281 // To update DNS configuration, see ConfigureDnsSettings
282 //
283 // To update contact information, see ConfigureContactSettings
284 func (c *Client) UpdateRegistration(ctx context.Context, req *domainspb.UpdateRegistrationRequest, opts ...gax.CallOption) (*UpdateRegistrationOperation, error) {
285 return c.internalClient.UpdateRegistration(ctx, req, opts...)
286 }
287
288 // UpdateRegistrationOperation returns a new UpdateRegistrationOperation from a given name.
289 // The name must be that of a previously created UpdateRegistrationOperation, possibly from a different process.
290 func (c *Client) UpdateRegistrationOperation(name string) *UpdateRegistrationOperation {
291 return c.internalClient.UpdateRegistrationOperation(name)
292 }
293
294 // ConfigureManagementSettings updates a Registration's management settings.
295 func (c *Client) ConfigureManagementSettings(ctx context.Context, req *domainspb.ConfigureManagementSettingsRequest, opts ...gax.CallOption) (*ConfigureManagementSettingsOperation, error) {
296 return c.internalClient.ConfigureManagementSettings(ctx, req, opts...)
297 }
298
299 // ConfigureManagementSettingsOperation returns a new ConfigureManagementSettingsOperation from a given name.
300 // The name must be that of a previously created ConfigureManagementSettingsOperation, possibly from a different process.
301 func (c *Client) ConfigureManagementSettingsOperation(name string) *ConfigureManagementSettingsOperation {
302 return c.internalClient.ConfigureManagementSettingsOperation(name)
303 }
304
305 // ConfigureDnsSettings updates a Registration's DNS settings.
306 func (c *Client) ConfigureDnsSettings(ctx context.Context, req *domainspb.ConfigureDnsSettingsRequest, opts ...gax.CallOption) (*ConfigureDnsSettingsOperation, error) {
307 return c.internalClient.ConfigureDnsSettings(ctx, req, opts...)
308 }
309
310 // ConfigureDnsSettingsOperation returns a new ConfigureDnsSettingsOperation from a given name.
311 // The name must be that of a previously created ConfigureDnsSettingsOperation, possibly from a different process.
312 func (c *Client) ConfigureDnsSettingsOperation(name string) *ConfigureDnsSettingsOperation {
313 return c.internalClient.ConfigureDnsSettingsOperation(name)
314 }
315
316 // ConfigureContactSettings updates a Registration's contact settings. Some changes require
317 // confirmation by the domain’s registrant contact .
318 func (c *Client) ConfigureContactSettings(ctx context.Context, req *domainspb.ConfigureContactSettingsRequest, opts ...gax.CallOption) (*ConfigureContactSettingsOperation, error) {
319 return c.internalClient.ConfigureContactSettings(ctx, req, opts...)
320 }
321
322 // ConfigureContactSettingsOperation returns a new ConfigureContactSettingsOperation from a given name.
323 // The name must be that of a previously created ConfigureContactSettingsOperation, possibly from a different process.
324 func (c *Client) ConfigureContactSettingsOperation(name string) *ConfigureContactSettingsOperation {
325 return c.internalClient.ConfigureContactSettingsOperation(name)
326 }
327
328 // ExportRegistration exports a Registration resource, such that it is no longer managed by
329 // Cloud Domains.
330 //
331 // When an active domain is successfully exported, you can continue to use the
332 // domain in Google Domains (at https://domains.google/) until it expires. The
333 // calling user becomes the domain’s sole owner in Google Domains, and
334 // permissions for the domain are subsequently managed there. The domain does
335 // not renew automatically unless the new owner sets up billing in Google
336 // Domains.
337 func (c *Client) ExportRegistration(ctx context.Context, req *domainspb.ExportRegistrationRequest, opts ...gax.CallOption) (*ExportRegistrationOperation, error) {
338 return c.internalClient.ExportRegistration(ctx, req, opts...)
339 }
340
341 // ExportRegistrationOperation returns a new ExportRegistrationOperation from a given name.
342 // The name must be that of a previously created ExportRegistrationOperation, possibly from a different process.
343 func (c *Client) ExportRegistrationOperation(name string) *ExportRegistrationOperation {
344 return c.internalClient.ExportRegistrationOperation(name)
345 }
346
347 // DeleteRegistration deletes a Registration resource.
348 //
349 // This method works on any Registration resource using Subscription or
350 // Commitment billing (at /domains/pricing#billing-models), provided that the
351 // resource was created at least 1 day in the past.
352 //
353 // For Registration resources using
354 // Monthly billing (at /domains/pricing#billing-models), this method works if:
355 //
356 // state is EXPORTED with expire_time in the past
357 //
358 // state is REGISTRATION_FAILED
359 //
360 // state is TRANSFER_FAILED
361 //
362 // When an active registration is successfully deleted, you can continue to
363 // use the domain in Google Domains (at https://domains.google/) until it
364 // expires. The calling user becomes the domain’s sole owner in Google
365 // Domains, and permissions for the domain are subsequently managed there. The
366 // domain does not renew automatically unless the new owner sets up billing in
367 // Google Domains.
368 func (c *Client) DeleteRegistration(ctx context.Context, req *domainspb.DeleteRegistrationRequest, opts ...gax.CallOption) (*DeleteRegistrationOperation, error) {
369 return c.internalClient.DeleteRegistration(ctx, req, opts...)
370 }
371
372 // DeleteRegistrationOperation returns a new DeleteRegistrationOperation from a given name.
373 // The name must be that of a previously created DeleteRegistrationOperation, possibly from a different process.
374 func (c *Client) DeleteRegistrationOperation(name string) *DeleteRegistrationOperation {
375 return c.internalClient.DeleteRegistrationOperation(name)
376 }
377
378 // RetrieveAuthorizationCode gets the authorization code of the Registration for the purpose of
379 // transferring the domain to another registrar.
380 //
381 // You can call this method only after 60 days have elapsed since the initial
382 // domain registration.
383 func (c *Client) RetrieveAuthorizationCode(ctx context.Context, req *domainspb.RetrieveAuthorizationCodeRequest, opts ...gax.CallOption) (*domainspb.AuthorizationCode, error) {
384 return c.internalClient.RetrieveAuthorizationCode(ctx, req, opts...)
385 }
386
387 // ResetAuthorizationCode resets the authorization code of the Registration to a new random string.
388 //
389 // You can call this method only after 60 days have elapsed since the initial
390 // domain registration.
391 func (c *Client) ResetAuthorizationCode(ctx context.Context, req *domainspb.ResetAuthorizationCodeRequest, opts ...gax.CallOption) (*domainspb.AuthorizationCode, error) {
392 return c.internalClient.ResetAuthorizationCode(ctx, req, opts...)
393 }
394
395 // gRPCClient is a client for interacting with Cloud Domains API over gRPC transport.
396 //
397 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
398 type gRPCClient struct {
399 // Connection pool of gRPC connections to the service.
400 connPool gtransport.ConnPool
401
402 // Points back to the CallOptions field of the containing Client
403 CallOptions **CallOptions
404
405 // The gRPC API client.
406 client domainspb.DomainsClient
407
408 // LROClient is used internally to handle long-running operations.
409 // It is exposed so that its CallOptions can be modified if required.
410 // Users should not Close this client.
411 LROClient **lroauto.OperationsClient
412
413 // The x-goog-* metadata to be sent with each request.
414 xGoogHeaders []string
415
416 logger *slog.Logger
417 }
418
419 // NewClient creates a new domains client based on gRPC.
420 // The returned client must be Closed when it is done being used to clean up its underlying connections.
421 //
422 // The Cloud Domains API enables management and configuration of domain names.
423 func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
424 clientOpts := defaultGRPCClientOptions()
425 if newClientHook != nil {
426 hookOpts, err := newClientHook(ctx, clientHookParams{})
427 if err != nil {
428 return nil, err
429 }
430 clientOpts = append(clientOpts, hookOpts...)
431 }
432
433 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
434 if err != nil {
435 return nil, err
436 }
437 client := Client{CallOptions: defaultCallOptions()}
438
439 c := &gRPCClient{
440 connPool: connPool,
441 client: domainspb.NewDomainsClient(connPool),
442 CallOptions: &client.CallOptions,
443 logger: internaloption.GetLogger(opts),
444 }
445 c.setGoogleClientInfo()
446
447 client.internalClient = c
448
449 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
450 if err != nil {
451 // This error "should not happen", since we are just reusing old connection pool
452 // and never actually need to dial.
453 // If this does happen, we could leak connp. However, we cannot close conn:
454 // If the user invoked the constructor with option.WithGRPCConn,
455 // we would close a connection that's still in use.
456 // TODO: investigate error conditions.
457 return nil, err
458 }
459 c.LROClient = &client.LROClient
460 return &client, nil
461 }
462
463 // Connection returns a connection to the API service.
464 //
465 // Deprecated: Connections are now pooled so this method does not always
466 // return the same resource.
467 func (c *gRPCClient) Connection() *grpc.ClientConn {
468 return c.connPool.Conn()
469 }
470
471 // setGoogleClientInfo sets the name and version of the application in
472 // the `x-goog-api-client` header passed on each request. Intended for
473 // use by Google-written clients.
474 func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
475 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
476 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
477 c.xGoogHeaders = []string{
478 "x-goog-api-client", gax.XGoogHeader(kv...),
479 }
480 }
481
482 // Close closes the connection to the API service. The user should invoke this when
483 // the client is no longer required.
484 func (c *gRPCClient) Close() error {
485 return c.connPool.Close()
486 }
487
488 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
489 type restClient struct {
490 // The http endpoint to connect to.
491 endpoint string
492
493 // The http client.
494 httpClient *http.Client
495
496 // LROClient is used internally to handle long-running operations.
497 // It is exposed so that its CallOptions can be modified if required.
498 // Users should not Close this client.
499 LROClient **lroauto.OperationsClient
500
501 // The x-goog-* headers to be sent with each request.
502 xGoogHeaders []string
503
504 // Points back to the CallOptions field of the containing Client
505 CallOptions **CallOptions
506
507 logger *slog.Logger
508 }
509
510 // NewRESTClient creates a new domains rest client.
511 //
512 // The Cloud Domains API enables management and configuration of domain names.
513 func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
514 clientOpts := append(defaultRESTClientOptions(), opts...)
515 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
516 if err != nil {
517 return nil, err
518 }
519
520 callOpts := defaultRESTCallOptions()
521 c := &restClient{
522 endpoint: endpoint,
523 httpClient: httpClient,
524 CallOptions: &callOpts,
525 logger: internaloption.GetLogger(opts),
526 }
527 c.setGoogleClientInfo()
528
529 lroOpts := []option.ClientOption{
530 option.WithHTTPClient(httpClient),
531 option.WithEndpoint(endpoint),
532 }
533 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
534 if err != nil {
535 return nil, err
536 }
537 c.LROClient = &opClient
538
539 return &Client{internalClient: c, CallOptions: callOpts}, nil
540 }
541
542 func defaultRESTClientOptions() []option.ClientOption {
543 return []option.ClientOption{
544 internaloption.WithDefaultEndpoint("https://domains.googleapis.com"),
545 internaloption.WithDefaultEndpointTemplate("https://domains.UNIVERSE_DOMAIN"),
546 internaloption.WithDefaultMTLSEndpoint("https://domains.mtls.googleapis.com"),
547 internaloption.WithDefaultUniverseDomain("googleapis.com"),
548 internaloption.WithDefaultAudience("https://domains.googleapis.com/"),
549 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
550 internaloption.EnableNewAuthLibrary(),
551 }
552 }
553
554 // setGoogleClientInfo sets the name and version of the application in
555 // the `x-goog-api-client` header passed on each request. Intended for
556 // use by Google-written clients.
557 func (c *restClient) setGoogleClientInfo(keyval ...string) {
558 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
559 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
560 c.xGoogHeaders = []string{
561 "x-goog-api-client", gax.XGoogHeader(kv...),
562 }
563 }
564
565 // Close closes the connection to the API service. The user should invoke this when
566 // the client is no longer required.
567 func (c *restClient) Close() error {
568 // Replace httpClient with nil to force cleanup.
569 c.httpClient = nil
570 return nil
571 }
572
573 // Connection returns a connection to the API service.
574 //
575 // Deprecated: This method always returns nil.
576 func (c *restClient) Connection() *grpc.ClientConn {
577 return nil
578 }
579 func (c *gRPCClient) SearchDomains(ctx context.Context, req *domainspb.SearchDomainsRequest, opts ...gax.CallOption) (*domainspb.SearchDomainsResponse, error) {
580 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "location", url.QueryEscape(req.GetLocation()))}
581
582 hds = append(c.xGoogHeaders, hds...)
583 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
584 opts = append((*c.CallOptions).SearchDomains[0:len((*c.CallOptions).SearchDomains):len((*c.CallOptions).SearchDomains)], opts...)
585 var resp *domainspb.SearchDomainsResponse
586 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
587 var err error
588 resp, err = executeRPC(ctx, c.client.SearchDomains, req, settings.GRPC, c.logger, "SearchDomains")
589 return err
590 }, opts...)
591 if err != nil {
592 return nil, err
593 }
594 return resp, nil
595 }
596
597 func (c *gRPCClient) RetrieveRegisterParameters(ctx context.Context, req *domainspb.RetrieveRegisterParametersRequest, opts ...gax.CallOption) (*domainspb.RetrieveRegisterParametersResponse, error) {
598 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "location", url.QueryEscape(req.GetLocation()))}
599
600 hds = append(c.xGoogHeaders, hds...)
601 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
602 opts = append((*c.CallOptions).RetrieveRegisterParameters[0:len((*c.CallOptions).RetrieveRegisterParameters):len((*c.CallOptions).RetrieveRegisterParameters)], opts...)
603 var resp *domainspb.RetrieveRegisterParametersResponse
604 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
605 var err error
606 resp, err = executeRPC(ctx, c.client.RetrieveRegisterParameters, req, settings.GRPC, c.logger, "RetrieveRegisterParameters")
607 return err
608 }, opts...)
609 if err != nil {
610 return nil, err
611 }
612 return resp, nil
613 }
614
615 func (c *gRPCClient) RegisterDomain(ctx context.Context, req *domainspb.RegisterDomainRequest, opts ...gax.CallOption) (*RegisterDomainOperation, error) {
616 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
617
618 hds = append(c.xGoogHeaders, hds...)
619 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
620 opts = append((*c.CallOptions).RegisterDomain[0:len((*c.CallOptions).RegisterDomain):len((*c.CallOptions).RegisterDomain)], opts...)
621 var resp *longrunningpb.Operation
622 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
623 var err error
624 resp, err = executeRPC(ctx, c.client.RegisterDomain, req, settings.GRPC, c.logger, "RegisterDomain")
625 return err
626 }, opts...)
627 if err != nil {
628 return nil, err
629 }
630 return &RegisterDomainOperation{
631 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
632 }, nil
633 }
634
635 func (c *gRPCClient) RetrieveTransferParameters(ctx context.Context, req *domainspb.RetrieveTransferParametersRequest, opts ...gax.CallOption) (*domainspb.RetrieveTransferParametersResponse, error) {
636 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "location", url.QueryEscape(req.GetLocation()))}
637
638 hds = append(c.xGoogHeaders, hds...)
639 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
640 opts = append((*c.CallOptions).RetrieveTransferParameters[0:len((*c.CallOptions).RetrieveTransferParameters):len((*c.CallOptions).RetrieveTransferParameters)], opts...)
641 var resp *domainspb.RetrieveTransferParametersResponse
642 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
643 var err error
644 resp, err = executeRPC(ctx, c.client.RetrieveTransferParameters, req, settings.GRPC, c.logger, "RetrieveTransferParameters")
645 return err
646 }, opts...)
647 if err != nil {
648 return nil, err
649 }
650 return resp, nil
651 }
652
653 func (c *gRPCClient) TransferDomain(ctx context.Context, req *domainspb.TransferDomainRequest, opts ...gax.CallOption) (*TransferDomainOperation, error) {
654 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
655
656 hds = append(c.xGoogHeaders, hds...)
657 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
658 opts = append((*c.CallOptions).TransferDomain[0:len((*c.CallOptions).TransferDomain):len((*c.CallOptions).TransferDomain)], opts...)
659 var resp *longrunningpb.Operation
660 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
661 var err error
662 resp, err = executeRPC(ctx, c.client.TransferDomain, req, settings.GRPC, c.logger, "TransferDomain")
663 return err
664 }, opts...)
665 if err != nil {
666 return nil, err
667 }
668 return &TransferDomainOperation{
669 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
670 }, nil
671 }
672
673 func (c *gRPCClient) ListRegistrations(ctx context.Context, req *domainspb.ListRegistrationsRequest, opts ...gax.CallOption) *RegistrationIterator {
674 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
675
676 hds = append(c.xGoogHeaders, hds...)
677 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
678 opts = append((*c.CallOptions).ListRegistrations[0:len((*c.CallOptions).ListRegistrations):len((*c.CallOptions).ListRegistrations)], opts...)
679 it := &RegistrationIterator{}
680 req = proto.Clone(req).(*domainspb.ListRegistrationsRequest)
681 it.InternalFetch = func(pageSize int, pageToken string) ([]*domainspb.Registration, string, error) {
682 resp := &domainspb.ListRegistrationsResponse{}
683 if pageToken != "" {
684 req.PageToken = pageToken
685 }
686 if pageSize > math.MaxInt32 {
687 req.PageSize = math.MaxInt32
688 } else if pageSize != 0 {
689 req.PageSize = int32(pageSize)
690 }
691 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
692 var err error
693 resp, err = executeRPC(ctx, c.client.ListRegistrations, req, settings.GRPC, c.logger, "ListRegistrations")
694 return err
695 }, opts...)
696 if err != nil {
697 return nil, "", err
698 }
699
700 it.Response = resp
701 return resp.GetRegistrations(), resp.GetNextPageToken(), nil
702 }
703 fetch := func(pageSize int, pageToken string) (string, error) {
704 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
705 if err != nil {
706 return "", err
707 }
708 it.items = append(it.items, items...)
709 return nextPageToken, nil
710 }
711
712 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
713 it.pageInfo.MaxSize = int(req.GetPageSize())
714 it.pageInfo.Token = req.GetPageToken()
715
716 return it
717 }
718
719 func (c *gRPCClient) GetRegistration(ctx context.Context, req *domainspb.GetRegistrationRequest, opts ...gax.CallOption) (*domainspb.Registration, error) {
720 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
721
722 hds = append(c.xGoogHeaders, hds...)
723 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
724 opts = append((*c.CallOptions).GetRegistration[0:len((*c.CallOptions).GetRegistration):len((*c.CallOptions).GetRegistration)], opts...)
725 var resp *domainspb.Registration
726 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
727 var err error
728 resp, err = executeRPC(ctx, c.client.GetRegistration, req, settings.GRPC, c.logger, "GetRegistration")
729 return err
730 }, opts...)
731 if err != nil {
732 return nil, err
733 }
734 return resp, nil
735 }
736
737 func (c *gRPCClient) UpdateRegistration(ctx context.Context, req *domainspb.UpdateRegistrationRequest, opts ...gax.CallOption) (*UpdateRegistrationOperation, error) {
738 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration.name", url.QueryEscape(req.GetRegistration().GetName()))}
739
740 hds = append(c.xGoogHeaders, hds...)
741 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
742 opts = append((*c.CallOptions).UpdateRegistration[0:len((*c.CallOptions).UpdateRegistration):len((*c.CallOptions).UpdateRegistration)], opts...)
743 var resp *longrunningpb.Operation
744 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
745 var err error
746 resp, err = executeRPC(ctx, c.client.UpdateRegistration, req, settings.GRPC, c.logger, "UpdateRegistration")
747 return err
748 }, opts...)
749 if err != nil {
750 return nil, err
751 }
752 return &UpdateRegistrationOperation{
753 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
754 }, nil
755 }
756
757 func (c *gRPCClient) ConfigureManagementSettings(ctx context.Context, req *domainspb.ConfigureManagementSettingsRequest, opts ...gax.CallOption) (*ConfigureManagementSettingsOperation, error) {
758 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration", url.QueryEscape(req.GetRegistration()))}
759
760 hds = append(c.xGoogHeaders, hds...)
761 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
762 opts = append((*c.CallOptions).ConfigureManagementSettings[0:len((*c.CallOptions).ConfigureManagementSettings):len((*c.CallOptions).ConfigureManagementSettings)], opts...)
763 var resp *longrunningpb.Operation
764 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
765 var err error
766 resp, err = executeRPC(ctx, c.client.ConfigureManagementSettings, req, settings.GRPC, c.logger, "ConfigureManagementSettings")
767 return err
768 }, opts...)
769 if err != nil {
770 return nil, err
771 }
772 return &ConfigureManagementSettingsOperation{
773 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
774 }, nil
775 }
776
777 func (c *gRPCClient) ConfigureDnsSettings(ctx context.Context, req *domainspb.ConfigureDnsSettingsRequest, opts ...gax.CallOption) (*ConfigureDnsSettingsOperation, error) {
778 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration", url.QueryEscape(req.GetRegistration()))}
779
780 hds = append(c.xGoogHeaders, hds...)
781 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
782 opts = append((*c.CallOptions).ConfigureDnsSettings[0:len((*c.CallOptions).ConfigureDnsSettings):len((*c.CallOptions).ConfigureDnsSettings)], opts...)
783 var resp *longrunningpb.Operation
784 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
785 var err error
786 resp, err = executeRPC(ctx, c.client.ConfigureDnsSettings, req, settings.GRPC, c.logger, "ConfigureDnsSettings")
787 return err
788 }, opts...)
789 if err != nil {
790 return nil, err
791 }
792 return &ConfigureDnsSettingsOperation{
793 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
794 }, nil
795 }
796
797 func (c *gRPCClient) ConfigureContactSettings(ctx context.Context, req *domainspb.ConfigureContactSettingsRequest, opts ...gax.CallOption) (*ConfigureContactSettingsOperation, error) {
798 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration", url.QueryEscape(req.GetRegistration()))}
799
800 hds = append(c.xGoogHeaders, hds...)
801 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
802 opts = append((*c.CallOptions).ConfigureContactSettings[0:len((*c.CallOptions).ConfigureContactSettings):len((*c.CallOptions).ConfigureContactSettings)], opts...)
803 var resp *longrunningpb.Operation
804 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
805 var err error
806 resp, err = executeRPC(ctx, c.client.ConfigureContactSettings, req, settings.GRPC, c.logger, "ConfigureContactSettings")
807 return err
808 }, opts...)
809 if err != nil {
810 return nil, err
811 }
812 return &ConfigureContactSettingsOperation{
813 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
814 }, nil
815 }
816
817 func (c *gRPCClient) ExportRegistration(ctx context.Context, req *domainspb.ExportRegistrationRequest, opts ...gax.CallOption) (*ExportRegistrationOperation, error) {
818 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
819
820 hds = append(c.xGoogHeaders, hds...)
821 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
822 opts = append((*c.CallOptions).ExportRegistration[0:len((*c.CallOptions).ExportRegistration):len((*c.CallOptions).ExportRegistration)], opts...)
823 var resp *longrunningpb.Operation
824 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
825 var err error
826 resp, err = executeRPC(ctx, c.client.ExportRegistration, req, settings.GRPC, c.logger, "ExportRegistration")
827 return err
828 }, opts...)
829 if err != nil {
830 return nil, err
831 }
832 return &ExportRegistrationOperation{
833 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
834 }, nil
835 }
836
837 func (c *gRPCClient) DeleteRegistration(ctx context.Context, req *domainspb.DeleteRegistrationRequest, opts ...gax.CallOption) (*DeleteRegistrationOperation, error) {
838 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
839
840 hds = append(c.xGoogHeaders, hds...)
841 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
842 opts = append((*c.CallOptions).DeleteRegistration[0:len((*c.CallOptions).DeleteRegistration):len((*c.CallOptions).DeleteRegistration)], opts...)
843 var resp *longrunningpb.Operation
844 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
845 var err error
846 resp, err = executeRPC(ctx, c.client.DeleteRegistration, req, settings.GRPC, c.logger, "DeleteRegistration")
847 return err
848 }, opts...)
849 if err != nil {
850 return nil, err
851 }
852 return &DeleteRegistrationOperation{
853 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
854 }, nil
855 }
856
857 func (c *gRPCClient) RetrieveAuthorizationCode(ctx context.Context, req *domainspb.RetrieveAuthorizationCodeRequest, opts ...gax.CallOption) (*domainspb.AuthorizationCode, error) {
858 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration", url.QueryEscape(req.GetRegistration()))}
859
860 hds = append(c.xGoogHeaders, hds...)
861 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
862 opts = append((*c.CallOptions).RetrieveAuthorizationCode[0:len((*c.CallOptions).RetrieveAuthorizationCode):len((*c.CallOptions).RetrieveAuthorizationCode)], opts...)
863 var resp *domainspb.AuthorizationCode
864 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
865 var err error
866 resp, err = executeRPC(ctx, c.client.RetrieveAuthorizationCode, req, settings.GRPC, c.logger, "RetrieveAuthorizationCode")
867 return err
868 }, opts...)
869 if err != nil {
870 return nil, err
871 }
872 return resp, nil
873 }
874
875 func (c *gRPCClient) ResetAuthorizationCode(ctx context.Context, req *domainspb.ResetAuthorizationCodeRequest, opts ...gax.CallOption) (*domainspb.AuthorizationCode, error) {
876 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration", url.QueryEscape(req.GetRegistration()))}
877
878 hds = append(c.xGoogHeaders, hds...)
879 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
880 opts = append((*c.CallOptions).ResetAuthorizationCode[0:len((*c.CallOptions).ResetAuthorizationCode):len((*c.CallOptions).ResetAuthorizationCode)], opts...)
881 var resp *domainspb.AuthorizationCode
882 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
883 var err error
884 resp, err = executeRPC(ctx, c.client.ResetAuthorizationCode, req, settings.GRPC, c.logger, "ResetAuthorizationCode")
885 return err
886 }, opts...)
887 if err != nil {
888 return nil, err
889 }
890 return resp, nil
891 }
892
893 // SearchDomains searches for available domain names similar to the provided query.
894 //
895 // Availability results from this method are approximate; call
896 // RetrieveRegisterParameters on a domain before registering to confirm
897 // availability.
898 func (c *restClient) SearchDomains(ctx context.Context, req *domainspb.SearchDomainsRequest, opts ...gax.CallOption) (*domainspb.SearchDomainsResponse, error) {
899 baseUrl, err := url.Parse(c.endpoint)
900 if err != nil {
901 return nil, err
902 }
903 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/registrations:searchDomains", req.GetLocation())
904
905 params := url.Values{}
906 params.Add("$alt", "json;enum-encoding=int")
907 params.Add("query", fmt.Sprintf("%v", req.GetQuery()))
908
909 baseUrl.RawQuery = params.Encode()
910
911 // Build HTTP headers from client and context metadata.
912 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "location", url.QueryEscape(req.GetLocation()))}
913
914 hds = append(c.xGoogHeaders, hds...)
915 hds = append(hds, "Content-Type", "application/json")
916 headers := gax.BuildHeaders(ctx, hds...)
917 opts = append((*c.CallOptions).SearchDomains[0:len((*c.CallOptions).SearchDomains):len((*c.CallOptions).SearchDomains)], opts...)
918 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
919 resp := &domainspb.SearchDomainsResponse{}
920 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
921 if settings.Path != "" {
922 baseUrl.Path = settings.Path
923 }
924 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
925 if err != nil {
926 return err
927 }
928 httpReq = httpReq.WithContext(ctx)
929 httpReq.Header = headers
930
931 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "SearchDomains")
932 if err != nil {
933 return err
934 }
935
936 if err := unm.Unmarshal(buf, resp); err != nil {
937 return err
938 }
939
940 return nil
941 }, opts...)
942 if e != nil {
943 return nil, e
944 }
945 return resp, nil
946 }
947
948 // RetrieveRegisterParameters gets parameters needed to register a new domain name, including price and
949 // up-to-date availability. Use the returned values to call RegisterDomain.
950 func (c *restClient) RetrieveRegisterParameters(ctx context.Context, req *domainspb.RetrieveRegisterParametersRequest, opts ...gax.CallOption) (*domainspb.RetrieveRegisterParametersResponse, error) {
951 baseUrl, err := url.Parse(c.endpoint)
952 if err != nil {
953 return nil, err
954 }
955 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/registrations:retrieveRegisterParameters", req.GetLocation())
956
957 params := url.Values{}
958 params.Add("$alt", "json;enum-encoding=int")
959 params.Add("domainName", fmt.Sprintf("%v", req.GetDomainName()))
960
961 baseUrl.RawQuery = params.Encode()
962
963 // Build HTTP headers from client and context metadata.
964 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "location", url.QueryEscape(req.GetLocation()))}
965
966 hds = append(c.xGoogHeaders, hds...)
967 hds = append(hds, "Content-Type", "application/json")
968 headers := gax.BuildHeaders(ctx, hds...)
969 opts = append((*c.CallOptions).RetrieveRegisterParameters[0:len((*c.CallOptions).RetrieveRegisterParameters):len((*c.CallOptions).RetrieveRegisterParameters)], opts...)
970 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
971 resp := &domainspb.RetrieveRegisterParametersResponse{}
972 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
973 if settings.Path != "" {
974 baseUrl.Path = settings.Path
975 }
976 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
977 if err != nil {
978 return err
979 }
980 httpReq = httpReq.WithContext(ctx)
981 httpReq.Header = headers
982
983 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "RetrieveRegisterParameters")
984 if err != nil {
985 return err
986 }
987
988 if err := unm.Unmarshal(buf, resp); err != nil {
989 return err
990 }
991
992 return nil
993 }, opts...)
994 if e != nil {
995 return nil, e
996 }
997 return resp, nil
998 }
999
1000 // RegisterDomain registers a new domain name and creates a corresponding Registration
1001 // resource.
1002 //
1003 // Call RetrieveRegisterParameters first to check availability of the domain
1004 // name and determine parameters like price that are needed to build a call to
1005 // this method.
1006 //
1007 // A successful call creates a Registration resource in state
1008 // REGISTRATION_PENDING, which resolves to ACTIVE within 1-2
1009 // minutes, indicating that the domain was successfully registered. If the
1010 // resource ends up in state REGISTRATION_FAILED, it indicates that the
1011 // domain was not registered successfully, and you can safely delete the
1012 // resource and retry registration.
1013 func (c *restClient) RegisterDomain(ctx context.Context, req *domainspb.RegisterDomainRequest, opts ...gax.CallOption) (*RegisterDomainOperation, error) {
1014 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1015 jsonReq, err := m.Marshal(req)
1016 if err != nil {
1017 return nil, err
1018 }
1019
1020 baseUrl, err := url.Parse(c.endpoint)
1021 if err != nil {
1022 return nil, err
1023 }
1024 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/registrations:register", req.GetParent())
1025
1026 params := url.Values{}
1027 params.Add("$alt", "json;enum-encoding=int")
1028
1029 baseUrl.RawQuery = params.Encode()
1030
1031 // Build HTTP headers from client and context metadata.
1032 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1033
1034 hds = append(c.xGoogHeaders, hds...)
1035 hds = append(hds, "Content-Type", "application/json")
1036 headers := gax.BuildHeaders(ctx, hds...)
1037 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1038 resp := &longrunningpb.Operation{}
1039 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1040 if settings.Path != "" {
1041 baseUrl.Path = settings.Path
1042 }
1043 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1044 if err != nil {
1045 return err
1046 }
1047 httpReq = httpReq.WithContext(ctx)
1048 httpReq.Header = headers
1049
1050 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RegisterDomain")
1051 if err != nil {
1052 return err
1053 }
1054 if err := unm.Unmarshal(buf, resp); err != nil {
1055 return err
1056 }
1057
1058 return nil
1059 }, opts...)
1060 if e != nil {
1061 return nil, e
1062 }
1063
1064 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
1065 return &RegisterDomainOperation{
1066 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1067 pollPath: override,
1068 }, nil
1069 }
1070
1071 // RetrieveTransferParameters gets parameters needed to transfer a domain name from another registrar to
1072 // Cloud Domains. For domains managed by Google Domains, transferring to Cloud
1073 // Domains is not supported.
1074 //
1075 // Use the returned values to call TransferDomain.
1076 func (c *restClient) RetrieveTransferParameters(ctx context.Context, req *domainspb.RetrieveTransferParametersRequest, opts ...gax.CallOption) (*domainspb.RetrieveTransferParametersResponse, error) {
1077 baseUrl, err := url.Parse(c.endpoint)
1078 if err != nil {
1079 return nil, err
1080 }
1081 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/registrations:retrieveTransferParameters", req.GetLocation())
1082
1083 params := url.Values{}
1084 params.Add("$alt", "json;enum-encoding=int")
1085 params.Add("domainName", fmt.Sprintf("%v", req.GetDomainName()))
1086
1087 baseUrl.RawQuery = params.Encode()
1088
1089 // Build HTTP headers from client and context metadata.
1090 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "location", url.QueryEscape(req.GetLocation()))}
1091
1092 hds = append(c.xGoogHeaders, hds...)
1093 hds = append(hds, "Content-Type", "application/json")
1094 headers := gax.BuildHeaders(ctx, hds...)
1095 opts = append((*c.CallOptions).RetrieveTransferParameters[0:len((*c.CallOptions).RetrieveTransferParameters):len((*c.CallOptions).RetrieveTransferParameters)], opts...)
1096 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1097 resp := &domainspb.RetrieveTransferParametersResponse{}
1098 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1099 if settings.Path != "" {
1100 baseUrl.Path = settings.Path
1101 }
1102 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1103 if err != nil {
1104 return err
1105 }
1106 httpReq = httpReq.WithContext(ctx)
1107 httpReq.Header = headers
1108
1109 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "RetrieveTransferParameters")
1110 if err != nil {
1111 return err
1112 }
1113
1114 if err := unm.Unmarshal(buf, resp); err != nil {
1115 return err
1116 }
1117
1118 return nil
1119 }, opts...)
1120 if e != nil {
1121 return nil, e
1122 }
1123 return resp, nil
1124 }
1125
1126 // TransferDomain transfers a domain name from another registrar to Cloud Domains. For
1127 // domains managed by Google Domains, transferring to Cloud Domains is not
1128 // supported.
1129 //
1130 // Before calling this method, go to the domain’s current registrar to unlock
1131 // the domain for transfer and retrieve the domain’s transfer authorization
1132 // code. Then call RetrieveTransferParameters to confirm that the domain is
1133 // unlocked and to get values needed to build a call to this method.
1134 //
1135 // A successful call creates a Registration resource in state
1136 // TRANSFER_PENDING. It can take several days to complete the transfer
1137 // process. The registrant can often speed up this process by approving the
1138 // transfer through the current registrar, either by clicking a link in an
1139 // email from the registrar or by visiting the registrar’s website.
1140 //
1141 // A few minutes after transfer approval, the resource transitions to state
1142 // ACTIVE, indicating that the transfer was successful. If the transfer is
1143 // rejected or the request expires without being approved, the resource can
1144 // end up in state TRANSFER_FAILED. If transfer fails, you can safely delete
1145 // the resource and retry the transfer.
1146 func (c *restClient) TransferDomain(ctx context.Context, req *domainspb.TransferDomainRequest, opts ...gax.CallOption) (*TransferDomainOperation, error) {
1147 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1148 jsonReq, err := m.Marshal(req)
1149 if err != nil {
1150 return nil, err
1151 }
1152
1153 baseUrl, err := url.Parse(c.endpoint)
1154 if err != nil {
1155 return nil, err
1156 }
1157 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/registrations:transfer", req.GetParent())
1158
1159 params := url.Values{}
1160 params.Add("$alt", "json;enum-encoding=int")
1161
1162 baseUrl.RawQuery = params.Encode()
1163
1164 // Build HTTP headers from client and context metadata.
1165 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1166
1167 hds = append(c.xGoogHeaders, hds...)
1168 hds = append(hds, "Content-Type", "application/json")
1169 headers := gax.BuildHeaders(ctx, hds...)
1170 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1171 resp := &longrunningpb.Operation{}
1172 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1173 if settings.Path != "" {
1174 baseUrl.Path = settings.Path
1175 }
1176 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1177 if err != nil {
1178 return err
1179 }
1180 httpReq = httpReq.WithContext(ctx)
1181 httpReq.Header = headers
1182
1183 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TransferDomain")
1184 if err != nil {
1185 return err
1186 }
1187 if err := unm.Unmarshal(buf, resp); err != nil {
1188 return err
1189 }
1190
1191 return nil
1192 }, opts...)
1193 if e != nil {
1194 return nil, e
1195 }
1196
1197 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
1198 return &TransferDomainOperation{
1199 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1200 pollPath: override,
1201 }, nil
1202 }
1203
1204 // ListRegistrations lists the Registration resources in a project.
1205 func (c *restClient) ListRegistrations(ctx context.Context, req *domainspb.ListRegistrationsRequest, opts ...gax.CallOption) *RegistrationIterator {
1206 it := &RegistrationIterator{}
1207 req = proto.Clone(req).(*domainspb.ListRegistrationsRequest)
1208 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1209 it.InternalFetch = func(pageSize int, pageToken string) ([]*domainspb.Registration, string, error) {
1210 resp := &domainspb.ListRegistrationsResponse{}
1211 if pageToken != "" {
1212 req.PageToken = pageToken
1213 }
1214 if pageSize > math.MaxInt32 {
1215 req.PageSize = math.MaxInt32
1216 } else if pageSize != 0 {
1217 req.PageSize = int32(pageSize)
1218 }
1219 baseUrl, err := url.Parse(c.endpoint)
1220 if err != nil {
1221 return nil, "", err
1222 }
1223 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/registrations", req.GetParent())
1224
1225 params := url.Values{}
1226 params.Add("$alt", "json;enum-encoding=int")
1227 if req.GetFilter() != "" {
1228 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
1229 }
1230 if req.GetPageSize() != 0 {
1231 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1232 }
1233 if req.GetPageToken() != "" {
1234 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1235 }
1236
1237 baseUrl.RawQuery = params.Encode()
1238
1239 // Build HTTP headers from client and context metadata.
1240 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1241 headers := gax.BuildHeaders(ctx, hds...)
1242 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1243 if settings.Path != "" {
1244 baseUrl.Path = settings.Path
1245 }
1246 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1247 if err != nil {
1248 return err
1249 }
1250 httpReq.Header = headers
1251
1252 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListRegistrations")
1253 if err != nil {
1254 return err
1255 }
1256 if err := unm.Unmarshal(buf, resp); err != nil {
1257 return err
1258 }
1259
1260 return nil
1261 }, opts...)
1262 if e != nil {
1263 return nil, "", e
1264 }
1265 it.Response = resp
1266 return resp.GetRegistrations(), resp.GetNextPageToken(), nil
1267 }
1268
1269 fetch := func(pageSize int, pageToken string) (string, error) {
1270 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1271 if err != nil {
1272 return "", err
1273 }
1274 it.items = append(it.items, items...)
1275 return nextPageToken, nil
1276 }
1277
1278 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1279 it.pageInfo.MaxSize = int(req.GetPageSize())
1280 it.pageInfo.Token = req.GetPageToken()
1281
1282 return it
1283 }
1284
1285 // GetRegistration gets the details of a Registration resource.
1286 func (c *restClient) GetRegistration(ctx context.Context, req *domainspb.GetRegistrationRequest, opts ...gax.CallOption) (*domainspb.Registration, error) {
1287 baseUrl, err := url.Parse(c.endpoint)
1288 if err != nil {
1289 return nil, err
1290 }
1291 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
1292
1293 params := url.Values{}
1294 params.Add("$alt", "json;enum-encoding=int")
1295
1296 baseUrl.RawQuery = params.Encode()
1297
1298 // Build HTTP headers from client and context metadata.
1299 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1300
1301 hds = append(c.xGoogHeaders, hds...)
1302 hds = append(hds, "Content-Type", "application/json")
1303 headers := gax.BuildHeaders(ctx, hds...)
1304 opts = append((*c.CallOptions).GetRegistration[0:len((*c.CallOptions).GetRegistration):len((*c.CallOptions).GetRegistration)], opts...)
1305 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1306 resp := &domainspb.Registration{}
1307 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1308 if settings.Path != "" {
1309 baseUrl.Path = settings.Path
1310 }
1311 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1312 if err != nil {
1313 return err
1314 }
1315 httpReq = httpReq.WithContext(ctx)
1316 httpReq.Header = headers
1317
1318 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetRegistration")
1319 if err != nil {
1320 return err
1321 }
1322
1323 if err := unm.Unmarshal(buf, resp); err != nil {
1324 return err
1325 }
1326
1327 return nil
1328 }, opts...)
1329 if e != nil {
1330 return nil, e
1331 }
1332 return resp, nil
1333 }
1334
1335 // UpdateRegistration updates select fields of a Registration resource, notably labels. To
1336 // update other fields, use the appropriate custom update method:
1337 //
1338 // To update management settings, see ConfigureManagementSettings
1339 //
1340 // To update DNS configuration, see ConfigureDnsSettings
1341 //
1342 // To update contact information, see ConfigureContactSettings
1343 func (c *restClient) UpdateRegistration(ctx context.Context, req *domainspb.UpdateRegistrationRequest, opts ...gax.CallOption) (*UpdateRegistrationOperation, error) {
1344 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1345 body := req.GetRegistration()
1346 jsonReq, err := m.Marshal(body)
1347 if err != nil {
1348 return nil, err
1349 }
1350
1351 baseUrl, err := url.Parse(c.endpoint)
1352 if err != nil {
1353 return nil, err
1354 }
1355 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetRegistration().GetName())
1356
1357 params := url.Values{}
1358 params.Add("$alt", "json;enum-encoding=int")
1359 if req.GetUpdateMask() != nil {
1360 field, err := protojson.Marshal(req.GetUpdateMask())
1361 if err != nil {
1362 return nil, err
1363 }
1364 params.Add("updateMask", string(field[1:len(field)-1]))
1365 }
1366
1367 baseUrl.RawQuery = params.Encode()
1368
1369 // Build HTTP headers from client and context metadata.
1370 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration.name", url.QueryEscape(req.GetRegistration().GetName()))}
1371
1372 hds = append(c.xGoogHeaders, hds...)
1373 hds = append(hds, "Content-Type", "application/json")
1374 headers := gax.BuildHeaders(ctx, hds...)
1375 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1376 resp := &longrunningpb.Operation{}
1377 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1378 if settings.Path != "" {
1379 baseUrl.Path = settings.Path
1380 }
1381 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
1382 if err != nil {
1383 return err
1384 }
1385 httpReq = httpReq.WithContext(ctx)
1386 httpReq.Header = headers
1387
1388 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateRegistration")
1389 if err != nil {
1390 return err
1391 }
1392 if err := unm.Unmarshal(buf, resp); err != nil {
1393 return err
1394 }
1395
1396 return nil
1397 }, opts...)
1398 if e != nil {
1399 return nil, e
1400 }
1401
1402 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
1403 return &UpdateRegistrationOperation{
1404 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1405 pollPath: override,
1406 }, nil
1407 }
1408
1409 // ConfigureManagementSettings updates a Registration's management settings.
1410 func (c *restClient) ConfigureManagementSettings(ctx context.Context, req *domainspb.ConfigureManagementSettingsRequest, opts ...gax.CallOption) (*ConfigureManagementSettingsOperation, error) {
1411 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1412 jsonReq, err := m.Marshal(req)
1413 if err != nil {
1414 return nil, err
1415 }
1416
1417 baseUrl, err := url.Parse(c.endpoint)
1418 if err != nil {
1419 return nil, err
1420 }
1421 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:configureManagementSettings", req.GetRegistration())
1422
1423 params := url.Values{}
1424 params.Add("$alt", "json;enum-encoding=int")
1425
1426 baseUrl.RawQuery = params.Encode()
1427
1428 // Build HTTP headers from client and context metadata.
1429 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration", url.QueryEscape(req.GetRegistration()))}
1430
1431 hds = append(c.xGoogHeaders, hds...)
1432 hds = append(hds, "Content-Type", "application/json")
1433 headers := gax.BuildHeaders(ctx, hds...)
1434 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1435 resp := &longrunningpb.Operation{}
1436 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1437 if settings.Path != "" {
1438 baseUrl.Path = settings.Path
1439 }
1440 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1441 if err != nil {
1442 return err
1443 }
1444 httpReq = httpReq.WithContext(ctx)
1445 httpReq.Header = headers
1446
1447 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ConfigureManagementSettings")
1448 if err != nil {
1449 return err
1450 }
1451 if err := unm.Unmarshal(buf, resp); err != nil {
1452 return err
1453 }
1454
1455 return nil
1456 }, opts...)
1457 if e != nil {
1458 return nil, e
1459 }
1460
1461 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
1462 return &ConfigureManagementSettingsOperation{
1463 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1464 pollPath: override,
1465 }, nil
1466 }
1467
1468 // ConfigureDnsSettings updates a Registration's DNS settings.
1469 func (c *restClient) ConfigureDnsSettings(ctx context.Context, req *domainspb.ConfigureDnsSettingsRequest, opts ...gax.CallOption) (*ConfigureDnsSettingsOperation, error) {
1470 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1471 jsonReq, err := m.Marshal(req)
1472 if err != nil {
1473 return nil, err
1474 }
1475
1476 baseUrl, err := url.Parse(c.endpoint)
1477 if err != nil {
1478 return nil, err
1479 }
1480 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:configureDnsSettings", req.GetRegistration())
1481
1482 params := url.Values{}
1483 params.Add("$alt", "json;enum-encoding=int")
1484
1485 baseUrl.RawQuery = params.Encode()
1486
1487 // Build HTTP headers from client and context metadata.
1488 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration", url.QueryEscape(req.GetRegistration()))}
1489
1490 hds = append(c.xGoogHeaders, hds...)
1491 hds = append(hds, "Content-Type", "application/json")
1492 headers := gax.BuildHeaders(ctx, hds...)
1493 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1494 resp := &longrunningpb.Operation{}
1495 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1496 if settings.Path != "" {
1497 baseUrl.Path = settings.Path
1498 }
1499 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1500 if err != nil {
1501 return err
1502 }
1503 httpReq = httpReq.WithContext(ctx)
1504 httpReq.Header = headers
1505
1506 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ConfigureDnsSettings")
1507 if err != nil {
1508 return err
1509 }
1510 if err := unm.Unmarshal(buf, resp); err != nil {
1511 return err
1512 }
1513
1514 return nil
1515 }, opts...)
1516 if e != nil {
1517 return nil, e
1518 }
1519
1520 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
1521 return &ConfigureDnsSettingsOperation{
1522 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1523 pollPath: override,
1524 }, nil
1525 }
1526
1527 // ConfigureContactSettings updates a Registration's contact settings. Some changes require
1528 // confirmation by the domain’s registrant contact .
1529 func (c *restClient) ConfigureContactSettings(ctx context.Context, req *domainspb.ConfigureContactSettingsRequest, opts ...gax.CallOption) (*ConfigureContactSettingsOperation, error) {
1530 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1531 jsonReq, err := m.Marshal(req)
1532 if err != nil {
1533 return nil, err
1534 }
1535
1536 baseUrl, err := url.Parse(c.endpoint)
1537 if err != nil {
1538 return nil, err
1539 }
1540 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:configureContactSettings", req.GetRegistration())
1541
1542 params := url.Values{}
1543 params.Add("$alt", "json;enum-encoding=int")
1544
1545 baseUrl.RawQuery = params.Encode()
1546
1547 // Build HTTP headers from client and context metadata.
1548 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration", url.QueryEscape(req.GetRegistration()))}
1549
1550 hds = append(c.xGoogHeaders, hds...)
1551 hds = append(hds, "Content-Type", "application/json")
1552 headers := gax.BuildHeaders(ctx, hds...)
1553 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1554 resp := &longrunningpb.Operation{}
1555 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1556 if settings.Path != "" {
1557 baseUrl.Path = settings.Path
1558 }
1559 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1560 if err != nil {
1561 return err
1562 }
1563 httpReq = httpReq.WithContext(ctx)
1564 httpReq.Header = headers
1565
1566 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ConfigureContactSettings")
1567 if err != nil {
1568 return err
1569 }
1570 if err := unm.Unmarshal(buf, resp); err != nil {
1571 return err
1572 }
1573
1574 return nil
1575 }, opts...)
1576 if e != nil {
1577 return nil, e
1578 }
1579
1580 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
1581 return &ConfigureContactSettingsOperation{
1582 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1583 pollPath: override,
1584 }, nil
1585 }
1586
1587 // ExportRegistration exports a Registration resource, such that it is no longer managed by
1588 // Cloud Domains.
1589 //
1590 // When an active domain is successfully exported, you can continue to use the
1591 // domain in Google Domains (at https://domains.google/) until it expires. The
1592 // calling user becomes the domain’s sole owner in Google Domains, and
1593 // permissions for the domain are subsequently managed there. The domain does
1594 // not renew automatically unless the new owner sets up billing in Google
1595 // Domains.
1596 func (c *restClient) ExportRegistration(ctx context.Context, req *domainspb.ExportRegistrationRequest, opts ...gax.CallOption) (*ExportRegistrationOperation, error) {
1597 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1598 jsonReq, err := m.Marshal(req)
1599 if err != nil {
1600 return nil, err
1601 }
1602
1603 baseUrl, err := url.Parse(c.endpoint)
1604 if err != nil {
1605 return nil, err
1606 }
1607 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:export", req.GetName())
1608
1609 params := url.Values{}
1610 params.Add("$alt", "json;enum-encoding=int")
1611
1612 baseUrl.RawQuery = params.Encode()
1613
1614 // Build HTTP headers from client and context metadata.
1615 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1616
1617 hds = append(c.xGoogHeaders, hds...)
1618 hds = append(hds, "Content-Type", "application/json")
1619 headers := gax.BuildHeaders(ctx, hds...)
1620 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1621 resp := &longrunningpb.Operation{}
1622 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1623 if settings.Path != "" {
1624 baseUrl.Path = settings.Path
1625 }
1626 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1627 if err != nil {
1628 return err
1629 }
1630 httpReq = httpReq.WithContext(ctx)
1631 httpReq.Header = headers
1632
1633 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExportRegistration")
1634 if err != nil {
1635 return err
1636 }
1637 if err := unm.Unmarshal(buf, resp); err != nil {
1638 return err
1639 }
1640
1641 return nil
1642 }, opts...)
1643 if e != nil {
1644 return nil, e
1645 }
1646
1647 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
1648 return &ExportRegistrationOperation{
1649 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1650 pollPath: override,
1651 }, nil
1652 }
1653
1654 // DeleteRegistration deletes a Registration resource.
1655 //
1656 // This method works on any Registration resource using Subscription or
1657 // Commitment billing (at /domains/pricing#billing-models), provided that the
1658 // resource was created at least 1 day in the past.
1659 //
1660 // For Registration resources using
1661 // Monthly billing (at /domains/pricing#billing-models), this method works if:
1662 //
1663 // state is EXPORTED with expire_time in the past
1664 //
1665 // state is REGISTRATION_FAILED
1666 //
1667 // state is TRANSFER_FAILED
1668 //
1669 // When an active registration is successfully deleted, you can continue to
1670 // use the domain in Google Domains (at https://domains.google/) until it
1671 // expires. The calling user becomes the domain’s sole owner in Google
1672 // Domains, and permissions for the domain are subsequently managed there. The
1673 // domain does not renew automatically unless the new owner sets up billing in
1674 // Google Domains.
1675 func (c *restClient) DeleteRegistration(ctx context.Context, req *domainspb.DeleteRegistrationRequest, opts ...gax.CallOption) (*DeleteRegistrationOperation, error) {
1676 baseUrl, err := url.Parse(c.endpoint)
1677 if err != nil {
1678 return nil, err
1679 }
1680 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
1681
1682 params := url.Values{}
1683 params.Add("$alt", "json;enum-encoding=int")
1684
1685 baseUrl.RawQuery = params.Encode()
1686
1687 // Build HTTP headers from client and context metadata.
1688 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1689
1690 hds = append(c.xGoogHeaders, hds...)
1691 hds = append(hds, "Content-Type", "application/json")
1692 headers := gax.BuildHeaders(ctx, hds...)
1693 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1694 resp := &longrunningpb.Operation{}
1695 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1696 if settings.Path != "" {
1697 baseUrl.Path = settings.Path
1698 }
1699 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1700 if err != nil {
1701 return err
1702 }
1703 httpReq = httpReq.WithContext(ctx)
1704 httpReq.Header = headers
1705
1706 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteRegistration")
1707 if err != nil {
1708 return err
1709 }
1710 if err := unm.Unmarshal(buf, resp); err != nil {
1711 return err
1712 }
1713
1714 return nil
1715 }, opts...)
1716 if e != nil {
1717 return nil, e
1718 }
1719
1720 override := fmt.Sprintf("/v1beta1/%s", resp.GetName())
1721 return &DeleteRegistrationOperation{
1722 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1723 pollPath: override,
1724 }, nil
1725 }
1726
1727 // RetrieveAuthorizationCode gets the authorization code of the Registration for the purpose of
1728 // transferring the domain to another registrar.
1729 //
1730 // You can call this method only after 60 days have elapsed since the initial
1731 // domain registration.
1732 func (c *restClient) RetrieveAuthorizationCode(ctx context.Context, req *domainspb.RetrieveAuthorizationCodeRequest, opts ...gax.CallOption) (*domainspb.AuthorizationCode, error) {
1733 baseUrl, err := url.Parse(c.endpoint)
1734 if err != nil {
1735 return nil, err
1736 }
1737 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:retrieveAuthorizationCode", req.GetRegistration())
1738
1739 params := url.Values{}
1740 params.Add("$alt", "json;enum-encoding=int")
1741
1742 baseUrl.RawQuery = params.Encode()
1743
1744 // Build HTTP headers from client and context metadata.
1745 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration", url.QueryEscape(req.GetRegistration()))}
1746
1747 hds = append(c.xGoogHeaders, hds...)
1748 hds = append(hds, "Content-Type", "application/json")
1749 headers := gax.BuildHeaders(ctx, hds...)
1750 opts = append((*c.CallOptions).RetrieveAuthorizationCode[0:len((*c.CallOptions).RetrieveAuthorizationCode):len((*c.CallOptions).RetrieveAuthorizationCode)], opts...)
1751 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1752 resp := &domainspb.AuthorizationCode{}
1753 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1754 if settings.Path != "" {
1755 baseUrl.Path = settings.Path
1756 }
1757 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1758 if err != nil {
1759 return err
1760 }
1761 httpReq = httpReq.WithContext(ctx)
1762 httpReq.Header = headers
1763
1764 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "RetrieveAuthorizationCode")
1765 if err != nil {
1766 return err
1767 }
1768
1769 if err := unm.Unmarshal(buf, resp); err != nil {
1770 return err
1771 }
1772
1773 return nil
1774 }, opts...)
1775 if e != nil {
1776 return nil, e
1777 }
1778 return resp, nil
1779 }
1780
1781 // ResetAuthorizationCode resets the authorization code of the Registration to a new random string.
1782 //
1783 // You can call this method only after 60 days have elapsed since the initial
1784 // domain registration.
1785 func (c *restClient) ResetAuthorizationCode(ctx context.Context, req *domainspb.ResetAuthorizationCodeRequest, opts ...gax.CallOption) (*domainspb.AuthorizationCode, error) {
1786 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1787 jsonReq, err := m.Marshal(req)
1788 if err != nil {
1789 return nil, err
1790 }
1791
1792 baseUrl, err := url.Parse(c.endpoint)
1793 if err != nil {
1794 return nil, err
1795 }
1796 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:resetAuthorizationCode", req.GetRegistration())
1797
1798 params := url.Values{}
1799 params.Add("$alt", "json;enum-encoding=int")
1800
1801 baseUrl.RawQuery = params.Encode()
1802
1803 // Build HTTP headers from client and context metadata.
1804 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "registration", url.QueryEscape(req.GetRegistration()))}
1805
1806 hds = append(c.xGoogHeaders, hds...)
1807 hds = append(hds, "Content-Type", "application/json")
1808 headers := gax.BuildHeaders(ctx, hds...)
1809 opts = append((*c.CallOptions).ResetAuthorizationCode[0:len((*c.CallOptions).ResetAuthorizationCode):len((*c.CallOptions).ResetAuthorizationCode)], opts...)
1810 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1811 resp := &domainspb.AuthorizationCode{}
1812 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1813 if settings.Path != "" {
1814 baseUrl.Path = settings.Path
1815 }
1816 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1817 if err != nil {
1818 return err
1819 }
1820 httpReq = httpReq.WithContext(ctx)
1821 httpReq.Header = headers
1822
1823 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ResetAuthorizationCode")
1824 if err != nil {
1825 return err
1826 }
1827
1828 if err := unm.Unmarshal(buf, resp); err != nil {
1829 return err
1830 }
1831
1832 return nil
1833 }, opts...)
1834 if e != nil {
1835 return nil, e
1836 }
1837 return resp, nil
1838 }
1839
1840 // ConfigureContactSettingsOperation returns a new ConfigureContactSettingsOperation from a given name.
1841 // The name must be that of a previously created ConfigureContactSettingsOperation, possibly from a different process.
1842 func (c *gRPCClient) ConfigureContactSettingsOperation(name string) *ConfigureContactSettingsOperation {
1843 return &ConfigureContactSettingsOperation{
1844 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1845 }
1846 }
1847
1848 // ConfigureContactSettingsOperation returns a new ConfigureContactSettingsOperation from a given name.
1849 // The name must be that of a previously created ConfigureContactSettingsOperation, possibly from a different process.
1850 func (c *restClient) ConfigureContactSettingsOperation(name string) *ConfigureContactSettingsOperation {
1851 override := fmt.Sprintf("/v1beta1/%s", name)
1852 return &ConfigureContactSettingsOperation{
1853 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1854 pollPath: override,
1855 }
1856 }
1857
1858 // ConfigureDnsSettingsOperation returns a new ConfigureDnsSettingsOperation from a given name.
1859 // The name must be that of a previously created ConfigureDnsSettingsOperation, possibly from a different process.
1860 func (c *gRPCClient) ConfigureDnsSettingsOperation(name string) *ConfigureDnsSettingsOperation {
1861 return &ConfigureDnsSettingsOperation{
1862 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1863 }
1864 }
1865
1866 // ConfigureDnsSettingsOperation returns a new ConfigureDnsSettingsOperation from a given name.
1867 // The name must be that of a previously created ConfigureDnsSettingsOperation, possibly from a different process.
1868 func (c *restClient) ConfigureDnsSettingsOperation(name string) *ConfigureDnsSettingsOperation {
1869 override := fmt.Sprintf("/v1beta1/%s", name)
1870 return &ConfigureDnsSettingsOperation{
1871 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1872 pollPath: override,
1873 }
1874 }
1875
1876 // ConfigureManagementSettingsOperation returns a new ConfigureManagementSettingsOperation from a given name.
1877 // The name must be that of a previously created ConfigureManagementSettingsOperation, possibly from a different process.
1878 func (c *gRPCClient) ConfigureManagementSettingsOperation(name string) *ConfigureManagementSettingsOperation {
1879 return &ConfigureManagementSettingsOperation{
1880 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1881 }
1882 }
1883
1884 // ConfigureManagementSettingsOperation returns a new ConfigureManagementSettingsOperation from a given name.
1885 // The name must be that of a previously created ConfigureManagementSettingsOperation, possibly from a different process.
1886 func (c *restClient) ConfigureManagementSettingsOperation(name string) *ConfigureManagementSettingsOperation {
1887 override := fmt.Sprintf("/v1beta1/%s", name)
1888 return &ConfigureManagementSettingsOperation{
1889 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1890 pollPath: override,
1891 }
1892 }
1893
1894 // DeleteRegistrationOperation returns a new DeleteRegistrationOperation from a given name.
1895 // The name must be that of a previously created DeleteRegistrationOperation, possibly from a different process.
1896 func (c *gRPCClient) DeleteRegistrationOperation(name string) *DeleteRegistrationOperation {
1897 return &DeleteRegistrationOperation{
1898 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1899 }
1900 }
1901
1902 // DeleteRegistrationOperation returns a new DeleteRegistrationOperation from a given name.
1903 // The name must be that of a previously created DeleteRegistrationOperation, possibly from a different process.
1904 func (c *restClient) DeleteRegistrationOperation(name string) *DeleteRegistrationOperation {
1905 override := fmt.Sprintf("/v1beta1/%s", name)
1906 return &DeleteRegistrationOperation{
1907 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1908 pollPath: override,
1909 }
1910 }
1911
1912 // ExportRegistrationOperation returns a new ExportRegistrationOperation from a given name.
1913 // The name must be that of a previously created ExportRegistrationOperation, possibly from a different process.
1914 func (c *gRPCClient) ExportRegistrationOperation(name string) *ExportRegistrationOperation {
1915 return &ExportRegistrationOperation{
1916 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1917 }
1918 }
1919
1920 // ExportRegistrationOperation returns a new ExportRegistrationOperation from a given name.
1921 // The name must be that of a previously created ExportRegistrationOperation, possibly from a different process.
1922 func (c *restClient) ExportRegistrationOperation(name string) *ExportRegistrationOperation {
1923 override := fmt.Sprintf("/v1beta1/%s", name)
1924 return &ExportRegistrationOperation{
1925 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1926 pollPath: override,
1927 }
1928 }
1929
1930 // RegisterDomainOperation returns a new RegisterDomainOperation from a given name.
1931 // The name must be that of a previously created RegisterDomainOperation, possibly from a different process.
1932 func (c *gRPCClient) RegisterDomainOperation(name string) *RegisterDomainOperation {
1933 return &RegisterDomainOperation{
1934 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1935 }
1936 }
1937
1938 // RegisterDomainOperation returns a new RegisterDomainOperation from a given name.
1939 // The name must be that of a previously created RegisterDomainOperation, possibly from a different process.
1940 func (c *restClient) RegisterDomainOperation(name string) *RegisterDomainOperation {
1941 override := fmt.Sprintf("/v1beta1/%s", name)
1942 return &RegisterDomainOperation{
1943 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1944 pollPath: override,
1945 }
1946 }
1947
1948 // TransferDomainOperation returns a new TransferDomainOperation from a given name.
1949 // The name must be that of a previously created TransferDomainOperation, possibly from a different process.
1950 func (c *gRPCClient) TransferDomainOperation(name string) *TransferDomainOperation {
1951 return &TransferDomainOperation{
1952 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1953 }
1954 }
1955
1956 // TransferDomainOperation returns a new TransferDomainOperation from a given name.
1957 // The name must be that of a previously created TransferDomainOperation, possibly from a different process.
1958 func (c *restClient) TransferDomainOperation(name string) *TransferDomainOperation {
1959 override := fmt.Sprintf("/v1beta1/%s", name)
1960 return &TransferDomainOperation{
1961 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1962 pollPath: override,
1963 }
1964 }
1965
1966 // UpdateRegistrationOperation returns a new UpdateRegistrationOperation from a given name.
1967 // The name must be that of a previously created UpdateRegistrationOperation, possibly from a different process.
1968 func (c *gRPCClient) UpdateRegistrationOperation(name string) *UpdateRegistrationOperation {
1969 return &UpdateRegistrationOperation{
1970 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1971 }
1972 }
1973
1974 // UpdateRegistrationOperation returns a new UpdateRegistrationOperation from a given name.
1975 // The name must be that of a previously created UpdateRegistrationOperation, possibly from a different process.
1976 func (c *restClient) UpdateRegistrationOperation(name string) *UpdateRegistrationOperation {
1977 override := fmt.Sprintf("/v1beta1/%s", name)
1978 return &UpdateRegistrationOperation{
1979 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
1980 pollPath: override,
1981 }
1982 }