diff --git a/packages/google-cloud-networkmanagement/.eslintignore b/packages/google-cloud-networkmanagement/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-networkmanagement/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-networkmanagement/.eslintrc.json b/packages/google-cloud-networkmanagement/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-networkmanagement/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-networkmanagement/README.md b/packages/google-cloud-networkmanagement/README.md index 5bda0d104795..c1801080756e 100644 --- a/packages/google-cloud-networkmanagement/README.md +++ b/packages/google-cloud-networkmanagement/README.md @@ -129,7 +129,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-networkmanagement/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -139,7 +139,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-networkmanagement/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-networkmanagement/protos/google/cloud/networkmanagement/v1beta1/connectivity_test.proto b/packages/google-cloud-networkmanagement/protos/google/cloud/networkmanagement/v1beta1/connectivity_test.proto index 56119b413027..5b9a7c79836f 100644 --- a/packages/google-cloud-networkmanagement/protos/google/cloud/networkmanagement/v1beta1/connectivity_test.proto +++ b/packages/google-cloud-networkmanagement/protos/google/cloud/networkmanagement/v1beta1/connectivity_test.proto @@ -267,6 +267,13 @@ message Endpoint { // Applicable only to source endpoint. CloudRunRevisionEndpoint cloud_run_revision = 12; + // A [Cloud Run](https://cloud.google.com/run) + // [job](https://docs.cloud.google.com/run/docs/reference/rest/v2/projects.locations.jobs#Job) + // URI. + // Applicable only to source endpoint. + // The format is: projects/{project}/locations/{location}/jobs/{job} + string cloud_run_job = 24; + // A VPC network URI. For source endpoints, used according to the // `network_type`. For destination endpoints, used only when the source is an // external IP address endpoint, and the destination is an internal IP address diff --git a/packages/google-cloud-networkmanagement/protos/google/cloud/networkmanagement/v1beta1/trace.proto b/packages/google-cloud-networkmanagement/protos/google/cloud/networkmanagement/v1beta1/trace.proto index 8c0d21d8922a..06d681c6bcf2 100644 --- a/packages/google-cloud-networkmanagement/protos/google/cloud/networkmanagement/v1beta1/trace.proto +++ b/packages/google-cloud-networkmanagement/protos/google/cloud/networkmanagement/v1beta1/trace.proto @@ -118,6 +118,10 @@ message Step { // A CloudRunRevisionInfo is populated with starting revision information. START_FROM_CLOUD_RUN_REVISION = 26; + // Initial state: packet originating from a Cloud Run Job. + // A CloudRunJobInfo is populated with starting Job information. + START_FROM_CLOUD_RUN_JOB = 50; + // Initial state: packet originating from a Storage Bucket. Used only for // return traces. // The storage_bucket information is populated. @@ -353,6 +357,9 @@ message Step { // Display information of a Cloud Run revision. CloudRunRevisionInfo cloud_run_revision = 23; + // Display information of a Cloud Run job. + CloudRunJobInfo cloud_run_job = 45; + // Display information of a NAT. NatInfo nat = 25; @@ -1155,6 +1162,9 @@ message DeliverInfo { // Target is a GKE Pod. GKE_POD = 19; + + // Target is a Cloud Run Job. Used only for return traces. + CLOUD_RUN_JOB = 20; } // Recognized type of a Google Service. @@ -1714,6 +1724,9 @@ message DropInfo { // Packet sent from a Cloud Run revision that is not ready. CLOUD_RUN_REVISION_NOT_READY = 29; + // Packet sent from a Cloud Run job that is not ready. + CLOUD_RUN_JOB_NOT_READY = 113; + // Packet was dropped inside Private Service Connect service producer. DROPPED_INSIDE_PSC_SERVICE_PRODUCER = 37; @@ -2121,6 +2134,18 @@ message CloudRunRevisionInfo { string service_uri = 5; } +// For display only. Metadata associated with a Cloud Run job. +message CloudRunJobInfo { + // Name of a Cloud Run job. + string display_name = 1; + + // URI of a Cloud Run job. + string uri = 2; + + // Location in which this job is deployed. + string location = 3; +} + // For display only. Metadata associated with an App Engine version. message AppEngineVersionInfo { // Name of an App Engine version. diff --git a/packages/google-cloud-networkmanagement/protos/protos.d.ts b/packages/google-cloud-networkmanagement/protos/protos.d.ts index 55319e26fa82..caa8e64f320d 100644 --- a/packages/google-cloud-networkmanagement/protos/protos.d.ts +++ b/packages/google-cloud-networkmanagement/protos/protos.d.ts @@ -10153,6 +10153,9 @@ export namespace google { /** Endpoint cloudRunRevision */ cloudRunRevision?: (google.cloud.networkmanagement.v1beta1.Endpoint.ICloudRunRevisionEndpoint|null); + /** Endpoint cloudRunJob */ + cloudRunJob?: (string|null); + /** Endpoint network */ network?: (string|null); @@ -10220,6 +10223,9 @@ export namespace google { /** Endpoint cloudRunRevision. */ public cloudRunRevision?: (google.cloud.networkmanagement.v1beta1.Endpoint.ICloudRunRevisionEndpoint|null); + /** Endpoint cloudRunJob. */ + public cloudRunJob: string; + /** Endpoint network. */ public network: string; @@ -11565,6 +11571,9 @@ export namespace google { /** Step cloudRunRevision */ cloudRunRevision?: (google.cloud.networkmanagement.v1beta1.ICloudRunRevisionInfo|null); + /** Step cloudRunJob */ + cloudRunJob?: (google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo|null); + /** Step nat */ nat?: (google.cloud.networkmanagement.v1beta1.INatInfo|null); @@ -11695,6 +11704,9 @@ export namespace google { /** Step cloudRunRevision. */ public cloudRunRevision?: (google.cloud.networkmanagement.v1beta1.ICloudRunRevisionInfo|null); + /** Step cloudRunJob. */ + public cloudRunJob?: (google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo|null); + /** Step nat. */ public nat?: (google.cloud.networkmanagement.v1beta1.INatInfo|null); @@ -11714,7 +11726,7 @@ export namespace google { public ngfwPacketInspection?: (google.cloud.networkmanagement.v1beta1.INgfwPacketInspectionInfo|null); /** Step stepInfo. */ - public stepInfo?: ("instance"|"firewall"|"route"|"endpoint"|"googleService"|"forwardingRule"|"hybridSubnet"|"vpnGateway"|"vpnTunnel"|"interconnectAttachment"|"vpcConnector"|"directVpcEgressConnection"|"serverlessExternalConnection"|"deliver"|"forward"|"abort"|"drop"|"loadBalancer"|"network"|"gkeMaster"|"gkePod"|"ipMasqueradingSkipped"|"gkeNetworkPolicy"|"gkeNetworkPolicySkipped"|"cloudSqlInstance"|"redisInstance"|"redisCluster"|"cloudFunction"|"appEngineVersion"|"cloudRunRevision"|"nat"|"proxyConnection"|"loadBalancerBackendInfo"|"storageBucket"|"serverlessNeg"|"ngfwPacketInspection"); + public stepInfo?: ("instance"|"firewall"|"route"|"endpoint"|"googleService"|"forwardingRule"|"hybridSubnet"|"vpnGateway"|"vpnTunnel"|"interconnectAttachment"|"vpcConnector"|"directVpcEgressConnection"|"serverlessExternalConnection"|"deliver"|"forward"|"abort"|"drop"|"loadBalancer"|"network"|"gkeMaster"|"gkePod"|"ipMasqueradingSkipped"|"gkeNetworkPolicy"|"gkeNetworkPolicySkipped"|"cloudSqlInstance"|"redisInstance"|"redisCluster"|"cloudFunction"|"appEngineVersion"|"cloudRunRevision"|"cloudRunJob"|"nat"|"proxyConnection"|"loadBalancerBackendInfo"|"storageBucket"|"serverlessNeg"|"ngfwPacketInspection"); /** * Creates a new Step instance using the specified properties. @@ -11811,6 +11823,7 @@ export namespace google { START_FROM_CLOUD_FUNCTION = 23, START_FROM_APP_ENGINE_VERSION = 25, START_FROM_CLOUD_RUN_REVISION = 26, + START_FROM_CLOUD_RUN_JOB = 50, START_FROM_STORAGE_BUCKET = 29, START_FROM_PSC_PUBLISHED_SERVICE = 30, START_FROM_SERVERLESS_NEG = 31, @@ -13979,7 +13992,8 @@ export namespace google { GOOGLE_MANAGED_SERVICE = 15, REDIS_INSTANCE = 16, REDIS_CLUSTER = 17, - GKE_POD = 19 + GKE_POD = 19, + CLOUD_RUN_JOB = 20 } /** GoogleServiceType enum. */ @@ -14489,6 +14503,7 @@ export namespace google { HYBRID_NEG_NON_DYNAMIC_ROUTE_MATCHED = 55, HYBRID_NEG_NON_LOCAL_DYNAMIC_ROUTE_MATCHED = 56, CLOUD_RUN_REVISION_NOT_READY = 29, + CLOUD_RUN_JOB_NOT_READY = 113, DROPPED_INSIDE_PSC_SERVICE_PRODUCER = 37, LOAD_BALANCER_HAS_NO_PROXY_SUBNET = 39, CLOUD_NAT_NO_ADDRESSES = 40, @@ -15715,6 +15730,115 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a CloudRunJobInfo. */ + interface ICloudRunJobInfo { + + /** CloudRunJobInfo displayName */ + displayName?: (string|null); + + /** CloudRunJobInfo uri */ + uri?: (string|null); + + /** CloudRunJobInfo location */ + location?: (string|null); + } + + /** Represents a CloudRunJobInfo. */ + class CloudRunJobInfo implements ICloudRunJobInfo { + + /** + * Constructs a new CloudRunJobInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo); + + /** CloudRunJobInfo displayName. */ + public displayName: string; + + /** CloudRunJobInfo uri. */ + public uri: string; + + /** CloudRunJobInfo location. */ + public location: string; + + /** + * Creates a new CloudRunJobInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns CloudRunJobInfo instance + */ + public static create(properties?: google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo): google.cloud.networkmanagement.v1beta1.CloudRunJobInfo; + + /** + * Encodes the specified CloudRunJobInfo message. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.CloudRunJobInfo.verify|verify} messages. + * @param message CloudRunJobInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CloudRunJobInfo message, length delimited. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.CloudRunJobInfo.verify|verify} messages. + * @param message CloudRunJobInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CloudRunJobInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CloudRunJobInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.networkmanagement.v1beta1.CloudRunJobInfo; + + /** + * Decodes a CloudRunJobInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CloudRunJobInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.networkmanagement.v1beta1.CloudRunJobInfo; + + /** + * Verifies a CloudRunJobInfo message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CloudRunJobInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CloudRunJobInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.networkmanagement.v1beta1.CloudRunJobInfo; + + /** + * Creates a plain object from a CloudRunJobInfo message. Also converts values to other types if specified. + * @param message CloudRunJobInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.networkmanagement.v1beta1.CloudRunJobInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CloudRunJobInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CloudRunJobInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of an AppEngineVersionInfo. */ interface IAppEngineVersionInfo { @@ -20088,6 +20212,9 @@ export namespace google { /** FieldInfo format */ format?: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format|null); + + /** FieldInfo referencedTypes */ + referencedTypes?: (google.api.ITypeReference[]|null); } /** Represents a FieldInfo. */ @@ -20102,6 +20229,9 @@ export namespace google { /** FieldInfo format. */ public format: (google.api.FieldInfo.Format|keyof typeof google.api.FieldInfo.Format); + /** FieldInfo referencedTypes. */ + public referencedTypes: google.api.ITypeReference[]; + /** * Creates a new FieldInfo instance using the specified properties. * @param [properties] Properties to set @@ -20192,6 +20322,103 @@ export namespace google { } } + /** Properties of a TypeReference. */ + interface ITypeReference { + + /** TypeReference typeName */ + typeName?: (string|null); + } + + /** Represents a TypeReference. */ + class TypeReference implements ITypeReference { + + /** + * Constructs a new TypeReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ITypeReference); + + /** TypeReference typeName. */ + public typeName: string; + + /** + * Creates a new TypeReference instance using the specified properties. + * @param [properties] Properties to set + * @returns TypeReference instance + */ + public static create(properties?: google.api.ITypeReference): google.api.TypeReference; + + /** + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @param message TypeReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ITypeReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TypeReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.TypeReference; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.TypeReference; + + /** + * Verifies a TypeReference message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a TypeReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TypeReference + */ + public static fromObject(object: { [k: string]: any }): google.api.TypeReference; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @param message TypeReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.TypeReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TypeReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TypeReference + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a Http. */ interface IHttp { @@ -20560,6 +20787,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -20577,6 +20807,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -21277,6 +21510,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -21291,6 +21527,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -21369,6 +21608,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -21695,6 +22046,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -21709,6 +22063,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -22033,6 +22390,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -22149,6 +22609,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -22179,6 +22640,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -22228,6 +22692,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -22362,6 +22829,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -22403,6 +22873,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -23250,6 +23723,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -23276,6 +23752,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -24210,6 +24689,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -24268,6 +24750,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -24488,6 +24973,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -24726,6 +25326,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -24748,6 +25351,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -25340,6 +25946,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -25369,6 +25981,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -25491,6 +26109,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -25610,8 +26338,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -25626,8 +26357,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -26160,6 +26894,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Timestamp. */ interface ITimestamp { diff --git a/packages/google-cloud-networkmanagement/protos/protos.js b/packages/google-cloud-networkmanagement/protos/protos.js index 2c66bb619565..9b9cc828bbe4 100644 --- a/packages/google-cloud-networkmanagement/protos/protos.js +++ b/packages/google-cloud-networkmanagement/protos/protos.js @@ -28709,6 +28709,7 @@ * @property {google.cloud.networkmanagement.v1beta1.Endpoint.ICloudFunctionEndpoint|null} [cloudFunction] Endpoint cloudFunction * @property {google.cloud.networkmanagement.v1beta1.Endpoint.IAppEngineVersionEndpoint|null} [appEngineVersion] Endpoint appEngineVersion * @property {google.cloud.networkmanagement.v1beta1.Endpoint.ICloudRunRevisionEndpoint|null} [cloudRunRevision] Endpoint cloudRunRevision + * @property {string|null} [cloudRunJob] Endpoint cloudRunJob * @property {string|null} [network] Endpoint network * @property {google.cloud.networkmanagement.v1beta1.Endpoint.NetworkType|null} [networkType] Endpoint networkType * @property {string|null} [projectId] Endpoint projectId @@ -28857,6 +28858,14 @@ */ Endpoint.prototype.cloudRunRevision = null; + /** + * Endpoint cloudRunJob. + * @member {string} cloudRunJob + * @memberof google.cloud.networkmanagement.v1beta1.Endpoint + * @instance + */ + Endpoint.prototype.cloudRunJob = ""; + /** * Endpoint network. * @member {string} network @@ -28964,6 +28973,8 @@ writer.uint32(/* id 19, wireType 2 =*/154).string(message.fqdn); if (message.gkePod != null && Object.hasOwnProperty.call(message, "gkePod")) writer.uint32(/* id 21, wireType 2 =*/170).string(message.gkePod); + if (message.cloudRunJob != null && Object.hasOwnProperty.call(message, "cloudRunJob")) + writer.uint32(/* id 24, wireType 2 =*/194).string(message.cloudRunJob); return writer; }; @@ -29064,6 +29075,10 @@ message.cloudRunRevision = $root.google.cloud.networkmanagement.v1beta1.Endpoint.CloudRunRevisionEndpoint.decode(reader, reader.uint32()); break; } + case 24: { + message.cloudRunJob = reader.string(); + break; + } case 4: { message.network = reader.string(); break; @@ -29194,6 +29209,9 @@ if (error) return "cloudRunRevision." + error; } + if (message.cloudRunJob != null && message.hasOwnProperty("cloudRunJob")) + if (!$util.isString(message.cloudRunJob)) + return "cloudRunJob: string expected"; if (message.network != null && message.hasOwnProperty("network")) if (!$util.isString(message.network)) return "network: string expected"; @@ -29342,6 +29360,8 @@ throw TypeError(".google.cloud.networkmanagement.v1beta1.Endpoint.cloudRunRevision: object expected"); message.cloudRunRevision = $root.google.cloud.networkmanagement.v1beta1.Endpoint.CloudRunRevisionEndpoint.fromObject(object.cloudRunRevision); } + if (object.cloudRunJob != null) + message.cloudRunJob = String(object.cloudRunJob); if (object.network != null) message.network = String(object.network); switch (object.networkType) { @@ -29403,6 +29423,7 @@ object.redisCluster = ""; object.fqdn = ""; object.gkePod = ""; + object.cloudRunJob = ""; } if (message.ipAddress != null && message.hasOwnProperty("ipAddress")) object.ipAddress = message.ipAddress; @@ -29451,6 +29472,8 @@ object.fqdn = message.fqdn; if (message.gkePod != null && message.hasOwnProperty("gkePod")) object.gkePod = message.gkePod; + if (message.cloudRunJob != null && message.hasOwnProperty("cloudRunJob")) + object.cloudRunJob = message.cloudRunJob; return object; }; @@ -32456,6 +32479,7 @@ * @property {google.cloud.networkmanagement.v1beta1.ICloudFunctionInfo|null} [cloudFunction] Step cloudFunction * @property {google.cloud.networkmanagement.v1beta1.IAppEngineVersionInfo|null} [appEngineVersion] Step appEngineVersion * @property {google.cloud.networkmanagement.v1beta1.ICloudRunRevisionInfo|null} [cloudRunRevision] Step cloudRunRevision + * @property {google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo|null} [cloudRunJob] Step cloudRunJob * @property {google.cloud.networkmanagement.v1beta1.INatInfo|null} [nat] Step nat * @property {google.cloud.networkmanagement.v1beta1.IProxyConnectionInfo|null} [proxyConnection] Step proxyConnection * @property {google.cloud.networkmanagement.v1beta1.ILoadBalancerBackendInfo|null} [loadBalancerBackendInfo] Step loadBalancerBackendInfo @@ -32751,6 +32775,14 @@ */ Step.prototype.cloudRunRevision = null; + /** + * Step cloudRunJob. + * @member {google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo|null|undefined} cloudRunJob + * @memberof google.cloud.networkmanagement.v1beta1.Step + * @instance + */ + Step.prototype.cloudRunJob = null; + /** * Step nat. * @member {google.cloud.networkmanagement.v1beta1.INatInfo|null|undefined} nat @@ -32804,12 +32836,12 @@ /** * Step stepInfo. - * @member {"instance"|"firewall"|"route"|"endpoint"|"googleService"|"forwardingRule"|"hybridSubnet"|"vpnGateway"|"vpnTunnel"|"interconnectAttachment"|"vpcConnector"|"directVpcEgressConnection"|"serverlessExternalConnection"|"deliver"|"forward"|"abort"|"drop"|"loadBalancer"|"network"|"gkeMaster"|"gkePod"|"ipMasqueradingSkipped"|"gkeNetworkPolicy"|"gkeNetworkPolicySkipped"|"cloudSqlInstance"|"redisInstance"|"redisCluster"|"cloudFunction"|"appEngineVersion"|"cloudRunRevision"|"nat"|"proxyConnection"|"loadBalancerBackendInfo"|"storageBucket"|"serverlessNeg"|"ngfwPacketInspection"|undefined} stepInfo + * @member {"instance"|"firewall"|"route"|"endpoint"|"googleService"|"forwardingRule"|"hybridSubnet"|"vpnGateway"|"vpnTunnel"|"interconnectAttachment"|"vpcConnector"|"directVpcEgressConnection"|"serverlessExternalConnection"|"deliver"|"forward"|"abort"|"drop"|"loadBalancer"|"network"|"gkeMaster"|"gkePod"|"ipMasqueradingSkipped"|"gkeNetworkPolicy"|"gkeNetworkPolicySkipped"|"cloudSqlInstance"|"redisInstance"|"redisCluster"|"cloudFunction"|"appEngineVersion"|"cloudRunRevision"|"cloudRunJob"|"nat"|"proxyConnection"|"loadBalancerBackendInfo"|"storageBucket"|"serverlessNeg"|"ngfwPacketInspection"|undefined} stepInfo * @memberof google.cloud.networkmanagement.v1beta1.Step * @instance */ Object.defineProperty(Step.prototype, "stepInfo", { - get: $util.oneOfGetter($oneOfFields = ["instance", "firewall", "route", "endpoint", "googleService", "forwardingRule", "hybridSubnet", "vpnGateway", "vpnTunnel", "interconnectAttachment", "vpcConnector", "directVpcEgressConnection", "serverlessExternalConnection", "deliver", "forward", "abort", "drop", "loadBalancer", "network", "gkeMaster", "gkePod", "ipMasqueradingSkipped", "gkeNetworkPolicy", "gkeNetworkPolicySkipped", "cloudSqlInstance", "redisInstance", "redisCluster", "cloudFunction", "appEngineVersion", "cloudRunRevision", "nat", "proxyConnection", "loadBalancerBackendInfo", "storageBucket", "serverlessNeg", "ngfwPacketInspection"]), + get: $util.oneOfGetter($oneOfFields = ["instance", "firewall", "route", "endpoint", "googleService", "forwardingRule", "hybridSubnet", "vpnGateway", "vpnTunnel", "interconnectAttachment", "vpcConnector", "directVpcEgressConnection", "serverlessExternalConnection", "deliver", "forward", "abort", "drop", "loadBalancer", "network", "gkeMaster", "gkePod", "ipMasqueradingSkipped", "gkeNetworkPolicy", "gkeNetworkPolicySkipped", "cloudSqlInstance", "redisInstance", "redisCluster", "cloudFunction", "appEngineVersion", "cloudRunRevision", "cloudRunJob", "nat", "proxyConnection", "loadBalancerBackendInfo", "storageBucket", "serverlessNeg", "ngfwPacketInspection"]), set: $util.oneOfSetter($oneOfFields) }); @@ -32917,6 +32949,8 @@ $root.google.cloud.networkmanagement.v1beta1.GkeNetworkPolicySkippedInfo.encode(message.gkeNetworkPolicySkipped, writer.uint32(/* id 40, wireType 2 =*/322).fork()).ldelim(); if (message.ngfwPacketInspection != null && Object.hasOwnProperty.call(message, "ngfwPacketInspection")) $root.google.cloud.networkmanagement.v1beta1.NgfwPacketInspectionInfo.encode(message.ngfwPacketInspection, writer.uint32(/* id 42, wireType 2 =*/338).fork()).ldelim(); + if (message.cloudRunJob != null && Object.hasOwnProperty.call(message, "cloudRunJob")) + $root.google.cloud.networkmanagement.v1beta1.CloudRunJobInfo.encode(message.cloudRunJob, writer.uint32(/* id 45, wireType 2 =*/362).fork()).ldelim(); return writer; }; @@ -33089,6 +33123,10 @@ message.cloudRunRevision = $root.google.cloud.networkmanagement.v1beta1.CloudRunRevisionInfo.decode(reader, reader.uint32()); break; } + case 45: { + message.cloudRunJob = $root.google.cloud.networkmanagement.v1beta1.CloudRunJobInfo.decode(reader, reader.uint32()); + break; + } case 25: { message.nat = $root.google.cloud.networkmanagement.v1beta1.NatInfo.decode(reader, reader.uint32()); break; @@ -33169,6 +33207,7 @@ case 23: case 25: case 26: + case 50: case 29: case 30: case 31: @@ -33508,6 +33547,16 @@ return "cloudRunRevision." + error; } } + if (message.cloudRunJob != null && message.hasOwnProperty("cloudRunJob")) { + if (properties.stepInfo === 1) + return "stepInfo: multiple values"; + properties.stepInfo = 1; + { + var error = $root.google.cloud.networkmanagement.v1beta1.CloudRunJobInfo.verify(message.cloudRunJob); + if (error) + return "cloudRunJob." + error; + } + } if (message.nat != null && message.hasOwnProperty("nat")) { if (properties.stepInfo === 1) return "stepInfo: multiple values"; @@ -33644,6 +33693,10 @@ case 26: message.state = 26; break; + case "START_FROM_CLOUD_RUN_JOB": + case 50: + message.state = 50; + break; case "START_FROM_STORAGE_BUCKET": case 29: message.state = 29; @@ -33931,6 +33984,11 @@ throw TypeError(".google.cloud.networkmanagement.v1beta1.Step.cloudRunRevision: object expected"); message.cloudRunRevision = $root.google.cloud.networkmanagement.v1beta1.CloudRunRevisionInfo.fromObject(object.cloudRunRevision); } + if (object.cloudRunJob != null) { + if (typeof object.cloudRunJob !== "object") + throw TypeError(".google.cloud.networkmanagement.v1beta1.Step.cloudRunJob: object expected"); + message.cloudRunJob = $root.google.cloud.networkmanagement.v1beta1.CloudRunJobInfo.fromObject(object.cloudRunJob); + } if (object.nat != null) { if (typeof object.nat !== "object") throw TypeError(".google.cloud.networkmanagement.v1beta1.Step.nat: object expected"); @@ -34171,6 +34229,11 @@ if (options.oneofs) object.stepInfo = "ngfwPacketInspection"; } + if (message.cloudRunJob != null && message.hasOwnProperty("cloudRunJob")) { + object.cloudRunJob = $root.google.cloud.networkmanagement.v1beta1.CloudRunJobInfo.toObject(message.cloudRunJob, options); + if (options.oneofs) + object.stepInfo = "cloudRunJob"; + } return object; }; @@ -34217,6 +34280,7 @@ * @property {number} START_FROM_CLOUD_FUNCTION=23 START_FROM_CLOUD_FUNCTION value * @property {number} START_FROM_APP_ENGINE_VERSION=25 START_FROM_APP_ENGINE_VERSION value * @property {number} START_FROM_CLOUD_RUN_REVISION=26 START_FROM_CLOUD_RUN_REVISION value + * @property {number} START_FROM_CLOUD_RUN_JOB=50 START_FROM_CLOUD_RUN_JOB value * @property {number} START_FROM_STORAGE_BUCKET=29 START_FROM_STORAGE_BUCKET value * @property {number} START_FROM_PSC_PUBLISHED_SERVICE=30 START_FROM_PSC_PUBLISHED_SERVICE value * @property {number} START_FROM_SERVERLESS_NEG=31 START_FROM_SERVERLESS_NEG value @@ -34266,6 +34330,7 @@ values[valuesById[23] = "START_FROM_CLOUD_FUNCTION"] = 23; values[valuesById[25] = "START_FROM_APP_ENGINE_VERSION"] = 25; values[valuesById[26] = "START_FROM_CLOUD_RUN_REVISION"] = 26; + values[valuesById[50] = "START_FROM_CLOUD_RUN_JOB"] = 50; values[valuesById[29] = "START_FROM_STORAGE_BUCKET"] = 29; values[valuesById[30] = "START_FROM_PSC_PUBLISHED_SERVICE"] = 30; values[valuesById[31] = "START_FROM_SERVERLESS_NEG"] = 31; @@ -40385,6 +40450,7 @@ case 16: case 17: case 19: + case 20: break; } if (message.resourceUri != null && message.hasOwnProperty("resourceUri")) @@ -40509,6 +40575,10 @@ case 19: message.target = 19; break; + case "CLOUD_RUN_JOB": + case 20: + message.target = 20; + break; } if (object.resourceUri != null) message.resourceUri = String(object.resourceUri); @@ -40638,6 +40708,7 @@ * @property {number} REDIS_INSTANCE=16 REDIS_INSTANCE value * @property {number} REDIS_CLUSTER=17 REDIS_CLUSTER value * @property {number} GKE_POD=19 GKE_POD value + * @property {number} CLOUD_RUN_JOB=20 CLOUD_RUN_JOB value */ DeliverInfo.Target = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -40660,6 +40731,7 @@ values[valuesById[16] = "REDIS_INSTANCE"] = 16; values[valuesById[17] = "REDIS_CLUSTER"] = 17; values[valuesById[19] = "GKE_POD"] = 19; + values[valuesById[20] = "CLOUD_RUN_JOB"] = 20; return values; })(); @@ -41948,6 +42020,7 @@ case 55: case 56: case 29: + case 113: case 37: case 39: case 40: @@ -42293,6 +42366,10 @@ case 29: message.cause = 29; break; + case "CLOUD_RUN_JOB_NOT_READY": + case 113: + message.cause = 113; + break; case "DROPPED_INSIDE_PSC_SERVICE_PRODUCER": case 37: message.cause = 37; @@ -42600,6 +42677,7 @@ * @property {number} HYBRID_NEG_NON_DYNAMIC_ROUTE_MATCHED=55 HYBRID_NEG_NON_DYNAMIC_ROUTE_MATCHED value * @property {number} HYBRID_NEG_NON_LOCAL_DYNAMIC_ROUTE_MATCHED=56 HYBRID_NEG_NON_LOCAL_DYNAMIC_ROUTE_MATCHED value * @property {number} CLOUD_RUN_REVISION_NOT_READY=29 CLOUD_RUN_REVISION_NOT_READY value + * @property {number} CLOUD_RUN_JOB_NOT_READY=113 CLOUD_RUN_JOB_NOT_READY value * @property {number} DROPPED_INSIDE_PSC_SERVICE_PRODUCER=37 DROPPED_INSIDE_PSC_SERVICE_PRODUCER value * @property {number} LOAD_BALANCER_HAS_NO_PROXY_SUBNET=39 LOAD_BALANCER_HAS_NO_PROXY_SUBNET value * @property {number} CLOUD_NAT_NO_ADDRESSES=40 CLOUD_NAT_NO_ADDRESSES value @@ -42708,6 +42786,7 @@ values[valuesById[55] = "HYBRID_NEG_NON_DYNAMIC_ROUTE_MATCHED"] = 55; values[valuesById[56] = "HYBRID_NEG_NON_LOCAL_DYNAMIC_ROUTE_MATCHED"] = 56; values[valuesById[29] = "CLOUD_RUN_REVISION_NOT_READY"] = 29; + values[valuesById[113] = "CLOUD_RUN_JOB_NOT_READY"] = 113; values[valuesById[37] = "DROPPED_INSIDE_PSC_SERVICE_PRODUCER"] = 37; values[valuesById[39] = "LOAD_BALANCER_HAS_NO_PROXY_SUBNET"] = 39; values[valuesById[40] = "CLOUD_NAT_NO_ADDRESSES"] = 40; @@ -45675,301 +45754,26 @@ return CloudRunRevisionInfo; })(); - v1beta1.AppEngineVersionInfo = (function() { - - /** - * Properties of an AppEngineVersionInfo. - * @memberof google.cloud.networkmanagement.v1beta1 - * @interface IAppEngineVersionInfo - * @property {string|null} [displayName] AppEngineVersionInfo displayName - * @property {string|null} [uri] AppEngineVersionInfo uri - * @property {string|null} [runtime] AppEngineVersionInfo runtime - * @property {string|null} [environment] AppEngineVersionInfo environment - */ - - /** - * Constructs a new AppEngineVersionInfo. - * @memberof google.cloud.networkmanagement.v1beta1 - * @classdesc Represents an AppEngineVersionInfo. - * @implements IAppEngineVersionInfo - * @constructor - * @param {google.cloud.networkmanagement.v1beta1.IAppEngineVersionInfo=} [properties] Properties to set - */ - function AppEngineVersionInfo(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * AppEngineVersionInfo displayName. - * @member {string} displayName - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @instance - */ - AppEngineVersionInfo.prototype.displayName = ""; - - /** - * AppEngineVersionInfo uri. - * @member {string} uri - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @instance - */ - AppEngineVersionInfo.prototype.uri = ""; - - /** - * AppEngineVersionInfo runtime. - * @member {string} runtime - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @instance - */ - AppEngineVersionInfo.prototype.runtime = ""; - - /** - * AppEngineVersionInfo environment. - * @member {string} environment - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @instance - */ - AppEngineVersionInfo.prototype.environment = ""; - - /** - * Creates a new AppEngineVersionInfo instance using the specified properties. - * @function create - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @static - * @param {google.cloud.networkmanagement.v1beta1.IAppEngineVersionInfo=} [properties] Properties to set - * @returns {google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo} AppEngineVersionInfo instance - */ - AppEngineVersionInfo.create = function create(properties) { - return new AppEngineVersionInfo(properties); - }; - - /** - * Encodes the specified AppEngineVersionInfo message. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo.verify|verify} messages. - * @function encode - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @static - * @param {google.cloud.networkmanagement.v1beta1.IAppEngineVersionInfo} message AppEngineVersionInfo message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - AppEngineVersionInfo.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayName); - if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.uri); - if (message.runtime != null && Object.hasOwnProperty.call(message, "runtime")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.runtime); - if (message.environment != null && Object.hasOwnProperty.call(message, "environment")) - writer.uint32(/* id 4, wireType 2 =*/34).string(message.environment); - return writer; - }; - - /** - * Encodes the specified AppEngineVersionInfo message, length delimited. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo.verify|verify} messages. - * @function encodeDelimited - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @static - * @param {google.cloud.networkmanagement.v1beta1.IAppEngineVersionInfo} message AppEngineVersionInfo message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - AppEngineVersionInfo.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an AppEngineVersionInfo message from the specified reader or buffer. - * @function decode - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo} AppEngineVersionInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - AppEngineVersionInfo.decode = function decode(reader, length, error) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo(); - while (reader.pos < end) { - var tag = reader.uint32(); - if (tag === error) - break; - switch (tag >>> 3) { - case 1: { - message.displayName = reader.string(); - break; - } - case 2: { - message.uri = reader.string(); - break; - } - case 3: { - message.runtime = reader.string(); - break; - } - case 4: { - message.environment = reader.string(); - break; - } - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an AppEngineVersionInfo message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo} AppEngineVersionInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - AppEngineVersionInfo.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an AppEngineVersionInfo message. - * @function verify - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - AppEngineVersionInfo.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.displayName != null && message.hasOwnProperty("displayName")) - if (!$util.isString(message.displayName)) - return "displayName: string expected"; - if (message.uri != null && message.hasOwnProperty("uri")) - if (!$util.isString(message.uri)) - return "uri: string expected"; - if (message.runtime != null && message.hasOwnProperty("runtime")) - if (!$util.isString(message.runtime)) - return "runtime: string expected"; - if (message.environment != null && message.hasOwnProperty("environment")) - if (!$util.isString(message.environment)) - return "environment: string expected"; - return null; - }; - - /** - * Creates an AppEngineVersionInfo message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @static - * @param {Object.} object Plain object - * @returns {google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo} AppEngineVersionInfo - */ - AppEngineVersionInfo.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo) - return object; - var message = new $root.google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo(); - if (object.displayName != null) - message.displayName = String(object.displayName); - if (object.uri != null) - message.uri = String(object.uri); - if (object.runtime != null) - message.runtime = String(object.runtime); - if (object.environment != null) - message.environment = String(object.environment); - return message; - }; - - /** - * Creates a plain object from an AppEngineVersionInfo message. Also converts values to other types if specified. - * @function toObject - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @static - * @param {google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo} message AppEngineVersionInfo - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - AppEngineVersionInfo.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.displayName = ""; - object.uri = ""; - object.runtime = ""; - object.environment = ""; - } - if (message.displayName != null && message.hasOwnProperty("displayName")) - object.displayName = message.displayName; - if (message.uri != null && message.hasOwnProperty("uri")) - object.uri = message.uri; - if (message.runtime != null && message.hasOwnProperty("runtime")) - object.runtime = message.runtime; - if (message.environment != null && message.hasOwnProperty("environment")) - object.environment = message.environment; - return object; - }; - - /** - * Converts this AppEngineVersionInfo to JSON. - * @function toJSON - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @instance - * @returns {Object.} JSON object - */ - AppEngineVersionInfo.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - /** - * Gets the default type url for AppEngineVersionInfo - * @function getTypeUrl - * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo - * @static - * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns {string} The default type url - */ - AppEngineVersionInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { - if (typeUrlPrefix === undefined) { - typeUrlPrefix = "type.googleapis.com"; - } - return typeUrlPrefix + "/google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo"; - }; - - return AppEngineVersionInfo; - })(); - - v1beta1.VpcConnectorInfo = (function() { + v1beta1.CloudRunJobInfo = (function() { /** - * Properties of a VpcConnectorInfo. + * Properties of a CloudRunJobInfo. * @memberof google.cloud.networkmanagement.v1beta1 - * @interface IVpcConnectorInfo - * @property {string|null} [displayName] VpcConnectorInfo displayName - * @property {string|null} [uri] VpcConnectorInfo uri - * @property {string|null} [location] VpcConnectorInfo location + * @interface ICloudRunJobInfo + * @property {string|null} [displayName] CloudRunJobInfo displayName + * @property {string|null} [uri] CloudRunJobInfo uri + * @property {string|null} [location] CloudRunJobInfo location */ /** - * Constructs a new VpcConnectorInfo. + * Constructs a new CloudRunJobInfo. * @memberof google.cloud.networkmanagement.v1beta1 - * @classdesc Represents a VpcConnectorInfo. - * @implements IVpcConnectorInfo + * @classdesc Represents a CloudRunJobInfo. + * @implements ICloudRunJobInfo * @constructor - * @param {google.cloud.networkmanagement.v1beta1.IVpcConnectorInfo=} [properties] Properties to set + * @param {google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo=} [properties] Properties to set */ - function VpcConnectorInfo(properties) { + function CloudRunJobInfo(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -45977,51 +45781,51 @@ } /** - * VpcConnectorInfo displayName. + * CloudRunJobInfo displayName. * @member {string} displayName - * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo * @instance */ - VpcConnectorInfo.prototype.displayName = ""; + CloudRunJobInfo.prototype.displayName = ""; /** - * VpcConnectorInfo uri. + * CloudRunJobInfo uri. * @member {string} uri - * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo * @instance */ - VpcConnectorInfo.prototype.uri = ""; + CloudRunJobInfo.prototype.uri = ""; /** - * VpcConnectorInfo location. + * CloudRunJobInfo location. * @member {string} location - * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo * @instance */ - VpcConnectorInfo.prototype.location = ""; + CloudRunJobInfo.prototype.location = ""; /** - * Creates a new VpcConnectorInfo instance using the specified properties. + * Creates a new CloudRunJobInfo instance using the specified properties. * @function create - * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo * @static - * @param {google.cloud.networkmanagement.v1beta1.IVpcConnectorInfo=} [properties] Properties to set - * @returns {google.cloud.networkmanagement.v1beta1.VpcConnectorInfo} VpcConnectorInfo instance + * @param {google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo=} [properties] Properties to set + * @returns {google.cloud.networkmanagement.v1beta1.CloudRunJobInfo} CloudRunJobInfo instance */ - VpcConnectorInfo.create = function create(properties) { - return new VpcConnectorInfo(properties); + CloudRunJobInfo.create = function create(properties) { + return new CloudRunJobInfo(properties); }; /** - * Encodes the specified VpcConnectorInfo message. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.VpcConnectorInfo.verify|verify} messages. + * Encodes the specified CloudRunJobInfo message. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.CloudRunJobInfo.verify|verify} messages. * @function encode - * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo * @static - * @param {google.cloud.networkmanagement.v1beta1.IVpcConnectorInfo} message VpcConnectorInfo message or plain object to encode + * @param {google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo} message CloudRunJobInfo message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - VpcConnectorInfo.encode = function encode(message, writer) { + CloudRunJobInfo.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) @@ -46034,33 +45838,560 @@ }; /** - * Encodes the specified VpcConnectorInfo message, length delimited. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.VpcConnectorInfo.verify|verify} messages. + * Encodes the specified CloudRunJobInfo message, length delimited. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.CloudRunJobInfo.verify|verify} messages. * @function encodeDelimited - * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo * @static - * @param {google.cloud.networkmanagement.v1beta1.IVpcConnectorInfo} message VpcConnectorInfo message or plain object to encode + * @param {google.cloud.networkmanagement.v1beta1.ICloudRunJobInfo} message CloudRunJobInfo message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - VpcConnectorInfo.encodeDelimited = function encodeDelimited(message, writer) { + CloudRunJobInfo.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a VpcConnectorInfo message from the specified reader or buffer. + * Decodes a CloudRunJobInfo message from the specified reader or buffer. * @function decode - * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.networkmanagement.v1beta1.VpcConnectorInfo} VpcConnectorInfo + * @returns {google.cloud.networkmanagement.v1beta1.CloudRunJobInfo} CloudRunJobInfo * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - VpcConnectorInfo.decode = function decode(reader, length, error) { + CloudRunJobInfo.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.networkmanagement.v1beta1.VpcConnectorInfo(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.networkmanagement.v1beta1.CloudRunJobInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.displayName = reader.string(); + break; + } + case 2: { + message.uri = reader.string(); + break; + } + case 3: { + message.location = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CloudRunJobInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.networkmanagement.v1beta1.CloudRunJobInfo} CloudRunJobInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CloudRunJobInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CloudRunJobInfo message. + * @function verify + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CloudRunJobInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.location != null && message.hasOwnProperty("location")) + if (!$util.isString(message.location)) + return "location: string expected"; + return null; + }; + + /** + * Creates a CloudRunJobInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.networkmanagement.v1beta1.CloudRunJobInfo} CloudRunJobInfo + */ + CloudRunJobInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.networkmanagement.v1beta1.CloudRunJobInfo) + return object; + var message = new $root.google.cloud.networkmanagement.v1beta1.CloudRunJobInfo(); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.uri != null) + message.uri = String(object.uri); + if (object.location != null) + message.location = String(object.location); + return message; + }; + + /** + * Creates a plain object from a CloudRunJobInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo + * @static + * @param {google.cloud.networkmanagement.v1beta1.CloudRunJobInfo} message CloudRunJobInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CloudRunJobInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.displayName = ""; + object.uri = ""; + object.location = ""; + } + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.location != null && message.hasOwnProperty("location")) + object.location = message.location; + return object; + }; + + /** + * Converts this CloudRunJobInfo to JSON. + * @function toJSON + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo + * @instance + * @returns {Object.} JSON object + */ + CloudRunJobInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CloudRunJobInfo + * @function getTypeUrl + * @memberof google.cloud.networkmanagement.v1beta1.CloudRunJobInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CloudRunJobInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.networkmanagement.v1beta1.CloudRunJobInfo"; + }; + + return CloudRunJobInfo; + })(); + + v1beta1.AppEngineVersionInfo = (function() { + + /** + * Properties of an AppEngineVersionInfo. + * @memberof google.cloud.networkmanagement.v1beta1 + * @interface IAppEngineVersionInfo + * @property {string|null} [displayName] AppEngineVersionInfo displayName + * @property {string|null} [uri] AppEngineVersionInfo uri + * @property {string|null} [runtime] AppEngineVersionInfo runtime + * @property {string|null} [environment] AppEngineVersionInfo environment + */ + + /** + * Constructs a new AppEngineVersionInfo. + * @memberof google.cloud.networkmanagement.v1beta1 + * @classdesc Represents an AppEngineVersionInfo. + * @implements IAppEngineVersionInfo + * @constructor + * @param {google.cloud.networkmanagement.v1beta1.IAppEngineVersionInfo=} [properties] Properties to set + */ + function AppEngineVersionInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * AppEngineVersionInfo displayName. + * @member {string} displayName + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @instance + */ + AppEngineVersionInfo.prototype.displayName = ""; + + /** + * AppEngineVersionInfo uri. + * @member {string} uri + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @instance + */ + AppEngineVersionInfo.prototype.uri = ""; + + /** + * AppEngineVersionInfo runtime. + * @member {string} runtime + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @instance + */ + AppEngineVersionInfo.prototype.runtime = ""; + + /** + * AppEngineVersionInfo environment. + * @member {string} environment + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @instance + */ + AppEngineVersionInfo.prototype.environment = ""; + + /** + * Creates a new AppEngineVersionInfo instance using the specified properties. + * @function create + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @static + * @param {google.cloud.networkmanagement.v1beta1.IAppEngineVersionInfo=} [properties] Properties to set + * @returns {google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo} AppEngineVersionInfo instance + */ + AppEngineVersionInfo.create = function create(properties) { + return new AppEngineVersionInfo(properties); + }; + + /** + * Encodes the specified AppEngineVersionInfo message. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @static + * @param {google.cloud.networkmanagement.v1beta1.IAppEngineVersionInfo} message AppEngineVersionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AppEngineVersionInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayName); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.uri); + if (message.runtime != null && Object.hasOwnProperty.call(message, "runtime")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.runtime); + if (message.environment != null && Object.hasOwnProperty.call(message, "environment")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.environment); + return writer; + }; + + /** + * Encodes the specified AppEngineVersionInfo message, length delimited. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @static + * @param {google.cloud.networkmanagement.v1beta1.IAppEngineVersionInfo} message AppEngineVersionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AppEngineVersionInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AppEngineVersionInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo} AppEngineVersionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AppEngineVersionInfo.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.displayName = reader.string(); + break; + } + case 2: { + message.uri = reader.string(); + break; + } + case 3: { + message.runtime = reader.string(); + break; + } + case 4: { + message.environment = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AppEngineVersionInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo} AppEngineVersionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AppEngineVersionInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AppEngineVersionInfo message. + * @function verify + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AppEngineVersionInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.runtime != null && message.hasOwnProperty("runtime")) + if (!$util.isString(message.runtime)) + return "runtime: string expected"; + if (message.environment != null && message.hasOwnProperty("environment")) + if (!$util.isString(message.environment)) + return "environment: string expected"; + return null; + }; + + /** + * Creates an AppEngineVersionInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo} AppEngineVersionInfo + */ + AppEngineVersionInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo) + return object; + var message = new $root.google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo(); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.uri != null) + message.uri = String(object.uri); + if (object.runtime != null) + message.runtime = String(object.runtime); + if (object.environment != null) + message.environment = String(object.environment); + return message; + }; + + /** + * Creates a plain object from an AppEngineVersionInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @static + * @param {google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo} message AppEngineVersionInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AppEngineVersionInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.displayName = ""; + object.uri = ""; + object.runtime = ""; + object.environment = ""; + } + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.runtime != null && message.hasOwnProperty("runtime")) + object.runtime = message.runtime; + if (message.environment != null && message.hasOwnProperty("environment")) + object.environment = message.environment; + return object; + }; + + /** + * Converts this AppEngineVersionInfo to JSON. + * @function toJSON + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @instance + * @returns {Object.} JSON object + */ + AppEngineVersionInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AppEngineVersionInfo + * @function getTypeUrl + * @memberof google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AppEngineVersionInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.networkmanagement.v1beta1.AppEngineVersionInfo"; + }; + + return AppEngineVersionInfo; + })(); + + v1beta1.VpcConnectorInfo = (function() { + + /** + * Properties of a VpcConnectorInfo. + * @memberof google.cloud.networkmanagement.v1beta1 + * @interface IVpcConnectorInfo + * @property {string|null} [displayName] VpcConnectorInfo displayName + * @property {string|null} [uri] VpcConnectorInfo uri + * @property {string|null} [location] VpcConnectorInfo location + */ + + /** + * Constructs a new VpcConnectorInfo. + * @memberof google.cloud.networkmanagement.v1beta1 + * @classdesc Represents a VpcConnectorInfo. + * @implements IVpcConnectorInfo + * @constructor + * @param {google.cloud.networkmanagement.v1beta1.IVpcConnectorInfo=} [properties] Properties to set + */ + function VpcConnectorInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * VpcConnectorInfo displayName. + * @member {string} displayName + * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @instance + */ + VpcConnectorInfo.prototype.displayName = ""; + + /** + * VpcConnectorInfo uri. + * @member {string} uri + * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @instance + */ + VpcConnectorInfo.prototype.uri = ""; + + /** + * VpcConnectorInfo location. + * @member {string} location + * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @instance + */ + VpcConnectorInfo.prototype.location = ""; + + /** + * Creates a new VpcConnectorInfo instance using the specified properties. + * @function create + * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @static + * @param {google.cloud.networkmanagement.v1beta1.IVpcConnectorInfo=} [properties] Properties to set + * @returns {google.cloud.networkmanagement.v1beta1.VpcConnectorInfo} VpcConnectorInfo instance + */ + VpcConnectorInfo.create = function create(properties) { + return new VpcConnectorInfo(properties); + }; + + /** + * Encodes the specified VpcConnectorInfo message. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.VpcConnectorInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @static + * @param {google.cloud.networkmanagement.v1beta1.IVpcConnectorInfo} message VpcConnectorInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VpcConnectorInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayName); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.uri); + if (message.location != null && Object.hasOwnProperty.call(message, "location")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.location); + return writer; + }; + + /** + * Encodes the specified VpcConnectorInfo message, length delimited. Does not implicitly {@link google.cloud.networkmanagement.v1beta1.VpcConnectorInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @static + * @param {google.cloud.networkmanagement.v1beta1.IVpcConnectorInfo} message VpcConnectorInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VpcConnectorInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VpcConnectorInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.networkmanagement.v1beta1.VpcConnectorInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.networkmanagement.v1beta1.VpcConnectorInfo} VpcConnectorInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VpcConnectorInfo.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.networkmanagement.v1beta1.VpcConnectorInfo(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -56805,6 +57136,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -56816,6 +57148,7 @@ * @param {google.api.IFieldInfo=} [properties] Properties to set */ function FieldInfo(properties) { + this.referencedTypes = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -56830,6 +57163,14 @@ */ FieldInfo.prototype.format = 0; + /** + * FieldInfo referencedTypes. + * @member {Array.} referencedTypes + * @memberof google.api.FieldInfo + * @instance + */ + FieldInfo.prototype.referencedTypes = $util.emptyArray; + /** * Creates a new FieldInfo instance using the specified properties. * @function create @@ -56856,6 +57197,9 @@ writer = $Writer.create(); if (message.format != null && Object.hasOwnProperty.call(message, "format")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.format); + if (message.referencedTypes != null && message.referencedTypes.length) + for (var i = 0; i < message.referencedTypes.length; ++i) + $root.google.api.TypeReference.encode(message.referencedTypes[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -56896,6 +57240,12 @@ message.format = reader.int32(); break; } + case 2: { + if (!(message.referencedTypes && message.referencedTypes.length)) + message.referencedTypes = []; + message.referencedTypes.push($root.google.api.TypeReference.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -56942,6 +57292,15 @@ case 4: break; } + if (message.referencedTypes != null && message.hasOwnProperty("referencedTypes")) { + if (!Array.isArray(message.referencedTypes)) + return "referencedTypes: array expected"; + for (var i = 0; i < message.referencedTypes.length; ++i) { + var error = $root.google.api.TypeReference.verify(message.referencedTypes[i]); + if (error) + return "referencedTypes." + error; + } + } return null; }; @@ -56985,6 +57344,16 @@ message.format = 4; break; } + if (object.referencedTypes) { + if (!Array.isArray(object.referencedTypes)) + throw TypeError(".google.api.FieldInfo.referencedTypes: array expected"); + message.referencedTypes = []; + for (var i = 0; i < object.referencedTypes.length; ++i) { + if (typeof object.referencedTypes[i] !== "object") + throw TypeError(".google.api.FieldInfo.referencedTypes: object expected"); + message.referencedTypes[i] = $root.google.api.TypeReference.fromObject(object.referencedTypes[i]); + } + } return message; }; @@ -57001,10 +57370,17 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.referencedTypes = []; if (options.defaults) object.format = options.enums === String ? "FORMAT_UNSPECIFIED" : 0; if (message.format != null && message.hasOwnProperty("format")) object.format = options.enums === String ? $root.google.api.FieldInfo.Format[message.format] === undefined ? message.format : $root.google.api.FieldInfo.Format[message.format] : message.format; + if (message.referencedTypes && message.referencedTypes.length) { + object.referencedTypes = []; + for (var j = 0; j < message.referencedTypes.length; ++j) + object.referencedTypes[j] = $root.google.api.TypeReference.toObject(message.referencedTypes[j], options); + } return object; }; @@ -57057,6 +57433,211 @@ return FieldInfo; })(); + api.TypeReference = (function() { + + /** + * Properties of a TypeReference. + * @memberof google.api + * @interface ITypeReference + * @property {string|null} [typeName] TypeReference typeName + */ + + /** + * Constructs a new TypeReference. + * @memberof google.api + * @classdesc Represents a TypeReference. + * @implements ITypeReference + * @constructor + * @param {google.api.ITypeReference=} [properties] Properties to set + */ + function TypeReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TypeReference typeName. + * @member {string} typeName + * @memberof google.api.TypeReference + * @instance + */ + TypeReference.prototype.typeName = ""; + + /** + * Creates a new TypeReference instance using the specified properties. + * @function create + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference=} [properties] Properties to set + * @returns {google.api.TypeReference} TypeReference instance + */ + TypeReference.create = function create(properties) { + return new TypeReference(properties); + }; + + /** + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encode + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TypeReference.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.typeName); + return writer; + }; + + /** + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TypeReference.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TypeReference message from the specified reader or buffer. + * @function decode + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TypeReference.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.TypeReference(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.typeName = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TypeReference.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TypeReference message. + * @function verify + * @memberof google.api.TypeReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TypeReference.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.typeName != null && message.hasOwnProperty("typeName")) + if (!$util.isString(message.typeName)) + return "typeName: string expected"; + return null; + }; + + /** + * Creates a TypeReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.TypeReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.TypeReference} TypeReference + */ + TypeReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.TypeReference) + return object; + var message = new $root.google.api.TypeReference(); + if (object.typeName != null) + message.typeName = String(object.typeName); + return message; + }; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.TypeReference + * @static + * @param {google.api.TypeReference} message TypeReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TypeReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.typeName = ""; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + return object; + }; + + /** + * Converts this TypeReference to JSON. + * @function toJSON + * @memberof google.api.TypeReference + * @instance + * @returns {Object.} JSON object + */ + TypeReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TypeReference + * @function getTypeUrl + * @memberof google.api.TypeReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TypeReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.TypeReference"; + }; + + return TypeReference; + })(); + api.Http = (function() { /** @@ -58034,6 +58615,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -58068,6 +58650,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -58100,6 +58690,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -58151,6 +58743,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -58202,6 +58798,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -58244,6 +58845,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -58262,8 +58868,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -58271,6 +58879,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -60093,6 +60703,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -60118,6 +60729,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -60144,6 +60763,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -60184,6 +60805,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -60224,6 +60849,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -60244,6 +60874,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -60260,10 +60895,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -60293,6 +60932,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -61169,6 +62060,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -61180,6 +62072,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -61194,6 +62087,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -61220,6 +62121,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -61250,7 +62154,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -61260,6 +62164,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -61300,6 +62227,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -61320,6 +62255,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -61336,10 +62278,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -61978,6 +62928,251 @@ return values; })(); + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + /** * LaunchStage enum. * @name google.api.LaunchStage @@ -62247,6 +63442,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -62261,6 +63457,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -62285,6 +63482,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -62307,6 +63505,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -62357,6 +63556,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -62478,6 +63685,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -62550,6 +63760,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -62652,6 +63868,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -62706,6 +63929,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -62758,6 +63982,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -62821,6 +64052,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -62886,6 +64121,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -62942,6 +64178,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -62990,6 +64231,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -63095,6 +64337,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -63147,6 +64397,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -63239,6 +64491,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -63352,6 +64608,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -63451,6 +64716,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -63480,6 +64765,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -63525,6 +64811,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -65569,6 +66857,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -65629,6 +66918,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -65666,6 +66963,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -65728,6 +67027,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -65796,6 +67099,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -65845,6 +67157,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -65869,6 +67201,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -65889,6 +67222,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -68207,6 +69542,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference @@ -68328,6 +69664,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -68410,6 +69754,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); 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(); @@ -68513,6 +69859,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -68652,6 +70002,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -68845,6 +70200,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -68947,6 +70307,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; object[".google.api.fieldInfo"] = null; } @@ -68980,6 +70341,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -69254,6 +70617,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -69295,6 +70659,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -69394,6 +70762,488 @@ return EditionDefault; })(); + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionRemoved = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionRemoved = 999; + break; + case "EDITION_2023": + case 1000: + message.editionRemoved = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionRemoved = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionRemoved = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionRemoved = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionRemoved = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionRemoved = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionRemoved = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionRemoved = 2147483647; + break; + } + return message; + }; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FeatureSupport.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; + return object; + }; + + /** + * Converts this FeatureSupport to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + * @returns {Object.} JSON object + */ + FeatureSupport.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FeatureSupport + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; + }; + + return FeatureSupport; + })(); + return FieldOptions; })(); @@ -69986,6 +71836,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -70029,6 +71880,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -70067,6 +71926,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); 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(); @@ -70118,6 +71979,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -70170,6 +72035,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -70203,6 +72073,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -70235,6 +72110,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -70242,6 +72118,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -71709,6 +73587,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -71774,6 +73654,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -71810,6 +73706,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -71870,6 +73770,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -71960,6 +73868,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -72099,6 +74027,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -72122,6 +74098,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -72135,6 +74113,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -72262,6 +74244,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -72446,6 +74641,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -72463,6 +74659,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -72511,6 +74708,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -72563,6 +74764,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -72671,7 +74876,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -72698,12 +74904,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -72729,10 +74943,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -72773,8 +74989,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -72817,6 +75037,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -72829,10 +75050,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -72860,6 +75086,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -72901,10 +75131,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -72923,13 +75158,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -74144,6 +76382,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Timestamp = (function() { /** diff --git a/packages/google-cloud-networkmanagement/protos/protos.json b/packages/google-cloud-networkmanagement/protos/protos.json index 59297a195419..2bb1c2c49b14 100644 --- a/packages/google-cloud-networkmanagement/protos/protos.json +++ b/packages/google-cloud-networkmanagement/protos/protos.json @@ -3688,6 +3688,10 @@ "type": "CloudRunRevisionEndpoint", "id": 12 }, + "cloudRunJob": { + "type": "string", + "id": 24 + }, "network": { "type": "string", "id": 4 @@ -3959,6 +3963,7 @@ "cloudFunction", "appEngineVersion", "cloudRunRevision", + "cloudRunJob", "nat", "proxyConnection", "loadBalancerBackendInfo", @@ -4108,6 +4113,10 @@ "type": "CloudRunRevisionInfo", "id": 23 }, + "cloudRunJob": { + "type": "CloudRunJobInfo", + "id": 45 + }, "nat": { "type": "NatInfo", "id": 25 @@ -4157,6 +4166,7 @@ "START_FROM_CLOUD_FUNCTION": 23, "START_FROM_APP_ENGINE_VERSION": 25, "START_FROM_CLOUD_RUN_REVISION": 26, + "START_FROM_CLOUD_RUN_JOB": 50, "START_FROM_STORAGE_BUCKET": 29, "START_FROM_PSC_PUBLISHED_SERVICE": 30, "START_FROM_SERVERLESS_NEG": 31, @@ -4934,7 +4944,8 @@ "GOOGLE_MANAGED_SERVICE": 15, "REDIS_INSTANCE": 16, "REDIS_CLUSTER": 17, - "GKE_POD": 19 + "GKE_POD": 19, + "CLOUD_RUN_JOB": 20 } }, "GoogleServiceType": { @@ -5193,6 +5204,7 @@ "HYBRID_NEG_NON_DYNAMIC_ROUTE_MATCHED": 55, "HYBRID_NEG_NON_LOCAL_DYNAMIC_ROUTE_MATCHED": 56, "CLOUD_RUN_REVISION_NOT_READY": 29, + "CLOUD_RUN_JOB_NOT_READY": 113, "DROPPED_INSIDE_PSC_SERVICE_PRODUCER": 37, "LOAD_BALANCER_HAS_NO_PROXY_SUBNET": 39, "CLOUD_NAT_NO_ADDRESSES": 40, @@ -5475,6 +5487,22 @@ } } }, + "CloudRunJobInfo": { + "fields": { + "displayName": { + "type": "string", + "id": 1 + }, + "uri": { + "type": "string", + "id": 2 + }, + "location": { + "type": "string", + "id": 3 + } + } + }, "AppEngineVersionInfo": { "fields": { "displayName": { @@ -6950,8 +6978,7 @@ "java_multiple_files": true, "java_outer_classname": "LaunchStageProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "fieldBehavior": { @@ -7063,6 +7090,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -7077,6 +7109,14 @@ } } }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } + }, "http": { "type": "HttpRule", "id": 72295728, @@ -7198,6 +7238,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -7338,6 +7382,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -7395,6 +7461,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -7456,6 +7527,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -7489,12 +7573,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -7533,6 +7624,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -7621,6 +7717,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -7846,6 +7946,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -7896,7 +8000,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -8060,6 +8171,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -8195,7 +8307,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -8223,6 +8336,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -8292,6 +8409,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -8380,6 +8517,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -8522,6 +8663,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -8532,6 +8674,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -8542,6 +8685,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -8552,6 +8696,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -8562,7 +8707,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -8572,27 +8718,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -8637,7 +8794,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -8652,6 +8815,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -8679,11 +8869,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -8696,6 +8901,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -8781,6 +8992,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Timestamp": { "fields": { "seconds": { @@ -8868,6 +9087,7 @@ "java_multiple_files": true, "java_outer_classname": "OperationsProto", "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", "php_namespace": "Google\\LongRunning" }, "nested": { diff --git a/packages/google-cloud-networkmanagement/samples/generated/v1/snippet_metadata_google.cloud.networkmanagement.v1.json b/packages/google-cloud-networkmanagement/samples/generated/v1/snippet_metadata_google.cloud.networkmanagement.v1.json index 7b86bd12dc64..6cd41afcbc57 100644 --- a/packages/google-cloud-networkmanagement/samples/generated/v1/snippet_metadata_google.cloud.networkmanagement.v1.json +++ b/packages/google-cloud-networkmanagement/samples/generated/v1/snippet_metadata_google.cloud.networkmanagement.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-networkmanagement", - "version": "5.3.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-networkmanagement/samples/generated/v1beta1/snippet_metadata_google.cloud.networkmanagement.v1beta1.json b/packages/google-cloud-networkmanagement/samples/generated/v1beta1/snippet_metadata_google.cloud.networkmanagement.v1beta1.json index 2e8781b37625..868abc9d6d44 100644 --- a/packages/google-cloud-networkmanagement/samples/generated/v1beta1/snippet_metadata_google.cloud.networkmanagement.v1beta1.json +++ b/packages/google-cloud-networkmanagement/samples/generated/v1beta1/snippet_metadata_google.cloud.networkmanagement.v1beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-networkmanagement", - "version": "5.3.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-networkmanagement/src/v1/index.ts b/packages/google-cloud-networkmanagement/src/v1/index.ts index 58f25a8e94e6..3f3737863e25 100644 --- a/packages/google-cloud-networkmanagement/src/v1/index.ts +++ b/packages/google-cloud-networkmanagement/src/v1/index.ts @@ -16,6 +16,6 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {OrganizationVpcFlowLogsServiceClient} from './organization_vpc_flow_logs_service_client'; -export {ReachabilityServiceClient} from './reachability_service_client'; -export {VpcFlowLogsServiceClient} from './vpc_flow_logs_service_client'; +export { OrganizationVpcFlowLogsServiceClient } from './organization_vpc_flow_logs_service_client'; +export { ReachabilityServiceClient } from './reachability_service_client'; +export { VpcFlowLogsServiceClient } from './vpc_flow_logs_service_client'; diff --git a/packages/google-cloud-networkmanagement/src/v1/organization_vpc_flow_logs_service_client.ts b/packages/google-cloud-networkmanagement/src/v1/organization_vpc_flow_logs_service_client.ts index f7a7de87a591..8bdd960e9761 100644 --- a/packages/google-cloud-networkmanagement/src/v1/organization_vpc_flow_logs_service_client.ts +++ b/packages/google-cloud-networkmanagement/src/v1/organization_vpc_flow_logs_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -47,7 +60,7 @@ export class OrganizationVpcFlowLogsServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-management'); @@ -60,12 +73,12 @@ export class OrganizationVpcFlowLogsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - organizationVpcFlowLogsServiceStub?: Promise<{[name: string]: Function}>; + organizationVpcFlowLogsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of OrganizationVpcFlowLogsServiceClient. @@ -106,21 +119,43 @@ export class OrganizationVpcFlowLogsServiceClient { * const client = new OrganizationVpcFlowLogsServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof OrganizationVpcFlowLogsServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof OrganizationVpcFlowLogsServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkmanagement.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -145,7 +180,7 @@ export class OrganizationVpcFlowLogsServiceClient { 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; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -158,18 +193,14 @@ export class OrganizationVpcFlowLogsServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -191,28 +222,33 @@ export class OrganizationVpcFlowLogsServiceClient { // Create useful helper objects for these. this.pathTemplates = { connectivityTestPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/connectivityTests/{test}' + 'projects/{project}/locations/global/connectivityTests/{test}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - organizationLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}/locations/{location}', ), + organizationLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - projectLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}', ), + projectLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listVpcFlowLogsConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vpcFlowLogsConfigs') + listVpcFlowLogsConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'vpcFlowLogsConfigs', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -221,51 +257,135 @@ export class OrganizationVpcFlowLogsServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',additional_bindings: [{get: '/v1/{name=organizations/*/locations/*}',}], - },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',additional_bindings: [{get: '/v1/{name=organizations/*}/locations',}], - },{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/global/operations/*}:cancel',body: '*',additional_bindings: [{post: '/v1/{name=organizations/*/locations/global/operations/*}:cancel',body: '*',}], - },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{delete: '/v1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{get: '/v1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/global}/operations',additional_bindings: [{get: '/v1/{name=organizations/*/locations/global}/operations',}], - }]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + additional_bindings: [ + { get: '/v1/{name=organizations/*/locations/*}' }, + ], + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + additional_bindings: [ + { get: '/v1/{name=organizations/*}/locations' }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/global/operations/*}:cancel', + body: '*', + additional_bindings: [ + { + post: '/v1/{name=organizations/*/locations/global/operations/*}:cancel', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { + delete: + '/v1/{name=organizations/*/locations/global/operations/*}', + }, + ], + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { get: '/v1/{name=organizations/*/locations/global/operations/*}' }, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/global}/operations', + additional_bindings: [ + { get: '/v1/{name=organizations/*/locations/global}/operations' }, + ], + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.VpcFlowLogsConfig') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.VpcFlowLogsConfig', + ) as gax.protobuf.Type; const createVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.VpcFlowLogsConfig') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.VpcFlowLogsConfig', + ) as gax.protobuf.Type; const updateVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createVpcFlowLogsConfigResponse.decode.bind(createVpcFlowLogsConfigResponse), - createVpcFlowLogsConfigMetadata.decode.bind(createVpcFlowLogsConfigMetadata)), + createVpcFlowLogsConfigResponse.decode.bind( + createVpcFlowLogsConfigResponse, + ), + createVpcFlowLogsConfigMetadata.decode.bind( + createVpcFlowLogsConfigMetadata, + ), + ), updateVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateVpcFlowLogsConfigResponse.decode.bind(updateVpcFlowLogsConfigResponse), - updateVpcFlowLogsConfigMetadata.decode.bind(updateVpcFlowLogsConfigMetadata)), + updateVpcFlowLogsConfigResponse.decode.bind( + updateVpcFlowLogsConfigResponse, + ), + updateVpcFlowLogsConfigMetadata.decode.bind( + updateVpcFlowLogsConfigMetadata, + ), + ), deleteVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteVpcFlowLogsConfigResponse.decode.bind(deleteVpcFlowLogsConfigResponse), - deleteVpcFlowLogsConfigMetadata.decode.bind(deleteVpcFlowLogsConfigMetadata)) + deleteVpcFlowLogsConfigResponse.decode.bind( + deleteVpcFlowLogsConfigResponse, + ), + deleteVpcFlowLogsConfigMetadata.decode.bind( + deleteVpcFlowLogsConfigMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkmanagement.v1.OrganizationVpcFlowLogsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkmanagement.v1.OrganizationVpcFlowLogsService', + 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 @@ -296,28 +416,40 @@ export class OrganizationVpcFlowLogsServiceClient { // Put together the "service stub" for // google.cloud.networkmanagement.v1.OrganizationVpcFlowLogsService. this.organizationVpcFlowLogsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkmanagement.v1.OrganizationVpcFlowLogsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkmanagement.v1.OrganizationVpcFlowLogsService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkmanagement.v1.OrganizationVpcFlowLogsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkmanagement.v1 + .OrganizationVpcFlowLogsService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const organizationVpcFlowLogsServiceStubMethods = - ['listVpcFlowLogsConfigs', 'getVpcFlowLogsConfig', 'createVpcFlowLogsConfig', 'updateVpcFlowLogsConfig', 'deleteVpcFlowLogsConfig']; + const organizationVpcFlowLogsServiceStubMethods = [ + 'listVpcFlowLogsConfigs', + 'getVpcFlowLogsConfig', + 'createVpcFlowLogsConfig', + 'updateVpcFlowLogsConfig', + 'deleteVpcFlowLogsConfig', + ]; for (const methodName of organizationVpcFlowLogsServiceStubMethods) { const callPromise = this.organizationVpcFlowLogsServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -327,7 +459,7 @@ export class OrganizationVpcFlowLogsServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -342,8 +474,14 @@ export class OrganizationVpcFlowLogsServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -354,8 +492,14 @@ export class OrganizationVpcFlowLogsServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -386,9 +530,7 @@ export class OrganizationVpcFlowLogsServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -397,8 +539,9 @@ export class OrganizationVpcFlowLogsServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -409,577 +552,837 @@ export class OrganizationVpcFlowLogsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a specific `VpcFlowLogsConfig`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: - * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/organization_vpc_flow_logs_service.get_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_GetVpcFlowLogsConfig_async - */ + /** + * Gets the details of a specific `VpcFlowLogsConfig`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: + * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/organization_vpc_flow_logs_service.get_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_GetVpcFlowLogsConfig_async + */ getVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ] + >; getVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, - callback: Callback< - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, + callback: Callback< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getVpcFlowLogsConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getVpcFlowLogsConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getVpcFlowLogsConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getVpcFlowLogsConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new `VpcFlowLogsConfig`. - * If a configuration with the exact same settings already exists (even if the - * ID is different), the creation fails. - * Notes: - * - * 1. Creating a configuration with `state=DISABLED` will fail - * 2. The following fields are not considered as settings for the purpose - * of the check mentioned above, therefore - creating another configuration - * with the same fields but different values for the following fields will - * fail as well: - * * name - * * create_time - * * update_time - * * labels - * * description - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig to create, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {string} request.vpcFlowLogsConfigId - * Required. ID of the `VpcFlowLogsConfig`. - * @param {google.cloud.networkmanagement.v1.VpcFlowLogsConfig} request.vpcFlowLogsConfig - * Required. A `VpcFlowLogsConfig` resource - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/organization_vpc_flow_logs_service.create_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_CreateVpcFlowLogsConfig_async - */ + /** + * Creates a new `VpcFlowLogsConfig`. + * If a configuration with the exact same settings already exists (even if the + * ID is different), the creation fails. + * Notes: + * + * 1. Creating a configuration with `state=DISABLED` will fail + * 2. The following fields are not considered as settings for the purpose + * of the check mentioned above, therefore - creating another configuration + * with the same fields but different values for the following fields will + * fail as well: + * * name + * * create_time + * * update_time + * * labels + * * description + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig to create, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {string} request.vpcFlowLogsConfigId + * Required. ID of the `VpcFlowLogsConfig`. + * @param {google.cloud.networkmanagement.v1.VpcFlowLogsConfig} request.vpcFlowLogsConfig + * Required. A `VpcFlowLogsConfig` resource + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/organization_vpc_flow_logs_service.create_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_CreateVpcFlowLogsConfig_async + */ createVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.createVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/organization_vpc_flow_logs_service.create_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_CreateVpcFlowLogsConfig_async - */ - async checkCreateVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/organization_vpc_flow_logs_service.create_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_CreateVpcFlowLogsConfig_async + */ + async checkCreateVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.OperationMetadata + > + > { this._log.info('createVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.OperationMetadata + >; } -/** - * Updates an existing `VpcFlowLogsConfig`. - * If a configuration with the exact same settings already exists (even if the - * ID is different), the creation fails. - * Notes: - * - * 1. Updating a configuration with `state=DISABLED` will fail - * 2. The following fields are not considered as settings for the purpose - * of the check mentioned above, therefore - updating another configuration - * with the same fields but different values for the following fields will - * fail as well: - * * name - * * create_time - * * update_time - * * labels - * * description - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. - * For example, to change the state of the configuration to ENABLED, specify - * `update_mask` = `"state"`, and the `vpc_flow_logs_config` would be: - * `vpc_flow_logs_config = { - * name = - * "projects/my-project/locations/global/vpcFlowLogsConfigs/my-config" - * state = "ENABLED" }` - * @param {google.cloud.networkmanagement.v1.VpcFlowLogsConfig} request.vpcFlowLogsConfig - * Required. Only fields specified in update_mask are 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/organization_vpc_flow_logs_service.update_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_UpdateVpcFlowLogsConfig_async - */ + /** + * Updates an existing `VpcFlowLogsConfig`. + * If a configuration with the exact same settings already exists (even if the + * ID is different), the creation fails. + * Notes: + * + * 1. Updating a configuration with `state=DISABLED` will fail + * 2. The following fields are not considered as settings for the purpose + * of the check mentioned above, therefore - updating another configuration + * with the same fields but different values for the following fields will + * fail as well: + * * name + * * create_time + * * update_time + * * labels + * * description + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. + * For example, to change the state of the configuration to ENABLED, specify + * `update_mask` = `"state"`, and the `vpc_flow_logs_config` would be: + * `vpc_flow_logs_config = { + * name = + * "projects/my-project/locations/global/vpcFlowLogsConfigs/my-config" + * state = "ENABLED" }` + * @param {google.cloud.networkmanagement.v1.VpcFlowLogsConfig} request.vpcFlowLogsConfig + * Required. Only fields specified in update_mask are 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/organization_vpc_flow_logs_service.update_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_UpdateVpcFlowLogsConfig_async + */ updateVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'vpc_flow_logs_config.name': request.vpcFlowLogsConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'vpc_flow_logs_config.name': request.vpcFlowLogsConfig!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.updateVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/organization_vpc_flow_logs_service.update_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_UpdateVpcFlowLogsConfig_async - */ - async checkUpdateVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/organization_vpc_flow_logs_service.update_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_UpdateVpcFlowLogsConfig_async + */ + async checkUpdateVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.OperationMetadata + > + > { this._log.info('updateVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.OperationMetadata + >; } -/** - * Deletes a specific `VpcFlowLogsConfig`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For a project-level resource: - * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` - * - * - For an organization-level resource: - * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/organization_vpc_flow_logs_service.delete_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_DeleteVpcFlowLogsConfig_async - */ + /** + * Deletes a specific `VpcFlowLogsConfig`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For a project-level resource: + * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` + * + * - For an organization-level resource: + * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/organization_vpc_flow_logs_service.delete_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_DeleteVpcFlowLogsConfig_async + */ deleteVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.deleteVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/organization_vpc_flow_logs_service.delete_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_DeleteVpcFlowLogsConfig_async - */ - async checkDeleteVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/organization_vpc_flow_logs_service.delete_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_DeleteVpcFlowLogsConfig_async + */ + async checkDeleteVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1.OperationMetadata + > + > { this._log.info('deleteVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1.OperationMetadata + >; } - /** - * Lists all `VpcFlowLogsConfigs` in a given organization. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `listVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all `VpcFlowLogsConfigs` in a given organization. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `listVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse - ]>; + request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse, + ] + >; listVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + ): void; listVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + ): void; listVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>): - Promise<[ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse - ]>|void { + | protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + callback?: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listVpcFlowLogsConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -988,159 +1391,163 @@ export class OrganizationVpcFlowLogsServiceClient { this._log.info('listVpcFlowLogsConfigs request %j', request); return this.innerApiCalls .listVpcFlowLogsConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse - ]) => { - this._log.info('listVpcFlowLogsConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse, + ]) => { + this._log.info('listVpcFlowLogsConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listVpcFlowLogsConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listVpcFlowLogsConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listVpcFlowLogsConfigsStream( - request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listVpcFlowLogsConfigs stream %j', request); return this.descriptors.page.listVpcFlowLogsConfigs.createStream( this.innerApiCalls.listVpcFlowLogsConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listVpcFlowLogsConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/organization_vpc_flow_logs_service.list_vpc_flow_logs_configs.js - * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_ListVpcFlowLogsConfigs_async - */ + /** + * Equivalent to `listVpcFlowLogsConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/organization_vpc_flow_logs_service.list_vpc_flow_logs_configs.js + * region_tag:networkmanagement_v1_generated_OrganizationVpcFlowLogsService_ListVpcFlowLogsConfigs_async + */ listVpcFlowLogsConfigsAsync( - request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listVpcFlowLogsConfigs iterate %j', request); return this.descriptors.page.listVpcFlowLogsConfigs.asyncIterate( this.innerApiCalls['listVpcFlowLogsConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1154,40 +1561,40 @@ export class OrganizationVpcFlowLogsServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1201,41 +1608,41 @@ export class OrganizationVpcFlowLogsServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1249,12 +1656,12 @@ export class OrganizationVpcFlowLogsServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1289,12 +1696,11 @@ export class OrganizationVpcFlowLogsServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1327,12 +1733,12 @@ export class OrganizationVpcFlowLogsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1375,22 +1781,22 @@ export class OrganizationVpcFlowLogsServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1425,15 +1831,15 @@ export class OrganizationVpcFlowLogsServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1467,7 +1873,7 @@ export class OrganizationVpcFlowLogsServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1480,25 +1886,24 @@ export class OrganizationVpcFlowLogsServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1537,22 +1942,22 @@ export class OrganizationVpcFlowLogsServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1567,7 +1972,7 @@ export class OrganizationVpcFlowLogsServiceClient { * @param {string} test * @returns {string} Resource name string. */ - connectivityTestPath(project:string,test:string) { + connectivityTestPath(project: string, test: string) { return this.pathTemplates.connectivityTestPathTemplate.render({ project: project, test: test, @@ -1582,7 +1987,9 @@ export class OrganizationVpcFlowLogsServiceClient { * @returns {string} A string representing the project. */ matchProjectFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).project; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).project; } /** @@ -1593,7 +2000,9 @@ export class OrganizationVpcFlowLogsServiceClient { * @returns {string} A string representing the test. */ matchTestFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).test; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).test; } /** @@ -1603,7 +2012,7 @@ export class OrganizationVpcFlowLogsServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1640,12 +2049,18 @@ export class OrganizationVpcFlowLogsServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - organizationLocationVpcFlowLogsConfigsPath(organization:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render({ - organization: organization, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + organizationLocationVpcFlowLogsConfigsPath( + organization: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render( + { + organization: organization, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -1655,8 +2070,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).organization; + matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).organization; } /** @@ -1666,8 +2085,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).location; + matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -1677,8 +2100,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -1687,7 +2114,7 @@ export class OrganizationVpcFlowLogsServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1712,12 +2139,18 @@ export class OrganizationVpcFlowLogsServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - projectLocationVpcFlowLogsConfigsPath(project:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render({ - project: project, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + projectLocationVpcFlowLogsConfigsPath( + project: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render( + { + project: project, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -1727,8 +2160,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).project; + matchProjectFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).project; } /** @@ -1738,8 +2175,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).location; + matchLocationFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -1749,8 +2190,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -1761,15 +2206,19 @@ export class OrganizationVpcFlowLogsServiceClient { */ close(): Promise { if (this.organizationVpcFlowLogsServiceStub && !this._terminated) { - return this.organizationVpcFlowLogsServiceStub.then(stub => { + return this.organizationVpcFlowLogsServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkmanagement/src/v1/reachability_service_client.ts b/packages/google-cloud-networkmanagement/src/v1/reachability_service_client.ts index 388796a2b5cc..57dab4e01282 100644 --- a/packages/google-cloud-networkmanagement/src/v1/reachability_service_client.ts +++ b/packages/google-cloud-networkmanagement/src/v1/reachability_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -51,7 +64,7 @@ export class ReachabilityServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-management'); @@ -64,12 +77,12 @@ export class ReachabilityServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - reachabilityServiceStub?: Promise<{[name: string]: Function}>; + reachabilityServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of ReachabilityServiceClient. @@ -110,21 +123,42 @@ export class ReachabilityServiceClient { * const client = new ReachabilityServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ReachabilityServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkmanagement.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -149,7 +183,7 @@ export class ReachabilityServiceClient { 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; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -162,18 +196,14 @@ export class ReachabilityServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -195,25 +225,30 @@ export class ReachabilityServiceClient { // Create useful helper objects for these. this.pathTemplates = { connectivityTestPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/connectivityTests/{test}' - ), - organizationLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}/locations/global/connectivityTests/{test}', ), + organizationLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - projectLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}', ), + projectLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listConnectivityTests: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources') + listConnectivityTests: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'resources', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -222,59 +257,150 @@ export class ReachabilityServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',additional_bindings: [{get: '/v1/{name=organizations/*/locations/*}',}], - },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',additional_bindings: [{get: '/v1/{name=organizations/*}/locations',}], - },{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/global/operations/*}:cancel',body: '*',additional_bindings: [{post: '/v1/{name=organizations/*/locations/global/operations/*}:cancel',body: '*',}], - },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{delete: '/v1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{get: '/v1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/global}/operations',additional_bindings: [{get: '/v1/{name=organizations/*/locations/global}/operations',}], - }]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + additional_bindings: [ + { get: '/v1/{name=organizations/*/locations/*}' }, + ], + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + additional_bindings: [ + { get: '/v1/{name=organizations/*}/locations' }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/global/operations/*}:cancel', + body: '*', + additional_bindings: [ + { + post: '/v1/{name=organizations/*/locations/global/operations/*}:cancel', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { + delete: + '/v1/{name=organizations/*/locations/global/operations/*}', + }, + ], + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { get: '/v1/{name=organizations/*/locations/global/operations/*}' }, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/global}/operations', + additional_bindings: [ + { get: '/v1/{name=organizations/*/locations/global}/operations' }, + ], + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createConnectivityTestResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.ConnectivityTest') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.ConnectivityTest', + ) as gax.protobuf.Type; const createConnectivityTestMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateConnectivityTestResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.ConnectivityTest') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.ConnectivityTest', + ) as gax.protobuf.Type; const updateConnectivityTestMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.OperationMetadata', + ) as gax.protobuf.Type; const rerunConnectivityTestResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.ConnectivityTest') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.ConnectivityTest', + ) as gax.protobuf.Type; const rerunConnectivityTestMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteConnectivityTestResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteConnectivityTestMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createConnectivityTest: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createConnectivityTestResponse.decode.bind(createConnectivityTestResponse), - createConnectivityTestMetadata.decode.bind(createConnectivityTestMetadata)), + createConnectivityTestResponse.decode.bind( + createConnectivityTestResponse, + ), + createConnectivityTestMetadata.decode.bind( + createConnectivityTestMetadata, + ), + ), updateConnectivityTest: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateConnectivityTestResponse.decode.bind(updateConnectivityTestResponse), - updateConnectivityTestMetadata.decode.bind(updateConnectivityTestMetadata)), + updateConnectivityTestResponse.decode.bind( + updateConnectivityTestResponse, + ), + updateConnectivityTestMetadata.decode.bind( + updateConnectivityTestMetadata, + ), + ), rerunConnectivityTest: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - rerunConnectivityTestResponse.decode.bind(rerunConnectivityTestResponse), - rerunConnectivityTestMetadata.decode.bind(rerunConnectivityTestMetadata)), + rerunConnectivityTestResponse.decode.bind( + rerunConnectivityTestResponse, + ), + rerunConnectivityTestMetadata.decode.bind( + rerunConnectivityTestMetadata, + ), + ), deleteConnectivityTest: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteConnectivityTestResponse.decode.bind(deleteConnectivityTestResponse), - deleteConnectivityTestMetadata.decode.bind(deleteConnectivityTestMetadata)) + deleteConnectivityTestResponse.decode.bind( + deleteConnectivityTestResponse, + ), + deleteConnectivityTestMetadata.decode.bind( + deleteConnectivityTestMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkmanagement.v1.ReachabilityService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkmanagement.v1.ReachabilityService', + 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 @@ -305,28 +431,41 @@ export class ReachabilityServiceClient { // Put together the "service stub" for // google.cloud.networkmanagement.v1.ReachabilityService. this.reachabilityServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkmanagement.v1.ReachabilityService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkmanagement.v1.ReachabilityService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkmanagement.v1.ReachabilityService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkmanagement.v1 + .ReachabilityService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const reachabilityServiceStubMethods = - ['listConnectivityTests', 'getConnectivityTest', 'createConnectivityTest', 'updateConnectivityTest', 'rerunConnectivityTest', 'deleteConnectivityTest']; + const reachabilityServiceStubMethods = [ + 'listConnectivityTests', + 'getConnectivityTest', + 'createConnectivityTest', + 'updateConnectivityTest', + 'rerunConnectivityTest', + 'deleteConnectivityTest', + ]; for (const methodName of reachabilityServiceStubMethods) { const callPromise = this.reachabilityServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -336,7 +475,7 @@ export class ReachabilityServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -351,8 +490,14 @@ export class ReachabilityServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -363,8 +508,14 @@ export class ReachabilityServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -395,9 +546,7 @@ export class ReachabilityServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -406,8 +555,9 @@ export class ReachabilityServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -418,686 +568,1008 @@ export class ReachabilityServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a specific Connectivity Test. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. `ConnectivityTest` resource name using the form: - * `projects/{project_id}/locations/global/connectivityTests/{test_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 {@link protos.google.cloud.networkmanagement.v1.ConnectivityTest|ConnectivityTest}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/reachability_service.get_connectivity_test.js - * region_tag:networkmanagement_v1_generated_ReachabilityService_GetConnectivityTest_async - */ + /** + * Gets the details of a specific Connectivity Test. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. `ConnectivityTest` resource name using the form: + * `projects/{project_id}/locations/global/connectivityTests/{test_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 {@link protos.google.cloud.networkmanagement.v1.ConnectivityTest|ConnectivityTest}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/reachability_service.get_connectivity_test.js + * region_tag:networkmanagement_v1_generated_ReachabilityService_GetConnectivityTest_async + */ getConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + ( + | protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest + | undefined + ), + {} | undefined, + ] + >; getConnectivityTest( - request: protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkmanagement.v1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + | protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getConnectivityTest( - request: protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest, - callback: Callback< - protos.google.cloud.networkmanagement.v1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest, + callback: Callback< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + | protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkmanagement.v1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkmanagement.v1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkmanagement.v1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + | protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + ( + | protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getConnectivityTest request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkmanagement.v1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + | protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getConnectivityTest response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getConnectivityTest(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkmanagement.v1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest|undefined, - {}|undefined - ]) => { - this._log.info('getConnectivityTest response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getConnectivityTest(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + ( + | protos.google.cloud.networkmanagement.v1.IGetConnectivityTestRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getConnectivityTest response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Connectivity Test. - * After you create a test, the reachability analysis is performed as part - * of the long running operation, which completes when the analysis completes. - * - * If the endpoint specifications in `ConnectivityTest` are invalid - * (for example, containing non-existent resources in the network, or you - * don't have read permissions to the network configurations of listed - * projects), then the reachability result returns a value of `UNKNOWN`. - * - * If the endpoint specifications in `ConnectivityTest` are - * incomplete, the reachability result returns a value of - * AMBIGUOUS. For more information, - * see the Connectivity Test documentation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the Connectivity Test to create: - * `projects/{project_id}/locations/global` - * @param {string} request.testId - * Required. The logical name of the Connectivity Test in your project - * with the following restrictions: - * - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-40 characters. - * * Must end with a number or a letter. - * * Must be unique within the customer project - * @param {google.cloud.networkmanagement.v1.ConnectivityTest} request.resource - * Required. A `ConnectivityTest` resource - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/reachability_service.create_connectivity_test.js - * region_tag:networkmanagement_v1_generated_ReachabilityService_CreateConnectivityTest_async - */ + /** + * Creates a new Connectivity Test. + * After you create a test, the reachability analysis is performed as part + * of the long running operation, which completes when the analysis completes. + * + * If the endpoint specifications in `ConnectivityTest` are invalid + * (for example, containing non-existent resources in the network, or you + * don't have read permissions to the network configurations of listed + * projects), then the reachability result returns a value of `UNKNOWN`. + * + * If the endpoint specifications in `ConnectivityTest` are + * incomplete, the reachability result returns a value of + * AMBIGUOUS. For more information, + * see the Connectivity Test documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the Connectivity Test to create: + * `projects/{project_id}/locations/global` + * @param {string} request.testId + * Required. The logical name of the Connectivity Test in your project + * with the following restrictions: + * + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-40 characters. + * * Must end with a number or a letter. + * * Must be unique within the customer project + * @param {google.cloud.networkmanagement.v1.ConnectivityTest} request.resource + * Required. A `ConnectivityTest` resource + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/reachability_service.create_connectivity_test.js + * region_tag:networkmanagement_v1_generated_ReachabilityService_CreateConnectivityTest_async + */ createConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1.ICreateConnectivityTestRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.ICreateConnectivityTestRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createConnectivityTest( - request: protos.google.cloud.networkmanagement.v1.ICreateConnectivityTestRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.ICreateConnectivityTestRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createConnectivityTest( - request: protos.google.cloud.networkmanagement.v1.ICreateConnectivityTestRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.ICreateConnectivityTestRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1.ICreateConnectivityTestRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1.ICreateConnectivityTestRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createConnectivityTest response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createConnectivityTest request %j', request); - return this.innerApiCalls.createConnectivityTest(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createConnectivityTest response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createConnectivityTest(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createConnectivityTest response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createConnectivityTest()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/reachability_service.create_connectivity_test.js - * region_tag:networkmanagement_v1_generated_ReachabilityService_CreateConnectivityTest_async - */ - async checkCreateConnectivityTestProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createConnectivityTest()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/reachability_service.create_connectivity_test.js + * region_tag:networkmanagement_v1_generated_ReachabilityService_CreateConnectivityTest_async + */ + async checkCreateConnectivityTestProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1.OperationMetadata + > + > { this._log.info('createConnectivityTest long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createConnectivityTest, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createConnectivityTest, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1.OperationMetadata + >; } -/** - * Updates the configuration of an existing `ConnectivityTest`. - * After you update a test, the reachability analysis is performed as part - * of the long running operation, which completes when the analysis completes. - * The Reachability state in the test resource is updated with the new result. - * - * If the endpoint specifications in `ConnectivityTest` are invalid - * (for example, they contain non-existent resources in the network, or the - * user does not have read permissions to the network configurations of - * listed projects), then the reachability result returns a value of - * UNKNOWN. - * - * If the endpoint specifications in `ConnectivityTest` are incomplete, the - * reachability result returns a value of `AMBIGUOUS`. See the documentation - * in `ConnectivityTest` for more details. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. - * @param {google.cloud.networkmanagement.v1.ConnectivityTest} request.resource - * Required. Only fields specified in update_mask are 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/reachability_service.update_connectivity_test.js - * region_tag:networkmanagement_v1_generated_ReachabilityService_UpdateConnectivityTest_async - */ + /** + * Updates the configuration of an existing `ConnectivityTest`. + * After you update a test, the reachability analysis is performed as part + * of the long running operation, which completes when the analysis completes. + * The Reachability state in the test resource is updated with the new result. + * + * If the endpoint specifications in `ConnectivityTest` are invalid + * (for example, they contain non-existent resources in the network, or the + * user does not have read permissions to the network configurations of + * listed projects), then the reachability result returns a value of + * UNKNOWN. + * + * If the endpoint specifications in `ConnectivityTest` are incomplete, the + * reachability result returns a value of `AMBIGUOUS`. See the documentation + * in `ConnectivityTest` for more details. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. + * @param {google.cloud.networkmanagement.v1.ConnectivityTest} request.resource + * Required. Only fields specified in update_mask are 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/reachability_service.update_connectivity_test.js + * region_tag:networkmanagement_v1_generated_ReachabilityService_UpdateConnectivityTest_async + */ updateConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1.IUpdateConnectivityTestRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.IUpdateConnectivityTestRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateConnectivityTest( - request: protos.google.cloud.networkmanagement.v1.IUpdateConnectivityTestRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IUpdateConnectivityTestRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateConnectivityTest( - request: protos.google.cloud.networkmanagement.v1.IUpdateConnectivityTestRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IUpdateConnectivityTestRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1.IUpdateConnectivityTestRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1.IUpdateConnectivityTestRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource.name': request.resource!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'resource.name': request.resource!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateConnectivityTest response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateConnectivityTest request %j', request); - return this.innerApiCalls.updateConnectivityTest(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateConnectivityTest response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateConnectivityTest(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateConnectivityTest response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateConnectivityTest()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/reachability_service.update_connectivity_test.js - * region_tag:networkmanagement_v1_generated_ReachabilityService_UpdateConnectivityTest_async - */ - async checkUpdateConnectivityTestProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateConnectivityTest()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/reachability_service.update_connectivity_test.js + * region_tag:networkmanagement_v1_generated_ReachabilityService_UpdateConnectivityTest_async + */ + async checkUpdateConnectivityTestProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1.OperationMetadata + > + > { this._log.info('updateConnectivityTest long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateConnectivityTest, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateConnectivityTest, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1.OperationMetadata + >; } -/** - * Rerun an existing `ConnectivityTest`. - * After the user triggers the rerun, the reachability analysis is performed - * as part of the long running operation, which completes when the analysis - * completes. - * - * Even though the test configuration remains the same, the reachability - * result may change due to underlying network configuration changes. - * - * If the endpoint specifications in `ConnectivityTest` become invalid (for - * example, specified resources are deleted in the network, or you lost - * read permissions to the network configurations of listed projects), then - * the reachability result returns a value of `UNKNOWN`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Connectivity Test resource name using the form: - * `projects/{project_id}/locations/global/connectivityTests/{test_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/reachability_service.rerun_connectivity_test.js - * region_tag:networkmanagement_v1_generated_ReachabilityService_RerunConnectivityTest_async - */ + /** + * Rerun an existing `ConnectivityTest`. + * After the user triggers the rerun, the reachability analysis is performed + * as part of the long running operation, which completes when the analysis + * completes. + * + * Even though the test configuration remains the same, the reachability + * result may change due to underlying network configuration changes. + * + * If the endpoint specifications in `ConnectivityTest` become invalid (for + * example, specified resources are deleted in the network, or you lost + * read permissions to the network configurations of listed projects), then + * the reachability result returns a value of `UNKNOWN`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Connectivity Test resource name using the form: + * `projects/{project_id}/locations/global/connectivityTests/{test_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/reachability_service.rerun_connectivity_test.js + * region_tag:networkmanagement_v1_generated_ReachabilityService_RerunConnectivityTest_async + */ rerunConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1.IRerunConnectivityTestRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.IRerunConnectivityTestRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rerunConnectivityTest( - request: protos.google.cloud.networkmanagement.v1.IRerunConnectivityTestRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IRerunConnectivityTestRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rerunConnectivityTest( - request: protos.google.cloud.networkmanagement.v1.IRerunConnectivityTestRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IRerunConnectivityTestRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rerunConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1.IRerunConnectivityTestRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1.IRerunConnectivityTestRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rerunConnectivityTest response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rerunConnectivityTest request %j', request); - return this.innerApiCalls.rerunConnectivityTest(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rerunConnectivityTest response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rerunConnectivityTest(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rerunConnectivityTest response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rerunConnectivityTest()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/reachability_service.rerun_connectivity_test.js - * region_tag:networkmanagement_v1_generated_ReachabilityService_RerunConnectivityTest_async - */ - async checkRerunConnectivityTestProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rerunConnectivityTest()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/reachability_service.rerun_connectivity_test.js + * region_tag:networkmanagement_v1_generated_ReachabilityService_RerunConnectivityTest_async + */ + async checkRerunConnectivityTestProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1.OperationMetadata + > + > { this._log.info('rerunConnectivityTest long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.rerunConnectivityTest, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rerunConnectivityTest, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1.OperationMetadata + >; } -/** - * Deletes a specific `ConnectivityTest`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Connectivity Test resource name using the form: - * `projects/{project_id}/locations/global/connectivityTests/{test_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/reachability_service.delete_connectivity_test.js - * region_tag:networkmanagement_v1_generated_ReachabilityService_DeleteConnectivityTest_async - */ + /** + * Deletes a specific `ConnectivityTest`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Connectivity Test resource name using the form: + * `projects/{project_id}/locations/global/connectivityTests/{test_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/reachability_service.delete_connectivity_test.js + * region_tag:networkmanagement_v1_generated_ReachabilityService_DeleteConnectivityTest_async + */ deleteConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1.IDeleteConnectivityTestRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.IDeleteConnectivityTestRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteConnectivityTest( - request: protos.google.cloud.networkmanagement.v1.IDeleteConnectivityTestRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IDeleteConnectivityTestRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteConnectivityTest( - request: protos.google.cloud.networkmanagement.v1.IDeleteConnectivityTestRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IDeleteConnectivityTestRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1.IDeleteConnectivityTestRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1.IDeleteConnectivityTestRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteConnectivityTest response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteConnectivityTest request %j', request); - return this.innerApiCalls.deleteConnectivityTest(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteConnectivityTest response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteConnectivityTest(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteConnectivityTest response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteConnectivityTest()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/reachability_service.delete_connectivity_test.js - * region_tag:networkmanagement_v1_generated_ReachabilityService_DeleteConnectivityTest_async - */ - async checkDeleteConnectivityTestProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteConnectivityTest()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/reachability_service.delete_connectivity_test.js + * region_tag:networkmanagement_v1_generated_ReachabilityService_DeleteConnectivityTest_async + */ + async checkDeleteConnectivityTestProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1.OperationMetadata + > + > { this._log.info('deleteConnectivityTest long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteConnectivityTest, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteConnectivityTest, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1.OperationMetadata + >; } - /** - * Lists all Connectivity Tests owned by a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the Connectivity Tests: - * `projects/{project_id}/locations/global` - * @param {number} request.pageSize - * Number of `ConnectivityTests` to return. - * @param {string} request.pageToken - * Page token from an earlier query, as returned in `next_page_token`. - * @param {string} request.filter - * Lists the `ConnectivityTests` that match the filter expression. A filter - * expression filters the resources listed in the response. The expression - * must be of the form ` ` where operators: `<`, `>`, - * `<=`, - * `>=`, - * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is - * roughly synonymous with equality). can refer to a proto or JSON - * field, or a synthetic field. Field names can be camelCase or snake_case. - * - * Examples: - * - Filter by name: - * name = "projects/proj-1/locations/global/connectivityTests/test-1 - * - * - Filter by labels: - * - Resources that have a key called `foo` - * labels.foo:* - * - Resources that have a key called `foo` whose value is `bar` - * labels.foo = bar - * @param {string} request.orderBy - * Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1.ConnectivityTest|ConnectivityTest}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `listConnectivityTestsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all Connectivity Tests owned by a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the Connectivity Tests: + * `projects/{project_id}/locations/global` + * @param {number} request.pageSize + * Number of `ConnectivityTests` to return. + * @param {string} request.pageToken + * Page token from an earlier query, as returned in `next_page_token`. + * @param {string} request.filter + * Lists the `ConnectivityTests` that match the filter expression. A filter + * expression filters the resources listed in the response. The expression + * must be of the form ` ` where operators: `<`, `>`, + * `<=`, + * `>=`, + * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is + * roughly synonymous with equality). can refer to a proto or JSON + * field, or a synthetic field. Field names can be camelCase or snake_case. + * + * Examples: + * - Filter by name: + * name = "projects/proj-1/locations/global/connectivityTests/test-1 + * + * - Filter by labels: + * - Resources that have a key called `foo` + * labels.foo:* + * - Resources that have a key called `foo` whose value is `bar` + * labels.foo = bar + * @param {string} request.orderBy + * Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1.ConnectivityTest|ConnectivityTest}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `listConnectivityTestsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listConnectivityTests( - request?: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1.IConnectivityTest[], - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest|null, - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse - ]>; + request?: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IConnectivityTest[], + protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest | null, + protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse, + ] + >; listConnectivityTests( - request: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IConnectivityTest>): void; + request: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, + | protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IConnectivityTest + >, + ): void; listConnectivityTests( - request: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IConnectivityTest>): void; + request: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, + | protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IConnectivityTest + >, + ): void; listConnectivityTests( - request?: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IConnectivityTest>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IConnectivityTest>): - Promise<[ - protos.google.cloud.networkmanagement.v1.IConnectivityTest[], - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest|null, - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse - ]>|void { + | protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IConnectivityTest + >, + callback?: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, + | protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IConnectivityTest + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IConnectivityTest[], + protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest | null, + protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IConnectivityTest>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, + | protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IConnectivityTest + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listConnectivityTests values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1106,177 +1578,181 @@ export class ReachabilityServiceClient { this._log.info('listConnectivityTests request %j', request); return this.innerApiCalls .listConnectivityTests(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkmanagement.v1.IConnectivityTest[], - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest|null, - protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse - ]) => { - this._log.info('listConnectivityTests values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkmanagement.v1.IConnectivityTest[], + protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest | null, + protos.google.cloud.networkmanagement.v1.IListConnectivityTestsResponse, + ]) => { + this._log.info('listConnectivityTests values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listConnectivityTests`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the Connectivity Tests: - * `projects/{project_id}/locations/global` - * @param {number} request.pageSize - * Number of `ConnectivityTests` to return. - * @param {string} request.pageToken - * Page token from an earlier query, as returned in `next_page_token`. - * @param {string} request.filter - * Lists the `ConnectivityTests` that match the filter expression. A filter - * expression filters the resources listed in the response. The expression - * must be of the form ` ` where operators: `<`, `>`, - * `<=`, - * `>=`, - * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is - * roughly synonymous with equality). can refer to a proto or JSON - * field, or a synthetic field. Field names can be camelCase or snake_case. - * - * Examples: - * - Filter by name: - * name = "projects/proj-1/locations/global/connectivityTests/test-1 - * - * - Filter by labels: - * - Resources that have a key called `foo` - * labels.foo:* - * - Resources that have a key called `foo` whose value is `bar` - * labels.foo = bar - * @param {string} request.orderBy - * Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1.ConnectivityTest|ConnectivityTest} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listConnectivityTestsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listConnectivityTests`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the Connectivity Tests: + * `projects/{project_id}/locations/global` + * @param {number} request.pageSize + * Number of `ConnectivityTests` to return. + * @param {string} request.pageToken + * Page token from an earlier query, as returned in `next_page_token`. + * @param {string} request.filter + * Lists the `ConnectivityTests` that match the filter expression. A filter + * expression filters the resources listed in the response. The expression + * must be of the form ` ` where operators: `<`, `>`, + * `<=`, + * `>=`, + * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is + * roughly synonymous with equality). can refer to a proto or JSON + * field, or a synthetic field. Field names can be camelCase or snake_case. + * + * Examples: + * - Filter by name: + * name = "projects/proj-1/locations/global/connectivityTests/test-1 + * + * - Filter by labels: + * - Resources that have a key called `foo` + * labels.foo:* + * - Resources that have a key called `foo` whose value is `bar` + * labels.foo = bar + * @param {string} request.orderBy + * Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1.ConnectivityTest|ConnectivityTest} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listConnectivityTestsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listConnectivityTestsStream( - request?: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listConnectivityTests']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listConnectivityTests stream %j', request); return this.descriptors.page.listConnectivityTests.createStream( this.innerApiCalls.listConnectivityTests as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listConnectivityTests`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the Connectivity Tests: - * `projects/{project_id}/locations/global` - * @param {number} request.pageSize - * Number of `ConnectivityTests` to return. - * @param {string} request.pageToken - * Page token from an earlier query, as returned in `next_page_token`. - * @param {string} request.filter - * Lists the `ConnectivityTests` that match the filter expression. A filter - * expression filters the resources listed in the response. The expression - * must be of the form ` ` where operators: `<`, `>`, - * `<=`, - * `>=`, - * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is - * roughly synonymous with equality). can refer to a proto or JSON - * field, or a synthetic field. Field names can be camelCase or snake_case. - * - * Examples: - * - Filter by name: - * name = "projects/proj-1/locations/global/connectivityTests/test-1 - * - * - Filter by labels: - * - Resources that have a key called `foo` - * labels.foo:* - * - Resources that have a key called `foo` whose value is `bar` - * labels.foo = bar - * @param {string} request.orderBy - * Field to use to sort the list. - * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkmanagement.v1.ConnectivityTest|ConnectivityTest}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/reachability_service.list_connectivity_tests.js - * region_tag:networkmanagement_v1_generated_ReachabilityService_ListConnectivityTests_async - */ + /** + * Equivalent to `listConnectivityTests`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the Connectivity Tests: + * `projects/{project_id}/locations/global` + * @param {number} request.pageSize + * Number of `ConnectivityTests` to return. + * @param {string} request.pageToken + * Page token from an earlier query, as returned in `next_page_token`. + * @param {string} request.filter + * Lists the `ConnectivityTests` that match the filter expression. A filter + * expression filters the resources listed in the response. The expression + * must be of the form ` ` where operators: `<`, `>`, + * `<=`, + * `>=`, + * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is + * roughly synonymous with equality). can refer to a proto or JSON + * field, or a synthetic field. Field names can be camelCase or snake_case. + * + * Examples: + * - Filter by name: + * name = "projects/proj-1/locations/global/connectivityTests/test-1 + * + * - Filter by labels: + * - Resources that have a key called `foo` + * labels.foo:* + * - Resources that have a key called `foo` whose value is `bar` + * labels.foo = bar + * @param {string} request.orderBy + * Field to use to sort the list. + * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkmanagement.v1.ConnectivityTest|ConnectivityTest}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/reachability_service.list_connectivity_tests.js + * region_tag:networkmanagement_v1_generated_ReachabilityService_ListConnectivityTests_async + */ listConnectivityTestsAsync( - request?: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkmanagement.v1.IListConnectivityTestsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listConnectivityTests']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listConnectivityTests iterate %j', request); return this.descriptors.page.listConnectivityTests.asyncIterate( this.innerApiCalls['listConnectivityTests'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1290,40 +1766,40 @@ export class ReachabilityServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1337,41 +1813,41 @@ export class ReachabilityServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1385,12 +1861,12 @@ export class ReachabilityServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1425,12 +1901,11 @@ export class ReachabilityServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1463,12 +1938,12 @@ export class ReachabilityServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1511,22 +1986,22 @@ export class ReachabilityServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1561,15 +2036,15 @@ export class ReachabilityServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1603,7 +2078,7 @@ export class ReachabilityServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1616,25 +2091,24 @@ export class ReachabilityServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1673,22 +2147,22 @@ export class ReachabilityServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1703,7 +2177,7 @@ export class ReachabilityServiceClient { * @param {string} test * @returns {string} Resource name string. */ - connectivityTestPath(project:string,test:string) { + connectivityTestPath(project: string, test: string) { return this.pathTemplates.connectivityTestPathTemplate.render({ project: project, test: test, @@ -1718,7 +2192,9 @@ export class ReachabilityServiceClient { * @returns {string} A string representing the project. */ matchProjectFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).project; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).project; } /** @@ -1729,7 +2205,9 @@ export class ReachabilityServiceClient { * @returns {string} A string representing the test. */ matchTestFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).test; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).test; } /** @@ -1740,12 +2218,18 @@ export class ReachabilityServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - organizationLocationVpcFlowLogsConfigsPath(organization:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render({ - organization: organization, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + organizationLocationVpcFlowLogsConfigsPath( + organization: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render( + { + organization: organization, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -1755,8 +2239,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).organization; + matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).organization; } /** @@ -1766,8 +2254,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).location; + matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -1777,8 +2269,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -1787,7 +2283,7 @@ export class ReachabilityServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1812,12 +2308,18 @@ export class ReachabilityServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - projectLocationVpcFlowLogsConfigsPath(project:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render({ - project: project, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + projectLocationVpcFlowLogsConfigsPath( + project: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render( + { + project: project, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -1827,8 +2329,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).project; + matchProjectFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).project; } /** @@ -1838,8 +2344,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).location; + matchLocationFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -1849,8 +2359,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -1861,15 +2375,19 @@ export class ReachabilityServiceClient { */ close(): Promise { if (this.reachabilityServiceStub && !this._terminated) { - return this.reachabilityServiceStub.then(stub => { + return this.reachabilityServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkmanagement/src/v1/vpc_flow_logs_service_client.ts b/packages/google-cloud-networkmanagement/src/v1/vpc_flow_logs_service_client.ts index 3231b7937104..4b1ff9264b24 100644 --- a/packages/google-cloud-networkmanagement/src/v1/vpc_flow_logs_service_client.ts +++ b/packages/google-cloud-networkmanagement/src/v1/vpc_flow_logs_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -46,7 +59,7 @@ export class VpcFlowLogsServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-management'); @@ -59,12 +72,12 @@ export class VpcFlowLogsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - vpcFlowLogsServiceStub?: Promise<{[name: string]: Function}>; + vpcFlowLogsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of VpcFlowLogsServiceClient. @@ -105,21 +118,42 @@ export class VpcFlowLogsServiceClient { * const client = new VpcFlowLogsServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof VpcFlowLogsServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkmanagement.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -144,7 +178,7 @@ export class VpcFlowLogsServiceClient { 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; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -157,18 +191,14 @@ export class VpcFlowLogsServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -190,32 +220,43 @@ export class VpcFlowLogsServiceClient { // Create useful helper objects for these. this.pathTemplates = { connectivityTestPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/connectivityTests/{test}' + 'projects/{project}/locations/global/connectivityTests/{test}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - organizationLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}/locations/{location}', ), + organizationLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - projectLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}', ), + projectLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listVpcFlowLogsConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vpcFlowLogsConfigs'), - queryOrgVpcFlowLogsConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vpcFlowLogsConfigs'), - showEffectiveFlowLogsConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'effectiveFlowLogsConfigs') + listVpcFlowLogsConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'vpcFlowLogsConfigs', + ), + queryOrgVpcFlowLogsConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'vpcFlowLogsConfigs', + ), + showEffectiveFlowLogsConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'effectiveFlowLogsConfigs', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -224,51 +265,135 @@ export class VpcFlowLogsServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',additional_bindings: [{get: '/v1/{name=organizations/*/locations/*}',}], - },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',additional_bindings: [{get: '/v1/{name=organizations/*}/locations',}], - },{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/global/operations/*}:cancel',body: '*',additional_bindings: [{post: '/v1/{name=organizations/*/locations/global/operations/*}:cancel',body: '*',}], - },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{delete: '/v1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{get: '/v1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/global}/operations',additional_bindings: [{get: '/v1/{name=organizations/*/locations/global}/operations',}], - }]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + additional_bindings: [ + { get: '/v1/{name=organizations/*/locations/*}' }, + ], + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + additional_bindings: [ + { get: '/v1/{name=organizations/*}/locations' }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/global/operations/*}:cancel', + body: '*', + additional_bindings: [ + { + post: '/v1/{name=organizations/*/locations/global/operations/*}:cancel', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { + delete: + '/v1/{name=organizations/*/locations/global/operations/*}', + }, + ], + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { get: '/v1/{name=organizations/*/locations/global/operations/*}' }, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/global}/operations', + additional_bindings: [ + { get: '/v1/{name=organizations/*/locations/global}/operations' }, + ], + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.VpcFlowLogsConfig') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.VpcFlowLogsConfig', + ) as gax.protobuf.Type; const createVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.VpcFlowLogsConfig') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.VpcFlowLogsConfig', + ) as gax.protobuf.Type; const updateVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createVpcFlowLogsConfigResponse.decode.bind(createVpcFlowLogsConfigResponse), - createVpcFlowLogsConfigMetadata.decode.bind(createVpcFlowLogsConfigMetadata)), + createVpcFlowLogsConfigResponse.decode.bind( + createVpcFlowLogsConfigResponse, + ), + createVpcFlowLogsConfigMetadata.decode.bind( + createVpcFlowLogsConfigMetadata, + ), + ), updateVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateVpcFlowLogsConfigResponse.decode.bind(updateVpcFlowLogsConfigResponse), - updateVpcFlowLogsConfigMetadata.decode.bind(updateVpcFlowLogsConfigMetadata)), + updateVpcFlowLogsConfigResponse.decode.bind( + updateVpcFlowLogsConfigResponse, + ), + updateVpcFlowLogsConfigMetadata.decode.bind( + updateVpcFlowLogsConfigMetadata, + ), + ), deleteVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteVpcFlowLogsConfigResponse.decode.bind(deleteVpcFlowLogsConfigResponse), - deleteVpcFlowLogsConfigMetadata.decode.bind(deleteVpcFlowLogsConfigMetadata)) + deleteVpcFlowLogsConfigResponse.decode.bind( + deleteVpcFlowLogsConfigResponse, + ), + deleteVpcFlowLogsConfigMetadata.decode.bind( + deleteVpcFlowLogsConfigMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkmanagement.v1.VpcFlowLogsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkmanagement.v1.VpcFlowLogsService', + 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 @@ -299,28 +424,42 @@ export class VpcFlowLogsServiceClient { // Put together the "service stub" for // google.cloud.networkmanagement.v1.VpcFlowLogsService. this.vpcFlowLogsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkmanagement.v1.VpcFlowLogsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkmanagement.v1.VpcFlowLogsService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkmanagement.v1.VpcFlowLogsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkmanagement.v1 + .VpcFlowLogsService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const vpcFlowLogsServiceStubMethods = - ['listVpcFlowLogsConfigs', 'getVpcFlowLogsConfig', 'createVpcFlowLogsConfig', 'updateVpcFlowLogsConfig', 'deleteVpcFlowLogsConfig', 'queryOrgVpcFlowLogsConfigs', 'showEffectiveFlowLogsConfigs']; + const vpcFlowLogsServiceStubMethods = [ + 'listVpcFlowLogsConfigs', + 'getVpcFlowLogsConfig', + 'createVpcFlowLogsConfig', + 'updateVpcFlowLogsConfig', + 'deleteVpcFlowLogsConfig', + 'queryOrgVpcFlowLogsConfigs', + 'showEffectiveFlowLogsConfigs', + ]; for (const methodName of vpcFlowLogsServiceStubMethods) { const callPromise = this.vpcFlowLogsServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -330,7 +469,7 @@ export class VpcFlowLogsServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -345,8 +484,14 @@ export class VpcFlowLogsServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -357,8 +502,14 @@ export class VpcFlowLogsServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -389,9 +540,7 @@ export class VpcFlowLogsServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -400,8 +549,9 @@ export class VpcFlowLogsServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -412,577 +562,837 @@ export class VpcFlowLogsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a specific `VpcFlowLogsConfig`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: - * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/vpc_flow_logs_service.get_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_GetVpcFlowLogsConfig_async - */ + /** + * Gets the details of a specific `VpcFlowLogsConfig`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: + * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/vpc_flow_logs_service.get_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_GetVpcFlowLogsConfig_async + */ getVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ] + >; getVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, - callback: Callback< - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, + callback: Callback< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getVpcFlowLogsConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getVpcFlowLogsConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getVpcFlowLogsConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getVpcFlowLogsConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new `VpcFlowLogsConfig`. - * If a configuration with the exact same settings already exists (even if the - * ID is different), the creation fails. - * Notes: - * - * 1. Creating a configuration with `state=DISABLED` will fail - * 2. The following fields are not considered as settings for the purpose - * of the check mentioned above, therefore - creating another configuration - * with the same fields but different values for the following fields will - * fail as well: - * * name - * * create_time - * * update_time - * * labels - * * description - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig to create, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {string} request.vpcFlowLogsConfigId - * Required. ID of the `VpcFlowLogsConfig`. - * @param {google.cloud.networkmanagement.v1.VpcFlowLogsConfig} request.vpcFlowLogsConfig - * Required. A `VpcFlowLogsConfig` resource - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/vpc_flow_logs_service.create_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_CreateVpcFlowLogsConfig_async - */ + /** + * Creates a new `VpcFlowLogsConfig`. + * If a configuration with the exact same settings already exists (even if the + * ID is different), the creation fails. + * Notes: + * + * 1. Creating a configuration with `state=DISABLED` will fail + * 2. The following fields are not considered as settings for the purpose + * of the check mentioned above, therefore - creating another configuration + * with the same fields but different values for the following fields will + * fail as well: + * * name + * * create_time + * * update_time + * * labels + * * description + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig to create, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {string} request.vpcFlowLogsConfigId + * Required. ID of the `VpcFlowLogsConfig`. + * @param {google.cloud.networkmanagement.v1.VpcFlowLogsConfig} request.vpcFlowLogsConfig + * Required. A `VpcFlowLogsConfig` resource + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/vpc_flow_logs_service.create_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_CreateVpcFlowLogsConfig_async + */ createVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1.ICreateVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.createVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/vpc_flow_logs_service.create_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_CreateVpcFlowLogsConfig_async - */ - async checkCreateVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/vpc_flow_logs_service.create_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_CreateVpcFlowLogsConfig_async + */ + async checkCreateVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.OperationMetadata + > + > { this._log.info('createVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.OperationMetadata + >; } -/** - * Updates an existing `VpcFlowLogsConfig`. - * If a configuration with the exact same settings already exists (even if the - * ID is different), the creation fails. - * Notes: - * - * 1. Updating a configuration with `state=DISABLED` will fail. - * 2. The following fields are not considered as settings for the purpose - * of the check mentioned above, therefore - updating another configuration - * with the same fields but different values for the following fields will - * fail as well: - * * name - * * create_time - * * update_time - * * labels - * * description - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. - * For example, to change the state of the configuration to ENABLED, specify - * `update_mask` = `"state"`, and the `vpc_flow_logs_config` would be: - * `vpc_flow_logs_config = { - * name = - * "projects/my-project/locations/global/vpcFlowLogsConfigs/my-config" - * state = "ENABLED" }` - * @param {google.cloud.networkmanagement.v1.VpcFlowLogsConfig} request.vpcFlowLogsConfig - * Required. Only fields specified in update_mask are 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/vpc_flow_logs_service.update_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_UpdateVpcFlowLogsConfig_async - */ + /** + * Updates an existing `VpcFlowLogsConfig`. + * If a configuration with the exact same settings already exists (even if the + * ID is different), the creation fails. + * Notes: + * + * 1. Updating a configuration with `state=DISABLED` will fail. + * 2. The following fields are not considered as settings for the purpose + * of the check mentioned above, therefore - updating another configuration + * with the same fields but different values for the following fields will + * fail as well: + * * name + * * create_time + * * update_time + * * labels + * * description + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. + * For example, to change the state of the configuration to ENABLED, specify + * `update_mask` = `"state"`, and the `vpc_flow_logs_config` would be: + * `vpc_flow_logs_config = { + * name = + * "projects/my-project/locations/global/vpcFlowLogsConfigs/my-config" + * state = "ENABLED" }` + * @param {google.cloud.networkmanagement.v1.VpcFlowLogsConfig} request.vpcFlowLogsConfig + * Required. Only fields specified in update_mask are 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/vpc_flow_logs_service.update_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_UpdateVpcFlowLogsConfig_async + */ updateVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1.IUpdateVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'vpc_flow_logs_config.name': request.vpcFlowLogsConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'vpc_flow_logs_config.name': request.vpcFlowLogsConfig!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.updateVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/vpc_flow_logs_service.update_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_UpdateVpcFlowLogsConfig_async - */ - async checkUpdateVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/vpc_flow_logs_service.update_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_UpdateVpcFlowLogsConfig_async + */ + async checkUpdateVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.OperationMetadata + > + > { this._log.info('updateVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.OperationMetadata + >; } -/** - * Deletes a specific `VpcFlowLogsConfig`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For a project-level resource: - * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` - * - * - For an organization-level resource: - * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/vpc_flow_logs_service.delete_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_DeleteVpcFlowLogsConfig_async - */ + /** + * Deletes a specific `VpcFlowLogsConfig`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For a project-level resource: + * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` + * + * - For an organization-level resource: + * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/vpc_flow_logs_service.delete_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_DeleteVpcFlowLogsConfig_async + */ deleteVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1.IDeleteVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.deleteVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/vpc_flow_logs_service.delete_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_DeleteVpcFlowLogsConfig_async - */ - async checkDeleteVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/vpc_flow_logs_service.delete_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_DeleteVpcFlowLogsConfig_async + */ + async checkDeleteVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1.OperationMetadata + > + > { this._log.info('deleteVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1.OperationMetadata + >; } - /** - * Lists all `VpcFlowLogsConfigs` in a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `listVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all `VpcFlowLogsConfigs` in a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `listVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse - ]>; + request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse, + ] + >; listVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + ): void; listVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + ): void; listVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>): - Promise<[ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse - ]>|void { + | protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + callback?: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listVpcFlowLogsConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -991,222 +1401,251 @@ export class VpcFlowLogsServiceClient { this._log.info('listVpcFlowLogsConfigs request %j', request); return this.innerApiCalls .listVpcFlowLogsConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse - ]) => { - this._log.info('listVpcFlowLogsConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsResponse, + ]) => { + this._log.info('listVpcFlowLogsConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listVpcFlowLogsConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listVpcFlowLogsConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listVpcFlowLogsConfigsStream( - request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listVpcFlowLogsConfigs stream %j', request); return this.descriptors.page.listVpcFlowLogsConfigs.createStream( this.innerApiCalls.listVpcFlowLogsConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listVpcFlowLogsConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/vpc_flow_logs_service.list_vpc_flow_logs_configs.js - * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_ListVpcFlowLogsConfigs_async - */ + /** + * Equivalent to `listVpcFlowLogsConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/vpc_flow_logs_service.list_vpc_flow_logs_configs.js + * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_ListVpcFlowLogsConfigs_async + */ listVpcFlowLogsConfigsAsync( - request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkmanagement.v1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listVpcFlowLogsConfigs iterate %j', request); return this.descriptors.page.listVpcFlowLogsConfigs.asyncIterate( this.innerApiCalls['listVpcFlowLogsConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * QueryOrgVpcFlowLogsConfigs returns a list of all organization-level VPC - * Flow Logs configurations applicable to the specified project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `queryOrgVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * QueryOrgVpcFlowLogsConfigs returns a list of all organization-level VPC + * Flow Logs configurations applicable to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `queryOrgVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ queryOrgVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse - ]>; + request?: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse, + ] + >; queryOrgVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + ): void; queryOrgVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + ): void; queryOrgVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>): - Promise<[ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse - ]>|void { + | protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + callback?: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('queryOrgVpcFlowLogsConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1215,214 +1654,243 @@ export class VpcFlowLogsServiceClient { this._log.info('queryOrgVpcFlowLogsConfigs request %j', request); return this.innerApiCalls .queryOrgVpcFlowLogsConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse - ]) => { - this._log.info('queryOrgVpcFlowLogsConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsResponse, + ]) => { + this._log.info('queryOrgVpcFlowLogsConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `queryOrgVpcFlowLogsConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `queryOrgVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `queryOrgVpcFlowLogsConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `queryOrgVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ queryOrgVpcFlowLogsConfigsStream( - request?: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['queryOrgVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('queryOrgVpcFlowLogsConfigs stream %j', request); return this.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream( this.innerApiCalls.queryOrgVpcFlowLogsConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `queryOrgVpcFlowLogsConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/vpc_flow_logs_service.query_org_vpc_flow_logs_configs.js - * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_QueryOrgVpcFlowLogsConfigs_async - */ + /** + * Equivalent to `queryOrgVpcFlowLogsConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/vpc_flow_logs_service.query_org_vpc_flow_logs_configs.js + * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_QueryOrgVpcFlowLogsConfigs_async + */ queryOrgVpcFlowLogsConfigsAsync( - request?: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkmanagement.v1.IQueryOrgVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['queryOrgVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('queryOrgVpcFlowLogsConfigs iterate %j', request); return this.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate( this.innerApiCalls['queryOrgVpcFlowLogsConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * ShowEffectiveFlowLogsConfigs returns a list of all VPC Flow Logs - * configurations applicable to a specified resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {string} request.resource - * Required. The resource to get the effective VPC Flow Logs configuration - * for. The resource must belong to the same project as the parent. The - * resource must be a network, subnetwork, interconnect attachment, VPN - * tunnel, or a project. - * @param {number} [request.pageSize] - * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter - * expression. A filter expression must use the supported [CEL logic - * operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 {@link protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `showEffectiveFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * ShowEffectiveFlowLogsConfigs returns a list of all VPC Flow Logs + * configurations applicable to a specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {string} request.resource + * Required. The resource to get the effective VPC Flow Logs configuration + * for. The resource must belong to the same project as the parent. The + * resource must be a network, subnetwork, interconnect attachment, VPN + * tunnel, or a project. + * @param {number} [request.pageSize] + * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter + * expression. A filter expression must use the supported [CEL logic + * operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 {@link protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `showEffectiveFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ showEffectiveFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse - ]>; + request?: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse, + ] + >; showEffectiveFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig + >, + ): void; showEffectiveFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig + >, + ): void; showEffectiveFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig>): - Promise<[ - protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse - ]>|void { + | protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig + >, + callback?: PaginationCallback< + protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('showEffectiveFlowLogsConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1431,157 +1899,161 @@ export class VpcFlowLogsServiceClient { this._log.info('showEffectiveFlowLogsConfigs request %j', request); return this.innerApiCalls .showEffectiveFlowLogsConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse - ]) => { - this._log.info('showEffectiveFlowLogsConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsResponse, + ]) => { + this._log.info('showEffectiveFlowLogsConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `showEffectiveFlowLogsConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {string} request.resource - * Required. The resource to get the effective VPC Flow Logs configuration - * for. The resource must belong to the same project as the parent. The - * resource must be a network, subnetwork, interconnect attachment, VPN - * tunnel, or a project. - * @param {number} [request.pageSize] - * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter - * expression. A filter expression must use the supported [CEL logic - * operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 {@link protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `showEffectiveFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `showEffectiveFlowLogsConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {string} request.resource + * Required. The resource to get the effective VPC Flow Logs configuration + * for. The resource must belong to the same project as the parent. The + * resource must be a network, subnetwork, interconnect attachment, VPN + * tunnel, or a project. + * @param {number} [request.pageSize] + * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter + * expression. A filter expression must use the supported [CEL logic + * operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 {@link protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `showEffectiveFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ showEffectiveFlowLogsConfigsStream( - request?: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['showEffectiveFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('showEffectiveFlowLogsConfigs stream %j', request); return this.descriptors.page.showEffectiveFlowLogsConfigs.createStream( this.innerApiCalls.showEffectiveFlowLogsConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `showEffectiveFlowLogsConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {string} request.resource - * Required. The resource to get the effective VPC Flow Logs configuration - * for. The resource must belong to the same project as the parent. The - * resource must be a network, subnetwork, interconnect attachment, VPN - * tunnel, or a project. - * @param {number} [request.pageSize] - * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter - * expression. A filter expression must use the supported [CEL logic - * operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/vpc_flow_logs_service.show_effective_flow_logs_configs.js - * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_ShowEffectiveFlowLogsConfigs_async - */ + /** + * Equivalent to `showEffectiveFlowLogsConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {string} request.resource + * Required. The resource to get the effective VPC Flow Logs configuration + * for. The resource must belong to the same project as the parent. The + * resource must be a network, subnetwork, interconnect attachment, VPN + * tunnel, or a project. + * @param {number} [request.pageSize] + * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter + * expression. A filter expression must use the supported [CEL logic + * operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/vpc_flow_logs_service.show_effective_flow_logs_configs.js + * region_tag:networkmanagement_v1_generated_VpcFlowLogsService_ShowEffectiveFlowLogsConfigs_async + */ showEffectiveFlowLogsConfigsAsync( - request?: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkmanagement.v1.IShowEffectiveFlowLogsConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['showEffectiveFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('showEffectiveFlowLogsConfigs iterate %j', request); return this.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate( this.innerApiCalls['showEffectiveFlowLogsConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1595,40 +2067,40 @@ export class VpcFlowLogsServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1642,41 +2114,41 @@ export class VpcFlowLogsServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1690,12 +2162,12 @@ export class VpcFlowLogsServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1730,12 +2202,11 @@ export class VpcFlowLogsServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1768,12 +2239,12 @@ export class VpcFlowLogsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1816,22 +2287,22 @@ export class VpcFlowLogsServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1866,15 +2337,15 @@ export class VpcFlowLogsServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1908,7 +2379,7 @@ export class VpcFlowLogsServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1921,25 +2392,24 @@ export class VpcFlowLogsServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1978,22 +2448,22 @@ export class VpcFlowLogsServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -2008,7 +2478,7 @@ export class VpcFlowLogsServiceClient { * @param {string} test * @returns {string} Resource name string. */ - connectivityTestPath(project:string,test:string) { + connectivityTestPath(project: string, test: string) { return this.pathTemplates.connectivityTestPathTemplate.render({ project: project, test: test, @@ -2023,7 +2493,9 @@ export class VpcFlowLogsServiceClient { * @returns {string} A string representing the project. */ matchProjectFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).project; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).project; } /** @@ -2034,7 +2506,9 @@ export class VpcFlowLogsServiceClient { * @returns {string} A string representing the test. */ matchTestFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).test; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).test; } /** @@ -2044,7 +2518,7 @@ export class VpcFlowLogsServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -2081,12 +2555,18 @@ export class VpcFlowLogsServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - organizationLocationVpcFlowLogsConfigsPath(organization:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render({ - organization: organization, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + organizationLocationVpcFlowLogsConfigsPath( + organization: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render( + { + organization: organization, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -2096,8 +2576,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).organization; + matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).organization; } /** @@ -2107,8 +2591,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).location; + matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -2118,8 +2606,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -2128,7 +2620,7 @@ export class VpcFlowLogsServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2153,12 +2645,18 @@ export class VpcFlowLogsServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - projectLocationVpcFlowLogsConfigsPath(project:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render({ - project: project, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + projectLocationVpcFlowLogsConfigsPath( + project: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render( + { + project: project, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -2168,8 +2666,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).project; + matchProjectFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).project; } /** @@ -2179,8 +2681,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).location; + matchLocationFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -2190,8 +2696,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -2202,15 +2712,19 @@ export class VpcFlowLogsServiceClient { */ close(): Promise { if (this.vpcFlowLogsServiceStub && !this._terminated) { - return this.vpcFlowLogsServiceStub.then(stub => { + return this.vpcFlowLogsServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkmanagement/src/v1beta1/index.ts b/packages/google-cloud-networkmanagement/src/v1beta1/index.ts index 58f25a8e94e6..3f3737863e25 100644 --- a/packages/google-cloud-networkmanagement/src/v1beta1/index.ts +++ b/packages/google-cloud-networkmanagement/src/v1beta1/index.ts @@ -16,6 +16,6 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {OrganizationVpcFlowLogsServiceClient} from './organization_vpc_flow_logs_service_client'; -export {ReachabilityServiceClient} from './reachability_service_client'; -export {VpcFlowLogsServiceClient} from './vpc_flow_logs_service_client'; +export { OrganizationVpcFlowLogsServiceClient } from './organization_vpc_flow_logs_service_client'; +export { ReachabilityServiceClient } from './reachability_service_client'; +export { VpcFlowLogsServiceClient } from './vpc_flow_logs_service_client'; diff --git a/packages/google-cloud-networkmanagement/src/v1beta1/organization_vpc_flow_logs_service_client.ts b/packages/google-cloud-networkmanagement/src/v1beta1/organization_vpc_flow_logs_service_client.ts index 799dd003211d..b5f05f2823f3 100644 --- a/packages/google-cloud-networkmanagement/src/v1beta1/organization_vpc_flow_logs_service_client.ts +++ b/packages/google-cloud-networkmanagement/src/v1beta1/organization_vpc_flow_logs_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -47,7 +60,7 @@ export class OrganizationVpcFlowLogsServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-management'); @@ -60,12 +73,12 @@ export class OrganizationVpcFlowLogsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - organizationVpcFlowLogsServiceStub?: Promise<{[name: string]: Function}>; + organizationVpcFlowLogsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of OrganizationVpcFlowLogsServiceClient. @@ -106,21 +119,43 @@ export class OrganizationVpcFlowLogsServiceClient { * const client = new OrganizationVpcFlowLogsServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof OrganizationVpcFlowLogsServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof OrganizationVpcFlowLogsServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkmanagement.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -145,7 +180,7 @@ export class OrganizationVpcFlowLogsServiceClient { 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; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -158,18 +193,14 @@ export class OrganizationVpcFlowLogsServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -191,28 +222,33 @@ export class OrganizationVpcFlowLogsServiceClient { // Create useful helper objects for these. this.pathTemplates = { connectivityTestPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/connectivityTests/{test}' + 'projects/{project}/locations/global/connectivityTests/{test}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - organizationLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}/locations/{location}', ), + organizationLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - projectLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}', ), + projectLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listVpcFlowLogsConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vpcFlowLogsConfigs') + listVpcFlowLogsConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'vpcFlowLogsConfigs', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -221,51 +257,139 @@ export class OrganizationVpcFlowLogsServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',additional_bindings: [{get: '/v1beta1/{name=organizations/*/locations/*}',}], - },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',additional_bindings: [{get: '/v1beta1/{name=organizations/*}/locations',}], - },{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/global/operations/*}:cancel',body: '*',additional_bindings: [{post: '/v1beta1/{name=organizations/*/locations/global/operations/*}:cancel',body: '*',}], - },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{delete: '/v1beta1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{get: '/v1beta1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/global}/operations',additional_bindings: [{get: '/v1beta1/{name=organizations/*/locations/global}/operations',}], - }]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta1/{name=projects/*/locations/*}', + additional_bindings: [ + { get: '/v1beta1/{name=organizations/*/locations/*}' }, + ], + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta1/{name=projects/*}/locations', + additional_bindings: [ + { get: '/v1beta1/{name=organizations/*}/locations' }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta1/{name=projects/*/locations/global/operations/*}:cancel', + body: '*', + additional_bindings: [ + { + post: '/v1beta1/{name=organizations/*/locations/global/operations/*}:cancel', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { + delete: + '/v1beta1/{name=organizations/*/locations/global/operations/*}', + }, + ], + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { + get: '/v1beta1/{name=organizations/*/locations/global/operations/*}', + }, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta1/{name=projects/*/locations/global}/operations', + additional_bindings: [ + { + get: '/v1beta1/{name=organizations/*/locations/global}/operations', + }, + ], + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig', + ) as gax.protobuf.Type; const createVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const updateVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig', + ) as gax.protobuf.Type; const updateVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const deleteVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createVpcFlowLogsConfigResponse.decode.bind(createVpcFlowLogsConfigResponse), - createVpcFlowLogsConfigMetadata.decode.bind(createVpcFlowLogsConfigMetadata)), + createVpcFlowLogsConfigResponse.decode.bind( + createVpcFlowLogsConfigResponse, + ), + createVpcFlowLogsConfigMetadata.decode.bind( + createVpcFlowLogsConfigMetadata, + ), + ), updateVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateVpcFlowLogsConfigResponse.decode.bind(updateVpcFlowLogsConfigResponse), - updateVpcFlowLogsConfigMetadata.decode.bind(updateVpcFlowLogsConfigMetadata)), + updateVpcFlowLogsConfigResponse.decode.bind( + updateVpcFlowLogsConfigResponse, + ), + updateVpcFlowLogsConfigMetadata.decode.bind( + updateVpcFlowLogsConfigMetadata, + ), + ), deleteVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteVpcFlowLogsConfigResponse.decode.bind(deleteVpcFlowLogsConfigResponse), - deleteVpcFlowLogsConfigMetadata.decode.bind(deleteVpcFlowLogsConfigMetadata)) + deleteVpcFlowLogsConfigResponse.decode.bind( + deleteVpcFlowLogsConfigResponse, + ), + deleteVpcFlowLogsConfigMetadata.decode.bind( + deleteVpcFlowLogsConfigMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkmanagement.v1beta1.OrganizationVpcFlowLogsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkmanagement.v1beta1.OrganizationVpcFlowLogsService', + 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 @@ -296,28 +420,40 @@ export class OrganizationVpcFlowLogsServiceClient { // Put together the "service stub" for // google.cloud.networkmanagement.v1beta1.OrganizationVpcFlowLogsService. this.organizationVpcFlowLogsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkmanagement.v1beta1.OrganizationVpcFlowLogsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkmanagement.v1beta1.OrganizationVpcFlowLogsService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkmanagement.v1beta1.OrganizationVpcFlowLogsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkmanagement.v1beta1 + .OrganizationVpcFlowLogsService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const organizationVpcFlowLogsServiceStubMethods = - ['listVpcFlowLogsConfigs', 'getVpcFlowLogsConfig', 'createVpcFlowLogsConfig', 'updateVpcFlowLogsConfig', 'deleteVpcFlowLogsConfig']; + const organizationVpcFlowLogsServiceStubMethods = [ + 'listVpcFlowLogsConfigs', + 'getVpcFlowLogsConfig', + 'createVpcFlowLogsConfig', + 'updateVpcFlowLogsConfig', + 'deleteVpcFlowLogsConfig', + ]; for (const methodName of organizationVpcFlowLogsServiceStubMethods) { const callPromise = this.organizationVpcFlowLogsServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -327,7 +463,7 @@ export class OrganizationVpcFlowLogsServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -342,8 +478,14 @@ export class OrganizationVpcFlowLogsServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -354,8 +496,14 @@ export class OrganizationVpcFlowLogsServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -386,9 +534,7 @@ export class OrganizationVpcFlowLogsServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -397,8 +543,9 @@ export class OrganizationVpcFlowLogsServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -409,577 +556,837 @@ export class OrganizationVpcFlowLogsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a specific `VpcFlowLogsConfig`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: - * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.get_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_GetVpcFlowLogsConfig_async - */ + /** + * Gets the details of a specific `VpcFlowLogsConfig`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: + * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.get_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_GetVpcFlowLogsConfig_async + */ getVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ] + >; getVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, - callback: Callback< - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, + callback: Callback< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getVpcFlowLogsConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getVpcFlowLogsConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getVpcFlowLogsConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getVpcFlowLogsConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new `VpcFlowLogsConfig`. - * If a configuration with the exact same settings already exists (even if the - * ID is different), the creation fails. - * Notes: - * - * 1. Creating a configuration with `state=DISABLED` will fail - * 2. The following fields are not considered as settings for the purpose - * of the check mentioned above, therefore - creating another configuration - * with the same fields but different values for the following fields will - * fail as well: - * * name - * * create_time - * * update_time - * * labels - * * description - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig to create, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {string} request.vpcFlowLogsConfigId - * Required. ID of the `VpcFlowLogsConfig`. - * @param {google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig} request.vpcFlowLogsConfig - * Required. A `VpcFlowLogsConfig` resource - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.create_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_CreateVpcFlowLogsConfig_async - */ + /** + * Creates a new `VpcFlowLogsConfig`. + * If a configuration with the exact same settings already exists (even if the + * ID is different), the creation fails. + * Notes: + * + * 1. Creating a configuration with `state=DISABLED` will fail + * 2. The following fields are not considered as settings for the purpose + * of the check mentioned above, therefore - creating another configuration + * with the same fields but different values for the following fields will + * fail as well: + * * name + * * create_time + * * update_time + * * labels + * * description + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig to create, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {string} request.vpcFlowLogsConfigId + * Required. ID of the `VpcFlowLogsConfig`. + * @param {google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig} request.vpcFlowLogsConfig + * Required. A `VpcFlowLogsConfig` resource + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.create_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_CreateVpcFlowLogsConfig_async + */ createVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.createVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.create_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_CreateVpcFlowLogsConfig_async - */ - async checkCreateVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.create_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_CreateVpcFlowLogsConfig_async + */ + async checkCreateVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + > + > { this._log.info('createVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + >; } -/** - * Updates an existing `VpcFlowLogsConfig`. - * If a configuration with the exact same settings already exists (even if the - * ID is different), the creation fails. - * Notes: - * - * 1. Updating a configuration with `state=DISABLED` will fail - * 2. The following fields are not considered as settings for the purpose - * of the check mentioned above, therefore - updating another configuration - * with the same fields but different values for the following fields will - * fail as well: - * * name - * * create_time - * * update_time - * * labels - * * description - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. - * For example, to change the state of the configuration to ENABLED, specify - * `update_mask` = `"state"`, and the `vpc_flow_logs_config` would be: - * `vpc_flow_logs_config = { - * name = - * "projects/my-project/locations/global/vpcFlowLogsConfigs/my-config" - * state = "ENABLED" }` - * @param {google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig} request.vpcFlowLogsConfig - * Required. Only fields specified in update_mask are 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.update_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_UpdateVpcFlowLogsConfig_async - */ + /** + * Updates an existing `VpcFlowLogsConfig`. + * If a configuration with the exact same settings already exists (even if the + * ID is different), the creation fails. + * Notes: + * + * 1. Updating a configuration with `state=DISABLED` will fail + * 2. The following fields are not considered as settings for the purpose + * of the check mentioned above, therefore - updating another configuration + * with the same fields but different values for the following fields will + * fail as well: + * * name + * * create_time + * * update_time + * * labels + * * description + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. + * For example, to change the state of the configuration to ENABLED, specify + * `update_mask` = `"state"`, and the `vpc_flow_logs_config` would be: + * `vpc_flow_logs_config = { + * name = + * "projects/my-project/locations/global/vpcFlowLogsConfigs/my-config" + * state = "ENABLED" }` + * @param {google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig} request.vpcFlowLogsConfig + * Required. Only fields specified in update_mask are 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.update_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_UpdateVpcFlowLogsConfig_async + */ updateVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'vpc_flow_logs_config.name': request.vpcFlowLogsConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'vpc_flow_logs_config.name': request.vpcFlowLogsConfig!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.updateVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.update_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_UpdateVpcFlowLogsConfig_async - */ - async checkUpdateVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.update_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_UpdateVpcFlowLogsConfig_async + */ + async checkUpdateVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + > + > { this._log.info('updateVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + >; } -/** - * Deletes a specific `VpcFlowLogsConfig`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For a project-level resource: - * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` - * - * - For an organization-level resource: - * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.delete_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_DeleteVpcFlowLogsConfig_async - */ + /** + * Deletes a specific `VpcFlowLogsConfig`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For a project-level resource: + * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` + * + * - For an organization-level resource: + * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.delete_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_DeleteVpcFlowLogsConfig_async + */ deleteVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.deleteVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.delete_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_DeleteVpcFlowLogsConfig_async - */ - async checkDeleteVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.delete_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_DeleteVpcFlowLogsConfig_async + */ + async checkDeleteVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + > + > { this._log.info('deleteVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + >; } - /** - * Lists all `VpcFlowLogsConfigs` in a given organization. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `listVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all `VpcFlowLogsConfigs` in a given organization. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `listVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse, + ] + >; listVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + ): void; listVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + ): void; listVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse - ]>|void { + | protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + callback?: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listVpcFlowLogsConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -988,159 +1395,163 @@ export class OrganizationVpcFlowLogsServiceClient { this._log.info('listVpcFlowLogsConfigs request %j', request); return this.innerApiCalls .listVpcFlowLogsConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse - ]) => { - this._log.info('listVpcFlowLogsConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse, + ]) => { + this._log.info('listVpcFlowLogsConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listVpcFlowLogsConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listVpcFlowLogsConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listVpcFlowLogsConfigsStream( - request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listVpcFlowLogsConfigs stream %j', request); return this.descriptors.page.listVpcFlowLogsConfigs.createStream( this.innerApiCalls.listVpcFlowLogsConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listVpcFlowLogsConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.list_vpc_flow_logs_configs.js - * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_ListVpcFlowLogsConfigs_async - */ + /** + * Equivalent to `listVpcFlowLogsConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/organization_vpc_flow_logs_service.list_vpc_flow_logs_configs.js + * region_tag:networkmanagement_v1beta1_generated_OrganizationVpcFlowLogsService_ListVpcFlowLogsConfigs_async + */ listVpcFlowLogsConfigsAsync( - request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listVpcFlowLogsConfigs iterate %j', request); return this.descriptors.page.listVpcFlowLogsConfigs.asyncIterate( this.innerApiCalls['listVpcFlowLogsConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1154,40 +1565,40 @@ export class OrganizationVpcFlowLogsServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1201,41 +1612,41 @@ export class OrganizationVpcFlowLogsServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1249,12 +1660,12 @@ export class OrganizationVpcFlowLogsServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1289,12 +1700,11 @@ export class OrganizationVpcFlowLogsServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1327,12 +1737,12 @@ export class OrganizationVpcFlowLogsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1375,22 +1785,22 @@ export class OrganizationVpcFlowLogsServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1425,15 +1835,15 @@ export class OrganizationVpcFlowLogsServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1467,7 +1877,7 @@ export class OrganizationVpcFlowLogsServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1480,25 +1890,24 @@ export class OrganizationVpcFlowLogsServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1537,22 +1946,22 @@ export class OrganizationVpcFlowLogsServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1567,7 +1976,7 @@ export class OrganizationVpcFlowLogsServiceClient { * @param {string} test * @returns {string} Resource name string. */ - connectivityTestPath(project:string,test:string) { + connectivityTestPath(project: string, test: string) { return this.pathTemplates.connectivityTestPathTemplate.render({ project: project, test: test, @@ -1582,7 +1991,9 @@ export class OrganizationVpcFlowLogsServiceClient { * @returns {string} A string representing the project. */ matchProjectFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).project; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).project; } /** @@ -1593,7 +2004,9 @@ export class OrganizationVpcFlowLogsServiceClient { * @returns {string} A string representing the test. */ matchTestFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).test; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).test; } /** @@ -1603,7 +2016,7 @@ export class OrganizationVpcFlowLogsServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -1640,12 +2053,18 @@ export class OrganizationVpcFlowLogsServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - organizationLocationVpcFlowLogsConfigsPath(organization:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render({ - organization: organization, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + organizationLocationVpcFlowLogsConfigsPath( + organization: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render( + { + organization: organization, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -1655,8 +2074,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).organization; + matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).organization; } /** @@ -1666,8 +2089,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).location; + matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -1677,8 +2104,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -1687,7 +2118,7 @@ export class OrganizationVpcFlowLogsServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1712,12 +2143,18 @@ export class OrganizationVpcFlowLogsServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - projectLocationVpcFlowLogsConfigsPath(project:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render({ - project: project, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + projectLocationVpcFlowLogsConfigsPath( + project: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render( + { + project: project, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -1727,8 +2164,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).project; + matchProjectFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).project; } /** @@ -1738,8 +2179,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).location; + matchLocationFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -1749,8 +2194,12 @@ export class OrganizationVpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -1761,15 +2210,19 @@ export class OrganizationVpcFlowLogsServiceClient { */ close(): Promise { if (this.organizationVpcFlowLogsServiceStub && !this._terminated) { - return this.organizationVpcFlowLogsServiceStub.then(stub => { + return this.organizationVpcFlowLogsServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkmanagement/src/v1beta1/reachability_service_client.ts b/packages/google-cloud-networkmanagement/src/v1beta1/reachability_service_client.ts index e58d610c91aa..bc16a81693e4 100644 --- a/packages/google-cloud-networkmanagement/src/v1beta1/reachability_service_client.ts +++ b/packages/google-cloud-networkmanagement/src/v1beta1/reachability_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -51,7 +64,7 @@ export class ReachabilityServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-management'); @@ -64,12 +77,12 @@ export class ReachabilityServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - reachabilityServiceStub?: Promise<{[name: string]: Function}>; + reachabilityServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of ReachabilityServiceClient. @@ -110,21 +123,42 @@ export class ReachabilityServiceClient { * const client = new ReachabilityServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof ReachabilityServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkmanagement.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -149,7 +183,7 @@ export class ReachabilityServiceClient { 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; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -162,18 +196,14 @@ export class ReachabilityServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -195,25 +225,30 @@ export class ReachabilityServiceClient { // Create useful helper objects for these. this.pathTemplates = { connectivityTestPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/connectivityTests/{test}' - ), - organizationLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}/locations/global/connectivityTests/{test}', ), + organizationLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - projectLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}', ), + projectLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listConnectivityTests: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources') + listConnectivityTests: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'resources', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -222,59 +257,154 @@ export class ReachabilityServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',additional_bindings: [{get: '/v1beta1/{name=organizations/*/locations/*}',}], - },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',additional_bindings: [{get: '/v1beta1/{name=organizations/*}/locations',}], - },{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/global/operations/*}:cancel',body: '*',additional_bindings: [{post: '/v1beta1/{name=organizations/*/locations/global/operations/*}:cancel',body: '*',}], - },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{delete: '/v1beta1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{get: '/v1beta1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/global}/operations',additional_bindings: [{get: '/v1beta1/{name=organizations/*/locations/global}/operations',}], - }]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta1/{name=projects/*/locations/*}', + additional_bindings: [ + { get: '/v1beta1/{name=organizations/*/locations/*}' }, + ], + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta1/{name=projects/*}/locations', + additional_bindings: [ + { get: '/v1beta1/{name=organizations/*}/locations' }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta1/{name=projects/*/locations/global/operations/*}:cancel', + body: '*', + additional_bindings: [ + { + post: '/v1beta1/{name=organizations/*/locations/global/operations/*}:cancel', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { + delete: + '/v1beta1/{name=organizations/*/locations/global/operations/*}', + }, + ], + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { + get: '/v1beta1/{name=organizations/*/locations/global/operations/*}', + }, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta1/{name=projects/*/locations/global}/operations', + additional_bindings: [ + { + get: '/v1beta1/{name=organizations/*/locations/global}/operations', + }, + ], + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createConnectivityTestResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.ConnectivityTest') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.ConnectivityTest', + ) as gax.protobuf.Type; const createConnectivityTestMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const updateConnectivityTestResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.ConnectivityTest') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.ConnectivityTest', + ) as gax.protobuf.Type; const updateConnectivityTestMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const rerunConnectivityTestResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.ConnectivityTest') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.ConnectivityTest', + ) as gax.protobuf.Type; const rerunConnectivityTestMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const deleteConnectivityTestResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteConnectivityTestMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createConnectivityTest: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createConnectivityTestResponse.decode.bind(createConnectivityTestResponse), - createConnectivityTestMetadata.decode.bind(createConnectivityTestMetadata)), + createConnectivityTestResponse.decode.bind( + createConnectivityTestResponse, + ), + createConnectivityTestMetadata.decode.bind( + createConnectivityTestMetadata, + ), + ), updateConnectivityTest: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateConnectivityTestResponse.decode.bind(updateConnectivityTestResponse), - updateConnectivityTestMetadata.decode.bind(updateConnectivityTestMetadata)), + updateConnectivityTestResponse.decode.bind( + updateConnectivityTestResponse, + ), + updateConnectivityTestMetadata.decode.bind( + updateConnectivityTestMetadata, + ), + ), rerunConnectivityTest: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - rerunConnectivityTestResponse.decode.bind(rerunConnectivityTestResponse), - rerunConnectivityTestMetadata.decode.bind(rerunConnectivityTestMetadata)), + rerunConnectivityTestResponse.decode.bind( + rerunConnectivityTestResponse, + ), + rerunConnectivityTestMetadata.decode.bind( + rerunConnectivityTestMetadata, + ), + ), deleteConnectivityTest: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteConnectivityTestResponse.decode.bind(deleteConnectivityTestResponse), - deleteConnectivityTestMetadata.decode.bind(deleteConnectivityTestMetadata)) + deleteConnectivityTestResponse.decode.bind( + deleteConnectivityTestResponse, + ), + deleteConnectivityTestMetadata.decode.bind( + deleteConnectivityTestMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkmanagement.v1beta1.ReachabilityService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkmanagement.v1beta1.ReachabilityService', + 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 @@ -305,28 +435,41 @@ export class ReachabilityServiceClient { // Put together the "service stub" for // google.cloud.networkmanagement.v1beta1.ReachabilityService. this.reachabilityServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkmanagement.v1beta1.ReachabilityService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkmanagement.v1beta1.ReachabilityService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkmanagement.v1beta1.ReachabilityService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkmanagement.v1beta1 + .ReachabilityService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const reachabilityServiceStubMethods = - ['listConnectivityTests', 'getConnectivityTest', 'createConnectivityTest', 'updateConnectivityTest', 'rerunConnectivityTest', 'deleteConnectivityTest']; + const reachabilityServiceStubMethods = [ + 'listConnectivityTests', + 'getConnectivityTest', + 'createConnectivityTest', + 'updateConnectivityTest', + 'rerunConnectivityTest', + 'deleteConnectivityTest', + ]; for (const methodName of reachabilityServiceStubMethods) { const callPromise = this.reachabilityServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -336,7 +479,7 @@ export class ReachabilityServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -351,8 +494,14 @@ export class ReachabilityServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -363,8 +512,14 @@ export class ReachabilityServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -395,9 +550,7 @@ export class ReachabilityServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -406,8 +559,9 @@ export class ReachabilityServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -418,686 +572,1008 @@ export class ReachabilityServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a specific Connectivity Test. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. `ConnectivityTest` resource name using the form: - * `projects/{project_id}/locations/global/connectivityTests/{test_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 {@link protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest|ConnectivityTest}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/reachability_service.get_connectivity_test.js - * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_GetConnectivityTest_async - */ + /** + * Gets the details of a specific Connectivity Test. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. `ConnectivityTest` resource name using the form: + * `projects/{project_id}/locations/global/connectivityTests/{test_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 {@link protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest|ConnectivityTest}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/reachability_service.get_connectivity_test.js + * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_GetConnectivityTest_async + */ getConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + ( + | protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest + | undefined + ), + {} | undefined, + ] + >; getConnectivityTest( - request: protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + | protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getConnectivityTest( - request: protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest, - callback: Callback< - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest, + callback: Callback< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + | protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + | protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + ( + | protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getConnectivityTest request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + | protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getConnectivityTest response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getConnectivityTest(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, - protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest|undefined, - {}|undefined - ]) => { - this._log.info('getConnectivityTest response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getConnectivityTest(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + ( + | protos.google.cloud.networkmanagement.v1beta1.IGetConnectivityTestRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getConnectivityTest response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new Connectivity Test. - * After you create a test, the reachability analysis is performed as part - * of the long running operation, which completes when the analysis completes. - * - * If the endpoint specifications in `ConnectivityTest` are invalid - * (for example, containing non-existent resources in the network, or you - * don't have read permissions to the network configurations of listed - * projects), then the reachability result returns a value of `UNKNOWN`. - * - * If the endpoint specifications in `ConnectivityTest` are - * incomplete, the reachability result returns a value of - * AMBIGUOUS. For more information, - * see the Connectivity Test documentation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the Connectivity Test to create: - * `projects/{project_id}/locations/global` - * @param {string} request.testId - * Required. The logical name of the Connectivity Test in your project - * with the following restrictions: - * - * * Must contain only lowercase letters, numbers, and hyphens. - * * Must start with a letter. - * * Must be between 1-40 characters. - * * Must end with a number or a letter. - * * Must be unique within the customer project - * @param {google.cloud.networkmanagement.v1beta1.ConnectivityTest} request.resource - * Required. A `ConnectivityTest` resource - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/reachability_service.create_connectivity_test.js - * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_CreateConnectivityTest_async - */ + /** + * Creates a new Connectivity Test. + * After you create a test, the reachability analysis is performed as part + * of the long running operation, which completes when the analysis completes. + * + * If the endpoint specifications in `ConnectivityTest` are invalid + * (for example, containing non-existent resources in the network, or you + * don't have read permissions to the network configurations of listed + * projects), then the reachability result returns a value of `UNKNOWN`. + * + * If the endpoint specifications in `ConnectivityTest` are + * incomplete, the reachability result returns a value of + * AMBIGUOUS. For more information, + * see the Connectivity Test documentation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the Connectivity Test to create: + * `projects/{project_id}/locations/global` + * @param {string} request.testId + * Required. The logical name of the Connectivity Test in your project + * with the following restrictions: + * + * * Must contain only lowercase letters, numbers, and hyphens. + * * Must start with a letter. + * * Must be between 1-40 characters. + * * Must end with a number or a letter. + * * Must be unique within the customer project + * @param {google.cloud.networkmanagement.v1beta1.ConnectivityTest} request.resource + * Required. A `ConnectivityTest` resource + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/reachability_service.create_connectivity_test.js + * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_CreateConnectivityTest_async + */ createConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1beta1.ICreateConnectivityTestRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.ICreateConnectivityTestRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createConnectivityTest( - request: protos.google.cloud.networkmanagement.v1beta1.ICreateConnectivityTestRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.ICreateConnectivityTestRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createConnectivityTest( - request: protos.google.cloud.networkmanagement.v1beta1.ICreateConnectivityTestRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.ICreateConnectivityTestRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1beta1.ICreateConnectivityTestRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1beta1.ICreateConnectivityTestRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createConnectivityTest response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createConnectivityTest request %j', request); - return this.innerApiCalls.createConnectivityTest(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createConnectivityTest response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createConnectivityTest(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createConnectivityTest response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createConnectivityTest()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/reachability_service.create_connectivity_test.js - * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_CreateConnectivityTest_async - */ - async checkCreateConnectivityTestProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createConnectivityTest()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/reachability_service.create_connectivity_test.js + * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_CreateConnectivityTest_async + */ + async checkCreateConnectivityTestProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + > + > { this._log.info('createConnectivityTest long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createConnectivityTest, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createConnectivityTest, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + >; } -/** - * Updates the configuration of an existing `ConnectivityTest`. - * After you update a test, the reachability analysis is performed as part - * of the long running operation, which completes when the analysis completes. - * The Reachability state in the test resource is updated with the new result. - * - * If the endpoint specifications in `ConnectivityTest` are invalid - * (for example, they contain non-existent resources in the network, or the - * user does not have read permissions to the network configurations of - * listed projects), then the reachability result returns a value of - * UNKNOWN. - * - * If the endpoint specifications in `ConnectivityTest` are incomplete, the - * reachability result returns a value of `AMBIGUOUS`. See the documentation - * in `ConnectivityTest` for more details. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. - * @param {google.cloud.networkmanagement.v1beta1.ConnectivityTest} request.resource - * Required. Only fields specified in update_mask are 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/reachability_service.update_connectivity_test.js - * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_UpdateConnectivityTest_async - */ + /** + * Updates the configuration of an existing `ConnectivityTest`. + * After you update a test, the reachability analysis is performed as part + * of the long running operation, which completes when the analysis completes. + * The Reachability state in the test resource is updated with the new result. + * + * If the endpoint specifications in `ConnectivityTest` are invalid + * (for example, they contain non-existent resources in the network, or the + * user does not have read permissions to the network configurations of + * listed projects), then the reachability result returns a value of + * UNKNOWN. + * + * If the endpoint specifications in `ConnectivityTest` are incomplete, the + * reachability result returns a value of `AMBIGUOUS`. See the documentation + * in `ConnectivityTest` for more details. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. + * @param {google.cloud.networkmanagement.v1beta1.ConnectivityTest} request.resource + * Required. Only fields specified in update_mask are 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/reachability_service.update_connectivity_test.js + * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_UpdateConnectivityTest_async + */ updateConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateConnectivityTestRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateConnectivityTestRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateConnectivityTest( - request: protos.google.cloud.networkmanagement.v1beta1.IUpdateConnectivityTestRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IUpdateConnectivityTestRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateConnectivityTest( - request: protos.google.cloud.networkmanagement.v1beta1.IUpdateConnectivityTestRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IUpdateConnectivityTestRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateConnectivityTestRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateConnectivityTestRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource.name': request.resource!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'resource.name': request.resource!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateConnectivityTest response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateConnectivityTest request %j', request); - return this.innerApiCalls.updateConnectivityTest(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateConnectivityTest response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateConnectivityTest(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateConnectivityTest response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateConnectivityTest()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/reachability_service.update_connectivity_test.js - * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_UpdateConnectivityTest_async - */ - async checkUpdateConnectivityTestProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateConnectivityTest()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/reachability_service.update_connectivity_test.js + * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_UpdateConnectivityTest_async + */ + async checkUpdateConnectivityTestProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + > + > { this._log.info('updateConnectivityTest long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateConnectivityTest, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateConnectivityTest, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + >; } -/** - * Rerun an existing `ConnectivityTest`. - * After the user triggers the rerun, the reachability analysis is performed - * as part of the long running operation, which completes when the analysis - * completes. - * - * Even though the test configuration remains the same, the reachability - * result may change due to underlying network configuration changes. - * - * If the endpoint specifications in `ConnectivityTest` become invalid (for - * example, specified resources are deleted in the network, or you lost - * read permissions to the network configurations of listed projects), then - * the reachability result returns a value of `UNKNOWN`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Connectivity Test resource name using the form: - * `projects/{project_id}/locations/global/connectivityTests/{test_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/reachability_service.rerun_connectivity_test.js - * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_RerunConnectivityTest_async - */ + /** + * Rerun an existing `ConnectivityTest`. + * After the user triggers the rerun, the reachability analysis is performed + * as part of the long running operation, which completes when the analysis + * completes. + * + * Even though the test configuration remains the same, the reachability + * result may change due to underlying network configuration changes. + * + * If the endpoint specifications in `ConnectivityTest` become invalid (for + * example, specified resources are deleted in the network, or you lost + * read permissions to the network configurations of listed projects), then + * the reachability result returns a value of `UNKNOWN`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Connectivity Test resource name using the form: + * `projects/{project_id}/locations/global/connectivityTests/{test_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/reachability_service.rerun_connectivity_test.js + * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_RerunConnectivityTest_async + */ rerunConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1beta1.IRerunConnectivityTestRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IRerunConnectivityTestRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rerunConnectivityTest( - request: protos.google.cloud.networkmanagement.v1beta1.IRerunConnectivityTestRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IRerunConnectivityTestRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rerunConnectivityTest( - request: protos.google.cloud.networkmanagement.v1beta1.IRerunConnectivityTestRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IRerunConnectivityTestRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rerunConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1beta1.IRerunConnectivityTestRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1beta1.IRerunConnectivityTestRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rerunConnectivityTest response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rerunConnectivityTest request %j', request); - return this.innerApiCalls.rerunConnectivityTest(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rerunConnectivityTest response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rerunConnectivityTest(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rerunConnectivityTest response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rerunConnectivityTest()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/reachability_service.rerun_connectivity_test.js - * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_RerunConnectivityTest_async - */ - async checkRerunConnectivityTestProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `rerunConnectivityTest()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/reachability_service.rerun_connectivity_test.js + * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_RerunConnectivityTest_async + */ + async checkRerunConnectivityTestProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + > + > { this._log.info('rerunConnectivityTest long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.rerunConnectivityTest, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rerunConnectivityTest, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + >; } -/** - * Deletes a specific `ConnectivityTest`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Connectivity Test resource name using the form: - * `projects/{project_id}/locations/global/connectivityTests/{test_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/reachability_service.delete_connectivity_test.js - * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_DeleteConnectivityTest_async - */ + /** + * Deletes a specific `ConnectivityTest`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Connectivity Test resource name using the form: + * `projects/{project_id}/locations/global/connectivityTests/{test_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/reachability_service.delete_connectivity_test.js + * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_DeleteConnectivityTest_async + */ deleteConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteConnectivityTestRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteConnectivityTestRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteConnectivityTest( - request: protos.google.cloud.networkmanagement.v1beta1.IDeleteConnectivityTestRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IDeleteConnectivityTestRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteConnectivityTest( - request: protos.google.cloud.networkmanagement.v1beta1.IDeleteConnectivityTestRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IDeleteConnectivityTestRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteConnectivityTest( - request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteConnectivityTestRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteConnectivityTestRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteConnectivityTest response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteConnectivityTest request %j', request); - return this.innerApiCalls.deleteConnectivityTest(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteConnectivityTest response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteConnectivityTest(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteConnectivityTest response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteConnectivityTest()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/reachability_service.delete_connectivity_test.js - * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_DeleteConnectivityTest_async - */ - async checkDeleteConnectivityTestProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteConnectivityTest()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/reachability_service.delete_connectivity_test.js + * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_DeleteConnectivityTest_async + */ + async checkDeleteConnectivityTestProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + > + > { this._log.info('deleteConnectivityTest long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteConnectivityTest, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteConnectivityTest, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + >; } - /** - * Lists all Connectivity Tests owned by a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the Connectivity Tests: - * `projects/{project_id}/locations/global` - * @param {number} request.pageSize - * Number of `ConnectivityTests` to return. - * @param {string} request.pageToken - * Page token from an earlier query, as returned in `next_page_token`. - * @param {string} request.filter - * Lists the `ConnectivityTests` that match the filter expression. A filter - * expression filters the resources listed in the response. The expression - * must be of the form ` ` where operators: `<`, `>`, - * `<=`, - * `>=`, - * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is - * roughly synonymous with equality). can refer to a proto or JSON - * field, or a synthetic field. Field names can be camelCase or snake_case. - * - * Examples: - * - Filter by name: - * name = "projects/proj-1/locations/global/connectivityTests/test-1 - * - * - Filter by labels: - * - Resources that have a key called `foo` - * labels.foo:* - * - Resources that have a key called `foo` whose value is `bar` - * labels.foo = bar - * @param {string} request.orderBy - * Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest|ConnectivityTest}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `listConnectivityTestsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all Connectivity Tests owned by a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the Connectivity Tests: + * `projects/{project_id}/locations/global` + * @param {number} request.pageSize + * Number of `ConnectivityTests` to return. + * @param {string} request.pageToken + * Page token from an earlier query, as returned in `next_page_token`. + * @param {string} request.filter + * Lists the `ConnectivityTests` that match the filter expression. A filter + * expression filters the resources listed in the response. The expression + * must be of the form ` ` where operators: `<`, `>`, + * `<=`, + * `>=`, + * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is + * roughly synonymous with equality). can refer to a proto or JSON + * field, or a synthetic field. Field names can be camelCase or snake_case. + * + * Examples: + * - Filter by name: + * name = "projects/proj-1/locations/global/connectivityTests/test-1 + * + * - Filter by labels: + * - Resources that have a key called `foo` + * labels.foo:* + * - Resources that have a key called `foo` whose value is `bar` + * labels.foo = bar + * @param {string} request.orderBy + * Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest|ConnectivityTest}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `listConnectivityTestsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listConnectivityTests( - request?: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[], - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[], + protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse, + ] + >; listConnectivityTests( - request: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest + >, + ): void; listConnectivityTests( - request: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest + >, + ): void; listConnectivityTests( - request?: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest>): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[], - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse - ]>|void { + | protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest + >, + callback?: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[], + protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listConnectivityTests values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1106,177 +1582,181 @@ export class ReachabilityServiceClient { this._log.info('listConnectivityTests request %j', request); return this.innerApiCalls .listConnectivityTests(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[], - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse - ]) => { - this._log.info('listConnectivityTests values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[], + protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsResponse, + ]) => { + this._log.info('listConnectivityTests values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listConnectivityTests`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the Connectivity Tests: - * `projects/{project_id}/locations/global` - * @param {number} request.pageSize - * Number of `ConnectivityTests` to return. - * @param {string} request.pageToken - * Page token from an earlier query, as returned in `next_page_token`. - * @param {string} request.filter - * Lists the `ConnectivityTests` that match the filter expression. A filter - * expression filters the resources listed in the response. The expression - * must be of the form ` ` where operators: `<`, `>`, - * `<=`, - * `>=`, - * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is - * roughly synonymous with equality). can refer to a proto or JSON - * field, or a synthetic field. Field names can be camelCase or snake_case. - * - * Examples: - * - Filter by name: - * name = "projects/proj-1/locations/global/connectivityTests/test-1 - * - * - Filter by labels: - * - Resources that have a key called `foo` - * labels.foo:* - * - Resources that have a key called `foo` whose value is `bar` - * labels.foo = bar - * @param {string} request.orderBy - * Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest|ConnectivityTest} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listConnectivityTestsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listConnectivityTests`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the Connectivity Tests: + * `projects/{project_id}/locations/global` + * @param {number} request.pageSize + * Number of `ConnectivityTests` to return. + * @param {string} request.pageToken + * Page token from an earlier query, as returned in `next_page_token`. + * @param {string} request.filter + * Lists the `ConnectivityTests` that match the filter expression. A filter + * expression filters the resources listed in the response. The expression + * must be of the form ` ` where operators: `<`, `>`, + * `<=`, + * `>=`, + * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is + * roughly synonymous with equality). can refer to a proto or JSON + * field, or a synthetic field. Field names can be camelCase or snake_case. + * + * Examples: + * - Filter by name: + * name = "projects/proj-1/locations/global/connectivityTests/test-1 + * + * - Filter by labels: + * - Resources that have a key called `foo` + * labels.foo:* + * - Resources that have a key called `foo` whose value is `bar` + * labels.foo = bar + * @param {string} request.orderBy + * Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest|ConnectivityTest} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listConnectivityTestsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listConnectivityTestsStream( - request?: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listConnectivityTests']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listConnectivityTests stream %j', request); return this.descriptors.page.listConnectivityTests.createStream( this.innerApiCalls.listConnectivityTests as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listConnectivityTests`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the Connectivity Tests: - * `projects/{project_id}/locations/global` - * @param {number} request.pageSize - * Number of `ConnectivityTests` to return. - * @param {string} request.pageToken - * Page token from an earlier query, as returned in `next_page_token`. - * @param {string} request.filter - * Lists the `ConnectivityTests` that match the filter expression. A filter - * expression filters the resources listed in the response. The expression - * must be of the form ` ` where operators: `<`, `>`, - * `<=`, - * `>=`, - * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is - * roughly synonymous with equality). can refer to a proto or JSON - * field, or a synthetic field. Field names can be camelCase or snake_case. - * - * Examples: - * - Filter by name: - * name = "projects/proj-1/locations/global/connectivityTests/test-1 - * - * - Filter by labels: - * - Resources that have a key called `foo` - * labels.foo:* - * - Resources that have a key called `foo` whose value is `bar` - * labels.foo = bar - * @param {string} request.orderBy - * Field to use to sort the list. - * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest|ConnectivityTest}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/reachability_service.list_connectivity_tests.js - * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_ListConnectivityTests_async - */ + /** + * Equivalent to `listConnectivityTests`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the Connectivity Tests: + * `projects/{project_id}/locations/global` + * @param {number} request.pageSize + * Number of `ConnectivityTests` to return. + * @param {string} request.pageToken + * Page token from an earlier query, as returned in `next_page_token`. + * @param {string} request.filter + * Lists the `ConnectivityTests` that match the filter expression. A filter + * expression filters the resources listed in the response. The expression + * must be of the form ` ` where operators: `<`, `>`, + * `<=`, + * `>=`, + * `!=`, `=`, `:` are supported (colon `:` represents a HAS operator which is + * roughly synonymous with equality). can refer to a proto or JSON + * field, or a synthetic field. Field names can be camelCase or snake_case. + * + * Examples: + * - Filter by name: + * name = "projects/proj-1/locations/global/connectivityTests/test-1 + * + * - Filter by labels: + * - Resources that have a key called `foo` + * labels.foo:* + * - Resources that have a key called `foo` whose value is `bar` + * labels.foo = bar + * @param {string} request.orderBy + * Field to use to sort the list. + * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest|ConnectivityTest}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/reachability_service.list_connectivity_tests.js + * region_tag:networkmanagement_v1beta1_generated_ReachabilityService_ListConnectivityTests_async + */ listConnectivityTestsAsync( - request?: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkmanagement.v1beta1.IListConnectivityTestsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listConnectivityTests']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listConnectivityTests iterate %j', request); return this.descriptors.page.listConnectivityTests.asyncIterate( this.innerApiCalls['listConnectivityTests'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1290,40 +1770,40 @@ export class ReachabilityServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1337,41 +1817,41 @@ export class ReachabilityServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1385,12 +1865,12 @@ export class ReachabilityServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1425,12 +1905,11 @@ export class ReachabilityServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1463,12 +1942,12 @@ export class ReachabilityServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1511,22 +1990,22 @@ export class ReachabilityServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1561,15 +2040,15 @@ export class ReachabilityServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1603,7 +2082,7 @@ export class ReachabilityServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1616,25 +2095,24 @@ export class ReachabilityServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1673,22 +2151,22 @@ export class ReachabilityServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -1703,7 +2181,7 @@ export class ReachabilityServiceClient { * @param {string} test * @returns {string} Resource name string. */ - connectivityTestPath(project:string,test:string) { + connectivityTestPath(project: string, test: string) { return this.pathTemplates.connectivityTestPathTemplate.render({ project: project, test: test, @@ -1718,7 +2196,9 @@ export class ReachabilityServiceClient { * @returns {string} A string representing the project. */ matchProjectFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).project; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).project; } /** @@ -1729,7 +2209,9 @@ export class ReachabilityServiceClient { * @returns {string} A string representing the test. */ matchTestFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).test; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).test; } /** @@ -1740,12 +2222,18 @@ export class ReachabilityServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - organizationLocationVpcFlowLogsConfigsPath(organization:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render({ - organization: organization, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + organizationLocationVpcFlowLogsConfigsPath( + organization: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render( + { + organization: organization, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -1755,8 +2243,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).organization; + matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).organization; } /** @@ -1766,8 +2258,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).location; + matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -1777,8 +2273,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -1787,7 +2287,7 @@ export class ReachabilityServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1812,12 +2312,18 @@ export class ReachabilityServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - projectLocationVpcFlowLogsConfigsPath(project:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render({ - project: project, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + projectLocationVpcFlowLogsConfigsPath( + project: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render( + { + project: project, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -1827,8 +2333,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).project; + matchProjectFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).project; } /** @@ -1838,8 +2348,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).location; + matchLocationFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -1849,8 +2363,12 @@ export class ReachabilityServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -1861,15 +2379,19 @@ export class ReachabilityServiceClient { */ close(): Promise { if (this.reachabilityServiceStub && !this._terminated) { - return this.reachabilityServiceStub.then(stub => { + return this.reachabilityServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkmanagement/src/v1beta1/vpc_flow_logs_service_client.ts b/packages/google-cloud-networkmanagement/src/v1beta1/vpc_flow_logs_service_client.ts index 505151adb320..0bc7bc9a2611 100644 --- a/packages/google-cloud-networkmanagement/src/v1beta1/vpc_flow_logs_service_client.ts +++ b/packages/google-cloud-networkmanagement/src/v1beta1/vpc_flow_logs_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -46,7 +59,7 @@ export class VpcFlowLogsServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('network-management'); @@ -59,12 +72,12 @@ export class VpcFlowLogsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - vpcFlowLogsServiceStub?: Promise<{[name: string]: Function}>; + vpcFlowLogsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of VpcFlowLogsServiceClient. @@ -105,21 +118,42 @@ export class VpcFlowLogsServiceClient { * const client = new VpcFlowLogsServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof VpcFlowLogsServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'networkmanagement.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -144,7 +178,7 @@ export class VpcFlowLogsServiceClient { 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; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -157,18 +191,14 @@ export class VpcFlowLogsServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -190,32 +220,43 @@ export class VpcFlowLogsServiceClient { // Create useful helper objects for these. this.pathTemplates = { connectivityTestPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/global/connectivityTests/{test}' + 'projects/{project}/locations/global/connectivityTests/{test}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - organizationLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}/locations/{location}', ), + organizationLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - projectLocationVpcFlowLogsConfigsPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}' + 'projects/{project}', ), + projectLocationVpcFlowLogsConfigsPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/vpcFlowLogsConfigs/{vpc_flow_logs_config}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listVpcFlowLogsConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vpcFlowLogsConfigs'), - queryOrgVpcFlowLogsConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'vpcFlowLogsConfigs'), - showEffectiveFlowLogsConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'effectiveFlowLogsConfigs') + listVpcFlowLogsConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'vpcFlowLogsConfigs', + ), + queryOrgVpcFlowLogsConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'vpcFlowLogsConfigs', + ), + showEffectiveFlowLogsConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'effectiveFlowLogsConfigs', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -224,51 +265,139 @@ export class VpcFlowLogsServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',additional_bindings: [{get: '/v1beta1/{name=organizations/*/locations/*}',}], - },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',additional_bindings: [{get: '/v1beta1/{name=organizations/*}/locations',}], - },{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/global/operations/*}:cancel',body: '*',additional_bindings: [{post: '/v1beta1/{name=organizations/*/locations/global/operations/*}:cancel',body: '*',}], - },{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{delete: '/v1beta1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/global/operations/*}',additional_bindings: [{get: '/v1beta1/{name=organizations/*/locations/global/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/global}/operations',additional_bindings: [{get: '/v1beta1/{name=organizations/*/locations/global}/operations',}], - }]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta1/{name=projects/*/locations/*}', + additional_bindings: [ + { get: '/v1beta1/{name=organizations/*/locations/*}' }, + ], + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta1/{name=projects/*}/locations', + additional_bindings: [ + { get: '/v1beta1/{name=organizations/*}/locations' }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta1/{resource=projects/*/locations/global/connectivityTests/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta1/{name=projects/*/locations/global/operations/*}:cancel', + body: '*', + additional_bindings: [ + { + post: '/v1beta1/{name=organizations/*/locations/global/operations/*}:cancel', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { + delete: + '/v1beta1/{name=organizations/*/locations/global/operations/*}', + }, + ], + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta1/{name=projects/*/locations/global/operations/*}', + additional_bindings: [ + { + get: '/v1beta1/{name=organizations/*/locations/global/operations/*}', + }, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta1/{name=projects/*/locations/global}/operations', + additional_bindings: [ + { + get: '/v1beta1/{name=organizations/*/locations/global}/operations', + }, + ], + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig', + ) as gax.protobuf.Type; const createVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const updateVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig', + ) as gax.protobuf.Type; const updateVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const deleteVpcFlowLogsConfigResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteVpcFlowLogsConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.networkmanagement.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.networkmanagement.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createVpcFlowLogsConfigResponse.decode.bind(createVpcFlowLogsConfigResponse), - createVpcFlowLogsConfigMetadata.decode.bind(createVpcFlowLogsConfigMetadata)), + createVpcFlowLogsConfigResponse.decode.bind( + createVpcFlowLogsConfigResponse, + ), + createVpcFlowLogsConfigMetadata.decode.bind( + createVpcFlowLogsConfigMetadata, + ), + ), updateVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateVpcFlowLogsConfigResponse.decode.bind(updateVpcFlowLogsConfigResponse), - updateVpcFlowLogsConfigMetadata.decode.bind(updateVpcFlowLogsConfigMetadata)), + updateVpcFlowLogsConfigResponse.decode.bind( + updateVpcFlowLogsConfigResponse, + ), + updateVpcFlowLogsConfigMetadata.decode.bind( + updateVpcFlowLogsConfigMetadata, + ), + ), deleteVpcFlowLogsConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteVpcFlowLogsConfigResponse.decode.bind(deleteVpcFlowLogsConfigResponse), - deleteVpcFlowLogsConfigMetadata.decode.bind(deleteVpcFlowLogsConfigMetadata)) + deleteVpcFlowLogsConfigResponse.decode.bind( + deleteVpcFlowLogsConfigResponse, + ), + deleteVpcFlowLogsConfigMetadata.decode.bind( + deleteVpcFlowLogsConfigMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.networkmanagement.v1beta1.VpcFlowLogsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.networkmanagement.v1beta1.VpcFlowLogsService', + 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 @@ -299,28 +428,42 @@ export class VpcFlowLogsServiceClient { // Put together the "service stub" for // google.cloud.networkmanagement.v1beta1.VpcFlowLogsService. this.vpcFlowLogsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.networkmanagement.v1beta1.VpcFlowLogsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.networkmanagement.v1beta1.VpcFlowLogsService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.networkmanagement.v1beta1.VpcFlowLogsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.networkmanagement.v1beta1 + .VpcFlowLogsService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const vpcFlowLogsServiceStubMethods = - ['listVpcFlowLogsConfigs', 'getVpcFlowLogsConfig', 'createVpcFlowLogsConfig', 'updateVpcFlowLogsConfig', 'deleteVpcFlowLogsConfig', 'queryOrgVpcFlowLogsConfigs', 'showEffectiveFlowLogsConfigs']; + const vpcFlowLogsServiceStubMethods = [ + 'listVpcFlowLogsConfigs', + 'getVpcFlowLogsConfig', + 'createVpcFlowLogsConfig', + 'updateVpcFlowLogsConfig', + 'deleteVpcFlowLogsConfig', + 'queryOrgVpcFlowLogsConfigs', + 'showEffectiveFlowLogsConfigs', + ]; for (const methodName of vpcFlowLogsServiceStubMethods) { const callPromise = this.vpcFlowLogsServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -330,7 +473,7 @@ export class VpcFlowLogsServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -345,8 +488,14 @@ export class VpcFlowLogsServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -357,8 +506,14 @@ export class VpcFlowLogsServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'networkmanagement.googleapis.com'; } @@ -389,9 +544,7 @@ export class VpcFlowLogsServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -400,8 +553,9 @@ export class VpcFlowLogsServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -412,577 +566,837 @@ export class VpcFlowLogsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a specific `VpcFlowLogsConfig`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: - * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/vpc_flow_logs_service.get_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_GetVpcFlowLogsConfig_async - */ + /** + * Gets the details of a specific `VpcFlowLogsConfig`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: + * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/vpc_flow_logs_service.get_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_GetVpcFlowLogsConfig_async + */ getVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ] + >; getVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, - callback: Callback< - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, + callback: Callback< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getVpcFlowLogsConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getVpcFlowLogsConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, - protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getVpcFlowLogsConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + ( + | protos.google.cloud.networkmanagement.v1beta1.IGetVpcFlowLogsConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getVpcFlowLogsConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Creates a new `VpcFlowLogsConfig`. - * If a configuration with the exact same settings already exists (even if the - * ID is different), the creation fails. - * Notes: - * - * 1. Creating a configuration with `state=DISABLED` will fail - * 2. The following fields are not considered as settings for the purpose - * of the check mentioned above, therefore - creating another configuration - * with the same fields but different values for the following fields will - * fail as well: - * * name - * * create_time - * * update_time - * * labels - * * description - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig to create, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {string} request.vpcFlowLogsConfigId - * Required. ID of the `VpcFlowLogsConfig`. - * @param {google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig} request.vpcFlowLogsConfig - * Required. A `VpcFlowLogsConfig` resource - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/vpc_flow_logs_service.create_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_CreateVpcFlowLogsConfig_async - */ + /** + * Creates a new `VpcFlowLogsConfig`. + * If a configuration with the exact same settings already exists (even if the + * ID is different), the creation fails. + * Notes: + * + * 1. Creating a configuration with `state=DISABLED` will fail + * 2. The following fields are not considered as settings for the purpose + * of the check mentioned above, therefore - creating another configuration + * with the same fields but different values for the following fields will + * fail as well: + * * name + * * create_time + * * update_time + * * labels + * * description + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig to create, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {string} request.vpcFlowLogsConfigId + * Required. ID of the `VpcFlowLogsConfig`. + * @param {google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig} request.vpcFlowLogsConfig + * Required. A `VpcFlowLogsConfig` resource + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/vpc_flow_logs_service.create_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_CreateVpcFlowLogsConfig_async + */ createVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1beta1.ICreateVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.createVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/vpc_flow_logs_service.create_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_CreateVpcFlowLogsConfig_async - */ - async checkCreateVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/vpc_flow_logs_service.create_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_CreateVpcFlowLogsConfig_async + */ + async checkCreateVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + > + > { this._log.info('createVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + >; } -/** - * Updates an existing `VpcFlowLogsConfig`. - * If a configuration with the exact same settings already exists (even if the - * ID is different), the creation fails. - * Notes: - * - * 1. Updating a configuration with `state=DISABLED` will fail - * 2. The following fields are not considered as settings for the purpose - * of the check mentioned above, therefore - updating another configuration - * with the same fields but different values for the following fields will - * fail as well: - * * name - * * create_time - * * update_time - * * labels - * * description - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. - * For example, to change the state of the configuration to ENABLED, specify - * `update_mask` = `"state"`, and the `vpc_flow_logs_config` would be: - * `vpc_flow_logs_config = { - * name = - * "projects/my-project/locations/global/vpcFlowLogsConfigs/my-config" - * state = "ENABLED" }` - * @param {google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig} request.vpcFlowLogsConfig - * Required. Only fields specified in update_mask are 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/vpc_flow_logs_service.update_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_UpdateVpcFlowLogsConfig_async - */ + /** + * Updates an existing `VpcFlowLogsConfig`. + * If a configuration with the exact same settings already exists (even if the + * ID is different), the creation fails. + * Notes: + * + * 1. Updating a configuration with `state=DISABLED` will fail + * 2. The following fields are not considered as settings for the purpose + * of the check mentioned above, therefore - updating another configuration + * with the same fields but different values for the following fields will + * fail as well: + * * name + * * create_time + * * update_time + * * labels + * * description + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. + * For example, to change the state of the configuration to ENABLED, specify + * `update_mask` = `"state"`, and the `vpc_flow_logs_config` would be: + * `vpc_flow_logs_config = { + * name = + * "projects/my-project/locations/global/vpcFlowLogsConfigs/my-config" + * state = "ENABLED" }` + * @param {google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig} request.vpcFlowLogsConfig + * Required. Only fields specified in update_mask are 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/vpc_flow_logs_service.update_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_UpdateVpcFlowLogsConfig_async + */ updateVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1beta1.IUpdateVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'vpc_flow_logs_config.name': request.vpcFlowLogsConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'vpc_flow_logs_config.name': request.vpcFlowLogsConfig!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.updateVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/vpc_flow_logs_service.update_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_UpdateVpcFlowLogsConfig_async - */ - async checkUpdateVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/vpc_flow_logs_service.update_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_UpdateVpcFlowLogsConfig_async + */ + async checkUpdateVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + > + > { this._log.info('updateVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + >; } -/** - * Deletes a specific `VpcFlowLogsConfig`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For a project-level resource: - * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` - * - * - For an organization-level resource: - * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/vpc_flow_logs_service.delete_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_DeleteVpcFlowLogsConfig_async - */ + /** + * Deletes a specific `VpcFlowLogsConfig`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For a project-level resource: + * `projects/{project_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_id}` + * + * - For an organization-level resource: + * `organizations/{organization_id}/locations/global/vpcFlowLogsConfigs/{vpc_flow_logs_config_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/vpc_flow_logs_service.delete_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_DeleteVpcFlowLogsConfig_async + */ deleteVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteVpcFlowLogsConfig( - request: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteVpcFlowLogsConfig( - request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.networkmanagement.v1beta1.IDeleteVpcFlowLogsConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteVpcFlowLogsConfig request %j', request); - return this.innerApiCalls.deleteVpcFlowLogsConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteVpcFlowLogsConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteVpcFlowLogsConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteVpcFlowLogsConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/vpc_flow_logs_service.delete_vpc_flow_logs_config.js - * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_DeleteVpcFlowLogsConfig_async - */ - async checkDeleteVpcFlowLogsConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteVpcFlowLogsConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/vpc_flow_logs_service.delete_vpc_flow_logs_config.js + * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_DeleteVpcFlowLogsConfig_async + */ + async checkDeleteVpcFlowLogsConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + > + > { this._log.info('deleteVpcFlowLogsConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteVpcFlowLogsConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteVpcFlowLogsConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.networkmanagement.v1beta1.OperationMetadata + >; } - /** - * Lists all `VpcFlowLogsConfigs` in a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `listVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists all `VpcFlowLogsConfigs` in a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `listVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse, + ] + >; listVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + ): void; listVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + ): void; listVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse - ]>|void { + | protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + callback?: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listVpcFlowLogsConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -991,222 +1405,251 @@ export class VpcFlowLogsServiceClient { this._log.info('listVpcFlowLogsConfigs request %j', request); return this.innerApiCalls .listVpcFlowLogsConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse - ]) => { - this._log.info('listVpcFlowLogsConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsResponse, + ]) => { + this._log.info('listVpcFlowLogsConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listVpcFlowLogsConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listVpcFlowLogsConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listVpcFlowLogsConfigsStream( - request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listVpcFlowLogsConfigs stream %j', request); return this.descriptors.page.listVpcFlowLogsConfigs.createStream( this.innerApiCalls.listVpcFlowLogsConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listVpcFlowLogsConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, - * in one of the following formats: - * - * - For project-level resources: `projects/{project_id}/locations/global` - * - * - For organization-level resources: - * `organizations/{organization_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @param {string} [request.orderBy] - * Optional. Field to use to sort the list. - * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/vpc_flow_logs_service.list_vpc_flow_logs_configs.js - * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_ListVpcFlowLogsConfigs_async - */ + /** + * Equivalent to `listVpcFlowLogsConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, + * in one of the following formats: + * + * - For project-level resources: `projects/{project_id}/locations/global` + * + * - For organization-level resources: + * `organizations/{organization_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @param {string} [request.orderBy] + * Optional. Field to use to sort the list. + * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/vpc_flow_logs_service.list_vpc_flow_logs_configs.js + * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_ListVpcFlowLogsConfigs_async + */ listVpcFlowLogsConfigsAsync( - request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkmanagement.v1beta1.IListVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listVpcFlowLogsConfigs iterate %j', request); return this.descriptors.page.listVpcFlowLogsConfigs.asyncIterate( this.innerApiCalls['listVpcFlowLogsConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * QueryOrgVpcFlowLogsConfigs returns a list of all organization-level VPC - * Flow Logs configurations applicable to the specified project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `queryOrgVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * QueryOrgVpcFlowLogsConfigs returns a list of all organization-level VPC + * Flow Logs configurations applicable to the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `queryOrgVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ queryOrgVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse, + ] + >; queryOrgVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + ): void; queryOrgVpcFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + ): void; queryOrgVpcFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse - ]>|void { + | protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + callback?: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('queryOrgVpcFlowLogsConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1215,214 +1658,243 @@ export class VpcFlowLogsServiceClient { this._log.info('queryOrgVpcFlowLogsConfigs request %j', request); return this.innerApiCalls .queryOrgVpcFlowLogsConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse - ]) => { - this._log.info('queryOrgVpcFlowLogsConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsResponse, + ]) => { + this._log.info('queryOrgVpcFlowLogsConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `queryOrgVpcFlowLogsConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `queryOrgVpcFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `queryOrgVpcFlowLogsConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `queryOrgVpcFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ queryOrgVpcFlowLogsConfigsStream( - request?: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['queryOrgVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('queryOrgVpcFlowLogsConfigs stream %j', request); return this.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream( this.innerApiCalls.queryOrgVpcFlowLogsConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `queryOrgVpcFlowLogsConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {number} [request.pageSize] - * Optional. Number of `VpcFlowLogsConfigs` to return. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. - * A filter expression must use the supported [CEL logic operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/vpc_flow_logs_service.query_org_vpc_flow_logs_configs.js - * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_QueryOrgVpcFlowLogsConfigs_async - */ + /** + * Equivalent to `queryOrgVpcFlowLogsConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {number} [request.pageSize] + * Optional. Number of `VpcFlowLogsConfigs` to return. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `VpcFlowLogsConfigs` that match the filter expression. + * A filter expression must use the supported [CEL logic operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig|VpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/vpc_flow_logs_service.query_org_vpc_flow_logs_configs.js + * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_QueryOrgVpcFlowLogsConfigs_async + */ queryOrgVpcFlowLogsConfigsAsync( - request?: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkmanagement.v1beta1.IQueryOrgVpcFlowLogsConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['queryOrgVpcFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('queryOrgVpcFlowLogsConfigs iterate %j', request); return this.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate( this.innerApiCalls['queryOrgVpcFlowLogsConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * ShowEffectiveFlowLogsConfigs returns a list of all VPC Flow Logs - * configurations applicable to a specified resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {string} request.resource - * Required. The resource to get the effective VPC Flow Logs configuration - * for. The resource must belong to the same project as the parent. The - * resource must be a network, subnetwork, interconnect attachment, VPN - * tunnel, or a project. - * @param {number} [request.pageSize] - * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter - * expression. A filter expression must use the supported [CEL logic - * operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 {@link protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig}. - * The client library will perform 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. - * Note that it can affect your quota. - * We recommend using `showEffectiveFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * ShowEffectiveFlowLogsConfigs returns a list of all VPC Flow Logs + * configurations applicable to a specified resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {string} request.resource + * Required. The resource to get the effective VPC Flow Logs configuration + * for. The resource must belong to the same project as the parent. The + * resource must be a network, subnetwork, interconnect attachment, VPN + * tunnel, or a project. + * @param {number} [request.pageSize] + * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter + * expression. A filter expression must use the supported [CEL logic + * operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 {@link protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig}. + * The client library will perform 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. + * Note that it can affect your quota. + * We recommend using `showEffectiveFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ showEffectiveFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse - ]>; + request?: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse, + ] + >; showEffectiveFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig + >, + ): void; showEffectiveFlowLogsConfigs( - request: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig>): void; + request: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig + >, + ): void; showEffectiveFlowLogsConfigs( - request?: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig>): - Promise<[ - protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse - ]>|void { + | protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig + >, + callback?: PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig + >, + ): Promise< + [ + protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse|null|undefined, - protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, + | protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse + | null + | undefined, + protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('showEffectiveFlowLogsConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1431,157 +1903,161 @@ export class VpcFlowLogsServiceClient { this._log.info('showEffectiveFlowLogsConfigs request %j', request); return this.innerApiCalls .showEffectiveFlowLogsConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[], - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest|null, - protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse - ]) => { - this._log.info('showEffectiveFlowLogsConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[], + protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest | null, + protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsResponse, + ]) => { + this._log.info('showEffectiveFlowLogsConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `showEffectiveFlowLogsConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {string} request.resource - * Required. The resource to get the effective VPC Flow Logs configuration - * for. The resource must belong to the same project as the parent. The - * resource must be a network, subnetwork, interconnect attachment, VPN - * tunnel, or a project. - * @param {number} [request.pageSize] - * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter - * expression. A filter expression must use the supported [CEL logic - * operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 {@link protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `showEffectiveFlowLogsConfigsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `showEffectiveFlowLogsConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {string} request.resource + * Required. The resource to get the effective VPC Flow Logs configuration + * for. The resource must belong to the same project as the parent. The + * resource must be a network, subnetwork, interconnect attachment, VPN + * tunnel, or a project. + * @param {number} [request.pageSize] + * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter + * expression. A filter expression must use the supported [CEL logic + * operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 {@link protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `showEffectiveFlowLogsConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ showEffectiveFlowLogsConfigsStream( - request?: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['showEffectiveFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('showEffectiveFlowLogsConfigs stream %j', request); return this.descriptors.page.showEffectiveFlowLogsConfigs.createStream( this.innerApiCalls.showEffectiveFlowLogsConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `showEffectiveFlowLogsConfigs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource of the VpcFlowLogsConfig, specified in - * the following format: `projects/{project_id}/locations/global` - * @param {string} request.resource - * Required. The resource to get the effective VPC Flow Logs configuration - * for. The resource must belong to the same project as the parent. The - * resource must be a network, subnetwork, interconnect attachment, VPN - * tunnel, or a project. - * @param {number} [request.pageSize] - * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. - * @param {string} [request.pageToken] - * Optional. Page token from an earlier query, as returned in - * `next_page_token`. - * @param {string} [request.filter] - * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter - * expression. A filter expression must use the supported [CEL logic - * operators] - * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). - * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/vpc_flow_logs_service.show_effective_flow_logs_configs.js - * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_ShowEffectiveFlowLogsConfigs_async - */ + /** + * Equivalent to `showEffectiveFlowLogsConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource of the VpcFlowLogsConfig, specified in + * the following format: `projects/{project_id}/locations/global` + * @param {string} request.resource + * Required. The resource to get the effective VPC Flow Logs configuration + * for. The resource must belong to the same project as the parent. The + * resource must be a network, subnetwork, interconnect attachment, VPN + * tunnel, or a project. + * @param {number} [request.pageSize] + * Optional. Number of `EffectiveVpcFlowLogsConfigs` to return. Default is 30. + * @param {string} [request.pageToken] + * Optional. Page token from an earlier query, as returned in + * `next_page_token`. + * @param {string} [request.filter] + * Optional. Lists the `EffectiveVpcFlowLogsConfigs` that match the filter + * expression. A filter expression must use the supported [CEL logic + * operators] + * (https://cloud.google.com/vpc/docs/about-flow-logs-records#supported_cel_logic_operators). + * @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 allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig|EffectiveVpcFlowLogsConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/vpc_flow_logs_service.show_effective_flow_logs_configs.js + * region_tag:networkmanagement_v1beta1_generated_VpcFlowLogsService_ShowEffectiveFlowLogsConfigs_async + */ showEffectiveFlowLogsConfigsAsync( - request?: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.networkmanagement.v1beta1.IShowEffectiveFlowLogsConfigsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['showEffectiveFlowLogsConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('showEffectiveFlowLogsConfigs iterate %j', request); return this.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate( this.innerApiCalls['showEffectiveFlowLogsConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1595,40 +2071,40 @@ export class VpcFlowLogsServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1642,41 +2118,41 @@ export class VpcFlowLogsServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1690,12 +2166,12 @@ export class VpcFlowLogsServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1730,12 +2206,11 @@ export class VpcFlowLogsServiceClient { | null | undefined, {} | null | undefined - > + >, ): Promise { return this.locationsClient.getLocation(request, options, callback); } - -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -1768,12 +2243,12 @@ export class VpcFlowLogsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -1816,22 +2291,22 @@ export class VpcFlowLogsServiceClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.getOperation(request, options, callback); } /** @@ -1866,15 +2341,15 @@ export class VpcFlowLogsServiceClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.listOperationsAsync(request, options); } /** @@ -1908,7 +2383,7 @@ export class VpcFlowLogsServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1921,25 +2396,24 @@ export class VpcFlowLogsServiceClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.cancelOperation(request, options, callback); } - /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the @@ -1978,22 +2452,22 @@ export class VpcFlowLogsServiceClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { - let options: gax.CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } else { - options = optionsOrCallback as gax.CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - name: request.name ?? '', - }); + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); return this.operationsClient.deleteOperation(request, options, callback); } @@ -2008,7 +2482,7 @@ export class VpcFlowLogsServiceClient { * @param {string} test * @returns {string} Resource name string. */ - connectivityTestPath(project:string,test:string) { + connectivityTestPath(project: string, test: string) { return this.pathTemplates.connectivityTestPathTemplate.render({ project: project, test: test, @@ -2023,7 +2497,9 @@ export class VpcFlowLogsServiceClient { * @returns {string} A string representing the project. */ matchProjectFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).project; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).project; } /** @@ -2034,7 +2510,9 @@ export class VpcFlowLogsServiceClient { * @returns {string} A string representing the test. */ matchTestFromConnectivityTestName(connectivityTestName: string) { - return this.pathTemplates.connectivityTestPathTemplate.match(connectivityTestName).test; + return this.pathTemplates.connectivityTestPathTemplate.match( + connectivityTestName, + ).test; } /** @@ -2044,7 +2522,7 @@ export class VpcFlowLogsServiceClient { * @param {string} location * @returns {string} Resource name string. */ - locationPath(project:string,location:string) { + locationPath(project: string, location: string) { return this.pathTemplates.locationPathTemplate.render({ project: project, location: location, @@ -2081,12 +2559,18 @@ export class VpcFlowLogsServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - organizationLocationVpcFlowLogsConfigsPath(organization:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render({ - organization: organization, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + organizationLocationVpcFlowLogsConfigsPath( + organization: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render( + { + organization: organization, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -2096,8 +2580,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).organization; + matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).organization; } /** @@ -2107,8 +2595,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).location; + matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -2118,8 +2610,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing organization_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(organizationLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match(organizationLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + organizationLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match( + organizationLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -2128,7 +2624,7 @@ export class VpcFlowLogsServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2153,12 +2649,18 @@ export class VpcFlowLogsServiceClient { * @param {string} vpc_flow_logs_config * @returns {string} Resource name string. */ - projectLocationVpcFlowLogsConfigsPath(project:string,location:string,vpcFlowLogsConfig:string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render({ - project: project, - location: location, - vpc_flow_logs_config: vpcFlowLogsConfig, - }); + projectLocationVpcFlowLogsConfigsPath( + project: string, + location: string, + vpcFlowLogsConfig: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render( + { + project: project, + location: location, + vpc_flow_logs_config: vpcFlowLogsConfig, + }, + ); } /** @@ -2168,8 +2670,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).project; + matchProjectFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).project; } /** @@ -2179,8 +2685,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).location; + matchLocationFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).location; } /** @@ -2190,8 +2700,12 @@ export class VpcFlowLogsServiceClient { * A fully-qualified path representing project_location_vpcFlowLogsConfigs resource. * @returns {string} A string representing the vpc_flow_logs_config. */ - matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(projectLocationVpcFlowLogsConfigsName: string) { - return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match(projectLocationVpcFlowLogsConfigsName).vpc_flow_logs_config; + matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + projectLocationVpcFlowLogsConfigsName: string, + ) { + return this.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match( + projectLocationVpcFlowLogsConfigsName, + ).vpc_flow_logs_config; } /** @@ -2202,15 +2716,19 @@ export class VpcFlowLogsServiceClient { */ close(): Promise { if (this.vpcFlowLogsServiceStub && !this._terminated) { - return this.vpcFlowLogsServiceStub.then(stub => { + return this.vpcFlowLogsServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-networkmanagement/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-networkmanagement/system-test/fixtures/sample/src/index.ts index a5ea1c799be2..dbfbf78b443b 100644 --- a/packages/google-cloud-networkmanagement/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-networkmanagement/system-test/fixtures/sample/src/index.ts @@ -16,13 +16,21 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {OrganizationVpcFlowLogsServiceClient, ReachabilityServiceClient, VpcFlowLogsServiceClient} from '@google-cloud/network-management'; +import { + OrganizationVpcFlowLogsServiceClient, + ReachabilityServiceClient, + VpcFlowLogsServiceClient, +} from '@google-cloud/network-management'; // check that the client class type name can be used -function doStuffWithOrganizationVpcFlowLogsServiceClient(client: OrganizationVpcFlowLogsServiceClient) { +function doStuffWithOrganizationVpcFlowLogsServiceClient( + client: OrganizationVpcFlowLogsServiceClient, +) { client.close(); } -function doStuffWithReachabilityServiceClient(client: ReachabilityServiceClient) { +function doStuffWithReachabilityServiceClient( + client: ReachabilityServiceClient, +) { client.close(); } function doStuffWithVpcFlowLogsServiceClient(client: VpcFlowLogsServiceClient) { @@ -31,8 +39,11 @@ function doStuffWithVpcFlowLogsServiceClient(client: VpcFlowLogsServiceClient) { function main() { // check that the client instance can be created - const organizationVpcFlowLogsServiceClient = new OrganizationVpcFlowLogsServiceClient(); - doStuffWithOrganizationVpcFlowLogsServiceClient(organizationVpcFlowLogsServiceClient); + const organizationVpcFlowLogsServiceClient = + new OrganizationVpcFlowLogsServiceClient(); + doStuffWithOrganizationVpcFlowLogsServiceClient( + organizationVpcFlowLogsServiceClient, + ); // check that the client instance can be created const reachabilityServiceClient = new ReachabilityServiceClient(); doStuffWithReachabilityServiceClient(reachabilityServiceClient); diff --git a/packages/google-cloud-networkmanagement/system-test/install.ts b/packages/google-cloud-networkmanagement/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-networkmanagement/system-test/install.ts +++ b/packages/google-cloud-networkmanagement/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('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript 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); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-networkmanagement/test/gapic_organization_vpc_flow_logs_service_v1.ts b/packages/google-cloud-networkmanagement/test/gapic_organization_vpc_flow_logs_service_v1.ts index 6a6eb0f210dc..d1af060dfe94 100644 --- a/packages/google-cloud-networkmanagement/test/gapic_organization_vpc_flow_logs_service_v1.ts +++ b/packages/google-cloud-networkmanagement/test/gapic_organization_vpc_flow_logs_service_v1.ts @@ -19,1976 +19,2797 @@ 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 { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as organizationvpcflowlogsserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -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.OrganizationVpcFlowLogsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient(); - assert(client); - }); + it('has universeDomain', () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - fallback: true, - }); - assert(client); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + organizationvpcflowlogsserviceModule.v1 + .OrganizationVpcFlowLogsServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + organizationvpcflowlogsserviceModule.v1 + .OrganizationVpcFlowLogsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.organizationVpcFlowLogsServiceStub, undefined); - await client.initialize(); - assert(client.organizationVpcFlowLogsServiceStub); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.organizationVpcFlowLogsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkmanagement.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('has close method for the non-initialized client', done => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.organizationVpcFlowLogsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + organizationvpcflowlogsserviceModule.v1 + .OrganizationVpcFlowLogsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - 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('should create a client with no option', () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient(); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - 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('should create a client with gRPC fallback', () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + fallback: true, + }, + ); + assert(client); }); - describe('getVpcFlowLogsConfig', () => { - it('invokes getVpcFlowLogsConfig without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig() - ); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getVpcFlowLogsConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.organizationVpcFlowLogsServiceStub, undefined); + await client.initialize(); + assert(client.organizationVpcFlowLogsServiceStub); + }); - it('invokes getVpcFlowLogsConfig without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig() - ); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getVpcFlowLogsConfig( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.organizationVpcFlowLogsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getVpcFlowLogsConfig with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.organizationVpcFlowLogsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getVpcFlowLogsConfig with closed client', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + 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('createVpcFlowLogsConfig', () => { - it('invokes createVpcFlowLogsConfig without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + 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('getVpcFlowLogsConfig', () => { + it('invokes getVpcFlowLogsConfig without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ); + client.innerApiCalls.getVpcFlowLogsConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getVpcFlowLogsConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createVpcFlowLogsConfig without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getVpcFlowLogsConfig without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ); + client.innerApiCalls.getVpcFlowLogsConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createVpcFlowLogsConfig with call error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getVpcFlowLogsConfig with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createVpcFlowLogsConfig with LRO error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getVpcFlowLogsConfig with closed client', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); + }); + }); + + describe('createVpcFlowLogsConfig', () => { + it('invokes createVpcFlowLogsConfig without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateVpcFlowLogsConfigProgress without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createVpcFlowLogsConfig without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateVpcFlowLogsConfigProgress with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createVpcFlowLogsConfig with call error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateVpcFlowLogsConfig', () => { - it('invokes updateVpcFlowLogsConfig without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createVpcFlowLogsConfig with LRO error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateVpcFlowLogsConfig without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateVpcFlowLogsConfigProgress without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateVpcFlowLogsConfig with call error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateVpcFlowLogsConfigProgress with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateVpcFlowLogsConfig', () => { + it('invokes updateVpcFlowLogsConfig without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateVpcFlowLogsConfig with LRO error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateVpcFlowLogsConfig without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateVpcFlowLogsConfigProgress without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateVpcFlowLogsConfig with call error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateVpcFlowLogsConfigProgress with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateVpcFlowLogsConfig with LRO error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteVpcFlowLogsConfig', () => { - it('invokes deleteVpcFlowLogsConfig without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateVpcFlowLogsConfigProgress without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkUpdateVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteVpcFlowLogsConfig without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateVpcFlowLogsConfigProgress with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteVpcFlowLogsConfig', () => { + it('invokes deleteVpcFlowLogsConfig without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteVpcFlowLogsConfig with call error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteVpcFlowLogsConfig without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteVpcFlowLogsConfig with LRO error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteVpcFlowLogsConfig with call error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteVpcFlowLogsConfigProgress without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteVpcFlowLogsConfig with LRO error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteVpcFlowLogsConfigProgress with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteVpcFlowLogsConfigProgress without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkDeleteVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listVpcFlowLogsConfigs', () => { - it('invokes listVpcFlowLogsConfigs without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listVpcFlowLogsConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteVpcFlowLogsConfigProgress with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listVpcFlowLogsConfigs', () => { + it('invokes listVpcFlowLogsConfigs without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.listVpcFlowLogsConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.listVpcFlowLogsConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listVpcFlowLogsConfigs without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listVpcFlowLogsConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listVpcFlowLogsConfigs without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.listVpcFlowLogsConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listVpcFlowLogsConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listVpcFlowLogsConfigs with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listVpcFlowLogsConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listVpcFlowLogsConfigs with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listVpcFlowLogsConfigs(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listVpcFlowLogsConfigsStream without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.listVpcFlowLogsConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig) => { - 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.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listVpcFlowLogsConfigsStream without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.listVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + ) => { + 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.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listVpcFlowLogsConfigsStream with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listVpcFlowLogsConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listVpcFlowLogsConfigsStream with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listVpcFlowLogsConfigs without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = []; - const iterable = client.listVpcFlowLogsConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listVpcFlowLogsConfigs without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = + []; + const iterable = client.listVpcFlowLogsConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listVpcFlowLogsConfigs with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listVpcFlowLogsConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listVpcFlowLogsConfigs with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listVpcFlowLogsConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('connectivityTest', async () => { + const fakePath = '/rendered/path/connectivityTest'; + const expectedParameters = { + project: 'projectValue', + test: 'testValue', + }; + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.connectivityTestPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.connectivityTestPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('connectivityTestPath', () => { + const result = client.connectivityTestPath('projectValue', 'testValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.connectivityTestPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromConnectivityTestName', () => { + const result = client.matchProjectFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTestFromConnectivityTestName', () => { + const result = client.matchTestFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'testValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('connectivityTest', async () => { - const fakePath = "/rendered/path/connectivityTest"; - const expectedParameters = { - project: "projectValue", - test: "testValue", - }; - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.connectivityTestPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.connectivityTestPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('connectivityTestPath', () => { - const result = client.connectivityTestPath("projectValue", "testValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.connectivityTestPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromConnectivityTestName', () => { - const result = client.matchProjectFromConnectivityTestName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTestFromConnectivityTestName', () => { - const result = client.matchTestFromConnectivityTestName(fakePath); - assert.strictEqual(result, "testValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/organizationLocationVpcFlowLogsConfigs"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationVpcFlowLogsConfigsPath', () => { - const result = client.organizationLocationVpcFlowLogsConfigsPath("organizationValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/organizationLocationVpcFlowLogsConfigs'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationVpcFlowLogsConfigsPath', () => { + const result = client.organizationLocationVpcFlowLogsConfigsPath( + 'organizationValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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), + ); + }); + }); - describe('projectLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/projectLocationVpcFlowLogsConfigs"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationVpcFlowLogsConfigsPath', () => { - const result = client.projectLocationVpcFlowLogsConfigsPath("projectValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchProjectFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/projectLocationVpcFlowLogsConfigs'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = + new organizationvpcflowlogsserviceModule.v1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationVpcFlowLogsConfigsPath', () => { + const result = client.projectLocationVpcFlowLogsConfigsPath( + 'projectValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchProjectFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkmanagement/test/gapic_organization_vpc_flow_logs_service_v1beta1.ts b/packages/google-cloud-networkmanagement/test/gapic_organization_vpc_flow_logs_service_v1beta1.ts index 6bec238abec6..90ddd1cae57a 100644 --- a/packages/google-cloud-networkmanagement/test/gapic_organization_vpc_flow_logs_service_v1beta1.ts +++ b/packages/google-cloud-networkmanagement/test/gapic_organization_vpc_flow_logs_service_v1beta1.ts @@ -19,1976 +19,2797 @@ 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 { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as organizationvpcflowlogsserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -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.OrganizationVpcFlowLogsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient(); - assert(client); - }); + it('has universeDomain', () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - fallback: true, - }); - assert(client); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + organizationvpcflowlogsserviceModule.v1beta1 + .OrganizationVpcFlowLogsServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + organizationvpcflowlogsserviceModule.v1beta1 + .OrganizationVpcFlowLogsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.organizationVpcFlowLogsServiceStub, undefined); - await client.initialize(); - assert(client.organizationVpcFlowLogsServiceStub); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.organizationVpcFlowLogsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkmanagement.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('has close method for the non-initialized client', done => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.organizationVpcFlowLogsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + organizationvpcflowlogsserviceModule.v1beta1 + .OrganizationVpcFlowLogsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - 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('should create a client with no option', () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient(); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - 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('should create a client with gRPC fallback', () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + fallback: true, + }, + ); + assert(client); }); - describe('getVpcFlowLogsConfig', () => { - it('invokes getVpcFlowLogsConfig without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig() - ); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getVpcFlowLogsConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.organizationVpcFlowLogsServiceStub, undefined); + await client.initialize(); + assert(client.organizationVpcFlowLogsServiceStub); + }); - it('invokes getVpcFlowLogsConfig without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig() - ); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getVpcFlowLogsConfig( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.organizationVpcFlowLogsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getVpcFlowLogsConfig with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.organizationVpcFlowLogsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getVpcFlowLogsConfig with closed client', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + 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('createVpcFlowLogsConfig', () => { - it('invokes createVpcFlowLogsConfig without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + 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('getVpcFlowLogsConfig', () => { + it('invokes getVpcFlowLogsConfig without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ); + client.innerApiCalls.getVpcFlowLogsConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getVpcFlowLogsConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createVpcFlowLogsConfig without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getVpcFlowLogsConfig without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ); + client.innerApiCalls.getVpcFlowLogsConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createVpcFlowLogsConfig with call error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getVpcFlowLogsConfig with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createVpcFlowLogsConfig with LRO error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getVpcFlowLogsConfig with closed client', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); + }); + }); + + describe('createVpcFlowLogsConfig', () => { + it('invokes createVpcFlowLogsConfig without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateVpcFlowLogsConfigProgress without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createVpcFlowLogsConfig without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateVpcFlowLogsConfigProgress with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createVpcFlowLogsConfig with call error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateVpcFlowLogsConfig', () => { - it('invokes updateVpcFlowLogsConfig without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createVpcFlowLogsConfig with LRO error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateVpcFlowLogsConfig without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateVpcFlowLogsConfigProgress without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateVpcFlowLogsConfig with call error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateVpcFlowLogsConfigProgress with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateVpcFlowLogsConfig', () => { + it('invokes updateVpcFlowLogsConfig without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateVpcFlowLogsConfig with LRO error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateVpcFlowLogsConfig without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateVpcFlowLogsConfigProgress without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateVpcFlowLogsConfig with call error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateVpcFlowLogsConfigProgress with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateVpcFlowLogsConfig with LRO error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteVpcFlowLogsConfig', () => { - it('invokes deleteVpcFlowLogsConfig without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateVpcFlowLogsConfigProgress without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkUpdateVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteVpcFlowLogsConfig without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateVpcFlowLogsConfigProgress with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteVpcFlowLogsConfig', () => { + it('invokes deleteVpcFlowLogsConfig without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteVpcFlowLogsConfig with call error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteVpcFlowLogsConfig without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteVpcFlowLogsConfig with LRO error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteVpcFlowLogsConfig with call error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteVpcFlowLogsConfigProgress without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteVpcFlowLogsConfig with LRO error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteVpcFlowLogsConfigProgress with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteVpcFlowLogsConfigProgress without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkDeleteVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listVpcFlowLogsConfigs', () => { - it('invokes listVpcFlowLogsConfigs without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listVpcFlowLogsConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteVpcFlowLogsConfigProgress with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listVpcFlowLogsConfigs', () => { + it('invokes listVpcFlowLogsConfigs without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.listVpcFlowLogsConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.listVpcFlowLogsConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listVpcFlowLogsConfigs without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listVpcFlowLogsConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listVpcFlowLogsConfigs without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.listVpcFlowLogsConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listVpcFlowLogsConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listVpcFlowLogsConfigs with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listVpcFlowLogsConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listVpcFlowLogsConfigs with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listVpcFlowLogsConfigs(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listVpcFlowLogsConfigsStream without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.listVpcFlowLogsConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig) => { - 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.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listVpcFlowLogsConfigsStream without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.listVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + ) => { + 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.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listVpcFlowLogsConfigsStream with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listVpcFlowLogsConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listVpcFlowLogsConfigsStream with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listVpcFlowLogsConfigs without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = []; - const iterable = client.listVpcFlowLogsConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listVpcFlowLogsConfigs without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = + []; + const iterable = client.listVpcFlowLogsConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listVpcFlowLogsConfigs with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listVpcFlowLogsConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listVpcFlowLogsConfigs with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listVpcFlowLogsConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('connectivityTest', async () => { + const fakePath = '/rendered/path/connectivityTest'; + const expectedParameters = { + project: 'projectValue', + test: 'testValue', + }; + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.connectivityTestPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.connectivityTestPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('connectivityTestPath', () => { + const result = client.connectivityTestPath('projectValue', 'testValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.connectivityTestPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromConnectivityTestName', () => { + const result = client.matchProjectFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTestFromConnectivityTestName', () => { + const result = client.matchTestFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'testValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('connectivityTest', async () => { - const fakePath = "/rendered/path/connectivityTest"; - const expectedParameters = { - project: "projectValue", - test: "testValue", - }; - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.connectivityTestPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.connectivityTestPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('connectivityTestPath', () => { - const result = client.connectivityTestPath("projectValue", "testValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.connectivityTestPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromConnectivityTestName', () => { - const result = client.matchProjectFromConnectivityTestName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTestFromConnectivityTestName', () => { - const result = client.matchTestFromConnectivityTestName(fakePath); - assert.strictEqual(result, "testValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/organizationLocationVpcFlowLogsConfigs"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationVpcFlowLogsConfigsPath', () => { - const result = client.organizationLocationVpcFlowLogsConfigsPath("organizationValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/organizationLocationVpcFlowLogsConfigs'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationVpcFlowLogsConfigsPath', () => { + const result = client.organizationLocationVpcFlowLogsConfigsPath( + 'organizationValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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), + ); + }); + }); - describe('projectLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/projectLocationVpcFlowLogsConfigs"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationVpcFlowLogsConfigsPath', () => { - const result = client.projectLocationVpcFlowLogsConfigsPath("projectValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchProjectFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/projectLocationVpcFlowLogsConfigs'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = + new organizationvpcflowlogsserviceModule.v1beta1.OrganizationVpcFlowLogsServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationVpcFlowLogsConfigsPath', () => { + const result = client.projectLocationVpcFlowLogsConfigsPath( + 'projectValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchProjectFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkmanagement/test/gapic_reachability_service_v1.ts b/packages/google-cloud-networkmanagement/test/gapic_reachability_service_v1.ts index 1727b5e74560..eeaab734775a 100644 --- a/packages/google-cloud-networkmanagement/test/gapic_reachability_service_v1.ts +++ b/packages/google-cloud-networkmanagement/test/gapic_reachability_service_v1.ts @@ -19,2092 +19,2882 @@ 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 { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as reachabilityserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -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.ReachabilityServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = reachabilityserviceModule.v1.ReachabilityServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = reachabilityserviceModule.v1.ReachabilityServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new reachabilityserviceModule.v1.ReachabilityServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = reachabilityserviceModule.v1.ReachabilityServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.reachabilityServiceStub, undefined); - await client.initialize(); - assert(client.reachabilityServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.reachabilityServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.reachabilityServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new reachabilityserviceModule.v1.ReachabilityServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - 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 universeDomain', () => { + const client = + new reachabilityserviceModule.v1.ReachabilityServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - 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); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + reachabilityserviceModule.v1.ReachabilityServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + reachabilityserviceModule.v1.ReachabilityServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); }); - describe('getConnectivityTest', () => { - it('invokes getConnectivityTest without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ConnectivityTest() - ); - client.innerApiCalls.getConnectivityTest = stubSimpleCall(expectedResponse); - const [response] = await client.getConnectivityTest(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('invokes getConnectivityTest without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ConnectivityTest() - ); - client.innerApiCalls.getConnectivityTest = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getConnectivityTest( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1.IConnectivityTest|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new reachabilityserviceModule.v1.ReachabilityServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new reachabilityserviceModule.v1.ReachabilityServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkmanagement.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new reachabilityserviceModule.v1.ReachabilityServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getConnectivityTest with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getConnectivityTest = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getConnectivityTest(request), expectedError); - const actualRequest = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = reachabilityserviceModule.v1.ReachabilityServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getConnectivityTest with closed client', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getConnectivityTest(request), expectedError); - }); + it('should create a client with no option', () => { + const client = + new reachabilityserviceModule.v1.ReachabilityServiceClient(); + assert(client); }); - describe('createConnectivityTest', () => { - it('invokes createConnectivityTest without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createConnectivityTest = stubLongRunningCall(expectedResponse); - const [operation] = await client.createConnectivityTest(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('invokes createConnectivityTest without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createConnectivityTest = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createConnectivityTest( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.reachabilityServiceStub, undefined); + await client.initialize(); + assert(client.reachabilityServiceStub); + }); - it('invokes createConnectivityTest with call error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createConnectivityTest = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createConnectivityTest(request), expectedError); - const actualRequest = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.reachabilityServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createConnectivityTest with LRO error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createConnectivityTest = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createConnectivityTest(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.reachabilityServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes checkCreateConnectivityTestProgress without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateConnectivityTestProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + 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('invokes checkCreateConnectivityTestProgress with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + 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('getConnectivityTest', () => { + it('invokes getConnectivityTest without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ); + client.innerApiCalls.getConnectivityTest = + stubSimpleCall(expectedResponse); + const [response] = await client.getConnectivityTest(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateConnectivityTestProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getConnectivityTest without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ); + client.innerApiCalls.getConnectivityTest = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getConnectivityTest( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkmanagement.v1.IConnectivityTest | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateConnectivityTest', () => { - it('invokes updateConnectivityTest without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateConnectivityTest = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateConnectivityTest(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getConnectivityTest with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getConnectivityTest = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getConnectivityTest(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateConnectivityTest without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateConnectivityTest = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateConnectivityTest( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getConnectivityTest with closed client', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getConnectivityTest(request), expectedError); + }); + }); + + describe('createConnectivityTest', () => { + it('invokes createConnectivityTest without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createConnectivityTest = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createConnectivityTest(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateConnectivityTest with call error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateConnectivityTest = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateConnectivityTest(request), expectedError); - const actualRequest = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createConnectivityTest without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createConnectivityTest = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createConnectivityTest( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateConnectivityTest with LRO error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateConnectivityTest = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateConnectivityTest(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createConnectivityTest with call error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createConnectivityTest = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createConnectivityTest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateConnectivityTestProgress without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateConnectivityTestProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createConnectivityTest with LRO error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createConnectivityTest = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createConnectivityTest(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateConnectivityTestProgress with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkCreateConnectivityTestProgress without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateConnectivityTestProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateConnectivityTestProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateConnectivityTestProgress with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateConnectivityTestProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateConnectivityTest', () => { + it('invokes updateConnectivityTest without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateConnectivityTest = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateConnectivityTest(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rerunConnectivityTest', () => { - it('invokes rerunConnectivityTest without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rerunConnectivityTest = stubLongRunningCall(expectedResponse); - const [operation] = await client.rerunConnectivityTest(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateConnectivityTest without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateConnectivityTest = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateConnectivityTest( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rerunConnectivityTest without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rerunConnectivityTest = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rerunConnectivityTest( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateConnectivityTest with call error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateConnectivityTest = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateConnectivityTest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rerunConnectivityTest with call error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rerunConnectivityTest = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rerunConnectivityTest(request), expectedError); - const actualRequest = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateConnectivityTest with LRO error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateConnectivityTest = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateConnectivityTest(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rerunConnectivityTest with LRO error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rerunConnectivityTest = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rerunConnectivityTest(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateConnectivityTestProgress without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateConnectivityTestProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkRerunConnectivityTestProgress without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRerunConnectivityTestProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateConnectivityTestProgress with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateConnectivityTestProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rerunConnectivityTest', () => { + it('invokes rerunConnectivityTest without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rerunConnectivityTest = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rerunConnectivityTest(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRerunConnectivityTestProgress with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes rerunConnectivityTest without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rerunConnectivityTest = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rerunConnectivityTest( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRerunConnectivityTestProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes rerunConnectivityTest with call error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rerunConnectivityTest = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.rerunConnectivityTest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteConnectivityTest', () => { - it('invokes deleteConnectivityTest without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteConnectivityTest = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteConnectivityTest(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rerunConnectivityTest with LRO error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rerunConnectivityTest = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rerunConnectivityTest(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteConnectivityTest without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteConnectivityTest = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteConnectivityTest( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRerunConnectivityTestProgress without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRerunConnectivityTestProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteConnectivityTest with call error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteConnectivityTest = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteConnectivityTest(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkRerunConnectivityTestProgress with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRerunConnectivityTestProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteConnectivityTest', () => { + it('invokes deleteConnectivityTest without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteConnectivityTest = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteConnectivityTest(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteConnectivityTest with LRO error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteConnectivityTest = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteConnectivityTest(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteConnectivityTest without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteConnectivityTest = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteConnectivityTest( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteConnectivityTestProgress without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteConnectivityTestProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteConnectivityTest with call error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteConnectivityTest = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteConnectivityTest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteConnectivityTestProgress with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes deleteConnectivityTest with LRO error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteConnectivityTest = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteConnectivityTest(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteConnectivityTestProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteConnectivityTestProgress without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteConnectivityTestProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listConnectivityTests', () => { - it('invokes listConnectivityTests without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - ]; - client.innerApiCalls.listConnectivityTests = stubSimpleCall(expectedResponse); - const [response] = await client.listConnectivityTests(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteConnectivityTestProgress with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteConnectivityTestProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listConnectivityTests', () => { + it('invokes listConnectivityTests without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + ]; + client.innerApiCalls.listConnectivityTests = + stubSimpleCall(expectedResponse); + const [response] = await client.listConnectivityTests(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listConnectivityTests without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - ]; - client.innerApiCalls.listConnectivityTests = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listConnectivityTests( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1.IConnectivityTest[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listConnectivityTests without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + ]; + client.innerApiCalls.listConnectivityTests = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listConnectivityTests( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkmanagement.v1.IConnectivityTest[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listConnectivityTests with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listConnectivityTests = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listConnectivityTests(request), expectedError); - const actualRequest = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listConnectivityTests with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listConnectivityTests = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listConnectivityTests(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listConnectivityTestsStream without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - ]; - client.descriptors.page.listConnectivityTests.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listConnectivityTestsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1.ConnectivityTest[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1.ConnectivityTest) => { - 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.listConnectivityTests.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listConnectivityTests, request)); - assert( - (client.descriptors.page.listConnectivityTests.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listConnectivityTestsStream without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + ]; + client.descriptors.page.listConnectivityTests.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listConnectivityTestsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1.ConnectivityTest[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1.ConnectivityTest, + ) => { + 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.listConnectivityTests + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listConnectivityTests, request), + ); + assert( + ( + client.descriptors.page.listConnectivityTests + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listConnectivityTestsStream with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listConnectivityTests.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listConnectivityTestsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1.ConnectivityTest[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1.ConnectivityTest) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listConnectivityTests.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listConnectivityTests, request)); - assert( - (client.descriptors.page.listConnectivityTests.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listConnectivityTestsStream with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listConnectivityTests.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listConnectivityTestsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1.ConnectivityTest[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1.ConnectivityTest, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listConnectivityTests + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listConnectivityTests, request), + ); + assert( + ( + client.descriptors.page.listConnectivityTests + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listConnectivityTests without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.ConnectivityTest()), - ]; - client.descriptors.page.listConnectivityTests.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkmanagement.v1.IConnectivityTest[] = []; - const iterable = client.listConnectivityTestsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listConnectivityTests.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listConnectivityTests.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listConnectivityTests without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ConnectivityTest(), + ), + ]; + client.descriptors.page.listConnectivityTests.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkmanagement.v1.IConnectivityTest[] = + []; + const iterable = client.listConnectivityTestsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listConnectivityTests + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listConnectivityTests + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listConnectivityTests with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listConnectivityTests.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listConnectivityTestsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkmanagement.v1.IConnectivityTest[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listConnectivityTests.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listConnectivityTests.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listConnectivityTests with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listConnectivityTests.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listConnectivityTestsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkmanagement.v1.IConnectivityTest[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listConnectivityTests + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listConnectivityTests + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('connectivityTest', async () => { + const fakePath = '/rendered/path/connectivityTest'; + const expectedParameters = { + project: 'projectValue', + test: 'testValue', + }; + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.connectivityTestPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.connectivityTestPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('connectivityTestPath', () => { + const result = client.connectivityTestPath('projectValue', 'testValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.connectivityTestPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromConnectivityTestName', () => { + const result = client.matchProjectFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTestFromConnectivityTestName', () => { + const result = client.matchTestFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'testValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('connectivityTest', async () => { - const fakePath = "/rendered/path/connectivityTest"; - const expectedParameters = { - project: "projectValue", - test: "testValue", - }; - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.connectivityTestPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.connectivityTestPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('connectivityTestPath', () => { - const result = client.connectivityTestPath("projectValue", "testValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.connectivityTestPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromConnectivityTestName', () => { - const result = client.matchProjectFromConnectivityTestName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTestFromConnectivityTestName', () => { - const result = client.matchTestFromConnectivityTestName(fakePath); - assert.strictEqual(result, "testValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/organizationLocationVpcFlowLogsConfigs"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationVpcFlowLogsConfigsPath', () => { - const result = client.organizationLocationVpcFlowLogsConfigsPath("organizationValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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)); - }); - }); - - describe('projectLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/projectLocationVpcFlowLogsConfigs"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new reachabilityserviceModule.v1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationVpcFlowLogsConfigsPath', () => { - const result = client.projectLocationVpcFlowLogsConfigsPath("projectValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchProjectFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('organizationLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/organizationLocationVpcFlowLogsConfigs'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationVpcFlowLogsConfigsPath', () => { + const result = client.organizationLocationVpcFlowLogsConfigsPath( + 'organizationValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await 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('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/projectLocationVpcFlowLogsConfigs'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = new reachabilityserviceModule.v1.ReachabilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationVpcFlowLogsConfigsPath', () => { + const result = client.projectLocationVpcFlowLogsConfigsPath( + 'projectValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchProjectFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkmanagement/test/gapic_reachability_service_v1beta1.ts b/packages/google-cloud-networkmanagement/test/gapic_reachability_service_v1beta1.ts index 5e8f791006c0..c3d015488fe2 100644 --- a/packages/google-cloud-networkmanagement/test/gapic_reachability_service_v1beta1.ts +++ b/packages/google-cloud-networkmanagement/test/gapic_reachability_service_v1beta1.ts @@ -19,2092 +19,2817 @@ 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 { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as reachabilityserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -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.ReachabilityServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = reachabilityserviceModule.v1beta1.ReachabilityServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = reachabilityserviceModule.v1beta1.ReachabilityServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = reachabilityserviceModule.v1beta1.ReachabilityServiceClient.port; - assert(port); - assert(typeof port === 'number'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + reachabilityserviceModule.v1beta1.ReachabilityServiceClient + .servicePath; + assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + reachabilityserviceModule.v1beta1.ReachabilityServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('should create a client with no option', () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - fallback: true, - }); - assert(client); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkmanagement.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.reachabilityServiceStub, undefined); - await client.initialize(); - assert(client.reachabilityServiceStub); - }); + it('has port', () => { + const port = + reachabilityserviceModule.v1beta1.ReachabilityServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.reachabilityServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('should create a client with no option', () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.reachabilityServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.reachabilityServiceStub, undefined); + await client.initialize(); + assert(client.reachabilityServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - 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 close method for the initialized client', (done) => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.reachabilityServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - 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 close method for the non-initialized client', (done) => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.reachabilityServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getConnectivityTest', () => { - it('invokes getConnectivityTest without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest() - ); - client.innerApiCalls.getConnectivityTest = stubSimpleCall(expectedResponse); - const [response] = await client.getConnectivityTest(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getConnectivityTest without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest() - ); - client.innerApiCalls.getConnectivityTest = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getConnectivityTest( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getConnectivityTest with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getConnectivityTest = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getConnectivityTest(request), expectedError); - const actualRequest = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getConnectivityTest with closed client', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getConnectivityTest(request), expectedError); - }); - }); - - describe('createConnectivityTest', () => { - it('invokes createConnectivityTest without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createConnectivityTest = stubLongRunningCall(expectedResponse); - const [operation] = await client.createConnectivityTest(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createConnectivityTest without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createConnectivityTest = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createConnectivityTest( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createConnectivityTest with call error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createConnectivityTest = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createConnectivityTest(request), expectedError); - const actualRequest = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createConnectivityTest with LRO error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createConnectivityTest = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createConnectivityTest(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateConnectivityTestProgress without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateConnectivityTestProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateConnectivityTestProgress with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + 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()); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateConnectivityTestProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + 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('getConnectivityTest', () => { + it('invokes getConnectivityTest without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ); + client.innerApiCalls.getConnectivityTest = + stubSimpleCall(expectedResponse); + const [response] = await client.getConnectivityTest(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateConnectivityTest', () => { - it('invokes updateConnectivityTest without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateConnectivityTest = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateConnectivityTest(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateConnectivityTest without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateConnectivityTest = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateConnectivityTest( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateConnectivityTest with call error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateConnectivityTest = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateConnectivityTest(request), expectedError); - const actualRequest = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateConnectivityTest with LRO error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest() - ); - request.resource ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest', ['resource', 'name']); - request.resource.name = defaultValue1; - const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateConnectivityTest = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateConnectivityTest(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateConnectivityTestProgress without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateConnectivityTestProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateConnectivityTestProgress with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getConnectivityTest without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ); + client.innerApiCalls.getConnectivityTest = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getConnectivityTest( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateConnectivityTestProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getConnectivityTest with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getConnectivityTest = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getConnectivityTest(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rerunConnectivityTest', () => { - it('invokes rerunConnectivityTest without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rerunConnectivityTest = stubLongRunningCall(expectedResponse); - const [operation] = await client.rerunConnectivityTest(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rerunConnectivityTest without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.rerunConnectivityTest = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rerunConnectivityTest( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rerunConnectivityTest with call error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rerunConnectivityTest = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rerunConnectivityTest(request), expectedError); - const actualRequest = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rerunConnectivityTest with LRO error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rerunConnectivityTest = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rerunConnectivityTest(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rerunConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRerunConnectivityTestProgress without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRerunConnectivityTestProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRerunConnectivityTestProgress with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getConnectivityTest with closed client', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getConnectivityTest(request), expectedError); + }); + }); + + describe('createConnectivityTest', () => { + it('invokes createConnectivityTest without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createConnectivityTest = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createConnectivityTest(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRerunConnectivityTestProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createConnectivityTest without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createConnectivityTest = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createConnectivityTest( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteConnectivityTest', () => { - it('invokes deleteConnectivityTest without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteConnectivityTest = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteConnectivityTest(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteConnectivityTest without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteConnectivityTest = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteConnectivityTest( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteConnectivityTest with call error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteConnectivityTest = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteConnectivityTest(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteConnectivityTest with LRO error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteConnectivityTest = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteConnectivityTest(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConnectivityTest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteConnectivityTestProgress without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteConnectivityTestProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteConnectivityTestProgress with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes createConnectivityTest with call error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createConnectivityTest = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createConnectivityTest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteConnectivityTestProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createConnectivityTest with LRO error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createConnectivityTest = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createConnectivityTest(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listConnectivityTests', () => { - it('invokes listConnectivityTests without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - ]; - client.innerApiCalls.listConnectivityTests = stubSimpleCall(expectedResponse); - const [response] = await client.listConnectivityTests(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listConnectivityTests without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - ]; - client.innerApiCalls.listConnectivityTests = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listConnectivityTests( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listConnectivityTests with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listConnectivityTests = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listConnectivityTests(request), expectedError); - const actualRequest = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConnectivityTests as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listConnectivityTestsStream without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - ]; - client.descriptors.page.listConnectivityTests.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listConnectivityTestsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest) => { - 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.listConnectivityTests.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listConnectivityTests, request)); - assert( - (client.descriptors.page.listConnectivityTests.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listConnectivityTestsStream with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listConnectivityTests.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listConnectivityTestsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listConnectivityTests.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listConnectivityTests, request)); - assert( - (client.descriptors.page.listConnectivityTests.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listConnectivityTests without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest()), - ]; - client.descriptors.page.listConnectivityTests.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[] = []; - const iterable = client.listConnectivityTestsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listConnectivityTests.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listConnectivityTests.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listConnectivityTests with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listConnectivityTests.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listConnectivityTestsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listConnectivityTests.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listConnectivityTests.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes checkCreateConnectivityTestProgress without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateConnectivityTestProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateConnectivityTestProgress with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateConnectivityTestProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateConnectivityTest', () => { + it('invokes updateConnectivityTest without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateConnectivityTest = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateConnectivityTest(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateConnectivityTest without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateConnectivityTest = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateConnectivityTest( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateConnectivityTest with call error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateConnectivityTest = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateConnectivityTest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateConnectivityTest with LRO error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest(), + ); + request.resource ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest', + ['resource', 'name'], + ); + request.resource.name = defaultValue1; + const expectedHeaderRequestParams = `resource.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateConnectivityTest = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateConnectivityTest(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateConnectivityTestProgress without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateConnectivityTestProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateConnectivityTestProgress with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateConnectivityTestProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rerunConnectivityTest', () => { + it('invokes rerunConnectivityTest without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rerunConnectivityTest = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rerunConnectivityTest(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rerunConnectivityTest without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.rerunConnectivityTest = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rerunConnectivityTest( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { + it('invokes rerunConnectivityTest with call error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rerunConnectivityTest = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.rerunConnectivityTest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('connectivityTest', async () => { - const fakePath = "/rendered/path/connectivityTest"; - const expectedParameters = { - project: "projectValue", - test: "testValue", - }; - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.connectivityTestPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.connectivityTestPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('connectivityTestPath', () => { - const result = client.connectivityTestPath("projectValue", "testValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.connectivityTestPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes rerunConnectivityTest with LRO error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rerunConnectivityTest = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.rerunConnectivityTest(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rerunConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromConnectivityTestName', () => { - const result = client.matchProjectFromConnectivityTestName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkRerunConnectivityTestProgress without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRerunConnectivityTestProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchTestFromConnectivityTestName', () => { - const result = client.matchTestFromConnectivityTestName(fakePath); - assert.strictEqual(result, "testValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes checkRerunConnectivityTestProgress with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRerunConnectivityTestProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteConnectivityTest', () => { + it('invokes deleteConnectivityTest without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteConnectivityTest = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteConnectivityTest(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('organizationLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/organizationLocationVpcFlowLogsConfigs"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationVpcFlowLogsConfigsPath', () => { - const result = client.organizationLocationVpcFlowLogsConfigsPath("organizationValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes deleteConnectivityTest without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteConnectivityTest = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteConnectivityTest( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteConnectivityTest with call error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteConnectivityTest = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteConnectivityTest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteConnectivityTest with LRO error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteConnectivityTest = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteConnectivityTest(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConnectivityTest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes checkDeleteConnectivityTestProgress without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteConnectivityTestProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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('invokes checkDeleteConnectivityTestProgress with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteConnectivityTestProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listConnectivityTests', () => { + it('invokes listConnectivityTests without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + ]; + client.innerApiCalls.listConnectivityTests = + stubSimpleCall(expectedResponse); + const [response] = await client.listConnectivityTests(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listConnectivityTests without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + ]; + client.innerApiCalls.listConnectivityTests = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listConnectivityTests( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('projectLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/projectLocationVpcFlowLogsConfigs"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationVpcFlowLogsConfigsPath', () => { - const result = client.projectLocationVpcFlowLogsConfigsPath("projectValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listConnectivityTests with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listConnectivityTests = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listConnectivityTests(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listConnectivityTests as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchProjectFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listConnectivityTestsStream without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + ]; + client.descriptors.page.listConnectivityTests.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listConnectivityTestsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest, + ) => { + 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.listConnectivityTests + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listConnectivityTests, request), + ); + assert( + ( + client.descriptors.page.listConnectivityTests + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listConnectivityTestsStream with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listConnectivityTests.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listConnectivityTestsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listConnectivityTests + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listConnectivityTests, request), + ); + assert( + ( + client.descriptors.page.listConnectivityTests + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listConnectivityTests without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ConnectivityTest(), + ), + ]; + client.descriptors.page.listConnectivityTests.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[] = + []; + const iterable = client.listConnectivityTestsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listConnectivityTests + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listConnectivityTests + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + + it('uses async iteration with listConnectivityTests with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listConnectivityTests.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listConnectivityTestsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkmanagement.v1beta1.IConnectivityTest[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listConnectivityTests + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listConnectivityTests + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('connectivityTest', async () => { + const fakePath = '/rendered/path/connectivityTest'; + const expectedParameters = { + project: 'projectValue', + test: 'testValue', + }; + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.connectivityTestPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.connectivityTestPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('connectivityTestPath', () => { + const result = client.connectivityTestPath('projectValue', 'testValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.connectivityTestPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromConnectivityTestName', () => { + const result = client.matchProjectFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTestFromConnectivityTestName', () => { + const result = client.matchTestFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'testValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('organizationLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/organizationLocationVpcFlowLogsConfigs'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationVpcFlowLogsConfigsPath', () => { + const result = client.organizationLocationVpcFlowLogsConfigsPath( + 'organizationValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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), + ); + }); + }); + + describe('projectLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/projectLocationVpcFlowLogsConfigs'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = + new reachabilityserviceModule.v1beta1.ReachabilityServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationVpcFlowLogsConfigsPath', () => { + const result = client.projectLocationVpcFlowLogsConfigsPath( + 'projectValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchProjectFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkmanagement/test/gapic_vpc_flow_logs_service_v1.ts b/packages/google-cloud-networkmanagement/test/gapic_vpc_flow_logs_service_v1.ts index 90d0941cda60..ebec0b40ea96 100644 --- a/packages/google-cloud-networkmanagement/test/gapic_vpc_flow_logs_service_v1.ts +++ b/packages/google-cloud-networkmanagement/test/gapic_vpc_flow_logs_service_v1.ts @@ -19,2466 +19,3318 @@ 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 { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as vpcflowlogsserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -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.VpcFlowLogsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient(); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has universeDomain', () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.vpcFlowLogsServiceStub, undefined); - await client.initialize(); - assert(client.vpcFlowLogsServiceStub); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.vpcFlowLogsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.vpcFlowLogsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkmanagement.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - 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 port', () => { + const port = vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - 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('should create a client with no option', () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient(); + assert(client); }); - describe('getVpcFlowLogsConfig', () => { - it('invokes getVpcFlowLogsConfig without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig() - ); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getVpcFlowLogsConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('should create a client with gRPC fallback', () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getVpcFlowLogsConfig without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig() - ); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getVpcFlowLogsConfig( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.vpcFlowLogsServiceStub, undefined); + await client.initialize(); + assert(client.vpcFlowLogsServiceStub); + }); - it('invokes getVpcFlowLogsConfig with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.vpcFlowLogsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getVpcFlowLogsConfig with closed client', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); + it('has close method for the non-initialized client', (done) => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.vpcFlowLogsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createVpcFlowLogsConfig', () => { - it('invokes createVpcFlowLogsConfig without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + 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('invokes createVpcFlowLogsConfig without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + 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('getVpcFlowLogsConfig', () => { + it('invokes getVpcFlowLogsConfig without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ); + client.innerApiCalls.getVpcFlowLogsConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getVpcFlowLogsConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createVpcFlowLogsConfig with call error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getVpcFlowLogsConfig without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ); + client.innerApiCalls.getVpcFlowLogsConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createVpcFlowLogsConfig with LRO error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getVpcFlowLogsConfig with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateVpcFlowLogsConfigProgress without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getVpcFlowLogsConfig with closed client', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); + }); + }); + + describe('createVpcFlowLogsConfig', () => { + it('invokes createVpcFlowLogsConfig without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateVpcFlowLogsConfigProgress with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes createVpcFlowLogsConfig without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createVpcFlowLogsConfig with call error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateVpcFlowLogsConfig', () => { - it('invokes updateVpcFlowLogsConfig without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createVpcFlowLogsConfig with LRO error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateVpcFlowLogsConfig without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateVpcFlowLogsConfigProgress without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateVpcFlowLogsConfig with call error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateVpcFlowLogsConfigProgress with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateVpcFlowLogsConfig', () => { + it('invokes updateVpcFlowLogsConfig without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateVpcFlowLogsConfig with LRO error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateVpcFlowLogsConfig without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateVpcFlowLogsConfigProgress without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateVpcFlowLogsConfig with call error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateVpcFlowLogsConfigProgress with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes updateVpcFlowLogsConfig with LRO error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateVpcFlowLogsConfigProgress without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkUpdateVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteVpcFlowLogsConfig', () => { - it('invokes deleteVpcFlowLogsConfig without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateVpcFlowLogsConfigProgress with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteVpcFlowLogsConfig', () => { + it('invokes deleteVpcFlowLogsConfig without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteVpcFlowLogsConfig without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteVpcFlowLogsConfig without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteVpcFlowLogsConfig with call error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteVpcFlowLogsConfig with call error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteVpcFlowLogsConfig with LRO error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteVpcFlowLogsConfig with LRO error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteVpcFlowLogsConfigProgress without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteVpcFlowLogsConfigProgress without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkDeleteVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteVpcFlowLogsConfigProgress with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkDeleteVpcFlowLogsConfigProgress with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listVpcFlowLogsConfigs', () => { + it('invokes listVpcFlowLogsConfigs without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.listVpcFlowLogsConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.listVpcFlowLogsConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listVpcFlowLogsConfigs without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.listVpcFlowLogsConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listVpcFlowLogsConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listVpcFlowLogsConfigs', () => { - it('invokes listVpcFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listVpcFlowLogsConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listVpcFlowLogsConfigs with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listVpcFlowLogsConfigs(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listVpcFlowLogsConfigs without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listVpcFlowLogsConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listVpcFlowLogsConfigsStream without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.listVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + ) => { + 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.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listVpcFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listVpcFlowLogsConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listVpcFlowLogsConfigsStream with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listVpcFlowLogsConfigsStream without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.listVpcFlowLogsConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig) => { - 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.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listVpcFlowLogsConfigs without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = + []; + const iterable = client.listVpcFlowLogsConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listVpcFlowLogsConfigsStream with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listVpcFlowLogsConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listVpcFlowLogsConfigs with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listVpcFlowLogsConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('queryOrgVpcFlowLogsConfigs', () => { + it('invokes queryOrgVpcFlowLogsConfigs without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.queryOrgVpcFlowLogsConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.queryOrgVpcFlowLogsConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listVpcFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = []; - const iterable = client.listVpcFlowLogsConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes queryOrgVpcFlowLogsConfigs without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.queryOrgVpcFlowLogsConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.queryOrgVpcFlowLogsConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listVpcFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listVpcFlowLogsConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('queryOrgVpcFlowLogsConfigs', () => { - it('invokes queryOrgVpcFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.queryOrgVpcFlowLogsConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.queryOrgVpcFlowLogsConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryOrgVpcFlowLogsConfigs with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryOrgVpcFlowLogsConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.queryOrgVpcFlowLogsConfigs(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes queryOrgVpcFlowLogsConfigs without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.queryOrgVpcFlowLogsConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.queryOrgVpcFlowLogsConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryOrgVpcFlowLogsConfigsStream without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.queryOrgVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + ) => { + 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.queryOrgVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.queryOrgVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes queryOrgVpcFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryOrgVpcFlowLogsConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.queryOrgVpcFlowLogsConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryOrgVpcFlowLogsConfigsStream with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.queryOrgVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.queryOrgVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes queryOrgVpcFlowLogsConfigsStream without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.queryOrgVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig) => { - 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.queryOrgVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.queryOrgVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with queryOrgVpcFlowLogsConfigs without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = + []; + const iterable = client.queryOrgVpcFlowLogsConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes queryOrgVpcFlowLogsConfigsStream with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.queryOrgVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.queryOrgVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with queryOrgVpcFlowLogsConfigs with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.queryOrgVpcFlowLogsConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('showEffectiveFlowLogsConfigs', () => { + it('invokes showEffectiveFlowLogsConfigs without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.showEffectiveFlowLogsConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.showEffectiveFlowLogsConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with queryOrgVpcFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = []; - const iterable = client.queryOrgVpcFlowLogsConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes showEffectiveFlowLogsConfigs without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.showEffectiveFlowLogsConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.showEffectiveFlowLogsConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with queryOrgVpcFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.queryOrgVpcFlowLogsConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkmanagement.v1.IVpcFlowLogsConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('showEffectiveFlowLogsConfigs', () => { - it('invokes showEffectiveFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - ]; - client.innerApiCalls.showEffectiveFlowLogsConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.showEffectiveFlowLogsConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes showEffectiveFlowLogsConfigs without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - ]; - client.innerApiCalls.showEffectiveFlowLogsConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.showEffectiveFlowLogsConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes showEffectiveFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.showEffectiveFlowLogsConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.showEffectiveFlowLogsConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes showEffectiveFlowLogsConfigs with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.showEffectiveFlowLogsConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.showEffectiveFlowLogsConfigs(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes showEffectiveFlowLogsConfigsStream without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - ]; - client.descriptors.page.showEffectiveFlowLogsConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.showEffectiveFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig) => { - 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.showEffectiveFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.showEffectiveFlowLogsConfigs, request)); - assert( - (client.descriptors.page.showEffectiveFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes showEffectiveFlowLogsConfigsStream without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.showEffectiveFlowLogsConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.showEffectiveFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig, + ) => { + 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.showEffectiveFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.showEffectiveFlowLogsConfigs, + request, + ), + ); + assert( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes showEffectiveFlowLogsConfigsStream with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.showEffectiveFlowLogsConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.showEffectiveFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.showEffectiveFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.showEffectiveFlowLogsConfigs, request)); - assert( - (client.descriptors.page.showEffectiveFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes showEffectiveFlowLogsConfigsStream with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.showEffectiveFlowLogsConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.showEffectiveFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.showEffectiveFlowLogsConfigs, + request, + ), + ); + assert( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with showEffectiveFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig()), - ]; - client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[] = []; - const iterable = client.showEffectiveFlowLogsConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with showEffectiveFlowLogsConfigs without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.EffectiveVpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[] = + []; + const iterable = client.showEffectiveFlowLogsConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with showEffectiveFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.showEffectiveFlowLogsConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with showEffectiveFlowLogsConfigs with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.showEffectiveFlowLogsConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkmanagement.v1.IEffectiveVpcFlowLogsConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('connectivityTest', async () => { + const fakePath = '/rendered/path/connectivityTest'; + const expectedParameters = { + project: 'projectValue', + test: 'testValue', + }; + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.connectivityTestPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.connectivityTestPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('connectivityTestPath', () => { + const result = client.connectivityTestPath('projectValue', 'testValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.connectivityTestPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromConnectivityTestName', () => { + const result = client.matchProjectFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTestFromConnectivityTestName', () => { + const result = client.matchTestFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'testValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('connectivityTest', async () => { - const fakePath = "/rendered/path/connectivityTest"; - const expectedParameters = { - project: "projectValue", - test: "testValue", - }; - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.connectivityTestPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.connectivityTestPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('connectivityTestPath', () => { - const result = client.connectivityTestPath("projectValue", "testValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.connectivityTestPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromConnectivityTestName', () => { - const result = client.matchProjectFromConnectivityTestName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTestFromConnectivityTestName', () => { - const result = client.matchTestFromConnectivityTestName(fakePath); - assert.strictEqual(result, "testValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/organizationLocationVpcFlowLogsConfigs"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationVpcFlowLogsConfigsPath', () => { - const result = client.organizationLocationVpcFlowLogsConfigsPath("organizationValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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)); - }); - }); - - describe('projectLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/projectLocationVpcFlowLogsConfigs"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationVpcFlowLogsConfigsPath', () => { - const result = client.projectLocationVpcFlowLogsConfigsPath("projectValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchProjectFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('organizationLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/organizationLocationVpcFlowLogsConfigs'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationVpcFlowLogsConfigsPath', () => { + const result = client.organizationLocationVpcFlowLogsConfigsPath( + 'organizationValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/projectLocationVpcFlowLogsConfigs'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = new vpcflowlogsserviceModule.v1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationVpcFlowLogsConfigsPath', () => { + const result = client.projectLocationVpcFlowLogsConfigsPath( + 'projectValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchProjectFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkmanagement/test/gapic_vpc_flow_logs_service_v1beta1.ts b/packages/google-cloud-networkmanagement/test/gapic_vpc_flow_logs_service_v1beta1.ts index 552be11f4a24..2811eca17fbc 100644 --- a/packages/google-cloud-networkmanagement/test/gapic_vpc_flow_logs_service_v1beta1.ts +++ b/packages/google-cloud-networkmanagement/test/gapic_vpc_flow_logs_service_v1beta1.ts @@ -19,2466 +19,3403 @@ 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 { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as vpcflowlogsserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } 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 stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -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.VpcFlowLogsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient.servicePath; - assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'networkmanagement.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient.port; - assert(port); - assert(typeof port === 'number'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient.servicePath; + assert.strictEqual(servicePath, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'networkmanagement.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('should create a client with no option', () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - fallback: true, - }); - assert(client); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'networkmanagement.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'networkmanagement.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.vpcFlowLogsServiceStub, undefined); - await client.initialize(); - assert(client.vpcFlowLogsServiceStub); - }); + it('has port', () => { + const port = + vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.vpcFlowLogsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient(); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.vpcFlowLogsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('should create a client with gRPC fallback', () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + fallback: true, }); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - 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 initialize method and supports deferred initialization', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.vpcFlowLogsServiceStub, undefined); + await client.initialize(); + assert(client.vpcFlowLogsServiceStub); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - 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 close method for the initialized client', (done) => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.vpcFlowLogsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getVpcFlowLogsConfig', () => { - it('invokes getVpcFlowLogsConfig without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig() - ); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getVpcFlowLogsConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getVpcFlowLogsConfig without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig() - ); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getVpcFlowLogsConfig( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getVpcFlowLogsConfig with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getVpcFlowLogsConfig with closed client', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); - }); - }); - - describe('createVpcFlowLogsConfig', () => { - it('invokes createVpcFlowLogsConfig without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createVpcFlowLogsConfig without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createVpcFlowLogsConfig with call error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createVpcFlowLogsConfig with LRO error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateVpcFlowLogsConfigProgress without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateVpcFlowLogsConfigProgress with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('has close method for the non-initialized client', (done) => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.vpcFlowLogsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('updateVpcFlowLogsConfig', () => { - it('invokes updateVpcFlowLogsConfig without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateVpcFlowLogsConfig without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateVpcFlowLogsConfig with call error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateVpcFlowLogsConfig with LRO error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest() - ); - request.vpcFlowLogsConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', ['vpcFlowLogsConfig', 'name']); - request.vpcFlowLogsConfig.name = defaultValue1; - const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateVpcFlowLogsConfigProgress without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateVpcFlowLogsConfigProgress with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + 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()); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + 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('getVpcFlowLogsConfig', () => { + it('invokes getVpcFlowLogsConfig without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ); + client.innerApiCalls.getVpcFlowLogsConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getVpcFlowLogsConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteVpcFlowLogsConfig', () => { - it('invokes deleteVpcFlowLogsConfig without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteVpcFlowLogsConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteVpcFlowLogsConfig without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteVpcFlowLogsConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteVpcFlowLogsConfig with call error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteVpcFlowLogsConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteVpcFlowLogsConfig with LRO error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteVpcFlowLogsConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteVpcFlowLogsConfigProgress without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteVpcFlowLogsConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteVpcFlowLogsConfigProgress with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getVpcFlowLogsConfig without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ); + client.innerApiCalls.getVpcFlowLogsConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteVpcFlowLogsConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getVpcFlowLogsConfig with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getVpcFlowLogsConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listVpcFlowLogsConfigs', () => { - it('invokes listVpcFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listVpcFlowLogsConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listVpcFlowLogsConfigs without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listVpcFlowLogsConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listVpcFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listVpcFlowLogsConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listVpcFlowLogsConfigsStream without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.listVpcFlowLogsConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig) => { - 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.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listVpcFlowLogsConfigsStream with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listVpcFlowLogsConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listVpcFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = []; - const iterable = client.listVpcFlowLogsConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listVpcFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listVpcFlowLogsConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('queryOrgVpcFlowLogsConfigs', () => { - it('invokes queryOrgVpcFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.queryOrgVpcFlowLogsConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.queryOrgVpcFlowLogsConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes queryOrgVpcFlowLogsConfigs without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.innerApiCalls.queryOrgVpcFlowLogsConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.queryOrgVpcFlowLogsConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes queryOrgVpcFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryOrgVpcFlowLogsConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.queryOrgVpcFlowLogsConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes queryOrgVpcFlowLogsConfigsStream without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.queryOrgVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig) => { - 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.queryOrgVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.queryOrgVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes queryOrgVpcFlowLogsConfigsStream with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.queryOrgVpcFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.queryOrgVpcFlowLogsConfigs, request)); - assert( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with queryOrgVpcFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig()), - ]; - client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = []; - const iterable = client.queryOrgVpcFlowLogsConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getVpcFlowLogsConfig with closed client', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.GetVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getVpcFlowLogsConfig(request), expectedError); + }); + }); + + describe('createVpcFlowLogsConfig', () => { + it('invokes createVpcFlowLogsConfig without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createVpcFlowLogsConfig without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with queryOrgVpcFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.queryOrgVpcFlowLogsConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('showEffectiveFlowLogsConfigs', () => { - it('invokes showEffectiveFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - ]; - client.innerApiCalls.showEffectiveFlowLogsConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.showEffectiveFlowLogsConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes showEffectiveFlowLogsConfigs without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - ]; - client.innerApiCalls.showEffectiveFlowLogsConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.showEffectiveFlowLogsConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes showEffectiveFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.showEffectiveFlowLogsConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.showEffectiveFlowLogsConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes showEffectiveFlowLogsConfigsStream without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - ]; - client.descriptors.page.showEffectiveFlowLogsConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.showEffectiveFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig) => { - 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.showEffectiveFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.showEffectiveFlowLogsConfigs, request)); - assert( - (client.descriptors.page.showEffectiveFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes showEffectiveFlowLogsConfigsStream with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.showEffectiveFlowLogsConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.showEffectiveFlowLogsConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig[] = []; - stream.on('data', (response: protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.showEffectiveFlowLogsConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.showEffectiveFlowLogsConfigs, request)); - assert( - (client.descriptors.page.showEffectiveFlowLogsConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with showEffectiveFlowLogsConfigs without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - generateSampleMessage(new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig()), - ]; - client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[] = []; - const iterable = client.showEffectiveFlowLogsConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createVpcFlowLogsConfig with call error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createVpcFlowLogsConfig with LRO error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.CreateVpcFlowLogsConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateVpcFlowLogsConfigProgress without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateVpcFlowLogsConfigProgress with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateVpcFlowLogsConfig', () => { + it('invokes updateVpcFlowLogsConfig without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateVpcFlowLogsConfig without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with showEffectiveFlowLogsConfigs with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.showEffectiveFlowLogsConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateVpcFlowLogsConfig with call error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateVpcFlowLogsConfig with LRO error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest(), + ); + request.vpcFlowLogsConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.UpdateVpcFlowLogsConfigRequest', + ['vpcFlowLogsConfig', 'name'], + ); + request.vpcFlowLogsConfig.name = defaultValue1; + const expectedHeaderRequestParams = `vpc_flow_logs_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateVpcFlowLogsConfigProgress without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkUpdateVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateVpcFlowLogsConfigProgress with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteVpcFlowLogsConfig', () => { + it('invokes deleteVpcFlowLogsConfig without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteVpcFlowLogsConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteVpcFlowLogsConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteVpcFlowLogsConfig without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteVpcFlowLogsConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteVpcFlowLogsConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.networkmanagement.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteVpcFlowLogsConfig with call error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteVpcFlowLogsConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteVpcFlowLogsConfig with LRO error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.DeleteVpcFlowLogsConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteVpcFlowLogsConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteVpcFlowLogsConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteVpcFlowLogsConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteVpcFlowLogsConfigProgress without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkDeleteVpcFlowLogsConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteVpcFlowLogsConfigProgress with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteVpcFlowLogsConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listVpcFlowLogsConfigs', () => { + it('invokes listVpcFlowLogsConfigs without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.listVpcFlowLogsConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.listVpcFlowLogsConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listVpcFlowLogsConfigs without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.listVpcFlowLogsConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listVpcFlowLogsConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { + it('invokes listVpcFlowLogsConfigs with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listVpcFlowLogsConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listVpcFlowLogsConfigs(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('connectivityTest', async () => { - const fakePath = "/rendered/path/connectivityTest"; - const expectedParameters = { - project: "projectValue", - test: "testValue", - }; - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.connectivityTestPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.connectivityTestPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('connectivityTestPath', () => { - const result = client.connectivityTestPath("projectValue", "testValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.connectivityTestPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listVpcFlowLogsConfigsStream without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.listVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + ) => { + 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.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchProjectFromConnectivityTestName', () => { - const result = client.matchProjectFromConnectivityTestName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listVpcFlowLogsConfigsStream with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchTestFromConnectivityTestName', () => { - const result = client.matchTestFromConnectivityTestName(fakePath); - assert.strictEqual(result, "testValue"); - assert((client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listVpcFlowLogsConfigs without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = + []; + const iterable = client.listVpcFlowLogsConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with listVpcFlowLogsConfigs with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ListVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listVpcFlowLogsConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('queryOrgVpcFlowLogsConfigs', () => { + it('invokes queryOrgVpcFlowLogsConfigs without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.queryOrgVpcFlowLogsConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.queryOrgVpcFlowLogsConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes queryOrgVpcFlowLogsConfigs without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.queryOrgVpcFlowLogsConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.queryOrgVpcFlowLogsConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes queryOrgVpcFlowLogsConfigs with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryOrgVpcFlowLogsConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.queryOrgVpcFlowLogsConfigs(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryOrgVpcFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('organizationLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/organizationLocationVpcFlowLogsConfigs"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationVpcFlowLogsConfigsPath', () => { - const result = client.organizationLocationVpcFlowLogsConfigsPath("organizationValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes queryOrgVpcFlowLogsConfigsStream without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.queryOrgVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + ) => { + 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.queryOrgVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.queryOrgVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes queryOrgVpcFlowLogsConfigsStream with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.queryOrgVpcFlowLogsConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.queryOrgVpcFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.queryOrgVpcFlowLogsConfigs, request), + ); + assert( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with queryOrgVpcFlowLogsConfigs without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.VpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = + []; + const iterable = client.queryOrgVpcFlowLogsConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with queryOrgVpcFlowLogsConfigs with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.QueryOrgVpcFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.queryOrgVpcFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.queryOrgVpcFlowLogsConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkmanagement.v1beta1.IVpcFlowLogsConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.queryOrgVpcFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('showEffectiveFlowLogsConfigs', () => { + it('invokes showEffectiveFlowLogsConfigs without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.showEffectiveFlowLogsConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.showEffectiveFlowLogsConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await 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('invokes showEffectiveFlowLogsConfigs without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + ]; + client.innerApiCalls.showEffectiveFlowLogsConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.showEffectiveFlowLogsConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes showEffectiveFlowLogsConfigs with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.showEffectiveFlowLogsConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.showEffectiveFlowLogsConfigs(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showEffectiveFlowLogsConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('projectLocationVpcFlowLogsConfigs', async () => { - const fakePath = "/rendered/path/projectLocationVpcFlowLogsConfigs"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - vpc_flow_logs_config: "vpcFlowLogsConfigValue", - }; - const client = new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationVpcFlowLogsConfigsPath', () => { - const result = client.projectLocationVpcFlowLogsConfigsPath("projectValue", "locationValue", "vpcFlowLogsConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes showEffectiveFlowLogsConfigsStream without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.showEffectiveFlowLogsConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.showEffectiveFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig, + ) => { + 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.showEffectiveFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.showEffectiveFlowLogsConfigs, + request, + ), + ); + assert( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchProjectFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes showEffectiveFlowLogsConfigsStream with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.showEffectiveFlowLogsConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.showEffectiveFlowLogsConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.showEffectiveFlowLogsConfigs, + request, + ), + ); + assert( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchLocationFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with showEffectiveFlowLogsConfigs without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.EffectiveVpcFlowLogsConfig(), + ), + ]; + client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[] = + []; + const iterable = client.showEffectiveFlowLogsConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { - const result = client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName(fakePath); - assert.strictEqual(result, "vpcFlowLogsConfigValue"); - assert((client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with showEffectiveFlowLogsConfigs with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.networkmanagement.v1beta1.ShowEffectiveFlowLogsConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.showEffectiveFlowLogsConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.showEffectiveFlowLogsConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.networkmanagement.v1beta1.IEffectiveVpcFlowLogsConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.showEffectiveFlowLogsConfigs + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError, + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient + .deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request), + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse(), + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.IOperation[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest(), + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('connectivityTest', async () => { + const fakePath = '/rendered/path/connectivityTest'; + const expectedParameters = { + project: 'projectValue', + test: 'testValue', + }; + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.connectivityTestPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.connectivityTestPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('connectivityTestPath', () => { + const result = client.connectivityTestPath('projectValue', 'testValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.connectivityTestPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromConnectivityTestName', () => { + const result = client.matchProjectFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTestFromConnectivityTestName', () => { + const result = client.matchTestFromConnectivityTestName(fakePath); + assert.strictEqual(result, 'testValue'); + assert( + (client.pathTemplates.connectivityTestPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('organizationLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/organizationLocationVpcFlowLogsConfigs'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationLocationVpcFlowLogsConfigsPath', () => { + const result = client.organizationLocationVpcFlowLogsConfigsPath( + 'organizationValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchOrganizationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromOrganizationLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates + .organizationLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await 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), + ); + }); + }); + + describe('projectLocationVpcFlowLogsConfigs', async () => { + const fakePath = '/rendered/path/projectLocationVpcFlowLogsConfigs'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + vpc_flow_logs_config: 'vpcFlowLogsConfigValue', + }; + const client = + new vpcflowlogsserviceModule.v1beta1.VpcFlowLogsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationVpcFlowLogsConfigsPath', () => { + const result = client.projectLocationVpcFlowLogsConfigsPath( + 'projectValue', + 'locationValue', + 'vpcFlowLogsConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchProjectFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchLocationFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName', () => { + const result = + client.matchVpcFlowLogsConfigFromProjectLocationVpcFlowLogsConfigsName( + fakePath, + ); + assert.strictEqual(result, 'vpcFlowLogsConfigValue'); + assert( + ( + client.pathTemplates.projectLocationVpcFlowLogsConfigsPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-networkmanagement/webpack.config.js b/packages/google-cloud-networkmanagement/webpack.config.js index b3c49d4758cf..8a664e9dd031 100644 --- a/packages/google-cloud-networkmanagement/webpack.config.js +++ b/packages/google-cloud-networkmanagement/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.