| 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 recaptchaenterprise |
| 18 |
|
| 19 |
import ( |
| 20 |
"context" |
| 21 |
"fmt" |
| 22 |
"log/slog" |
| 23 |
"math" |
| 24 |
"net/url" |
| 25 |
"time" |
| 26 |
|
| 27 |
recaptchaenterprisepb "cloud.google.com/go/recaptchaenterprise/v2/apiv1/recaptchaenterprisepb" |
| 28 |
gax "github.com/googleapis/gax-go/v2" |
| 29 |
"google.golang.org/api/iterator" |
| 30 |
"google.golang.org/api/option" |
| 31 |
"google.golang.org/api/option/internaloption" |
| 32 |
gtransport "google.golang.org/api/transport/grpc" |
| 33 |
"google.golang.org/grpc" |
| 34 |
"google.golang.org/protobuf/proto" |
| 35 |
) |
| 36 |
|
| 37 |
var newClientHook clientHook |
| 38 |
|
| 39 |
// CallOptions contains the retry settings for each method of Client. |
| 40 |
type CallOptions struct { |
| 41 |
CreateAssessment []gax.CallOption |
| 42 |
AnnotateAssessment []gax.CallOption |
| 43 |
CreateKey []gax.CallOption |
| 44 |
ListKeys []gax.CallOption |
| 45 |
RetrieveLegacySecretKey []gax.CallOption |
| 46 |
GetKey []gax.CallOption |
| 47 |
UpdateKey []gax.CallOption |
| 48 |
DeleteKey []gax.CallOption |
| 49 |
MigrateKey []gax.CallOption |
| 50 |
AddIpOverride []gax.CallOption |
| 51 |
RemoveIpOverride []gax.CallOption |
| 52 |
ListIpOverrides []gax.CallOption |
| 53 |
GetMetrics []gax.CallOption |
| 54 |
CreateFirewallPolicy []gax.CallOption |
| 55 |
ListFirewallPolicies []gax.CallOption |
| 56 |
GetFirewallPolicy []gax.CallOption |
| 57 |
UpdateFirewallPolicy []gax.CallOption |
| 58 |
DeleteFirewallPolicy []gax.CallOption |
| 59 |
ReorderFirewallPolicies []gax.CallOption |
| 60 |
ListRelatedAccountGroups []gax.CallOption |
| 61 |
ListRelatedAccountGroupMemberships []gax.CallOption |
| 62 |
SearchRelatedAccountGroupMemberships []gax.CallOption |
| 63 |
} |
| 64 |
|
| 65 |
func defaultGRPCClientOptions() []option.ClientOption { |
| 66 |
return []option.ClientOption{ |
| 67 |
internaloption.WithDefaultEndpoint("recaptchaenterprise.googleapis.com:443"), |
| 68 |
internaloption.WithDefaultEndpointTemplate("recaptchaenterprise.UNIVERSE_DOMAIN:443"), |
| 69 |
internaloption.WithDefaultMTLSEndpoint("recaptchaenterprise.mtls.googleapis.com:443"), |
| 70 |
internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| 71 |
internaloption.WithDefaultAudience("https://recaptchaenterprise.googleapis.com/"), |
| 72 |
internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| 73 |
internaloption.EnableJwtWithScope(), |
| 74 |
internaloption.EnableNewAuthLibrary(), |
| 75 |
option.WithGRPCDialOption(grpc.WithDefaultCallOptions( |
| 76 |
grpc.MaxCallRecvMsgSize(math.MaxInt32))), |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
func defaultCallOptions() *CallOptions { |
| 81 |
return &CallOptions{ |
| 82 |
CreateAssessment: []gax.CallOption{ |
| 83 |
gax.WithTimeout(600000 * time.Millisecond), |
| 84 |
}, |
| 85 |
AnnotateAssessment: []gax.CallOption{ |
| 86 |
gax.WithTimeout(600000 * time.Millisecond), |
| 87 |
}, |
| 88 |
CreateKey: []gax.CallOption{ |
| 89 |
gax.WithTimeout(600000 * time.Millisecond), |
| 90 |
}, |
| 91 |
ListKeys: []gax.CallOption{ |
| 92 |
gax.WithTimeout(600000 * time.Millisecond), |
| 93 |
}, |
| 94 |
RetrieveLegacySecretKey: []gax.CallOption{}, |
| 95 |
GetKey: []gax.CallOption{ |
| 96 |
gax.WithTimeout(600000 * time.Millisecond), |
| 97 |
}, |
| 98 |
UpdateKey: []gax.CallOption{ |
| 99 |
gax.WithTimeout(600000 * time.Millisecond), |
| 100 |
}, |
| 101 |
DeleteKey: []gax.CallOption{ |
| 102 |
gax.WithTimeout(600000 * time.Millisecond), |
| 103 |
}, |
| 104 |
MigrateKey: []gax.CallOption{}, |
| 105 |
AddIpOverride: []gax.CallOption{}, |
| 106 |
RemoveIpOverride: []gax.CallOption{}, |
| 107 |
ListIpOverrides: []gax.CallOption{}, |
| 108 |
GetMetrics: []gax.CallOption{}, |
| 109 |
CreateFirewallPolicy: []gax.CallOption{}, |
| 110 |
ListFirewallPolicies: []gax.CallOption{}, |
| 111 |
GetFirewallPolicy: []gax.CallOption{}, |
| 112 |
UpdateFirewallPolicy: []gax.CallOption{}, |
| 113 |
DeleteFirewallPolicy: []gax.CallOption{}, |
| 114 |
ReorderFirewallPolicies: []gax.CallOption{}, |
| 115 |
ListRelatedAccountGroups: []gax.CallOption{}, |
| 116 |
ListRelatedAccountGroupMemberships: []gax.CallOption{}, |
| 117 |
SearchRelatedAccountGroupMemberships: []gax.CallOption{}, |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
// internalClient is an interface that defines the methods available from reCAPTCHA Enterprise API. |
| 122 |
type internalClient interface { |
| 123 |
Close() error |
| 124 |
setGoogleClientInfo(...string) |
| 125 |
Connection() *grpc.ClientConn |
| 126 |
CreateAssessment(context.Context, *recaptchaenterprisepb.CreateAssessmentRequest, ...gax.CallOption) (*recaptchaenterprisepb.Assessment, error) |
| 127 |
AnnotateAssessment(context.Context, *recaptchaenterprisepb.AnnotateAssessmentRequest, ...gax.CallOption) (*recaptchaenterprisepb.AnnotateAssessmentResponse, error) |
| 128 |
CreateKey(context.Context, *recaptchaenterprisepb.CreateKeyRequest, ...gax.CallOption) (*recaptchaenterprisepb.Key, error) |
| 129 |
ListKeys(context.Context, *recaptchaenterprisepb.ListKeysRequest, ...gax.CallOption) *KeyIterator |
| 130 |
RetrieveLegacySecretKey(context.Context, *recaptchaenterprisepb.RetrieveLegacySecretKeyRequest, ...gax.CallOption) (*recaptchaenterprisepb.RetrieveLegacySecretKeyResponse, error) |
| 131 |
GetKey(context.Context, *recaptchaenterprisepb.GetKeyRequest, ...gax.CallOption) (*recaptchaenterprisepb.Key, error) |
| 132 |
UpdateKey(context.Context, *recaptchaenterprisepb.UpdateKeyRequest, ...gax.CallOption) (*recaptchaenterprisepb.Key, error) |
| 133 |
DeleteKey(context.Context, *recaptchaenterprisepb.DeleteKeyRequest, ...gax.CallOption) error |
| 134 |
MigrateKey(context.Context, *recaptchaenterprisepb.MigrateKeyRequest, ...gax.CallOption) (*recaptchaenterprisepb.Key, error) |
| 135 |
AddIpOverride(context.Context, *recaptchaenterprisepb.AddIpOverrideRequest, ...gax.CallOption) (*recaptchaenterprisepb.AddIpOverrideResponse, error) |
| 136 |
RemoveIpOverride(context.Context, *recaptchaenterprisepb.RemoveIpOverrideRequest, ...gax.CallOption) (*recaptchaenterprisepb.RemoveIpOverrideResponse, error) |
| 137 |
ListIpOverrides(context.Context, *recaptchaenterprisepb.ListIpOverridesRequest, ...gax.CallOption) *IpOverrideDataIterator |
| 138 |
GetMetrics(context.Context, *recaptchaenterprisepb.GetMetricsRequest, ...gax.CallOption) (*recaptchaenterprisepb.Metrics, error) |
| 139 |
CreateFirewallPolicy(context.Context, *recaptchaenterprisepb.CreateFirewallPolicyRequest, ...gax.CallOption) (*recaptchaenterprisepb.FirewallPolicy, error) |
| 140 |
ListFirewallPolicies(context.Context, *recaptchaenterprisepb.ListFirewallPoliciesRequest, ...gax.CallOption) *FirewallPolicyIterator |
| 141 |
GetFirewallPolicy(context.Context, *recaptchaenterprisepb.GetFirewallPolicyRequest, ...gax.CallOption) (*recaptchaenterprisepb.FirewallPolicy, error) |
| 142 |
UpdateFirewallPolicy(context.Context, *recaptchaenterprisepb.UpdateFirewallPolicyRequest, ...gax.CallOption) (*recaptchaenterprisepb.FirewallPolicy, error) |
| 143 |
DeleteFirewallPolicy(context.Context, *recaptchaenterprisepb.DeleteFirewallPolicyRequest, ...gax.CallOption) error |
| 144 |
ReorderFirewallPolicies(context.Context, *recaptchaenterprisepb.ReorderFirewallPoliciesRequest, ...gax.CallOption) (*recaptchaenterprisepb.ReorderFirewallPoliciesResponse, error) |
| 145 |
ListRelatedAccountGroups(context.Context, *recaptchaenterprisepb.ListRelatedAccountGroupsRequest, ...gax.CallOption) *RelatedAccountGroupIterator |
| 146 |
ListRelatedAccountGroupMemberships(context.Context, *recaptchaenterprisepb.ListRelatedAccountGroupMembershipsRequest, ...gax.CallOption) *RelatedAccountGroupMembershipIterator |
| 147 |
SearchRelatedAccountGroupMemberships(context.Context, *recaptchaenterprisepb.SearchRelatedAccountGroupMembershipsRequest, ...gax.CallOption) *RelatedAccountGroupMembershipIterator |
| 148 |
} |
| 149 |
|
| 150 |
// Client is a client for interacting with reCAPTCHA Enterprise API. |
| 151 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 152 |
// |
| 153 |
// Service to determine the likelihood an event is legitimate. |
| 154 |
type Client struct { |
| 155 |
// The internal transport-dependent client. |
| 156 |
internalClient internalClient |
| 157 |
|
| 158 |
// The call options for this service. |
| 159 |
CallOptions *CallOptions |
| 160 |
} |
| 161 |
|
| 162 |
// Wrapper methods routed to the internal client. |
| 163 |
|
| 164 |
// Close closes the connection to the API service. The user should invoke this when |
| 165 |
// the client is no longer required. |
| 166 |
func (c *Client) Close() error { |
| 167 |
return c.internalClient.Close() |
| 168 |
} |
| 169 |
|
| 170 |
// setGoogleClientInfo sets the name and version of the application in |
| 171 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 172 |
// use by Google-written clients. |
| 173 |
func (c *Client) setGoogleClientInfo(keyval ...string) { |
| 174 |
c.internalClient.setGoogleClientInfo(keyval...) |
| 175 |
} |
| 176 |
|
| 177 |
// Connection returns a connection to the API service. |
| 178 |
// |
| 179 |
// Deprecated: Connections are now pooled so this method does not always |
| 180 |
// return the same resource. |
| 181 |
func (c *Client) Connection() *grpc.ClientConn { |
| 182 |
return c.internalClient.Connection() |
| 183 |
} |
| 184 |
|
| 185 |
// CreateAssessment creates an Assessment of the likelihood an event is legitimate. |
| 186 |
func (c *Client) CreateAssessment(ctx context.Context, req *recaptchaenterprisepb.CreateAssessmentRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Assessment, error) { |
| 187 |
return c.internalClient.CreateAssessment(ctx, req, opts...) |
| 188 |
} |
| 189 |
|
| 190 |
// AnnotateAssessment annotates a previously created Assessment to provide additional information |
| 191 |
// on whether the event turned out to be authentic or fraudulent. |
| 192 |
func (c *Client) AnnotateAssessment(ctx context.Context, req *recaptchaenterprisepb.AnnotateAssessmentRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.AnnotateAssessmentResponse, error) { |
| 193 |
return c.internalClient.AnnotateAssessment(ctx, req, opts...) |
| 194 |
} |
| 195 |
|
| 196 |
// CreateKey creates a new reCAPTCHA Enterprise key. |
| 197 |
func (c *Client) CreateKey(ctx context.Context, req *recaptchaenterprisepb.CreateKeyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Key, error) { |
| 198 |
return c.internalClient.CreateKey(ctx, req, opts...) |
| 199 |
} |
| 200 |
|
| 201 |
// ListKeys returns the list of all keys that belong to a project. |
| 202 |
func (c *Client) ListKeys(ctx context.Context, req *recaptchaenterprisepb.ListKeysRequest, opts ...gax.CallOption) *KeyIterator { |
| 203 |
return c.internalClient.ListKeys(ctx, req, opts...) |
| 204 |
} |
| 205 |
|
| 206 |
// RetrieveLegacySecretKey returns the secret key related to the specified public key. |
| 207 |
// You must use the legacy secret key only in a 3rd party integration with |
| 208 |
// legacy reCAPTCHA. |
| 209 |
func (c *Client) RetrieveLegacySecretKey(ctx context.Context, req *recaptchaenterprisepb.RetrieveLegacySecretKeyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.RetrieveLegacySecretKeyResponse, error) { |
| 210 |
return c.internalClient.RetrieveLegacySecretKey(ctx, req, opts...) |
| 211 |
} |
| 212 |
|
| 213 |
// GetKey returns the specified key. |
| 214 |
func (c *Client) GetKey(ctx context.Context, req *recaptchaenterprisepb.GetKeyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Key, error) { |
| 215 |
return c.internalClient.GetKey(ctx, req, opts...) |
| 216 |
} |
| 217 |
|
| 218 |
// UpdateKey updates the specified key. |
| 219 |
func (c *Client) UpdateKey(ctx context.Context, req *recaptchaenterprisepb.UpdateKeyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Key, error) { |
| 220 |
return c.internalClient.UpdateKey(ctx, req, opts...) |
| 221 |
} |
| 222 |
|
| 223 |
// DeleteKey deletes the specified key. |
| 224 |
func (c *Client) DeleteKey(ctx context.Context, req *recaptchaenterprisepb.DeleteKeyRequest, opts ...gax.CallOption) error { |
| 225 |
return c.internalClient.DeleteKey(ctx, req, opts...) |
| 226 |
} |
| 227 |
|
| 228 |
// MigrateKey migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. |
| 229 |
// Once a key is migrated, it can be used from either product. SiteVerify |
| 230 |
// requests are billed as CreateAssessment calls. You must be |
| 231 |
// authenticated as one of the current owners of the reCAPTCHA Key, and |
| 232 |
// your user must have the reCAPTCHA Enterprise Admin IAM role in the |
| 233 |
// destination project. |
| 234 |
func (c *Client) MigrateKey(ctx context.Context, req *recaptchaenterprisepb.MigrateKeyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Key, error) { |
| 235 |
return c.internalClient.MigrateKey(ctx, req, opts...) |
| 236 |
} |
| 237 |
|
| 238 |
// AddIpOverride adds an IP override to a key. The following restrictions hold: |
| 239 |
// |
| 240 |
// The maximum number of IP overrides per key is 100. |
| 241 |
// |
| 242 |
// For any conflict (such as IP already exists or IP part of an existing |
| 243 |
// IP range), an error is returned. |
| 244 |
func (c *Client) AddIpOverride(ctx context.Context, req *recaptchaenterprisepb.AddIpOverrideRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.AddIpOverrideResponse, error) { |
| 245 |
return c.internalClient.AddIpOverride(ctx, req, opts...) |
| 246 |
} |
| 247 |
|
| 248 |
// RemoveIpOverride removes an IP override from a key. The following restrictions hold: |
| 249 |
// |
| 250 |
// If the IP isn’t found in an existing IP override, a NOT_FOUND error |
| 251 |
// is returned. |
| 252 |
// |
| 253 |
// If the IP is found in an existing IP override, but the |
| 254 |
// override type does not match, a NOT_FOUND error is returned. |
| 255 |
func (c *Client) RemoveIpOverride(ctx context.Context, req *recaptchaenterprisepb.RemoveIpOverrideRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.RemoveIpOverrideResponse, error) { |
| 256 |
return c.internalClient.RemoveIpOverride(ctx, req, opts...) |
| 257 |
} |
| 258 |
|
| 259 |
// ListIpOverrides lists all IP overrides for a key. |
| 260 |
func (c *Client) ListIpOverrides(ctx context.Context, req *recaptchaenterprisepb.ListIpOverridesRequest, opts ...gax.CallOption) *IpOverrideDataIterator { |
| 261 |
return c.internalClient.ListIpOverrides(ctx, req, opts...) |
| 262 |
} |
| 263 |
|
| 264 |
// GetMetrics get some aggregated metrics for a Key. This data can be used to build |
| 265 |
// dashboards. |
| 266 |
func (c *Client) GetMetrics(ctx context.Context, req *recaptchaenterprisepb.GetMetricsRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Metrics, error) { |
| 267 |
return c.internalClient.GetMetrics(ctx, req, opts...) |
| 268 |
} |
| 269 |
|
| 270 |
// CreateFirewallPolicy creates a new FirewallPolicy, specifying conditions at which reCAPTCHA |
| 271 |
// Enterprise actions can be executed. |
| 272 |
// A project may have a maximum of 1000 policies. |
| 273 |
func (c *Client) CreateFirewallPolicy(ctx context.Context, req *recaptchaenterprisepb.CreateFirewallPolicyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.FirewallPolicy, error) { |
| 274 |
return c.internalClient.CreateFirewallPolicy(ctx, req, opts...) |
| 275 |
} |
| 276 |
|
| 277 |
// ListFirewallPolicies returns the list of all firewall policies that belong to a project. |
| 278 |
func (c *Client) ListFirewallPolicies(ctx context.Context, req *recaptchaenterprisepb.ListFirewallPoliciesRequest, opts ...gax.CallOption) *FirewallPolicyIterator { |
| 279 |
return c.internalClient.ListFirewallPolicies(ctx, req, opts...) |
| 280 |
} |
| 281 |
|
| 282 |
// GetFirewallPolicy returns the specified firewall policy. |
| 283 |
func (c *Client) GetFirewallPolicy(ctx context.Context, req *recaptchaenterprisepb.GetFirewallPolicyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.FirewallPolicy, error) { |
| 284 |
return c.internalClient.GetFirewallPolicy(ctx, req, opts...) |
| 285 |
} |
| 286 |
|
| 287 |
// UpdateFirewallPolicy updates the specified firewall policy. |
| 288 |
func (c *Client) UpdateFirewallPolicy(ctx context.Context, req *recaptchaenterprisepb.UpdateFirewallPolicyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.FirewallPolicy, error) { |
| 289 |
return c.internalClient.UpdateFirewallPolicy(ctx, req, opts...) |
| 290 |
} |
| 291 |
|
| 292 |
// DeleteFirewallPolicy deletes the specified firewall policy. |
| 293 |
func (c *Client) DeleteFirewallPolicy(ctx context.Context, req *recaptchaenterprisepb.DeleteFirewallPolicyRequest, opts ...gax.CallOption) error { |
| 294 |
return c.internalClient.DeleteFirewallPolicy(ctx, req, opts...) |
| 295 |
} |
| 296 |
|
| 297 |
// ReorderFirewallPolicies reorders all firewall policies. |
| 298 |
func (c *Client) ReorderFirewallPolicies(ctx context.Context, req *recaptchaenterprisepb.ReorderFirewallPoliciesRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.ReorderFirewallPoliciesResponse, error) { |
| 299 |
return c.internalClient.ReorderFirewallPolicies(ctx, req, opts...) |
| 300 |
} |
| 301 |
|
| 302 |
// ListRelatedAccountGroups list groups of related accounts. |
| 303 |
func (c *Client) ListRelatedAccountGroups(ctx context.Context, req *recaptchaenterprisepb.ListRelatedAccountGroupsRequest, opts ...gax.CallOption) *RelatedAccountGroupIterator { |
| 304 |
return c.internalClient.ListRelatedAccountGroups(ctx, req, opts...) |
| 305 |
} |
| 306 |
|
| 307 |
// ListRelatedAccountGroupMemberships get memberships in a group of related accounts. |
| 308 |
func (c *Client) ListRelatedAccountGroupMemberships(ctx context.Context, req *recaptchaenterprisepb.ListRelatedAccountGroupMembershipsRequest, opts ...gax.CallOption) *RelatedAccountGroupMembershipIterator { |
| 309 |
return c.internalClient.ListRelatedAccountGroupMemberships(ctx, req, opts...) |
| 310 |
} |
| 311 |
|
| 312 |
// SearchRelatedAccountGroupMemberships search group memberships related to a given account. |
| 313 |
func (c *Client) SearchRelatedAccountGroupMemberships(ctx context.Context, req *recaptchaenterprisepb.SearchRelatedAccountGroupMembershipsRequest, opts ...gax.CallOption) *RelatedAccountGroupMembershipIterator { |
| 314 |
return c.internalClient.SearchRelatedAccountGroupMemberships(ctx, req, opts...) |
| 315 |
} |
| 316 |
|
| 317 |
// gRPCClient is a client for interacting with reCAPTCHA Enterprise API over gRPC transport. |
| 318 |
// |
| 319 |
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| 320 |
type gRPCClient struct { |
| 321 |
// Connection pool of gRPC connections to the service. |
| 322 |
connPool gtransport.ConnPool |
| 323 |
|
| 324 |
// Points back to the CallOptions field of the containing Client |
| 325 |
CallOptions **CallOptions |
| 326 |
|
| 327 |
// The gRPC API client. |
| 328 |
client recaptchaenterprisepb.RecaptchaEnterpriseServiceClient |
| 329 |
|
| 330 |
// The x-goog-* metadata to be sent with each request. |
| 331 |
xGoogHeaders []string |
| 332 |
|
| 333 |
logger *slog.Logger |
| 334 |
} |
| 335 |
|
| 336 |
// NewClient creates a new recaptcha enterprise service client based on gRPC. |
| 337 |
// The returned client must be Closed when it is done being used to clean up its underlying connections. |
| 338 |
// |
| 339 |
// Service to determine the likelihood an event is legitimate. |
| 340 |
func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { |
| 341 |
clientOpts := defaultGRPCClientOptions() |
| 342 |
if newClientHook != nil { |
| 343 |
hookOpts, err := newClientHook(ctx, clientHookParams{}) |
| 344 |
if err != nil { |
| 345 |
return nil, err |
| 346 |
} |
| 347 |
clientOpts = append(clientOpts, hookOpts...) |
| 348 |
} |
| 349 |
|
| 350 |
connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) |
| 351 |
if err != nil { |
| 352 |
return nil, err |
| 353 |
} |
| 354 |
client := Client{CallOptions: defaultCallOptions()} |
| 355 |
|
| 356 |
c := &gRPCClient{ |
| 357 |
connPool: connPool, |
| 358 |
client: recaptchaenterprisepb.NewRecaptchaEnterpriseServiceClient(connPool), |
| 359 |
CallOptions: &client.CallOptions, |
| 360 |
logger: internaloption.GetLogger(opts), |
| 361 |
} |
| 362 |
c.setGoogleClientInfo() |
| 363 |
|
| 364 |
client.internalClient = c |
| 365 |
|
| 366 |
return &client, nil |
| 367 |
} |
| 368 |
|
| 369 |
// Connection returns a connection to the API service. |
| 370 |
// |
| 371 |
// Deprecated: Connections are now pooled so this method does not always |
| 372 |
// return the same resource. |
| 373 |
func (c *gRPCClient) Connection() *grpc.ClientConn { |
| 374 |
return c.connPool.Conn() |
| 375 |
} |
| 376 |
|
| 377 |
// setGoogleClientInfo sets the name and version of the application in |
| 378 |
// the `x-goog-api-client` header passed on each request. Intended for |
| 379 |
// use by Google-written clients. |
| 380 |
func (c *gRPCClient) setGoogleClientInfo(keyval ...string) { |
| 381 |
kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| 382 |
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) |
| 383 |
c.xGoogHeaders = []string{ |
| 384 |
"x-goog-api-client", gax.XGoogHeader(kv...), |
| 385 |
} |
| 386 |
} |
| 387 |
|
| 388 |
// Close closes the connection to the API service. The user should invoke this when |
| 389 |
// the client is no longer required. |
| 390 |
func (c *gRPCClient) Close() error { |
| 391 |
return c.connPool.Close() |
| 392 |
} |
| 393 |
|
| 394 |
func (c *gRPCClient) CreateAssessment(ctx context.Context, req *recaptchaenterprisepb.CreateAssessmentRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Assessment, error) { |
| 395 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 396 |
|
| 397 |
hds = append(c.xGoogHeaders, hds...) |
| 398 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 399 |
opts = append((*c.CallOptions).CreateAssessment[0:len((*c.CallOptions).CreateAssessment):len((*c.CallOptions).CreateAssessment)], opts...) |
| 400 |
var resp *recaptchaenterprisepb.Assessment |
| 401 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 402 |
var err error |
| 403 |
resp, err = executeRPC(ctx, c.client.CreateAssessment, req, settings.GRPC, c.logger, "CreateAssessment") |
| 404 |
return err |
| 405 |
}, opts...) |
| 406 |
if err != nil { |
| 407 |
return nil, err |
| 408 |
} |
| 409 |
return resp, nil |
| 410 |
} |
| 411 |
|
| 412 |
func (c *gRPCClient) AnnotateAssessment(ctx context.Context, req *recaptchaenterprisepb.AnnotateAssessmentRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.AnnotateAssessmentResponse, error) { |
| 413 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 414 |
|
| 415 |
hds = append(c.xGoogHeaders, hds...) |
| 416 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 417 |
opts = append((*c.CallOptions).AnnotateAssessment[0:len((*c.CallOptions).AnnotateAssessment):len((*c.CallOptions).AnnotateAssessment)], opts...) |
| 418 |
var resp *recaptchaenterprisepb.AnnotateAssessmentResponse |
| 419 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 420 |
var err error |
| 421 |
resp, err = executeRPC(ctx, c.client.AnnotateAssessment, req, settings.GRPC, c.logger, "AnnotateAssessment") |
| 422 |
return err |
| 423 |
}, opts...) |
| 424 |
if err != nil { |
| 425 |
return nil, err |
| 426 |
} |
| 427 |
return resp, nil |
| 428 |
} |
| 429 |
|
| 430 |
func (c *gRPCClient) CreateKey(ctx context.Context, req *recaptchaenterprisepb.CreateKeyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Key, error) { |
| 431 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 432 |
|
| 433 |
hds = append(c.xGoogHeaders, hds...) |
| 434 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 435 |
opts = append((*c.CallOptions).CreateKey[0:len((*c.CallOptions).CreateKey):len((*c.CallOptions).CreateKey)], opts...) |
| 436 |
var resp *recaptchaenterprisepb.Key |
| 437 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 438 |
var err error |
| 439 |
resp, err = executeRPC(ctx, c.client.CreateKey, req, settings.GRPC, c.logger, "CreateKey") |
| 440 |
return err |
| 441 |
}, opts...) |
| 442 |
if err != nil { |
| 443 |
return nil, err |
| 444 |
} |
| 445 |
return resp, nil |
| 446 |
} |
| 447 |
|
| 448 |
func (c *gRPCClient) ListKeys(ctx context.Context, req *recaptchaenterprisepb.ListKeysRequest, opts ...gax.CallOption) *KeyIterator { |
| 449 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 450 |
|
| 451 |
hds = append(c.xGoogHeaders, hds...) |
| 452 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 453 |
opts = append((*c.CallOptions).ListKeys[0:len((*c.CallOptions).ListKeys):len((*c.CallOptions).ListKeys)], opts...) |
| 454 |
it := &KeyIterator{} |
| 455 |
req = proto.Clone(req).(*recaptchaenterprisepb.ListKeysRequest) |
| 456 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*recaptchaenterprisepb.Key, string, error) { |
| 457 |
resp := &recaptchaenterprisepb.ListKeysResponse{} |
| 458 |
if pageToken != "" { |
| 459 |
req.PageToken = pageToken |
| 460 |
} |
| 461 |
if pageSize > math.MaxInt32 { |
| 462 |
req.PageSize = math.MaxInt32 |
| 463 |
} else if pageSize != 0 { |
| 464 |
req.PageSize = int32(pageSize) |
| 465 |
} |
| 466 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 467 |
var err error |
| 468 |
resp, err = executeRPC(ctx, c.client.ListKeys, req, settings.GRPC, c.logger, "ListKeys") |
| 469 |
return err |
| 470 |
}, opts...) |
| 471 |
if err != nil { |
| 472 |
return nil, "", err |
| 473 |
} |
| 474 |
|
| 475 |
it.Response = resp |
| 476 |
return resp.GetKeys(), resp.GetNextPageToken(), nil |
| 477 |
} |
| 478 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 479 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 480 |
if err != nil { |
| 481 |
return "", err |
| 482 |
} |
| 483 |
it.items = append(it.items, items...) |
| 484 |
return nextPageToken, nil |
| 485 |
} |
| 486 |
|
| 487 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 488 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 489 |
it.pageInfo.Token = req.GetPageToken() |
| 490 |
|
| 491 |
return it |
| 492 |
} |
| 493 |
|
| 494 |
func (c *gRPCClient) RetrieveLegacySecretKey(ctx context.Context, req *recaptchaenterprisepb.RetrieveLegacySecretKeyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.RetrieveLegacySecretKeyResponse, error) { |
| 495 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "key", url.QueryEscape(req.GetKey()))} |
| 496 |
|
| 497 |
hds = append(c.xGoogHeaders, hds...) |
| 498 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 499 |
opts = append((*c.CallOptions).RetrieveLegacySecretKey[0:len((*c.CallOptions).RetrieveLegacySecretKey):len((*c.CallOptions).RetrieveLegacySecretKey)], opts...) |
| 500 |
var resp *recaptchaenterprisepb.RetrieveLegacySecretKeyResponse |
| 501 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 502 |
var err error |
| 503 |
resp, err = executeRPC(ctx, c.client.RetrieveLegacySecretKey, req, settings.GRPC, c.logger, "RetrieveLegacySecretKey") |
| 504 |
return err |
| 505 |
}, opts...) |
| 506 |
if err != nil { |
| 507 |
return nil, err |
| 508 |
} |
| 509 |
return resp, nil |
| 510 |
} |
| 511 |
|
| 512 |
func (c *gRPCClient) GetKey(ctx context.Context, req *recaptchaenterprisepb.GetKeyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Key, error) { |
| 513 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 514 |
|
| 515 |
hds = append(c.xGoogHeaders, hds...) |
| 516 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 517 |
opts = append((*c.CallOptions).GetKey[0:len((*c.CallOptions).GetKey):len((*c.CallOptions).GetKey)], opts...) |
| 518 |
var resp *recaptchaenterprisepb.Key |
| 519 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 520 |
var err error |
| 521 |
resp, err = executeRPC(ctx, c.client.GetKey, req, settings.GRPC, c.logger, "GetKey") |
| 522 |
return err |
| 523 |
}, opts...) |
| 524 |
if err != nil { |
| 525 |
return nil, err |
| 526 |
} |
| 527 |
return resp, nil |
| 528 |
} |
| 529 |
|
| 530 |
func (c *gRPCClient) UpdateKey(ctx context.Context, req *recaptchaenterprisepb.UpdateKeyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Key, error) { |
| 531 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "key.name", url.QueryEscape(req.GetKey().GetName()))} |
| 532 |
|
| 533 |
hds = append(c.xGoogHeaders, hds...) |
| 534 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 535 |
opts = append((*c.CallOptions).UpdateKey[0:len((*c.CallOptions).UpdateKey):len((*c.CallOptions).UpdateKey)], opts...) |
| 536 |
var resp *recaptchaenterprisepb.Key |
| 537 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 538 |
var err error |
| 539 |
resp, err = executeRPC(ctx, c.client.UpdateKey, req, settings.GRPC, c.logger, "UpdateKey") |
| 540 |
return err |
| 541 |
}, opts...) |
| 542 |
if err != nil { |
| 543 |
return nil, err |
| 544 |
} |
| 545 |
return resp, nil |
| 546 |
} |
| 547 |
|
| 548 |
func (c *gRPCClient) DeleteKey(ctx context.Context, req *recaptchaenterprisepb.DeleteKeyRequest, opts ...gax.CallOption) error { |
| 549 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 550 |
|
| 551 |
hds = append(c.xGoogHeaders, hds...) |
| 552 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 553 |
opts = append((*c.CallOptions).DeleteKey[0:len((*c.CallOptions).DeleteKey):len((*c.CallOptions).DeleteKey)], opts...) |
| 554 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 555 |
var err error |
| 556 |
_, err = executeRPC(ctx, c.client.DeleteKey, req, settings.GRPC, c.logger, "DeleteKey") |
| 557 |
return err |
| 558 |
}, opts...) |
| 559 |
return err |
| 560 |
} |
| 561 |
|
| 562 |
func (c *gRPCClient) MigrateKey(ctx context.Context, req *recaptchaenterprisepb.MigrateKeyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Key, error) { |
| 563 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 564 |
|
| 565 |
hds = append(c.xGoogHeaders, hds...) |
| 566 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 567 |
opts = append((*c.CallOptions).MigrateKey[0:len((*c.CallOptions).MigrateKey):len((*c.CallOptions).MigrateKey)], opts...) |
| 568 |
var resp *recaptchaenterprisepb.Key |
| 569 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 570 |
var err error |
| 571 |
resp, err = executeRPC(ctx, c.client.MigrateKey, req, settings.GRPC, c.logger, "MigrateKey") |
| 572 |
return err |
| 573 |
}, opts...) |
| 574 |
if err != nil { |
| 575 |
return nil, err |
| 576 |
} |
| 577 |
return resp, nil |
| 578 |
} |
| 579 |
|
| 580 |
func (c *gRPCClient) AddIpOverride(ctx context.Context, req *recaptchaenterprisepb.AddIpOverrideRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.AddIpOverrideResponse, error) { |
| 581 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 582 |
|
| 583 |
hds = append(c.xGoogHeaders, hds...) |
| 584 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 585 |
opts = append((*c.CallOptions).AddIpOverride[0:len((*c.CallOptions).AddIpOverride):len((*c.CallOptions).AddIpOverride)], opts...) |
| 586 |
var resp *recaptchaenterprisepb.AddIpOverrideResponse |
| 587 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 588 |
var err error |
| 589 |
resp, err = executeRPC(ctx, c.client.AddIpOverride, req, settings.GRPC, c.logger, "AddIpOverride") |
| 590 |
return err |
| 591 |
}, opts...) |
| 592 |
if err != nil { |
| 593 |
return nil, err |
| 594 |
} |
| 595 |
return resp, nil |
| 596 |
} |
| 597 |
|
| 598 |
func (c *gRPCClient) RemoveIpOverride(ctx context.Context, req *recaptchaenterprisepb.RemoveIpOverrideRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.RemoveIpOverrideResponse, error) { |
| 599 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 600 |
|
| 601 |
hds = append(c.xGoogHeaders, hds...) |
| 602 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 603 |
opts = append((*c.CallOptions).RemoveIpOverride[0:len((*c.CallOptions).RemoveIpOverride):len((*c.CallOptions).RemoveIpOverride)], opts...) |
| 604 |
var resp *recaptchaenterprisepb.RemoveIpOverrideResponse |
| 605 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 606 |
var err error |
| 607 |
resp, err = executeRPC(ctx, c.client.RemoveIpOverride, req, settings.GRPC, c.logger, "RemoveIpOverride") |
| 608 |
return err |
| 609 |
}, opts...) |
| 610 |
if err != nil { |
| 611 |
return nil, err |
| 612 |
} |
| 613 |
return resp, nil |
| 614 |
} |
| 615 |
|
| 616 |
func (c *gRPCClient) ListIpOverrides(ctx context.Context, req *recaptchaenterprisepb.ListIpOverridesRequest, opts ...gax.CallOption) *IpOverrideDataIterator { |
| 617 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 618 |
|
| 619 |
hds = append(c.xGoogHeaders, hds...) |
| 620 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 621 |
opts = append((*c.CallOptions).ListIpOverrides[0:len((*c.CallOptions).ListIpOverrides):len((*c.CallOptions).ListIpOverrides)], opts...) |
| 622 |
it := &IpOverrideDataIterator{} |
| 623 |
req = proto.Clone(req).(*recaptchaenterprisepb.ListIpOverridesRequest) |
| 624 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*recaptchaenterprisepb.IpOverrideData, string, error) { |
| 625 |
resp := &recaptchaenterprisepb.ListIpOverridesResponse{} |
| 626 |
if pageToken != "" { |
| 627 |
req.PageToken = pageToken |
| 628 |
} |
| 629 |
if pageSize > math.MaxInt32 { |
| 630 |
req.PageSize = math.MaxInt32 |
| 631 |
} else if pageSize != 0 { |
| 632 |
req.PageSize = int32(pageSize) |
| 633 |
} |
| 634 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 635 |
var err error |
| 636 |
resp, err = executeRPC(ctx, c.client.ListIpOverrides, req, settings.GRPC, c.logger, "ListIpOverrides") |
| 637 |
return err |
| 638 |
}, opts...) |
| 639 |
if err != nil { |
| 640 |
return nil, "", err |
| 641 |
} |
| 642 |
|
| 643 |
it.Response = resp |
| 644 |
return resp.GetIpOverrides(), resp.GetNextPageToken(), nil |
| 645 |
} |
| 646 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 647 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 648 |
if err != nil { |
| 649 |
return "", err |
| 650 |
} |
| 651 |
it.items = append(it.items, items...) |
| 652 |
return nextPageToken, nil |
| 653 |
} |
| 654 |
|
| 655 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 656 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 657 |
it.pageInfo.Token = req.GetPageToken() |
| 658 |
|
| 659 |
return it |
| 660 |
} |
| 661 |
|
| 662 |
func (c *gRPCClient) GetMetrics(ctx context.Context, req *recaptchaenterprisepb.GetMetricsRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.Metrics, error) { |
| 663 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 664 |
|
| 665 |
hds = append(c.xGoogHeaders, hds...) |
| 666 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 667 |
opts = append((*c.CallOptions).GetMetrics[0:len((*c.CallOptions).GetMetrics):len((*c.CallOptions).GetMetrics)], opts...) |
| 668 |
var resp *recaptchaenterprisepb.Metrics |
| 669 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 670 |
var err error |
| 671 |
resp, err = executeRPC(ctx, c.client.GetMetrics, req, settings.GRPC, c.logger, "GetMetrics") |
| 672 |
return err |
| 673 |
}, opts...) |
| 674 |
if err != nil { |
| 675 |
return nil, err |
| 676 |
} |
| 677 |
return resp, nil |
| 678 |
} |
| 679 |
|
| 680 |
func (c *gRPCClient) CreateFirewallPolicy(ctx context.Context, req *recaptchaenterprisepb.CreateFirewallPolicyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.FirewallPolicy, error) { |
| 681 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 682 |
|
| 683 |
hds = append(c.xGoogHeaders, hds...) |
| 684 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 685 |
opts = append((*c.CallOptions).CreateFirewallPolicy[0:len((*c.CallOptions).CreateFirewallPolicy):len((*c.CallOptions).CreateFirewallPolicy)], opts...) |
| 686 |
var resp *recaptchaenterprisepb.FirewallPolicy |
| 687 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 688 |
var err error |
| 689 |
resp, err = executeRPC(ctx, c.client.CreateFirewallPolicy, req, settings.GRPC, c.logger, "CreateFirewallPolicy") |
| 690 |
return err |
| 691 |
}, opts...) |
| 692 |
if err != nil { |
| 693 |
return nil, err |
| 694 |
} |
| 695 |
return resp, nil |
| 696 |
} |
| 697 |
|
| 698 |
func (c *gRPCClient) ListFirewallPolicies(ctx context.Context, req *recaptchaenterprisepb.ListFirewallPoliciesRequest, opts ...gax.CallOption) *FirewallPolicyIterator { |
| 699 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 700 |
|
| 701 |
hds = append(c.xGoogHeaders, hds...) |
| 702 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 703 |
opts = append((*c.CallOptions).ListFirewallPolicies[0:len((*c.CallOptions).ListFirewallPolicies):len((*c.CallOptions).ListFirewallPolicies)], opts...) |
| 704 |
it := &FirewallPolicyIterator{} |
| 705 |
req = proto.Clone(req).(*recaptchaenterprisepb.ListFirewallPoliciesRequest) |
| 706 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*recaptchaenterprisepb.FirewallPolicy, string, error) { |
| 707 |
resp := &recaptchaenterprisepb.ListFirewallPoliciesResponse{} |
| 708 |
if pageToken != "" { |
| 709 |
req.PageToken = pageToken |
| 710 |
} |
| 711 |
if pageSize > math.MaxInt32 { |
| 712 |
req.PageSize = math.MaxInt32 |
| 713 |
} else if pageSize != 0 { |
| 714 |
req.PageSize = int32(pageSize) |
| 715 |
} |
| 716 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 717 |
var err error |
| 718 |
resp, err = executeRPC(ctx, c.client.ListFirewallPolicies, req, settings.GRPC, c.logger, "ListFirewallPolicies") |
| 719 |
return err |
| 720 |
}, opts...) |
| 721 |
if err != nil { |
| 722 |
return nil, "", err |
| 723 |
} |
| 724 |
|
| 725 |
it.Response = resp |
| 726 |
return resp.GetFirewallPolicies(), resp.GetNextPageToken(), nil |
| 727 |
} |
| 728 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 729 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 730 |
if err != nil { |
| 731 |
return "", err |
| 732 |
} |
| 733 |
it.items = append(it.items, items...) |
| 734 |
return nextPageToken, nil |
| 735 |
} |
| 736 |
|
| 737 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 738 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 739 |
it.pageInfo.Token = req.GetPageToken() |
| 740 |
|
| 741 |
return it |
| 742 |
} |
| 743 |
|
| 744 |
func (c *gRPCClient) GetFirewallPolicy(ctx context.Context, req *recaptchaenterprisepb.GetFirewallPolicyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.FirewallPolicy, error) { |
| 745 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 746 |
|
| 747 |
hds = append(c.xGoogHeaders, hds...) |
| 748 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 749 |
opts = append((*c.CallOptions).GetFirewallPolicy[0:len((*c.CallOptions).GetFirewallPolicy):len((*c.CallOptions).GetFirewallPolicy)], opts...) |
| 750 |
var resp *recaptchaenterprisepb.FirewallPolicy |
| 751 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 752 |
var err error |
| 753 |
resp, err = executeRPC(ctx, c.client.GetFirewallPolicy, req, settings.GRPC, c.logger, "GetFirewallPolicy") |
| 754 |
return err |
| 755 |
}, opts...) |
| 756 |
if err != nil { |
| 757 |
return nil, err |
| 758 |
} |
| 759 |
return resp, nil |
| 760 |
} |
| 761 |
|
| 762 |
func (c *gRPCClient) UpdateFirewallPolicy(ctx context.Context, req *recaptchaenterprisepb.UpdateFirewallPolicyRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.FirewallPolicy, error) { |
| 763 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "firewall_policy.name", url.QueryEscape(req.GetFirewallPolicy().GetName()))} |
| 764 |
|
| 765 |
hds = append(c.xGoogHeaders, hds...) |
| 766 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 767 |
opts = append((*c.CallOptions).UpdateFirewallPolicy[0:len((*c.CallOptions).UpdateFirewallPolicy):len((*c.CallOptions).UpdateFirewallPolicy)], opts...) |
| 768 |
var resp *recaptchaenterprisepb.FirewallPolicy |
| 769 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 770 |
var err error |
| 771 |
resp, err = executeRPC(ctx, c.client.UpdateFirewallPolicy, req, settings.GRPC, c.logger, "UpdateFirewallPolicy") |
| 772 |
return err |
| 773 |
}, opts...) |
| 774 |
if err != nil { |
| 775 |
return nil, err |
| 776 |
} |
| 777 |
return resp, nil |
| 778 |
} |
| 779 |
|
| 780 |
func (c *gRPCClient) DeleteFirewallPolicy(ctx context.Context, req *recaptchaenterprisepb.DeleteFirewallPolicyRequest, opts ...gax.CallOption) error { |
| 781 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| 782 |
|
| 783 |
hds = append(c.xGoogHeaders, hds...) |
| 784 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 785 |
opts = append((*c.CallOptions).DeleteFirewallPolicy[0:len((*c.CallOptions).DeleteFirewallPolicy):len((*c.CallOptions).DeleteFirewallPolicy)], opts...) |
| 786 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 787 |
var err error |
| 788 |
_, err = executeRPC(ctx, c.client.DeleteFirewallPolicy, req, settings.GRPC, c.logger, "DeleteFirewallPolicy") |
| 789 |
return err |
| 790 |
}, opts...) |
| 791 |
return err |
| 792 |
} |
| 793 |
|
| 794 |
func (c *gRPCClient) ReorderFirewallPolicies(ctx context.Context, req *recaptchaenterprisepb.ReorderFirewallPoliciesRequest, opts ...gax.CallOption) (*recaptchaenterprisepb.ReorderFirewallPoliciesResponse, error) { |
| 795 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 796 |
|
| 797 |
hds = append(c.xGoogHeaders, hds...) |
| 798 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 799 |
opts = append((*c.CallOptions).ReorderFirewallPolicies[0:len((*c.CallOptions).ReorderFirewallPolicies):len((*c.CallOptions).ReorderFirewallPolicies)], opts...) |
| 800 |
var resp *recaptchaenterprisepb.ReorderFirewallPoliciesResponse |
| 801 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 802 |
var err error |
| 803 |
resp, err = executeRPC(ctx, c.client.ReorderFirewallPolicies, req, settings.GRPC, c.logger, "ReorderFirewallPolicies") |
| 804 |
return err |
| 805 |
}, opts...) |
| 806 |
if err != nil { |
| 807 |
return nil, err |
| 808 |
} |
| 809 |
return resp, nil |
| 810 |
} |
| 811 |
|
| 812 |
func (c *gRPCClient) ListRelatedAccountGroups(ctx context.Context, req *recaptchaenterprisepb.ListRelatedAccountGroupsRequest, opts ...gax.CallOption) *RelatedAccountGroupIterator { |
| 813 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 814 |
|
| 815 |
hds = append(c.xGoogHeaders, hds...) |
| 816 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 817 |
opts = append((*c.CallOptions).ListRelatedAccountGroups[0:len((*c.CallOptions).ListRelatedAccountGroups):len((*c.CallOptions).ListRelatedAccountGroups)], opts...) |
| 818 |
it := &RelatedAccountGroupIterator{} |
| 819 |
req = proto.Clone(req).(*recaptchaenterprisepb.ListRelatedAccountGroupsRequest) |
| 820 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*recaptchaenterprisepb.RelatedAccountGroup, string, error) { |
| 821 |
resp := &recaptchaenterprisepb.ListRelatedAccountGroupsResponse{} |
| 822 |
if pageToken != "" { |
| 823 |
req.PageToken = pageToken |
| 824 |
} |
| 825 |
if pageSize > math.MaxInt32 { |
| 826 |
req.PageSize = math.MaxInt32 |
| 827 |
} else if pageSize != 0 { |
| 828 |
req.PageSize = int32(pageSize) |
| 829 |
} |
| 830 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 831 |
var err error |
| 832 |
resp, err = executeRPC(ctx, c.client.ListRelatedAccountGroups, req, settings.GRPC, c.logger, "ListRelatedAccountGroups") |
| 833 |
return err |
| 834 |
}, opts...) |
| 835 |
if err != nil { |
| 836 |
return nil, "", err |
| 837 |
} |
| 838 |
|
| 839 |
it.Response = resp |
| 840 |
return resp.GetRelatedAccountGroups(), resp.GetNextPageToken(), nil |
| 841 |
} |
| 842 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 843 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 844 |
if err != nil { |
| 845 |
return "", err |
| 846 |
} |
| 847 |
it.items = append(it.items, items...) |
| 848 |
return nextPageToken, nil |
| 849 |
} |
| 850 |
|
| 851 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 852 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 853 |
it.pageInfo.Token = req.GetPageToken() |
| 854 |
|
| 855 |
return it |
| 856 |
} |
| 857 |
|
| 858 |
func (c *gRPCClient) ListRelatedAccountGroupMemberships(ctx context.Context, req *recaptchaenterprisepb.ListRelatedAccountGroupMembershipsRequest, opts ...gax.CallOption) *RelatedAccountGroupMembershipIterator { |
| 859 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| 860 |
|
| 861 |
hds = append(c.xGoogHeaders, hds...) |
| 862 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 863 |
opts = append((*c.CallOptions).ListRelatedAccountGroupMemberships[0:len((*c.CallOptions).ListRelatedAccountGroupMemberships):len((*c.CallOptions).ListRelatedAccountGroupMemberships)], opts...) |
| 864 |
it := &RelatedAccountGroupMembershipIterator{} |
| 865 |
req = proto.Clone(req).(*recaptchaenterprisepb.ListRelatedAccountGroupMembershipsRequest) |
| 866 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*recaptchaenterprisepb.RelatedAccountGroupMembership, string, error) { |
| 867 |
resp := &recaptchaenterprisepb.ListRelatedAccountGroupMembershipsResponse{} |
| 868 |
if pageToken != "" { |
| 869 |
req.PageToken = pageToken |
| 870 |
} |
| 871 |
if pageSize > math.MaxInt32 { |
| 872 |
req.PageSize = math.MaxInt32 |
| 873 |
} else if pageSize != 0 { |
| 874 |
req.PageSize = int32(pageSize) |
| 875 |
} |
| 876 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 877 |
var err error |
| 878 |
resp, err = executeRPC(ctx, c.client.ListRelatedAccountGroupMemberships, req, settings.GRPC, c.logger, "ListRelatedAccountGroupMemberships") |
| 879 |
return err |
| 880 |
}, opts...) |
| 881 |
if err != nil { |
| 882 |
return nil, "", err |
| 883 |
} |
| 884 |
|
| 885 |
it.Response = resp |
| 886 |
return resp.GetRelatedAccountGroupMemberships(), resp.GetNextPageToken(), nil |
| 887 |
} |
| 888 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 889 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 890 |
if err != nil { |
| 891 |
return "", err |
| 892 |
} |
| 893 |
it.items = append(it.items, items...) |
| 894 |
return nextPageToken, nil |
| 895 |
} |
| 896 |
|
| 897 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 898 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 899 |
it.pageInfo.Token = req.GetPageToken() |
| 900 |
|
| 901 |
return it |
| 902 |
} |
| 903 |
|
| 904 |
func (c *gRPCClient) SearchRelatedAccountGroupMemberships(ctx context.Context, req *recaptchaenterprisepb.SearchRelatedAccountGroupMembershipsRequest, opts ...gax.CallOption) *RelatedAccountGroupMembershipIterator { |
| 905 |
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "project", url.QueryEscape(req.GetProject()))} |
| 906 |
|
| 907 |
hds = append(c.xGoogHeaders, hds...) |
| 908 |
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| 909 |
opts = append((*c.CallOptions).SearchRelatedAccountGroupMemberships[0:len((*c.CallOptions).SearchRelatedAccountGroupMemberships):len((*c.CallOptions).SearchRelatedAccountGroupMemberships)], opts...) |
| 910 |
it := &RelatedAccountGroupMembershipIterator{} |
| 911 |
req = proto.Clone(req).(*recaptchaenterprisepb.SearchRelatedAccountGroupMembershipsRequest) |
| 912 |
it.InternalFetch = func(pageSize int, pageToken string) ([]*recaptchaenterprisepb.RelatedAccountGroupMembership, string, error) { |
| 913 |
resp := &recaptchaenterprisepb.SearchRelatedAccountGroupMembershipsResponse{} |
| 914 |
if pageToken != "" { |
| 915 |
req.PageToken = pageToken |
| 916 |
} |
| 917 |
if pageSize > math.MaxInt32 { |
| 918 |
req.PageSize = math.MaxInt32 |
| 919 |
} else if pageSize != 0 { |
| 920 |
req.PageSize = int32(pageSize) |
| 921 |
} |
| 922 |
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| 923 |
var err error |
| 924 |
resp, err = executeRPC(ctx, c.client.SearchRelatedAccountGroupMemberships, req, settings.GRPC, c.logger, "SearchRelatedAccountGroupMemberships") |
| 925 |
return err |
| 926 |
}, opts...) |
| 927 |
if err != nil { |
| 928 |
return nil, "", err |
| 929 |
} |
| 930 |
|
| 931 |
it.Response = resp |
| 932 |
return resp.GetRelatedAccountGroupMemberships(), resp.GetNextPageToken(), nil |
| 933 |
} |
| 934 |
fetch := func(pageSize int, pageToken string) (string, error) { |
| 935 |
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| 936 |
if err != nil { |
| 937 |
return "", err |
| 938 |
} |
| 939 |
it.items = append(it.items, items...) |
| 940 |
return nextPageToken, nil |
| 941 |
} |
| 942 |
|
| 943 |
it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| 944 |
it.pageInfo.MaxSize = int(req.GetPageSize()) |
| 945 |
it.pageInfo.Token = req.GetPageToken() |
| 946 |
|
| 947 |
return it |
| 948 |
} |