diff --git a/packages/google-cloud-recaptchaenterprise/protos/protos.js b/packages/google-cloud-recaptchaenterprise/protos/protos.js index 95df1028294..6ab2d1c40c7 100644 --- a/packages/google-cloud-recaptchaenterprise/protos/protos.js +++ b/packages/google-cloud-recaptchaenterprise/protos/protos.js @@ -397,9 +397,9 @@ CreateAssessmentRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.parent != null && message.hasOwnProperty("parent")) + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); - if (message.assessment != null && message.hasOwnProperty("assessment")) + if (message.assessment != null && Object.hasOwnProperty.call(message, "assessment")) $root.google.cloud.recaptchaenterprise.v1.Assessment.encode(message.assessment, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -612,9 +612,9 @@ AnnotateAssessmentRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.annotation != null && message.hasOwnProperty("annotation")) + if (message.annotation != null && Object.hasOwnProperty.call(message, "annotation")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.annotation); return writer; }; @@ -785,7 +785,7 @@ /** * Annotation enum. * @name google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest.Annotation - * @enum {string} + * @enum {number} * @property {number} ANNOTATION_UNSPECIFIED=0 ANNOTATION_UNSPECIFIED value * @property {number} LEGITIMATE=1 LEGITIMATE value * @property {number} FRAUDULENT=2 FRAUDULENT value @@ -1048,13 +1048,13 @@ Assessment.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.event != null && message.hasOwnProperty("event")) + if (message.event != null && Object.hasOwnProperty.call(message, "event")) $root.google.cloud.recaptchaenterprise.v1.Event.encode(message.event, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.riskAnalysis != null && message.hasOwnProperty("riskAnalysis")) + if (message.riskAnalysis != null && Object.hasOwnProperty.call(message, "riskAnalysis")) $root.google.cloud.recaptchaenterprise.v1.RiskAnalysis.encode(message.riskAnalysis, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.tokenProperties != null && message.hasOwnProperty("tokenProperties")) + if (message.tokenProperties != null && Object.hasOwnProperty.call(message, "tokenProperties")) $root.google.cloud.recaptchaenterprise.v1.TokenProperties.encode(message.tokenProperties, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; @@ -1326,15 +1326,15 @@ Event.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.token != null && message.hasOwnProperty("token")) + if (message.token != null && Object.hasOwnProperty.call(message, "token")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.token); - if (message.siteKey != null && message.hasOwnProperty("siteKey")) + if (message.siteKey != null && Object.hasOwnProperty.call(message, "siteKey")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.siteKey); - if (message.userAgent != null && message.hasOwnProperty("userAgent")) + if (message.userAgent != null && Object.hasOwnProperty.call(message, "userAgent")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.userAgent); - if (message.userIpAddress != null && message.hasOwnProperty("userIpAddress")) + if (message.userIpAddress != null && Object.hasOwnProperty.call(message, "userIpAddress")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.userIpAddress); - if (message.expectedAction != null && message.hasOwnProperty("expectedAction")) + if (message.expectedAction != null && Object.hasOwnProperty.call(message, "expectedAction")) writer.uint32(/* id 5, wireType 2 =*/42).string(message.expectedAction); return writer; }; @@ -1576,7 +1576,7 @@ RiskAnalysis.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.score != null && message.hasOwnProperty("score")) + if (message.score != null && Object.hasOwnProperty.call(message, "score")) writer.uint32(/* id 1, wireType 5 =*/13).float(message.score); if (message.reasons != null && message.reasons.length) { writer.uint32(/* id 2, wireType 2 =*/18).fork(); @@ -1779,7 +1779,7 @@ /** * ClassificationReason enum. * @name google.cloud.recaptchaenterprise.v1.RiskAnalysis.ClassificationReason - * @enum {string} + * @enum {number} * @property {number} CLASSIFICATION_REASON_UNSPECIFIED=0 CLASSIFICATION_REASON_UNSPECIFIED value * @property {number} AUTOMATION=1 AUTOMATION value * @property {number} UNEXPECTED_ENVIRONMENT=2 UNEXPECTED_ENVIRONMENT value @@ -1893,15 +1893,15 @@ TokenProperties.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.valid != null && message.hasOwnProperty("valid")) + if (message.valid != null && Object.hasOwnProperty.call(message, "valid")) writer.uint32(/* id 1, wireType 0 =*/8).bool(message.valid); - if (message.invalidReason != null && message.hasOwnProperty("invalidReason")) + if (message.invalidReason != null && Object.hasOwnProperty.call(message, "invalidReason")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.invalidReason); - if (message.createTime != null && message.hasOwnProperty("createTime")) + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.hostname != null && message.hasOwnProperty("hostname")) + if (message.hostname != null && Object.hasOwnProperty.call(message, "hostname")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.hostname); - if (message.action != null && message.hasOwnProperty("action")) + if (message.action != null && Object.hasOwnProperty.call(message, "action")) writer.uint32(/* id 5, wireType 2 =*/42).string(message.action); return writer; }; @@ -2115,7 +2115,7 @@ /** * InvalidReason enum. * @name google.cloud.recaptchaenterprise.v1.TokenProperties.InvalidReason - * @enum {string} + * @enum {number} * @property {number} INVALID_REASON_UNSPECIFIED=0 INVALID_REASON_UNSPECIFIED value * @property {number} UNKNOWN_INVALID_REASON=1 UNKNOWN_INVALID_REASON value * @property {number} MALFORMED=2 MALFORMED value @@ -2202,9 +2202,9 @@ CreateKeyRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.parent != null && message.hasOwnProperty("parent")) + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); - if (message.key != null && message.hasOwnProperty("key")) + if (message.key != null && Object.hasOwnProperty.call(message, "key")) $root.google.cloud.recaptchaenterprise.v1.Key.encode(message.key, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -2426,11 +2426,11 @@ ListKeysRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.parent != null && message.hasOwnProperty("parent")) + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); - if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); - if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); return writer; }; @@ -2653,7 +2653,7 @@ if (message.keys != null && message.keys.length) for (var i = 0; i < message.keys.length; ++i) $root.google.cloud.recaptchaenterprise.v1.Key.encode(message.keys[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); return writer; }; @@ -2871,7 +2871,7 @@ GetKeyRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); return writer; }; @@ -3067,9 +3067,9 @@ UpdateKeyRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.key != null && message.hasOwnProperty("key")) + if (message.key != null && Object.hasOwnProperty.call(message, "key")) $root.google.cloud.recaptchaenterprise.v1.Key.encode(message.key, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.updateMask != null && message.hasOwnProperty("updateMask")) + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -3278,7 +3278,7 @@ DeleteKeyRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); return writer; }; @@ -3534,20 +3534,20 @@ Key.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.displayName != null && message.hasOwnProperty("displayName")) + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); - if (message.webSettings != null && message.hasOwnProperty("webSettings")) + if (message.webSettings != null && Object.hasOwnProperty.call(message, "webSettings")) $root.google.cloud.recaptchaenterprise.v1.WebKeySettings.encode(message.webSettings, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.androidSettings != null && message.hasOwnProperty("androidSettings")) + if (message.androidSettings != null && Object.hasOwnProperty.call(message, "androidSettings")) $root.google.cloud.recaptchaenterprise.v1.AndroidKeySettings.encode(message.androidSettings, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.iosSettings != null && message.hasOwnProperty("iosSettings")) + if (message.iosSettings != null && Object.hasOwnProperty.call(message, "iosSettings")) $root.google.cloud.recaptchaenterprise.v1.IOSKeySettings.encode(message.iosSettings, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - if (message.labels != null && message.hasOwnProperty("labels")) + if (message.labels != null && Object.hasOwnProperty.call(message, "labels")) for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) writer.uint32(/* id 6, wireType 2 =*/50).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); - if (message.createTime != null && message.hasOwnProperty("createTime")) + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); return writer; }; @@ -3901,13 +3901,13 @@ if (message.allowedDomains != null && message.allowedDomains.length) for (var i = 0; i < message.allowedDomains.length; ++i) writer.uint32(/* id 1, wireType 2 =*/10).string(message.allowedDomains[i]); - if (message.allowAmpTraffic != null && message.hasOwnProperty("allowAmpTraffic")) + if (message.allowAmpTraffic != null && Object.hasOwnProperty.call(message, "allowAmpTraffic")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.allowAmpTraffic); - if (message.allowAllDomains != null && message.hasOwnProperty("allowAllDomains")) + if (message.allowAllDomains != null && Object.hasOwnProperty.call(message, "allowAllDomains")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.allowAllDomains); - if (message.integrationType != null && message.hasOwnProperty("integrationType")) + if (message.integrationType != null && Object.hasOwnProperty.call(message, "integrationType")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.integrationType); - if (message.challengeSecurityPreference != null && message.hasOwnProperty("challengeSecurityPreference")) + if (message.challengeSecurityPreference != null && Object.hasOwnProperty.call(message, "challengeSecurityPreference")) writer.uint32(/* id 5, wireType 0 =*/40).int32(message.challengeSecurityPreference); return writer; }; @@ -4144,7 +4144,7 @@ /** * IntegrationType enum. * @name google.cloud.recaptchaenterprise.v1.WebKeySettings.IntegrationType - * @enum {string} + * @enum {number} * @property {number} INTEGRATION_TYPE_UNSPECIFIED=0 INTEGRATION_TYPE_UNSPECIFIED value * @property {number} SCORE=1 SCORE value * @property {number} CHECKBOX=2 CHECKBOX value @@ -4162,7 +4162,7 @@ /** * ChallengeSecurityPreference enum. * @name google.cloud.recaptchaenterprise.v1.WebKeySettings.ChallengeSecurityPreference - * @enum {string} + * @enum {number} * @property {number} CHALLENGE_SECURITY_PREFERENCE_UNSPECIFIED=0 CHALLENGE_SECURITY_PREFERENCE_UNSPECIFIED value * @property {number} USABILITY=1 USABILITY value * @property {number} BALANCE=2 BALANCE value @@ -4929,9 +4929,9 @@ CreateAssessmentRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.parent != null && message.hasOwnProperty("parent")) + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); - if (message.assessment != null && message.hasOwnProperty("assessment")) + if (message.assessment != null && Object.hasOwnProperty.call(message, "assessment")) $root.google.cloud.recaptchaenterprise.v1beta1.Assessment.encode(message.assessment, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -5144,9 +5144,9 @@ AnnotateAssessmentRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.annotation != null && message.hasOwnProperty("annotation")) + if (message.annotation != null && Object.hasOwnProperty.call(message, "annotation")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.annotation); return writer; }; @@ -5307,7 +5307,7 @@ /** * Annotation enum. * @name google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest.Annotation - * @enum {string} + * @enum {number} * @property {number} ANNOTATION_UNSPECIFIED=0 ANNOTATION_UNSPECIFIED value * @property {number} LEGITIMATE=1 LEGITIMATE value * @property {number} FRAUDULENT=2 FRAUDULENT value @@ -5576,13 +5576,13 @@ Assessment.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.event != null && message.hasOwnProperty("event")) + if (message.event != null && Object.hasOwnProperty.call(message, "event")) $root.google.cloud.recaptchaenterprise.v1beta1.Event.encode(message.event, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.score != null && message.hasOwnProperty("score")) + if (message.score != null && Object.hasOwnProperty.call(message, "score")) writer.uint32(/* id 3, wireType 5 =*/29).float(message.score); - if (message.tokenProperties != null && message.hasOwnProperty("tokenProperties")) + if (message.tokenProperties != null && Object.hasOwnProperty.call(message, "tokenProperties")) $root.google.cloud.recaptchaenterprise.v1beta1.TokenProperties.encode(message.tokenProperties, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.reasons != null && message.reasons.length) { writer.uint32(/* id 5, wireType 2 =*/42).fork(); @@ -5829,7 +5829,7 @@ /** * ClassificationReason enum. * @name google.cloud.recaptchaenterprise.v1beta1.Assessment.ClassificationReason - * @enum {string} + * @enum {number} * @property {number} CLASSIFICATION_REASON_UNSPECIFIED=0 CLASSIFICATION_REASON_UNSPECIFIED value * @property {number} AUTOMATION=1 AUTOMATION value * @property {number} UNEXPECTED_ENVIRONMENT=2 UNEXPECTED_ENVIRONMENT value @@ -5943,15 +5943,15 @@ Event.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.token != null && message.hasOwnProperty("token")) + if (message.token != null && Object.hasOwnProperty.call(message, "token")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.token); - if (message.siteKey != null && message.hasOwnProperty("siteKey")) + if (message.siteKey != null && Object.hasOwnProperty.call(message, "siteKey")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.siteKey); - if (message.userAgent != null && message.hasOwnProperty("userAgent")) + if (message.userAgent != null && Object.hasOwnProperty.call(message, "userAgent")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.userAgent); - if (message.userIpAddress != null && message.hasOwnProperty("userIpAddress")) + if (message.userIpAddress != null && Object.hasOwnProperty.call(message, "userIpAddress")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.userIpAddress); - if (message.expectedAction != null && message.hasOwnProperty("expectedAction")) + if (message.expectedAction != null && Object.hasOwnProperty.call(message, "expectedAction")) writer.uint32(/* id 5, wireType 2 =*/42).string(message.expectedAction); return writer; }; @@ -6219,15 +6219,15 @@ TokenProperties.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.valid != null && message.hasOwnProperty("valid")) + if (message.valid != null && Object.hasOwnProperty.call(message, "valid")) writer.uint32(/* id 1, wireType 0 =*/8).bool(message.valid); - if (message.invalidReason != null && message.hasOwnProperty("invalidReason")) + if (message.invalidReason != null && Object.hasOwnProperty.call(message, "invalidReason")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.invalidReason); - if (message.createTime != null && message.hasOwnProperty("createTime")) + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.hostname != null && message.hasOwnProperty("hostname")) + if (message.hostname != null && Object.hasOwnProperty.call(message, "hostname")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.hostname); - if (message.action != null && message.hasOwnProperty("action")) + if (message.action != null && Object.hasOwnProperty.call(message, "action")) writer.uint32(/* id 5, wireType 2 =*/42).string(message.action); return writer; }; @@ -6446,7 +6446,7 @@ /** * InvalidReason enum. * @name google.cloud.recaptchaenterprise.v1beta1.TokenProperties.InvalidReason - * @enum {string} + * @enum {number} * @property {number} INVALID_REASON_UNSPECIFIED=0 INVALID_REASON_UNSPECIFIED value * @property {number} UNKNOWN_INVALID_REASON=1 UNKNOWN_INVALID_REASON value * @property {number} MALFORMED=2 MALFORMED value @@ -6535,9 +6535,9 @@ CreateKeyRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.parent != null && message.hasOwnProperty("parent")) + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); - if (message.key != null && message.hasOwnProperty("key")) + if (message.key != null && Object.hasOwnProperty.call(message, "key")) $root.google.cloud.recaptchaenterprise.v1beta1.Key.encode(message.key, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -6759,11 +6759,11 @@ ListKeysRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.parent != null && message.hasOwnProperty("parent")) + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); - if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); - if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); return writer; }; @@ -6986,7 +6986,7 @@ if (message.keys != null && message.keys.length) for (var i = 0; i < message.keys.length; ++i) $root.google.cloud.recaptchaenterprise.v1beta1.Key.encode(message.keys[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); return writer; }; @@ -7204,7 +7204,7 @@ GetKeyRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); return writer; }; @@ -7400,9 +7400,9 @@ UpdateKeyRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.key != null && message.hasOwnProperty("key")) + if (message.key != null && Object.hasOwnProperty.call(message, "key")) $root.google.cloud.recaptchaenterprise.v1beta1.Key.encode(message.key, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.updateMask != null && message.hasOwnProperty("updateMask")) + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -7611,7 +7611,7 @@ DeleteKeyRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); return writer; }; @@ -7848,15 +7848,15 @@ Key.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.displayName != null && message.hasOwnProperty("displayName")) + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); - if (message.webSettings != null && message.hasOwnProperty("webSettings")) + if (message.webSettings != null && Object.hasOwnProperty.call(message, "webSettings")) $root.google.cloud.recaptchaenterprise.v1beta1.WebKeySettings.encode(message.webSettings, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.androidSettings != null && message.hasOwnProperty("androidSettings")) + if (message.androidSettings != null && Object.hasOwnProperty.call(message, "androidSettings")) $root.google.cloud.recaptchaenterprise.v1beta1.AndroidKeySettings.encode(message.androidSettings, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.iosSettings != null && message.hasOwnProperty("iosSettings")) + if (message.iosSettings != null && Object.hasOwnProperty.call(message, "iosSettings")) $root.google.cloud.recaptchaenterprise.v1beta1.IOSKeySettings.encode(message.iosSettings, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -8163,13 +8163,13 @@ if (message.allowedDomains != null && message.allowedDomains.length) for (var i = 0; i < message.allowedDomains.length; ++i) writer.uint32(/* id 1, wireType 2 =*/10).string(message.allowedDomains[i]); - if (message.allowAmpTraffic != null && message.hasOwnProperty("allowAmpTraffic")) + if (message.allowAmpTraffic != null && Object.hasOwnProperty.call(message, "allowAmpTraffic")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.allowAmpTraffic); - if (message.enforceAllowedDomains != null && message.hasOwnProperty("enforceAllowedDomains")) + if (message.enforceAllowedDomains != null && Object.hasOwnProperty.call(message, "enforceAllowedDomains")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.enforceAllowedDomains); - if (message.integrationType != null && message.hasOwnProperty("integrationType")) + if (message.integrationType != null && Object.hasOwnProperty.call(message, "integrationType")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.integrationType); - if (message.challengeSecurityPreference != null && message.hasOwnProperty("challengeSecurityPreference")) + if (message.challengeSecurityPreference != null && Object.hasOwnProperty.call(message, "challengeSecurityPreference")) writer.uint32(/* id 5, wireType 0 =*/40).int32(message.challengeSecurityPreference); return writer; }; @@ -8406,7 +8406,7 @@ /** * IntegrationType enum. * @name google.cloud.recaptchaenterprise.v1beta1.WebKeySettings.IntegrationType - * @enum {string} + * @enum {number} * @property {number} INTEGRATION_TYPE_UNSPECIFIED=0 INTEGRATION_TYPE_UNSPECIFIED value * @property {number} SCORE_ONLY=1 SCORE_ONLY value * @property {number} CHECKBOX_CHALLENGE=2 CHECKBOX_CHALLENGE value @@ -8424,7 +8424,7 @@ /** * ChallengeSecurityPreference enum. * @name google.cloud.recaptchaenterprise.v1beta1.WebKeySettings.ChallengeSecurityPreference - * @enum {string} + * @enum {number} * @property {number} CHALLENGE_SECURITY_PREFERENCE_UNSPECIFIED=0 CHALLENGE_SECURITY_PREFERENCE_UNSPECIFIED value * @property {number} USABILITY=1 USABILITY value * @property {number} BALANCED=2 BALANCED value @@ -8935,7 +8935,7 @@ if (message.rules != null && message.rules.length) for (var i = 0; i < message.rules.length; ++i) $root.google.api.HttpRule.encode(message.rules[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.fullyDecodeReservedExpansion != null && message.hasOwnProperty("fullyDecodeReservedExpansion")) + if (message.fullyDecodeReservedExpansion != null && Object.hasOwnProperty.call(message, "fullyDecodeReservedExpansion")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.fullyDecodeReservedExpansion); return writer; }; @@ -9249,26 +9249,26 @@ HttpRule.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.selector != null && message.hasOwnProperty("selector")) + if (message.selector != null && Object.hasOwnProperty.call(message, "selector")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.selector); - if (message.get != null && message.hasOwnProperty("get")) + if (message.get != null && Object.hasOwnProperty.call(message, "get")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.get); - if (message.put != null && message.hasOwnProperty("put")) + if (message.put != null && Object.hasOwnProperty.call(message, "put")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.put); - if (message.post != null && message.hasOwnProperty("post")) + if (message.post != null && Object.hasOwnProperty.call(message, "post")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.post); - if (message["delete"] != null && message.hasOwnProperty("delete")) + if (message["delete"] != null && Object.hasOwnProperty.call(message, "delete")) writer.uint32(/* id 5, wireType 2 =*/42).string(message["delete"]); - if (message.patch != null && message.hasOwnProperty("patch")) + if (message.patch != null && Object.hasOwnProperty.call(message, "patch")) writer.uint32(/* id 6, wireType 2 =*/50).string(message.patch); - if (message.body != null && message.hasOwnProperty("body")) + if (message.body != null && Object.hasOwnProperty.call(message, "body")) writer.uint32(/* id 7, wireType 2 =*/58).string(message.body); - if (message.custom != null && message.hasOwnProperty("custom")) + if (message.custom != null && Object.hasOwnProperty.call(message, "custom")) $root.google.api.CustomHttpPattern.encode(message.custom, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); if (message.additionalBindings != null && message.additionalBindings.length) for (var i = 0; i < message.additionalBindings.length; ++i) $root.google.api.HttpRule.encode(message.additionalBindings[i], writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); - if (message.responseBody != null && message.hasOwnProperty("responseBody")) + if (message.responseBody != null && Object.hasOwnProperty.call(message, "responseBody")) writer.uint32(/* id 12, wireType 2 =*/98).string(message.responseBody); return writer; }; @@ -9625,9 +9625,9 @@ CustomHttpPattern.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.kind != null && message.hasOwnProperty("kind")) + if (message.kind != null && Object.hasOwnProperty.call(message, "kind")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.kind); - if (message.path != null && message.hasOwnProperty("path")) + if (message.path != null && Object.hasOwnProperty.call(message, "path")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.path); return writer; }; @@ -9773,7 +9773,7 @@ /** * FieldBehavior enum. * @name google.api.FieldBehavior - * @enum {string} + * @enum {number} * @property {number} FIELD_BEHAVIOR_UNSPECIFIED=0 FIELD_BEHAVIOR_UNSPECIFIED value * @property {number} OPTIONAL=1 OPTIONAL value * @property {number} REQUIRED=2 REQUIRED value @@ -9894,18 +9894,18 @@ ResourceDescriptor.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.type != null && message.hasOwnProperty("type")) + if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.type); if (message.pattern != null && message.pattern.length) for (var i = 0; i < message.pattern.length; ++i) writer.uint32(/* id 2, wireType 2 =*/18).string(message.pattern[i]); - if (message.nameField != null && message.hasOwnProperty("nameField")) + if (message.nameField != null && Object.hasOwnProperty.call(message, "nameField")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.nameField); - if (message.history != null && message.hasOwnProperty("history")) + if (message.history != null && Object.hasOwnProperty.call(message, "history")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.history); - if (message.plural != null && message.hasOwnProperty("plural")) + if (message.plural != null && Object.hasOwnProperty.call(message, "plural")) writer.uint32(/* id 5, wireType 2 =*/42).string(message.plural); - if (message.singular != null && message.hasOwnProperty("singular")) + if (message.singular != null && Object.hasOwnProperty.call(message, "singular")) writer.uint32(/* id 6, wireType 2 =*/50).string(message.singular); return writer; }; @@ -10125,7 +10125,7 @@ /** * History enum. * @name google.api.ResourceDescriptor.History - * @enum {string} + * @enum {number} * @property {number} HISTORY_UNSPECIFIED=0 HISTORY_UNSPECIFIED value * @property {number} ORIGINALLY_SINGLE_PATTERN=1 ORIGINALLY_SINGLE_PATTERN value * @property {number} FUTURE_MULTI_PATTERN=2 FUTURE_MULTI_PATTERN value @@ -10206,9 +10206,9 @@ ResourceReference.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.type != null && message.hasOwnProperty("type")) + if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.type); - if (message.childType != null && message.hasOwnProperty("childType")) + if (message.childType != null && Object.hasOwnProperty.call(message, "childType")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.childType); return writer; }; @@ -10733,9 +10733,9 @@ FileDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message["package"] != null && message.hasOwnProperty("package")) + if (message["package"] != null && Object.hasOwnProperty.call(message, "package")) writer.uint32(/* id 2, wireType 2 =*/18).string(message["package"]); if (message.dependency != null && message.dependency.length) for (var i = 0; i < message.dependency.length; ++i) @@ -10752,9 +10752,9 @@ if (message.extension != null && message.extension.length) for (var i = 0; i < message.extension.length; ++i) $root.google.protobuf.FieldDescriptorProto.encode(message.extension[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.FileOptions.encode(message.options, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); - if (message.sourceCodeInfo != null && message.hasOwnProperty("sourceCodeInfo")) + if (message.sourceCodeInfo != null && Object.hasOwnProperty.call(message, "sourceCodeInfo")) $root.google.protobuf.SourceCodeInfo.encode(message.sourceCodeInfo, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); if (message.publicDependency != null && message.publicDependency.length) for (var i = 0; i < message.publicDependency.length; ++i) @@ -10762,7 +10762,7 @@ if (message.weakDependency != null && message.weakDependency.length) for (var i = 0; i < message.weakDependency.length; ++i) writer.uint32(/* id 11, wireType 0 =*/88).int32(message.weakDependency[i]); - if (message.syntax != null && message.hasOwnProperty("syntax")) + if (message.syntax != null && Object.hasOwnProperty.call(message, "syntax")) writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); return writer; }; @@ -11300,7 +11300,7 @@ DescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); if (message.field != null && message.field.length) for (var i = 0; i < message.field.length; ++i) @@ -11317,7 +11317,7 @@ if (message.extension != null && message.extension.length) for (var i = 0; i < message.extension.length; ++i) $root.google.protobuf.FieldDescriptorProto.encode(message.extension[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.MessageOptions.encode(message.options, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); if (message.oneofDecl != null && message.oneofDecl.length) for (var i = 0; i < message.oneofDecl.length; ++i) @@ -11782,11 +11782,11 @@ ExtensionRange.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.start != null && message.hasOwnProperty("start")) + if (message.start != null && Object.hasOwnProperty.call(message, "start")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); - if (message.end != null && message.hasOwnProperty("end")) + if (message.end != null && Object.hasOwnProperty.call(message, "end")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.ExtensionRangeOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -12010,9 +12010,9 @@ ReservedRange.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.start != null && message.hasOwnProperty("start")) + if (message.start != null && Object.hasOwnProperty.call(message, "start")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); - if (message.end != null && message.hasOwnProperty("end")) + if (message.end != null && Object.hasOwnProperty.call(message, "end")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); return writer; }; @@ -12503,25 +12503,25 @@ FieldDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.extendee != null && message.hasOwnProperty("extendee")) + if (message.extendee != null && Object.hasOwnProperty.call(message, "extendee")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.extendee); - if (message.number != null && message.hasOwnProperty("number")) + if (message.number != null && Object.hasOwnProperty.call(message, "number")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.number); - if (message.label != null && message.hasOwnProperty("label")) + if (message.label != null && Object.hasOwnProperty.call(message, "label")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.label); - if (message.type != null && message.hasOwnProperty("type")) + if (message.type != null && Object.hasOwnProperty.call(message, "type")) writer.uint32(/* id 5, wireType 0 =*/40).int32(message.type); - if (message.typeName != null && message.hasOwnProperty("typeName")) + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) writer.uint32(/* id 6, wireType 2 =*/50).string(message.typeName); - if (message.defaultValue != null && message.hasOwnProperty("defaultValue")) + if (message.defaultValue != null && Object.hasOwnProperty.call(message, "defaultValue")) writer.uint32(/* id 7, wireType 2 =*/58).string(message.defaultValue); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.FieldOptions.encode(message.options, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); - if (message.oneofIndex != null && message.hasOwnProperty("oneofIndex")) + if (message.oneofIndex != null && Object.hasOwnProperty.call(message, "oneofIndex")) writer.uint32(/* id 9, wireType 0 =*/72).int32(message.oneofIndex); - if (message.jsonName != null && message.hasOwnProperty("jsonName")) + if (message.jsonName != null && Object.hasOwnProperty.call(message, "jsonName")) writer.uint32(/* id 10, wireType 2 =*/82).string(message.jsonName); return writer; }; @@ -12868,7 +12868,7 @@ /** * Type enum. * @name google.protobuf.FieldDescriptorProto.Type - * @enum {string} + * @enum {number} * @property {number} TYPE_DOUBLE=1 TYPE_DOUBLE value * @property {number} TYPE_FLOAT=2 TYPE_FLOAT value * @property {number} TYPE_INT64=3 TYPE_INT64 value @@ -12914,7 +12914,7 @@ /** * Label enum. * @name google.protobuf.FieldDescriptorProto.Label - * @enum {string} + * @enum {number} * @property {number} LABEL_OPTIONAL=1 LABEL_OPTIONAL value * @property {number} LABEL_REQUIRED=2 LABEL_REQUIRED value * @property {number} LABEL_REPEATED=3 LABEL_REPEATED value @@ -12995,9 +12995,9 @@ OneofDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.OneofOptions.encode(message.options, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -13240,12 +13240,12 @@ EnumDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); if (message.value != null && message.value.length) for (var i = 0; i < message.value.length; ++i) $root.google.protobuf.EnumValueDescriptorProto.encode(message.value[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.EnumOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.reservedRange != null && message.reservedRange.length) for (var i = 0; i < message.reservedRange.length; ++i) @@ -13548,9 +13548,9 @@ EnumReservedRange.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.start != null && message.hasOwnProperty("start")) + if (message.start != null && Object.hasOwnProperty.call(message, "start")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); - if (message.end != null && message.hasOwnProperty("end")) + if (message.end != null && Object.hasOwnProperty.call(message, "end")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); return writer; }; @@ -13770,11 +13770,11 @@ EnumValueDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.number != null && message.hasOwnProperty("number")) + if (message.number != null && Object.hasOwnProperty.call(message, "number")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.number); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.EnumValueOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -14008,12 +14008,12 @@ ServiceDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); if (message.method != null && message.method.length) for (var i = 0; i < message.method.length; ++i) $root.google.protobuf.MethodDescriptorProto.encode(message.method[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.ServiceOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -14293,17 +14293,17 @@ MethodDescriptorProto.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && message.hasOwnProperty("name")) + if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.inputType != null && message.hasOwnProperty("inputType")) + if (message.inputType != null && Object.hasOwnProperty.call(message, "inputType")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.inputType); - if (message.outputType != null && message.hasOwnProperty("outputType")) + if (message.outputType != null && Object.hasOwnProperty.call(message, "outputType")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.outputType); - if (message.options != null && message.hasOwnProperty("options")) + if (message.options != null && Object.hasOwnProperty.call(message, "options")) $root.google.protobuf.MethodOptions.encode(message.options, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.clientStreaming != null && message.hasOwnProperty("clientStreaming")) + if (message.clientStreaming != null && Object.hasOwnProperty.call(message, "clientStreaming")) writer.uint32(/* id 5, wireType 0 =*/40).bool(message.clientStreaming); - if (message.serverStreaming != null && message.hasOwnProperty("serverStreaming")) + if (message.serverStreaming != null && Object.hasOwnProperty.call(message, "serverStreaming")) writer.uint32(/* id 6, wireType 0 =*/48).bool(message.serverStreaming); return writer; }; @@ -14742,45 +14742,45 @@ FileOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.javaPackage != null && message.hasOwnProperty("javaPackage")) + if (message.javaPackage != null && Object.hasOwnProperty.call(message, "javaPackage")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.javaPackage); - if (message.javaOuterClassname != null && message.hasOwnProperty("javaOuterClassname")) + if (message.javaOuterClassname != null && Object.hasOwnProperty.call(message, "javaOuterClassname")) writer.uint32(/* id 8, wireType 2 =*/66).string(message.javaOuterClassname); - if (message.optimizeFor != null && message.hasOwnProperty("optimizeFor")) + if (message.optimizeFor != null && Object.hasOwnProperty.call(message, "optimizeFor")) writer.uint32(/* id 9, wireType 0 =*/72).int32(message.optimizeFor); - if (message.javaMultipleFiles != null && message.hasOwnProperty("javaMultipleFiles")) + if (message.javaMultipleFiles != null && Object.hasOwnProperty.call(message, "javaMultipleFiles")) writer.uint32(/* id 10, wireType 0 =*/80).bool(message.javaMultipleFiles); - if (message.goPackage != null && message.hasOwnProperty("goPackage")) + if (message.goPackage != null && Object.hasOwnProperty.call(message, "goPackage")) writer.uint32(/* id 11, wireType 2 =*/90).string(message.goPackage); - if (message.ccGenericServices != null && message.hasOwnProperty("ccGenericServices")) + if (message.ccGenericServices != null && Object.hasOwnProperty.call(message, "ccGenericServices")) writer.uint32(/* id 16, wireType 0 =*/128).bool(message.ccGenericServices); - if (message.javaGenericServices != null && message.hasOwnProperty("javaGenericServices")) + if (message.javaGenericServices != null && Object.hasOwnProperty.call(message, "javaGenericServices")) writer.uint32(/* id 17, wireType 0 =*/136).bool(message.javaGenericServices); - if (message.pyGenericServices != null && message.hasOwnProperty("pyGenericServices")) + if (message.pyGenericServices != null && Object.hasOwnProperty.call(message, "pyGenericServices")) writer.uint32(/* id 18, wireType 0 =*/144).bool(message.pyGenericServices); - if (message.javaGenerateEqualsAndHash != null && message.hasOwnProperty("javaGenerateEqualsAndHash")) + if (message.javaGenerateEqualsAndHash != null && Object.hasOwnProperty.call(message, "javaGenerateEqualsAndHash")) writer.uint32(/* id 20, wireType 0 =*/160).bool(message.javaGenerateEqualsAndHash); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 23, wireType 0 =*/184).bool(message.deprecated); - if (message.javaStringCheckUtf8 != null && message.hasOwnProperty("javaStringCheckUtf8")) + if (message.javaStringCheckUtf8 != null && Object.hasOwnProperty.call(message, "javaStringCheckUtf8")) writer.uint32(/* id 27, wireType 0 =*/216).bool(message.javaStringCheckUtf8); - if (message.ccEnableArenas != null && message.hasOwnProperty("ccEnableArenas")) + if (message.ccEnableArenas != null && Object.hasOwnProperty.call(message, "ccEnableArenas")) writer.uint32(/* id 31, wireType 0 =*/248).bool(message.ccEnableArenas); - if (message.objcClassPrefix != null && message.hasOwnProperty("objcClassPrefix")) + if (message.objcClassPrefix != null && Object.hasOwnProperty.call(message, "objcClassPrefix")) writer.uint32(/* id 36, wireType 2 =*/290).string(message.objcClassPrefix); - if (message.csharpNamespace != null && message.hasOwnProperty("csharpNamespace")) + if (message.csharpNamespace != null && Object.hasOwnProperty.call(message, "csharpNamespace")) writer.uint32(/* id 37, wireType 2 =*/298).string(message.csharpNamespace); - if (message.swiftPrefix != null && message.hasOwnProperty("swiftPrefix")) + if (message.swiftPrefix != null && Object.hasOwnProperty.call(message, "swiftPrefix")) writer.uint32(/* id 39, wireType 2 =*/314).string(message.swiftPrefix); - if (message.phpClassPrefix != null && message.hasOwnProperty("phpClassPrefix")) + if (message.phpClassPrefix != null && Object.hasOwnProperty.call(message, "phpClassPrefix")) writer.uint32(/* id 40, wireType 2 =*/322).string(message.phpClassPrefix); - if (message.phpNamespace != null && message.hasOwnProperty("phpNamespace")) + if (message.phpNamespace != null && Object.hasOwnProperty.call(message, "phpNamespace")) writer.uint32(/* id 41, wireType 2 =*/330).string(message.phpNamespace); - if (message.phpGenericServices != null && message.hasOwnProperty("phpGenericServices")) + if (message.phpGenericServices != null && Object.hasOwnProperty.call(message, "phpGenericServices")) writer.uint32(/* id 42, wireType 0 =*/336).bool(message.phpGenericServices); - if (message.phpMetadataNamespace != null && message.hasOwnProperty("phpMetadataNamespace")) + if (message.phpMetadataNamespace != null && Object.hasOwnProperty.call(message, "phpMetadataNamespace")) writer.uint32(/* id 44, wireType 2 =*/354).string(message.phpMetadataNamespace); - if (message.rubyPackage != null && message.hasOwnProperty("rubyPackage")) + if (message.rubyPackage != null && Object.hasOwnProperty.call(message, "rubyPackage")) writer.uint32(/* id 45, wireType 2 =*/362).string(message.rubyPackage); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -15207,7 +15207,7 @@ /** * OptimizeMode enum. * @name google.protobuf.FileOptions.OptimizeMode - * @enum {string} + * @enum {number} * @property {number} SPEED=1 SPEED value * @property {number} CODE_SIZE=2 CODE_SIZE value * @property {number} LITE_RUNTIME=3 LITE_RUNTIME value @@ -15325,18 +15325,18 @@ MessageOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.messageSetWireFormat != null && message.hasOwnProperty("messageSetWireFormat")) + if (message.messageSetWireFormat != null && Object.hasOwnProperty.call(message, "messageSetWireFormat")) writer.uint32(/* id 1, wireType 0 =*/8).bool(message.messageSetWireFormat); - if (message.noStandardDescriptorAccessor != null && message.hasOwnProperty("noStandardDescriptorAccessor")) + if (message.noStandardDescriptorAccessor != null && Object.hasOwnProperty.call(message, "noStandardDescriptorAccessor")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.noStandardDescriptorAccessor); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); - if (message.mapEntry != null && message.hasOwnProperty("mapEntry")) + if (message.mapEntry != null && Object.hasOwnProperty.call(message, "mapEntry")) writer.uint32(/* id 7, wireType 0 =*/56).bool(message.mapEntry); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); - if (message[".google.api.resource"] != null && message.hasOwnProperty(".google.api.resource")) + if (message[".google.api.resource"] != null && Object.hasOwnProperty.call(message, ".google.api.resource")) $root.google.api.ResourceDescriptor.encode(message[".google.api.resource"], writer.uint32(/* id 1053, wireType 2 =*/8426).fork()).ldelim(); return writer; }; @@ -15678,17 +15678,17 @@ FieldOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.ctype != null && message.hasOwnProperty("ctype")) + if (message.ctype != null && Object.hasOwnProperty.call(message, "ctype")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.ctype); - if (message.packed != null && message.hasOwnProperty("packed")) + if (message.packed != null && Object.hasOwnProperty.call(message, "packed")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.packed); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); - if (message.lazy != null && message.hasOwnProperty("lazy")) + if (message.lazy != null && Object.hasOwnProperty.call(message, "lazy")) writer.uint32(/* id 5, wireType 0 =*/40).bool(message.lazy); - if (message.jstype != null && message.hasOwnProperty("jstype")) + if (message.jstype != null && Object.hasOwnProperty.call(message, "jstype")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jstype); - if (message.weak != null && message.hasOwnProperty("weak")) + if (message.weak != null && Object.hasOwnProperty.call(message, "weak")) writer.uint32(/* id 10, wireType 0 =*/80).bool(message.weak); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -15699,7 +15699,7 @@ writer.int32(message[".google.api.fieldBehavior"][i]); writer.ldelim(); } - if (message[".google.api.resourceReference"] != null && message.hasOwnProperty(".google.api.resourceReference")) + if (message[".google.api.resourceReference"] != null && Object.hasOwnProperty.call(message, ".google.api.resourceReference")) $root.google.api.ResourceReference.encode(message[".google.api.resourceReference"], writer.uint32(/* id 1055, wireType 2 =*/8442).fork()).ldelim(); return writer; }; @@ -16035,7 +16035,7 @@ /** * CType enum. * @name google.protobuf.FieldOptions.CType - * @enum {string} + * @enum {number} * @property {number} STRING=0 STRING value * @property {number} CORD=1 CORD value * @property {number} STRING_PIECE=2 STRING_PIECE value @@ -16051,7 +16051,7 @@ /** * JSType enum. * @name google.protobuf.FieldOptions.JSType - * @enum {string} + * @enum {number} * @property {number} JS_NORMAL=0 JS_NORMAL value * @property {number} JS_STRING=1 JS_STRING value * @property {number} JS_NUMBER=2 JS_NUMBER value @@ -16350,9 +16350,9 @@ EnumOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.allowAlias != null && message.hasOwnProperty("allowAlias")) + if (message.allowAlias != null && Object.hasOwnProperty.call(message, "allowAlias")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.allowAlias); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -16595,7 +16595,7 @@ EnumValueOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 1, wireType 0 =*/8).bool(message.deprecated); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -16844,14 +16844,14 @@ ServiceOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 33, wireType 0 =*/264).bool(message.deprecated); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); - if (message[".google.api.defaultHost"] != null && message.hasOwnProperty(".google.api.defaultHost")) + if (message[".google.api.defaultHost"] != null && Object.hasOwnProperty.call(message, ".google.api.defaultHost")) writer.uint32(/* id 1049, wireType 2 =*/8394).string(message[".google.api.defaultHost"]); - if (message[".google.api.oauthScopes"] != null && message.hasOwnProperty(".google.api.oauthScopes")) + if (message[".google.api.oauthScopes"] != null && Object.hasOwnProperty.call(message, ".google.api.oauthScopes")) writer.uint32(/* id 1050, wireType 2 =*/8402).string(message[".google.api.oauthScopes"]); return writer; }; @@ -17130,9 +17130,9 @@ MethodOptions.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) writer.uint32(/* id 33, wireType 0 =*/264).bool(message.deprecated); - if (message.idempotencyLevel != null && message.hasOwnProperty("idempotencyLevel")) + if (message.idempotencyLevel != null && Object.hasOwnProperty.call(message, "idempotencyLevel")) writer.uint32(/* id 34, wireType 0 =*/272).int32(message.idempotencyLevel); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) @@ -17140,7 +17140,7 @@ if (message[".google.api.methodSignature"] != null && message[".google.api.methodSignature"].length) for (var i = 0; i < message[".google.api.methodSignature"].length; ++i) writer.uint32(/* id 1051, wireType 2 =*/8410).string(message[".google.api.methodSignature"][i]); - if (message[".google.api.http"] != null && message.hasOwnProperty(".google.api.http")) + if (message[".google.api.http"] != null && Object.hasOwnProperty.call(message, ".google.api.http")) $root.google.api.HttpRule.encode(message[".google.api.http"], writer.uint32(/* id 72295728, wireType 2 =*/578365826).fork()).ldelim(); return writer; }; @@ -17374,7 +17374,7 @@ /** * IdempotencyLevel enum. * @name google.protobuf.MethodOptions.IdempotencyLevel - * @enum {string} + * @enum {number} * @property {number} IDEMPOTENCY_UNKNOWN=0 IDEMPOTENCY_UNKNOWN value * @property {number} NO_SIDE_EFFECTS=1 NO_SIDE_EFFECTS value * @property {number} IDEMPOTENT=2 IDEMPOTENT value @@ -17504,17 +17504,17 @@ if (message.name != null && message.name.length) for (var i = 0; i < message.name.length; ++i) $root.google.protobuf.UninterpretedOption.NamePart.encode(message.name[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.identifierValue != null && message.hasOwnProperty("identifierValue")) + if (message.identifierValue != null && Object.hasOwnProperty.call(message, "identifierValue")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.identifierValue); - if (message.positiveIntValue != null && message.hasOwnProperty("positiveIntValue")) + if (message.positiveIntValue != null && Object.hasOwnProperty.call(message, "positiveIntValue")) writer.uint32(/* id 4, wireType 0 =*/32).uint64(message.positiveIntValue); - if (message.negativeIntValue != null && message.hasOwnProperty("negativeIntValue")) + if (message.negativeIntValue != null && Object.hasOwnProperty.call(message, "negativeIntValue")) writer.uint32(/* id 5, wireType 0 =*/40).int64(message.negativeIntValue); - if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) + if (message.doubleValue != null && Object.hasOwnProperty.call(message, "doubleValue")) writer.uint32(/* id 6, wireType 1 =*/49).double(message.doubleValue); - if (message.stringValue != null && message.hasOwnProperty("stringValue")) + if (message.stringValue != null && Object.hasOwnProperty.call(message, "stringValue")) writer.uint32(/* id 7, wireType 2 =*/58).bytes(message.stringValue); - if (message.aggregateValue != null && message.hasOwnProperty("aggregateValue")) + if (message.aggregateValue != null && Object.hasOwnProperty.call(message, "aggregateValue")) writer.uint32(/* id 8, wireType 2 =*/66).string(message.aggregateValue); return writer; }; @@ -18291,9 +18291,9 @@ writer.int32(message.span[i]); writer.ldelim(); } - if (message.leadingComments != null && message.hasOwnProperty("leadingComments")) + if (message.leadingComments != null && Object.hasOwnProperty.call(message, "leadingComments")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.leadingComments); - if (message.trailingComments != null && message.hasOwnProperty("trailingComments")) + if (message.trailingComments != null && Object.hasOwnProperty.call(message, "trailingComments")) writer.uint32(/* id 4, wireType 2 =*/34).string(message.trailingComments); if (message.leadingDetachedComments != null && message.leadingDetachedComments.length) for (var i = 0; i < message.leadingDetachedComments.length; ++i) @@ -18824,11 +18824,11 @@ writer.int32(message.path[i]); writer.ldelim(); } - if (message.sourceFile != null && message.hasOwnProperty("sourceFile")) + if (message.sourceFile != null && Object.hasOwnProperty.call(message, "sourceFile")) writer.uint32(/* id 2, wireType 2 =*/18).string(message.sourceFile); - if (message.begin != null && message.hasOwnProperty("begin")) + if (message.begin != null && Object.hasOwnProperty.call(message, "begin")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.begin); - if (message.end != null && message.hasOwnProperty("end")) + if (message.end != null && Object.hasOwnProperty.call(message, "end")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.end); return writer; }; @@ -19444,9 +19444,9 @@ Timestamp.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.seconds != null && message.hasOwnProperty("seconds")) + if (message.seconds != null && Object.hasOwnProperty.call(message, "seconds")) writer.uint32(/* id 1, wireType 0 =*/8).int64(message.seconds); - if (message.nanos != null && message.hasOwnProperty("nanos")) + if (message.nanos != null && Object.hasOwnProperty.call(message, "nanos")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.nanos); return writer; }; diff --git a/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts b/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts index e4f4b087195..57d53669357 100644 --- a/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts +++ b/packages/google-cloud-recaptchaenterprise/src/v1/recaptcha_enterprise_service_client.ts @@ -17,11 +17,18 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; import * as path from 'path'; -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; +import {Transform} from 'stream'; +import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './recaptcha_enterprise_service_client_config.json'; @@ -40,7 +47,12 @@ export class RecaptchaEnterpriseServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; recaptchaEnterpriseServiceStub?: Promise<{[name: string]: Function}>; @@ -73,11 +85,14 @@ export class RecaptchaEnterpriseServiceClient { constructor(opts?: ClientOptions) { // Ensure that options include the service address and port. - const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceClient; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); + const staticMembers = this + .constructor as typeof RecaptchaEnterpriseServiceClient; + const servicePath = + opts && opts.servicePath + ? opts.servicePath + : opts && opts.apiEndpoint + ? opts.apiEndpoint + : staticMembers.servicePath; const port = opts && opts.port ? opts.port : staticMembers.port; if (!opts) { @@ -87,8 +102,8 @@ export class RecaptchaEnterpriseServiceClient { opts.port = opts.port || port; opts.clientConfig = opts.clientConfig || {}; - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ + const isBrowser = typeof window !== 'undefined'; + if (isBrowser) { opts.fallback = true; } // If we are in browser, we are already using fallback because of the @@ -98,20 +113,18 @@ export class RecaptchaEnterpriseServiceClient { // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. - opts.scopes = (this.constructor as typeof RecaptchaEnterpriseServiceClient).scopes; + opts.scopes = (this + .constructor as typeof RecaptchaEnterpriseServiceClient).scopes; this._gaxGrpc = new this._gaxModule.GrpcClient(opts); // Save options to use in initialize() method. this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -127,12 +140,18 @@ export class RecaptchaEnterpriseServiceClient { // For Node.js, pass the path to JSON proto file. // For browsers, pass the JSON content. - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? - // eslint-disable-next-line @typescript-eslint/no-var-requires - require("../../protos/protos.json") : - nodejsProtoPath + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + require('../../protos/protos.json') + : nodejsProtoPath ); // This API contains "path templates"; forward-slash-separated @@ -154,14 +173,20 @@ export class RecaptchaEnterpriseServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listKeys: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keys') + listKeys: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'keys' + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -189,16 +214,27 @@ export class RecaptchaEnterpriseServiceClient { // Put together the "service stub" for // google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService. this.recaptchaEnterpriseServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService, - this._opts) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.recaptchaenterprise.v1 + .RecaptchaEnterpriseService, + this._opts + ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const recaptchaEnterpriseServiceStubMethods = - ['createAssessment', 'annotateAssessment', 'createKey', 'listKeys', 'getKey', 'updateKey', 'deleteKey']; + const recaptchaEnterpriseServiceStubMethods = [ + 'createAssessment', + 'annotateAssessment', + 'createKey', + 'listKeys', + 'getKey', + 'updateKey', + 'deleteKey', + ]; for (const methodName of recaptchaEnterpriseServiceStubMethods) { const callPromise = this.recaptchaEnterpriseServiceStub.then( stub => (...args: Array<{}>) => { @@ -208,16 +244,17 @@ export class RecaptchaEnterpriseServiceClient { const func = stub[methodName]; return func.apply(stub, args); }, - (err: Error|null|undefined) => () => { + (err: Error | null | undefined) => () => { throw err; - }); + } + ); const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); this.innerApiCalls[methodName] = apiCall; @@ -253,9 +290,7 @@ export class RecaptchaEnterpriseServiceClient { * in this service. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -265,8 +300,9 @@ export class RecaptchaEnterpriseServiceClient { * @param {function(Error, string)} callback - the callback to * be called with the current project Id. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -278,62 +314,89 @@ export class RecaptchaEnterpriseServiceClient { // -- Service calls -- // ------------------- createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + ( + | protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest + | undefined + ), + {} | undefined + ] + >; createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + | protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): void; createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates an Assessment of the likelihood an event is legitimate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project}". - * @param {google.cloud.recaptchaenterprise.v1.Assessment} request.assessment - * Required. The assessment details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Assessment]{@link google.cloud.recaptchaenterprise.v1.Assessment}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + | protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Creates an Assessment of the likelihood an event is legitimate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the assessment will be created, + * in the format "projects/{project}". + * @param {google.cloud.recaptchaenterprise.v1.Assessment} request.assessment + * Required. The assessment details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Assessment]{@link google.cloud.recaptchaenterprise.v1.Assessment}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + | protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IAssessment, + ( + | protos.google.cloud.recaptchaenterprise.v1.ICreateAssessmentRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -342,69 +405,96 @@ export class RecaptchaEnterpriseServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); this.initialize(); return this.innerApiCalls.createAssessment(request, options, callback); } annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + ( + | protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest + | undefined + ), + {} | undefined + ] + >; annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + | protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): void; annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): void; -/** - * Annotates a previously created Assessment to provide additional information - * on whether the event turned out to be authentic or fradulent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Assessment, in the format - * "projects/{project}/assessments/{assessment}". - * @param {google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest.Annotation} request.annotation - * Required. The annotation that will be assigned to the Event. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnnotateAssessmentResponse]{@link google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + | protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Annotates a previously created Assessment to provide additional information + * on whether the event turned out to be authentic or fradulent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Assessment, in the format + * "projects/{project}/assessments/{assessment}". + * @param {google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest.Annotation} request.annotation + * Required. The annotation that will be assigned to the Event. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnnotateAssessmentResponse]{@link google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + | protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse, + ( + | protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -413,68 +503,89 @@ export class RecaptchaEnterpriseServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.annotateAssessment(request, options, callback); } createKey( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest | undefined, + {} | undefined + ] + >; createKey( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + | protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; createKey( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new reCAPTCHA Enterprise key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the key will be created, in the - * format "projects/{project}". - * @param {google.cloud.recaptchaenterprise.v1.Key} request.key - * Required. Information to create a reCAPTCHA Enterprise key. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + | protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Creates a new reCAPTCHA Enterprise key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the key will be created, in the + * format "projects/{project}". + * @param {google.cloud.recaptchaenterprise.v1.Key} request.key + * Required. Information to create a reCAPTCHA Enterprise key. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ createKey( - request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + | protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.ICreateKeyRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -483,66 +594,87 @@ export class RecaptchaEnterpriseServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); this.initialize(); return this.innerApiCalls.createKey(request, options, callback); } getKey( - request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest | undefined, + {} | undefined + ] + >; getKey( - request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + | protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; getKey( - request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Returns the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the requested key, in the format - * "projects/{project}/keys/{key}". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + | protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Returns the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the requested key, in the format + * "projects/{project}/keys/{key}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getKey( - request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + | protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IGetKeyRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -551,68 +683,89 @@ export class RecaptchaEnterpriseServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.getKey(request, options, callback); } updateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest | undefined, + {} | undefined + ] + >; updateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + | protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; updateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Updates the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.recaptchaenterprise.v1.Key} request.key - * Required. The key to update. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. The mask to control which field of the key get updated. If the mask is not - * present, all fields will be updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + | protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Updates the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.recaptchaenterprise.v1.Key} request.key + * Required. The key to update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. The mask to control which field of the key get updated. If the mask is not + * present, all fields will be updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ updateKey( - request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey, - protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1.IKey, + | protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IKey, + protos.google.cloud.recaptchaenterprise.v1.IUpdateKeyRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -627,60 +780,81 @@ export class RecaptchaEnterpriseServiceClient { return this.innerApiCalls.updateKey(request, options, callback); } deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest | undefined, + {} | undefined + ] + >; deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Deletes the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the key to be deleted, in the format - * "projects/{project}/keys/{key}". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Deletes the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the key to be deleted, in the format + * "projects/{project}/keys/{key}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.recaptchaenterprise.v1.IDeleteKeyRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -689,87 +863,106 @@ export class RecaptchaEnterpriseServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.deleteKey(request, options, callback); } listKeys( - request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey[], - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse - ]>; + request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IKey[], + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest | null, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse + ] + >; listKeys( - request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - options: gax.CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>): void; + request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + options: gax.CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + | protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse + | null + | undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey + > + ): void; listKeys( - request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>): void; -/** - * Returns the list of all keys that belong to a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Key]{@link google.cloud.recaptchaenterprise.v1.Key} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListKeysRequest]{@link google.cloud.recaptchaenterprise.v1.ListKeysRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListKeysResponse]{@link google.cloud.recaptchaenterprise.v1.ListKeysResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + | protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse + | null + | undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey + > + ): void; + /** + * Returns the list of all keys that belong to a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Key]{@link google.cloud.recaptchaenterprise.v1.Key}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [Key]{@link google.cloud.recaptchaenterprise.v1.Key} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListKeysRequest]{@link google.cloud.recaptchaenterprise.v1.ListKeysRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListKeysResponse]{@link google.cloud.recaptchaenterprise.v1.ListKeysResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ listKeys( - request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - optionsOrCallback?: gax.CallOptions|PaginationCallback< + request: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + optionsOrCallback?: + | gax.CallOptions + | PaginationCallback< protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>, - callback?: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1.IKey>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1.IKey[], - protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest|null, - protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse + | null + | undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey + >, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + | protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse + | null + | undefined, + protos.google.cloud.recaptchaenterprise.v1.IKey + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1.IKey[], + protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest | null, + protos.google.cloud.recaptchaenterprise.v1.IListKeysResponse + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -778,45 +971,45 @@ export class RecaptchaEnterpriseServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); this.initialize(); return this.innerApiCalls.listKeys(request, options, callback); } -/** - * Equivalent to {@link listKeys}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listKeys} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key} on 'data' event. - */ + /** + * Equivalent to {@link listKeys}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listKeys} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Key]{@link google.cloud.recaptchaenterprise.v1.Key} on 'data' event. + */ listKeysStream( - request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - options?: gax.CallOptions): - Transform{ + request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + options?: gax.CallOptions + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -824,7 +1017,7 @@ export class RecaptchaEnterpriseServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); this.initialize(); @@ -835,31 +1028,31 @@ export class RecaptchaEnterpriseServiceClient { ); } -/** - * Equivalent to {@link listKeys}, but returns an iterable object. - * - * for-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. - */ + /** + * Equivalent to {@link listKeys}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ listKeysAsync( - request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, - options?: gax.CallOptions): - AsyncIterable{ + request?: protos.google.cloud.recaptchaenterprise.v1.IListKeysRequest, + options?: gax.CallOptions + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -867,14 +1060,14 @@ export class RecaptchaEnterpriseServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); options = options || {}; const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listKeys.asyncIterate( this.innerApiCalls['listKeys'] as GaxCall, - request as unknown as RequestType, + (request as unknown) as RequestType, callSettings ) as AsyncIterable; } @@ -889,7 +1082,7 @@ export class RecaptchaEnterpriseServiceClient { * @param {string} assessment * @returns {string} Resource name string. */ - assessmentPath(project:string,assessment:string) { + assessmentPath(project: string, assessment: string) { return this.pathTemplates.assessmentPathTemplate.render({ project: project, assessment: assessment, @@ -904,7 +1097,8 @@ export class RecaptchaEnterpriseServiceClient { * @returns {string} A string representing the project. */ matchProjectFromAssessmentName(assessmentName: string) { - return this.pathTemplates.assessmentPathTemplate.match(assessmentName).project; + return this.pathTemplates.assessmentPathTemplate.match(assessmentName) + .project; } /** @@ -915,7 +1109,8 @@ export class RecaptchaEnterpriseServiceClient { * @returns {string} A string representing the assessment. */ matchAssessmentFromAssessmentName(assessmentName: string) { - return this.pathTemplates.assessmentPathTemplate.match(assessmentName).assessment; + return this.pathTemplates.assessmentPathTemplate.match(assessmentName) + .assessment; } /** @@ -925,7 +1120,7 @@ export class RecaptchaEnterpriseServiceClient { * @param {string} key * @returns {string} Resource name string. */ - keyPath(project:string,key:string) { + keyPath(project: string, key: string) { return this.pathTemplates.keyPathTemplate.render({ project: project, key: key, @@ -960,7 +1155,7 @@ export class RecaptchaEnterpriseServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); diff --git a/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts b/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts index 97f274233d3..fbbfc223310 100644 --- a/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts +++ b/packages/google-cloud-recaptchaenterprise/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts @@ -17,11 +17,18 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; import * as path from 'path'; -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; +import {Transform} from 'stream'; +import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './recaptcha_enterprise_service_v1_beta1_client_config.json'; @@ -40,7 +47,12 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; recaptchaEnterpriseServiceV1Beta1Stub?: Promise<{[name: string]: Function}>; @@ -73,11 +85,14 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { constructor(opts?: ClientOptions) { // Ensure that options include the service address and port. - const staticMembers = this.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client; - const servicePath = opts && opts.servicePath ? - opts.servicePath : - ((opts && opts.apiEndpoint) ? opts.apiEndpoint : - staticMembers.servicePath); + const staticMembers = this + .constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client; + const servicePath = + opts && opts.servicePath + ? opts.servicePath + : opts && opts.apiEndpoint + ? opts.apiEndpoint + : staticMembers.servicePath; const port = opts && opts.port ? opts.port : staticMembers.port; if (!opts) { @@ -87,8 +102,8 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { opts.port = opts.port || port; opts.clientConfig = opts.clientConfig || {}; - const isBrowser = (typeof window !== 'undefined'); - if (isBrowser){ + const isBrowser = typeof window !== 'undefined'; + if (isBrowser) { opts.fallback = true; } // If we are in browser, we are already using fallback because of the @@ -98,20 +113,18 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. - opts.scopes = (this.constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client).scopes; + opts.scopes = (this + .constructor as typeof RecaptchaEnterpriseServiceV1Beta1Client).scopes; this._gaxGrpc = new this._gaxModule.GrpcClient(opts); // Save options to use in initialize() method. this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -127,12 +140,18 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // For Node.js, pass the path to JSON proto file. // For browsers, pass the JSON content. - const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); this._protos = this._gaxGrpc.loadProto( - opts.fallback ? - // eslint-disable-next-line @typescript-eslint/no-var-requires - require("../../protos/protos.json") : - nodejsProtoPath + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + require('../../protos/protos.json') + : nodejsProtoPath ); // This API contains "path templates"; forward-slash-separated @@ -154,14 +173,20 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listKeys: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keys') + listKeys: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'keys' + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -189,16 +214,27 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // Put together the "service stub" for // google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1. this.recaptchaEnterpriseServiceV1Beta1Stub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1, - this._opts) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.recaptchaenterprise.v1beta1 + .RecaptchaEnterpriseServiceV1Beta1, + this._opts + ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const recaptchaEnterpriseServiceV1Beta1StubMethods = - ['createAssessment', 'annotateAssessment', 'createKey', 'listKeys', 'getKey', 'updateKey', 'deleteKey']; + const recaptchaEnterpriseServiceV1Beta1StubMethods = [ + 'createAssessment', + 'annotateAssessment', + 'createKey', + 'listKeys', + 'getKey', + 'updateKey', + 'deleteKey', + ]; for (const methodName of recaptchaEnterpriseServiceV1Beta1StubMethods) { const callPromise = this.recaptchaEnterpriseServiceV1Beta1Stub.then( stub => (...args: Array<{}>) => { @@ -208,16 +244,17 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { const func = stub[methodName]; return func.apply(stub, args); }, - (err: Error|null|undefined) => () => { + (err: Error | null | undefined) => () => { throw err; - }); + } + ); const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); this.innerApiCalls[methodName] = apiCall; @@ -253,9 +290,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * in this service. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -265,8 +300,9 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @param {function(Error, string)} callback - the callback to * be called with the current project Id. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -278,62 +314,89 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { // -- Service calls -- // ------------------- createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | undefined + ), + {} | undefined + ] + >; createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): void; createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates an Assessment of the likelihood an event is legitimate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the assessment will be created, - * in the format "projects/{project_number}". - * @param {google.cloud.recaptchaenterprise.v1beta1.Assessment} request.assessment - * Required. The assessment details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Assessment]{@link google.cloud.recaptchaenterprise.v1beta1.Assessment}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Creates an Assessment of the likelihood an event is legitimate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the assessment will be created, + * in the format "projects/{project_number}". + * @param {google.cloud.recaptchaenterprise.v1beta1.Assessment} request.assessment + * Required. The assessment details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Assessment]{@link google.cloud.recaptchaenterprise.v1beta1.Assessment}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ createAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateAssessmentRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -342,69 +405,96 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); this.initialize(); return this.innerApiCalls.createAssessment(request, options, callback); } annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | undefined + ), + {} | undefined + ] + >; annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + | protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): void; annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): void; -/** - * Annotates a previously created Assessment to provide additional information - * on whether the event turned out to be authentic or fradulent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Assessment, in the format - * "projects/{project_number}/assessments/{assessment_id}". - * @param {google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest.Annotation} request.annotation - * Required. The annotation that will be assigned to the Event. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AnnotateAssessmentResponse]{@link google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + | protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Annotates a previously created Assessment to provide additional information + * on whether the event turned out to be authentic or fradulent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Assessment, in the format + * "projects/{project_number}/assessments/{assessment_id}". + * @param {google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest.Annotation} request.annotation + * Required. The annotation that will be assigned to the Event. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AnnotateAssessmentResponse]{@link google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ annotateAssessment( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, - optionsOrCallback?: gax.CallOptions|Callback< + request: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, - protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + | protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -413,68 +503,95 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.annotateAssessment(request, options, callback); } createKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | undefined + ), + {} | undefined + ] + >; createKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; createKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a new reCAPTCHA Enterprise key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project in which the key will be created, in the - * format "projects/{project_number}". - * @param {google.cloud.recaptchaenterprise.v1beta1.Key} request.key - * Required. Information to create a reCAPTCHA Enterprise key. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Creates a new reCAPTCHA Enterprise key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project in which the key will be created, in the + * format "projects/{project_number}". + * @param {google.cloud.recaptchaenterprise.v1beta1.Key} request.key + * Required. Information to create a reCAPTCHA Enterprise key. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ createKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.ICreateKeyRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -483,66 +600,93 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); this.initialize(); return this.innerApiCalls.createKey(request, options, callback); } getKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | undefined + ), + {} | undefined + ] + >; getKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; getKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Returns the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the requested key, in the format - * "projects/{project_number}/keys/{key_id}". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Returns the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the requested key, in the format + * "projects/{project_number}/keys/{key_id}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.IGetKeyRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -551,68 +695,95 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.getKey(request, options, callback); } updateKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | undefined + ), + {} | undefined + ] + >; updateKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; updateKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - callback: Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Updates the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.recaptchaenterprise.v1beta1.Key} request.key - * Required. The key to update. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. The mask to control which field of the key get updated. If the mask is not - * present, all fields will be updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + callback: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Updates the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.recaptchaenterprise.v1beta1.Key} request.key + * Required. The key to update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. The mask to control which field of the key get updated. If the mask is not + * present, all fields will be updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ updateKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey, - protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + | protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.IUpdateKeyRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -627,60 +798,87 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { return this.innerApiCalls.updateKey(request, options, callback); } deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined - ]>; + request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | undefined + ), + {} | undefined + ] + >; deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): void; -/** - * Deletes the specified key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the key to be deleted, in the format - * "projects/{project_number}/keys/{key_id}". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Deletes the specified key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the key to be deleted, in the format + * "projects/{project_number}/keys/{key_id}". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ deleteKey( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, - optionsOrCallback?: gax.CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest, + optionsOrCallback?: + | gax.CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.recaptchaenterprise.v1beta1.IDeleteKeyRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -689,87 +887,106 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'name': request.name || '', + name: request.name || '', }); this.initialize(); return this.innerApiCalls.deleteKey(request, options, callback); } listKeys( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options?: gax.CallOptions): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey[], - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse - ]>; + request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options?: gax.CallOptions + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest | null, + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + ] + >; listKeys( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options: gax.CallOptions, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1beta1.IKey>): void; + request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options: gax.CallOptions, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + | protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + | null + | undefined, + protos.google.cloud.recaptchaenterprise.v1beta1.IKey + > + ): void; listKeys( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - callback: PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1beta1.IKey>): void; -/** - * Returns the list of all keys that belong to a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project_number}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. - * The client library support auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * - * When autoPaginate: false is specified through options, the array has three elements. - * The first element is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} that corresponds to - * the one page received from the API server. - * If the second element is not null it contains the request object of type [ListKeysRequest]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest} - * that can be used to obtain the next page of the results. - * If it is null, the next page does not exist. - * The third element contains the raw response received from the API server. Its type is - * [ListKeysResponse]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysResponse}. - * - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + callback: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + | protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + | null + | undefined, + protos.google.cloud.recaptchaenterprise.v1beta1.IKey + > + ): void; + /** + * Returns the list of all keys that belong to a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project_number}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key}. + * The client library support auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * + * When autoPaginate: false is specified through options, the array has three elements. + * The first element is Array of [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} that corresponds to + * the one page received from the API server. + * If the second element is not null it contains the request object of type [ListKeysRequest]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest} + * that can be used to obtain the next page of the results. + * If it is null, the next page does not exist. + * The third element contains the raw response received from the API server. Its type is + * [ListKeysResponse]{@link google.cloud.recaptchaenterprise.v1beta1.ListKeysResponse}. + * + * The promise has a method named "cancel" which cancels the ongoing API call. + */ listKeys( - request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - optionsOrCallback?: gax.CallOptions|PaginationCallback< - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1beta1.IKey>, - callback?: PaginationCallback< + request: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + optionsOrCallback?: + | gax.CallOptions + | PaginationCallback< protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse|null|undefined, - protos.google.cloud.recaptchaenterprise.v1beta1.IKey>): - Promise<[ - protos.google.cloud.recaptchaenterprise.v1beta1.IKey[], - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest|null, - protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse - ]>|void { + | protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + | null + | undefined, + protos.google.cloud.recaptchaenterprise.v1beta1.IKey + >, + callback?: PaginationCallback< + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + | protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + | null + | undefined, + protos.google.cloud.recaptchaenterprise.v1beta1.IKey + > + ): Promise< + [ + protos.google.cloud.recaptchaenterprise.v1beta1.IKey[], + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest | null, + protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysResponse + ] + > | void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -778,45 +995,45 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); this.initialize(); return this.innerApiCalls.listKeys(request, options, callback); } -/** - * Equivalent to {@link listKeys}, but returns a NodeJS Stream object. - * - * This fetches the paged responses for {@link listKeys} continuously - * and invokes the callback registered for 'data' event for each element in the - * responses. - * - * The returned object has 'end' method when no more elements are required. - * - * autoPaginate option will be ignored. - * - * @see {@link https://nodejs.org/api/stream.html} - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project_number}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} on 'data' event. - */ + /** + * Equivalent to {@link listKeys}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listKeys} continuously + * and invokes the callback registered for 'data' event for each element in the + * responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project_number}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Key]{@link google.cloud.recaptchaenterprise.v1beta1.Key} on 'data' event. + */ listKeysStream( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options?: gax.CallOptions): - Transform{ + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options?: gax.CallOptions + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -824,7 +1041,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); const callSettings = new gax.CallSettings(options); this.initialize(); @@ -835,31 +1052,31 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { ); } -/** - * Equivalent to {@link listKeys}, but returns an iterable object. - * - * for-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the project that contains the keys that will be - * listed, in the format "projects/{project_number}". - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. Default is 10. Max limit is - * 1000. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous. - * ListKeysRequest, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. - */ + /** + * Equivalent to {@link listKeys}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project that contains the keys that will be + * listed, in the format "projects/{project_number}". + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. Default is 10. Max limit is + * 1000. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous. + * ListKeysRequest, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ listKeysAsync( - request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, - options?: gax.CallOptions): - AsyncIterable{ + request?: protos.google.cloud.recaptchaenterprise.v1beta1.IListKeysRequest, + options?: gax.CallOptions + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -867,14 +1084,14 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', + parent: request.parent || '', }); options = options || {}; const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listKeys.asyncIterate( this.innerApiCalls['listKeys'] as GaxCall, - request as unknown as RequestType, + (request as unknown) as RequestType, callSettings ) as AsyncIterable; } @@ -889,7 +1106,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @param {string} assessment * @returns {string} Resource name string. */ - assessmentPath(project:string,assessment:string) { + assessmentPath(project: string, assessment: string) { return this.pathTemplates.assessmentPathTemplate.render({ project: project, assessment: assessment, @@ -904,7 +1121,8 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @returns {string} A string representing the project. */ matchProjectFromAssessmentName(assessmentName: string) { - return this.pathTemplates.assessmentPathTemplate.match(assessmentName).project; + return this.pathTemplates.assessmentPathTemplate.match(assessmentName) + .project; } /** @@ -915,7 +1133,8 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @returns {string} A string representing the assessment. */ matchAssessmentFromAssessmentName(assessmentName: string) { - return this.pathTemplates.assessmentPathTemplate.match(assessmentName).assessment; + return this.pathTemplates.assessmentPathTemplate.match(assessmentName) + .assessment; } /** @@ -925,7 +1144,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @param {string} key * @returns {string} Resource name string. */ - keyPath(project:string,key:string) { + keyPath(project: string, key: string) { return this.pathTemplates.keyPathTemplate.render({ project: project, key: key, @@ -960,7 +1179,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); diff --git a/packages/google-cloud-recaptchaenterprise/synth.metadata b/packages/google-cloud-recaptchaenterprise/synth.metadata index ed8e6e86ccf..584e9cdb322 100644 --- a/packages/google-cloud-recaptchaenterprise/synth.metadata +++ b/packages/google-cloud-recaptchaenterprise/synth.metadata @@ -4,22 +4,22 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-recaptcha-enterprise.git", - "sha": "fa5b1c493666627a49ac1793fb830f0b9e6bdbf1" + "sha": "e05cfb84b4f46841a19b2b6dfb81ef3ac9668451" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "3028060618e8024af9a32b3ab3456c160091ecb7", - "internalRef": "306450502" + "sha": "42ee97c1b93a0e3759bbba3013da309f670a90ab", + "internalRef": "307114445" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "52638600f387deb98efb5f9c85fec39e82aa9052" + "sha": "19465d3ec5e5acdb01521d8f3bddd311bcbee28d" } } ], diff --git a/packages/google-cloud-recaptchaenterprise/system-test/fixtures/sample/src/index.js b/packages/google-cloud-recaptchaenterprise/system-test/fixtures/sample/src/index.js index d0565cdf3b3..cb2d9ca7462 100644 --- a/packages/google-cloud-recaptchaenterprise/system-test/fixtures/sample/src/index.js +++ b/packages/google-cloud-recaptchaenterprise/system-test/fixtures/sample/src/index.js @@ -16,7 +16,6 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** - /* eslint-disable node/no-missing-require, no-unused-vars */ const recaptchaenterprise = require('@google-cloud/recaptcha-enterprise'); diff --git a/packages/google-cloud-recaptchaenterprise/system-test/install.ts b/packages/google-cloud-recaptchaenterprise/system-test/install.ts index 5e4ed636481..4c1ba3eb79a 100644 --- a/packages/google-cloud-recaptchaenterprise/system-test/install.ts +++ b/packages/google-cloud-recaptchaenterprise/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; describe('typescript consumer tests', () => { - - it('should have correct type signature for typescript users', async function() { + it('should have correct type signature for typescript users', async function () { this.timeout(300000); const options = { - packageDir: process.cwd(), // path to your module. + packageDir: process.cwd(), // path to your module. sample: { description: 'typescript based user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts' + ).toString(), + }, }; - await packNTest(options); // will throw upon error. + await packNTest(options); // will throw upon error. }); - it('should have correct type signature for javascript users', async function() { + it('should have correct type signature for javascript users', async function () { this.timeout(300000); const options = { - packageDir: process.cwd(), // path to your module. + packageDir: process.cwd(), // path to your module. sample: { description: 'typescript based user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.js' + ).toString(), + }, }; - await packNTest(options); // will throw upon error. + await packNTest(options); // will throw upon error. }); - }); diff --git a/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1.ts b/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1.ts index ba427e14fe0..6a28b288ab3 100644 --- a/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1.ts +++ b/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1.ts @@ -20,7 +20,7 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; +import {describe, it} from 'mocha'; import * as recaptchaenterpriseserviceModule from '../src'; import {PassThrough} from 'stream'; @@ -28,978 +28,1362 @@ import {PassThrough} from 'stream'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.RecaptchaEnterpriseServiceClient', () => { - it('has servicePath', () => { - const servicePath = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.servicePath; - assert(servicePath); + it('has servicePath', () => { + const servicePath = + recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient + .servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient + .apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = + recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + fallback: true, + } + ); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.recaptchaEnterpriseServiceStub, undefined); + await client.initialize(); + assert(client.recaptchaEnterpriseServiceStub); + }); + + it('has close method', () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); - it('has apiEndpoint', () => { - const apiEndpoint = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.apiEndpoint; - assert(apiEndpoint); + describe('createAssessment', () => { + it('invokes createAssessment without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Assessment() + ); + client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); + const [response] = await client.createAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has port', () => { - const port = recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('invokes createAssessment without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Assessment() + ); + client.innerApiCalls.createAssessment = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createAssessment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1.IAssessment | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('should create a client with no option', () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient(); - assert(client); + it('invokes createAssessment with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createAssessment = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.createAssessment(request); + }, expectedError); + assert( + (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - it('should create a client with gRPC fallback', () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - fallback: true, - }); - assert(client); + describe('annotateAssessment', () => { + it('invokes annotateAssessment without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse() + ); + client.innerApiCalls.annotateAssessment = stubSimpleCall( + expectedResponse + ); + const [response] = await client.annotateAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has initialize method and supports deferred initialization', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.recaptchaEnterpriseServiceStub, undefined); - await client.initialize(); - assert(client.recaptchaEnterpriseServiceStub); + it('invokes annotateAssessment without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse() + ); + client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.annotateAssessment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('has close method', () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); + it('invokes annotateAssessment with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.annotateAssessment = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.annotateAssessment(request); + }, expectedError); + assert( + (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + describe('createKey', () => { + it('invokes createKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.createKey = stubSimpleCall(expectedResponse); + const [response] = await client.createKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createAssessment', () => { - it('invokes createAssessment without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Assessment()); - client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.createAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes createKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.createKey = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1.IKey | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes createAssessment without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Assessment()); - client.innerApiCalls.createAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IAssessment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes createKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.createKey(request); + }, expectedError); + assert( + (client.innerApiCalls.createKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes createAssessment with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.createAssessment(request); }, expectedError); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('getKey', () => { + it('invokes getKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.getKey = stubSimpleCall(expectedResponse); + const [response] = await client.getKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('annotateAssessment', () => { - it('invokes annotateAssessment without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse()); - client.innerApiCalls.annotateAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.annotateAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.getKey = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1.IKey | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes annotateAssessment without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentResponse()); - client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IAnnotateAssessmentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes getKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.getKey(request); + }, expectedError); + assert( + (client.innerApiCalls.getKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes annotateAssessment with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.annotateAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.annotateAssessment(request); }, expectedError); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('updateKey', () => { + it('invokes updateKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() + ); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = 'key.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.updateKey = stubSimpleCall(expectedResponse); + const [response] = await client.updateKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('createKey', () => { - it('invokes createKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.createKey = stubSimpleCall(expectedResponse); - const [response] = await client.createKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes updateKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() + ); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = 'key.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ); + client.innerApiCalls.updateKey = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1.IKey | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes createKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.createKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes updateKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest() + ); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = 'key.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.updateKey(request); + }, expectedError); + assert( + (client.innerApiCalls.updateKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes createKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.createKey(request); }, expectedError); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('deleteKey', () => { + it('invokes deleteKey without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('getKey', () => { - it('invokes getKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.getKey = stubSimpleCall(expectedResponse); - const [response] = await client.getKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes deleteKey without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteKey = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteKey( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes getKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.getKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes deleteKey with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.deleteKey(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes getKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.getKey(request); }, expectedError); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('listKeys', () => { + it('invokes listKeys without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + ]; + client.innerApiCalls.listKeys = stubSimpleCall(expectedResponse); + const [response] = await client.listKeys(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listKeys as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('updateKey', () => { - it('invokes updateKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.updateKey = stubSimpleCall(expectedResponse); - const [response] = await client.updateKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes listKeys without error using callback', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + ]; + client.innerApiCalls.listKeys = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listKeys( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1.IKey[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listKeys as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes updateKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()); - client.innerApiCalls.updateKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes listKeys with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listKeys = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.listKeys(request); + }, expectedError); + assert( + (client.innerApiCalls.listKeys as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes updateKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.updateKey(request); }, expectedError); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); + it('invokes listKeysStream without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + ]; + client.descriptors.page.listKeys.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; + stream.on( + 'data', + (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listKeys, request) + ); + assert.strictEqual( + (client.descriptors.page.listKeys.createStream as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); }); - describe('deleteKey', () => { - it('invokes deleteKey without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteKey = stubSimpleCall(expectedResponse); - const [response] = await client.deleteKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); + it('invokes listKeysStream with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listKeys.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; + stream.on( + 'data', + (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes deleteKey without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteKey( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listKeys, request) + ); + assert.strictEqual( + (client.descriptors.page.listKeys.createStream as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes deleteKey with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.deleteKey(request); }, expectedError); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('uses async iteration with listKeys without error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.Key() + ), + ]; + client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; + const iterable = client.listKeysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); }); - describe('listKeys', () => { - it('invokes listKeys without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.innerApiCalls.listKeys = stubSimpleCall(expectedResponse); - const [response] = await client.listKeys(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('uses async iteration with listKeys with error', async () => { + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listKeysAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); - it('invokes listKeys without error using callback', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.innerApiCalls.listKeys = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listKeys( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1.IKey[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + describe('Path templates', () => { + describe('assessment', () => { + const fakePath = '/rendered/path/assessment'; + const expectedParameters = { + project: 'projectValue', + assessment: 'assessmentValue', + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.assessmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.assessmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('invokes listKeys with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listKeys = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.listKeys(request); }, expectedError); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('assessmentPath', () => { + const result = client.assessmentPath('projectValue', 'assessmentValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.assessmentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); - it('invokes listKeysStream without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.descriptors.page.listKeys.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); - assert.strictEqual( - (client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('matchProjectFromAssessmentName', () => { + const result = client.matchProjectFromAssessmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); - it('invokes listKeysStream with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listKeys.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1.Key[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1.Key) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(async () => { await promise; }, expectedError); - assert((client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); - assert.strictEqual( - (client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('matchAssessmentFromAssessmentName', () => { + const result = client.matchAssessmentFromAssessmentName(fakePath); + assert.strictEqual(result, 'assessmentValue'); + assert( + (client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - it('uses async iteration with listKeys without error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.Key()), - ]; - client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; - const iterable = client.listKeysAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + describe('key', () => { + const fakePath = '/rendered/path/key'; + const expectedParameters = { + project: 'projectValue', + key: 'keyValue', + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.keyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('uses async iteration with listKeys with error', async () => { - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listKeysAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1.IKey[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('keyPath', () => { + const result = client.keyPath('projectValue', 'keyValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromKeyName', () => { + const result = client.matchProjectFromKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchKeyFromKeyName', () => { + const result = client.matchKeyFromKeyName(fakePath); + assert.strictEqual(result, 'keyValue'); + assert( + (client.pathTemplates.keyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); }); - describe('Path templates', () => { - - describe('assessment', () => { - const fakePath = "/rendered/path/assessment"; - const expectedParameters = { - project: "projectValue", - assessment: "assessmentValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.assessmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.assessmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('assessmentPath', () => { - const result = client.assessmentPath("projectValue", "assessmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.assessmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAssessmentName', () => { - const result = client.matchProjectFromAssessmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAssessmentFromAssessmentName', () => { - const result = client.matchAssessmentFromAssessmentName(fakePath); - assert.strictEqual(result, "assessmentValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - describe('key', () => { - const fakePath = "/rendered/path/key"; - const expectedParameters = { - project: "projectValue", - key: "keyValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.keyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyPath', () => { - const result = client.keyPath("projectValue", "keyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyName', () => { - const result = client.matchProjectFromKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyFromKeyName', () => { - const result = client.matchKeyFromKeyName(fakePath); - assert.strictEqual(result, "keyValue"); - assert((client.pathTemplates.keyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new recaptchaenterpriseserviceModule.v1.RecaptchaEnterpriseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); }); + }); }); diff --git a/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts b/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts index a90909e64af..da6ed0287f8 100644 --- a/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts +++ b/packages/google-cloud-recaptchaenterprise/test/gapic_recaptcha_enterprise_service_v1_beta1_v1beta1.ts @@ -20,7 +20,7 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; +import {describe, it} from 'mocha'; import * as recaptchaenterpriseservicev1beta1Module from '../src'; import {PassThrough} from 'stream'; @@ -28,978 +28,1365 @@ import {PassThrough} from 'stream'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta1.RecaptchaEnterpriseServiceV1Beta1Client', () => { - it('has servicePath', () => { - const servicePath = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.servicePath; - assert(servicePath); + it('has servicePath', () => { + const servicePath = + recaptchaenterpriseservicev1beta1Module.v1beta1 + .RecaptchaEnterpriseServiceV1Beta1Client.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + recaptchaenterpriseservicev1beta1Module.v1beta1 + .RecaptchaEnterpriseServiceV1Beta1Client.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = + recaptchaenterpriseservicev1beta1Module.v1beta1 + .RecaptchaEnterpriseServiceV1Beta1Client.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + fallback: true, + } + ); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.recaptchaEnterpriseServiceV1Beta1Stub, undefined); + await client.initialize(); + assert(client.recaptchaEnterpriseServiceV1Beta1Stub); + }); + + it('has close method', () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); - it('has apiEndpoint', () => { - const apiEndpoint = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.apiEndpoint; - assert(apiEndpoint); + describe('createAssessment', () => { + it('invokes createAssessment without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment() + ); + client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); + const [response] = await client.createAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has port', () => { - const port = recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.port; - assert(port); - assert(typeof port === 'number'); + it('invokes createAssessment without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment() + ); + client.innerApiCalls.createAssessment = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createAssessment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('should create a client with no option', () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(); - assert(client); + it('invokes createAssessment with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createAssessment = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.createAssessment(request); + }, expectedError); + assert( + (client.innerApiCalls.createAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - it('should create a client with gRPC fallback', () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - fallback: true, - }); - assert(client); + describe('annotateAssessment', () => { + it('invokes annotateAssessment without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse() + ); + client.innerApiCalls.annotateAssessment = stubSimpleCall( + expectedResponse + ); + const [response] = await client.annotateAssessment(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has initialize method and supports deferred initialization', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - assert.strictEqual(client.recaptchaEnterpriseServiceV1Beta1Stub, undefined); - await client.initialize(); - assert(client.recaptchaEnterpriseServiceV1Beta1Stub); + it('invokes annotateAssessment without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse() + ); + client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.annotateAssessment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('has close method', () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); + it('invokes annotateAssessment with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.annotateAssessment = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.annotateAssessment(request); + }, expectedError); + assert( + (client.innerApiCalls.annotateAssessment as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + describe('createKey', () => { + it('invokes createKey without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ); + client.innerApiCalls.createKey = stubSimpleCall(expectedResponse); + const [response] = await client.createKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createAssessment', () => { - it('invokes createAssessment without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment()); - client.innerApiCalls.createAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.createAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes createKey without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ); + client.innerApiCalls.createKey = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes createAssessment without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Assessment()); - client.innerApiCalls.createAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAssessment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes createKey with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.createKey(request); + }, expectedError); + assert( + (client.innerApiCalls.createKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes createAssessment with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateAssessmentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.createAssessment(request); }, expectedError); - assert((client.innerApiCalls.createAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('getKey', () => { + it('invokes getKey without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ); + client.innerApiCalls.getKey = stubSimpleCall(expectedResponse); + const [response] = await client.getKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('annotateAssessment', () => { - it('invokes annotateAssessment without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse()); - client.innerApiCalls.annotateAssessment = stubSimpleCall(expectedResponse); - const [response] = await client.annotateAssessment(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getKey without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ); + client.innerApiCalls.getKey = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes annotateAssessment without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse()); - client.innerApiCalls.annotateAssessment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateAssessment( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IAnnotateAssessmentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes getKey with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.getKey(request); + }, expectedError); + assert( + (client.innerApiCalls.getKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes annotateAssessment with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.annotateAssessment = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.annotateAssessment(request); }, expectedError); - assert((client.innerApiCalls.annotateAssessment as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('updateKey', () => { + it('invokes updateKey without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest() + ); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = 'key.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ); + client.innerApiCalls.updateKey = stubSimpleCall(expectedResponse); + const [response] = await client.updateKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('createKey', () => { - it('invokes createKey without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.createKey = stubSimpleCall(expectedResponse); - const [response] = await client.createKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes updateKey without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest() + ); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = 'key.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ); + client.innerApiCalls.updateKey = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes createKey without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.createKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes updateKey with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest() + ); + request.key = {}; + request.key.name = ''; + const expectedHeaderRequestParams = 'key.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.updateKey(request); + }, expectedError); + assert( + (client.innerApiCalls.updateKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes createKey with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.CreateKeyRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.createKey(request); }, expectedError); - assert((client.innerApiCalls.createKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('deleteKey', () => { + it('invokes deleteKey without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('getKey', () => { - it('invokes getKey without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.getKey = stubSimpleCall(expectedResponse); - const [response] = await client.getKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes deleteKey without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteKey = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteKey( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes getKey without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.getKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes deleteKey with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.deleteKey(request); + }, expectedError); + assert( + (client.innerApiCalls.deleteKey as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); - it('invokes getKey with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.GetKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.getKey(request); }, expectedError); - assert((client.innerApiCalls.getKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + describe('listKeys', () => { + it('invokes listKeys without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + ]; + client.innerApiCalls.listKeys = stubSimpleCall(expectedResponse); + const [response] = await client.listKeys(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listKeys as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('updateKey', () => { - it('invokes updateKey without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.updateKey = stubSimpleCall(expectedResponse); - const [response] = await client.updateKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes listKeys without error using callback', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + ]; + client.innerApiCalls.listKeys = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listKeys( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.recaptchaenterprise.v1beta1.IKey[] + | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listKeys as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes updateKey without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()); - client.innerApiCalls.updateKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateKey( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes listKeys with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listKeys = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { + await client.listKeys(request); + }, expectedError); + assert( + (client.innerApiCalls.listKeys as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes updateKey with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.UpdateKeyRequest()); - request.key = {}; - request.key.name = ''; - const expectedHeaderRequestParams = "key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.updateKey(request); }, expectedError); - assert((client.innerApiCalls.updateKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); + it('invokes listKeysStream without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + ]; + client.descriptors.page.listKeys.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1beta1.Key[] = []; + stream.on( + 'data', + (response: protos.google.cloud.recaptchaenterprise.v1beta1.Key) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listKeys, request) + ); + assert.strictEqual( + (client.descriptors.page.listKeys.createStream as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); }); - describe('deleteKey', () => { - it('invokes deleteKey without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteKey = stubSimpleCall(expectedResponse); - const [response] = await client.deleteKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); + it('invokes listKeysStream with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listKeys.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.recaptchaenterprise.v1beta1.Key[] = []; + stream.on( + 'data', + (response: protos.google.cloud.recaptchaenterprise.v1beta1.Key) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes deleteKey without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteKey( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(async () => { + await promise; + }, expectedError); + assert( + (client.descriptors.page.listKeys.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listKeys, request) + ); + assert.strictEqual( + (client.descriptors.page.listKeys.createStream as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes deleteKey with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.DeleteKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.deleteKey(request); }, expectedError); - assert((client.innerApiCalls.deleteKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('uses async iteration with listKeys without error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.Key() + ), + ]; + client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[] = []; + const iterable = client.listKeysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); }); - describe('listKeys', () => { - it('invokes listKeys without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - ]; - client.innerApiCalls.listKeys = stubSimpleCall(expectedResponse); - const [response] = await client.listKeys(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('uses async iteration with listKeys with error', async () => { + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listKeysAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listKeys.asyncIterate as SinonStub).getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); - it('invokes listKeys without error using callback', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - ]; - client.innerApiCalls.listKeys = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listKeys( - request, - (err?: Error|null, result?: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + describe('Path templates', () => { + describe('assessment', () => { + const fakePath = '/rendered/path/assessment'; + const expectedParameters = { + project: 'projectValue', + assessment: 'assessmentValue', + }; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.assessmentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.assessmentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('invokes listKeys with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listKeys = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => { await client.listKeys(request); }, expectedError); - assert((client.innerApiCalls.listKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('assessmentPath', () => { + const result = client.assessmentPath('projectValue', 'assessmentValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.assessmentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); - it('invokes listKeysStream without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - ]; - client.descriptors.page.listKeys.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1beta1.Key[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1beta1.Key) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); - assert.strictEqual( - (client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('matchProjectFromAssessmentName', () => { + const result = client.matchProjectFromAssessmentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); - it('invokes listKeysStream with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listKeys.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.recaptchaenterprise.v1beta1.Key[] = []; - stream.on('data', (response: protos.google.cloud.recaptchaenterprise.v1beta1.Key) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(async () => { await promise; }, expectedError); - assert((client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeys, request)); - assert.strictEqual( - (client.descriptors.page.listKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('matchAssessmentFromAssessmentName', () => { + const result = client.matchAssessmentFromAssessmentName(fakePath); + assert.strictEqual(result, 'assessmentValue'); + assert( + (client.pathTemplates.assessmentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - it('uses async iteration with listKeys without error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.Key()), - ]; - client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[] = []; - const iterable = client.listKeysAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + describe('key', () => { + const fakePath = '/rendered/path/key'; + const expectedParameters = { + project: 'projectValue', + key: 'keyValue', + }; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.keyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('uses async iteration with listKeys with error', async () => { - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.recaptchaenterprise.v1beta1.ListKeysRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listKeysAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.recaptchaenterprise.v1beta1.IKey[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('keyPath', () => { + const result = client.keyPath('projectValue', 'keyValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromKeyName', () => { + const result = client.matchProjectFromKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchKeyFromKeyName', () => { + const result = client.matchKeyFromKeyName(fakePath); + assert.strictEqual(result, 'keyValue'); + assert( + (client.pathTemplates.keyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); }); - describe('Path templates', () => { - - describe('assessment', () => { - const fakePath = "/rendered/path/assessment"; - const expectedParameters = { - project: "projectValue", - assessment: "assessmentValue", - }; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.assessmentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.assessmentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('assessmentPath', () => { - const result = client.assessmentPath("projectValue", "assessmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.assessmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAssessmentName', () => { - const result = client.matchProjectFromAssessmentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAssessmentFromAssessmentName', () => { - const result = client.matchAssessmentFromAssessmentName(fakePath); - assert.strictEqual(result, "assessmentValue"); - assert((client.pathTemplates.assessmentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - describe('key', () => { - const fakePath = "/rendered/path/key"; - const expectedParameters = { - project: "projectValue", - key: "keyValue", - }; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.keyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyPath', () => { - const result = client.keyPath("projectValue", "keyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyName', () => { - const result = client.matchProjectFromKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyFromKeyName', () => { - const result = client.matchKeyFromKeyName(fakePath); - assert.strictEqual(result, "keyValue"); - assert((client.pathTemplates.keyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new recaptchaenterpriseservicev1beta1Module.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); }); + }); }); diff --git a/packages/google-cloud-recaptchaenterprise/webpack.config.js b/packages/google-cloud-recaptchaenterprise/webpack.config.js index 2435e0e2d56..04831b77a4d 100644 --- a/packages/google-cloud-recaptchaenterprise/webpack.config.js +++ b/packages/google-cloud-recaptchaenterprise/webpack.config.js @@ -36,27 +36,27 @@ module.exports = { { test: /\.tsx?$/, use: 'ts-loader', - exclude: /node_modules/ + exclude: /node_modules/, }, { test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]grpc/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]retry-request/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' + use: 'null-loader', }, { test: /node_modules[\\/]gtoken/, - use: 'null-loader' + use: 'null-loader', }, ], },