`__.
-
- Attributes:
- name (str):
- Full path to the ``AuthorizedDomain`` resource in the API.
- Example: ``apps/myapp/authorizedDomains/example.com``.
-
- @OutputOnly
- id (str):
- Fully qualified domain name of the domain authorized for
- use. Example: ``example.com``.
- """
-
- name: str = proto.Field(
- proto.STRING,
- number=1,
- )
- id: str = proto.Field(
- proto.STRING,
- number=2,
- )
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/google/cloud/appengine_admin_v1/types/domain_mapping.py b/google/cloud/appengine_admin_v1/types/domain_mapping.py
deleted file mode 100644
index a69702f..0000000
--- a/google/cloud/appengine_admin_v1/types/domain_mapping.py
+++ /dev/null
@@ -1,198 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from __future__ import annotations
-
-from typing import MutableMapping, MutableSequence
-
-import proto # type: ignore
-
-__protobuf__ = proto.module(
- package="google.appengine.v1",
- manifest={
- "DomainMapping",
- "SslSettings",
- "ResourceRecord",
- },
-)
-
-
-class DomainMapping(proto.Message):
- r"""A domain serving an App Engine application.
-
- Attributes:
- name (str):
- Full path to the ``DomainMapping`` resource in the API.
- Example: ``apps/myapp/domainMapping/example.com``.
-
- @OutputOnly
- id (str):
- Relative name of the domain serving the application.
- Example: ``example.com``.
- ssl_settings (google.cloud.appengine_admin_v1.types.SslSettings):
- SSL configuration for this domain. If
- unconfigured, this domain will not serve with
- SSL.
- resource_records (MutableSequence[google.cloud.appengine_admin_v1.types.ResourceRecord]):
- The resource records required to configure
- this domain mapping. These records must be added
- to the domain's DNS configuration in order to
- serve the application via this domain mapping.
-
- @OutputOnly
- """
-
- name: str = proto.Field(
- proto.STRING,
- number=1,
- )
- id: str = proto.Field(
- proto.STRING,
- number=2,
- )
- ssl_settings: "SslSettings" = proto.Field(
- proto.MESSAGE,
- number=3,
- message="SslSettings",
- )
- resource_records: MutableSequence["ResourceRecord"] = proto.RepeatedField(
- proto.MESSAGE,
- number=4,
- message="ResourceRecord",
- )
-
-
-class SslSettings(proto.Message):
- r"""SSL configuration for a ``DomainMapping`` resource.
-
- Attributes:
- certificate_id (str):
- ID of the ``AuthorizedCertificate`` resource configuring SSL
- for the application. Clearing this field will remove SSL
- support.
-
- By default, a managed certificate is automatically created
- for every domain mapping. To omit SSL support or to
- configure SSL manually, specify ``SslManagementType.MANUAL``
- on a ``CREATE`` or ``UPDATE`` request. You must be
- authorized to administer the ``AuthorizedCertificate``
- resource to manually map it to a ``DomainMapping`` resource.
- Example: ``12345``.
- ssl_management_type (google.cloud.appengine_admin_v1.types.SslSettings.SslManagementType):
- SSL management type for this domain. If ``AUTOMATIC``, a
- managed certificate is automatically provisioned. If
- ``MANUAL``, ``certificate_id`` must be manually specified in
- order to configure SSL for this domain.
- pending_managed_certificate_id (str):
- ID of the managed ``AuthorizedCertificate`` resource
- currently being provisioned, if applicable. Until the new
- managed certificate has been successfully provisioned, the
- previous SSL state will be preserved. Once the provisioning
- process completes, the ``certificate_id`` field will reflect
- the new managed certificate and this field will be left
- empty. To remove SSL support while there is still a pending
- managed certificate, clear the ``certificate_id`` field with
- an ``UpdateDomainMappingRequest``.
-
- @OutputOnly
- """
-
- class SslManagementType(proto.Enum):
- r"""The SSL management type for this domain.
-
- Values:
- SSL_MANAGEMENT_TYPE_UNSPECIFIED (0):
- Defaults to ``AUTOMATIC``.
- AUTOMATIC (1):
- SSL support for this domain is configured
- automatically. The mapped SSL certificate will
- be automatically renewed.
- MANUAL (2):
- SSL support for this domain is configured
- manually by the user. Either the domain has no
- SSL support or a user-obtained SSL certificate
- has been explictly mapped to this domain.
- """
- SSL_MANAGEMENT_TYPE_UNSPECIFIED = 0
- AUTOMATIC = 1
- MANUAL = 2
-
- certificate_id: str = proto.Field(
- proto.STRING,
- number=1,
- )
- ssl_management_type: SslManagementType = proto.Field(
- proto.ENUM,
- number=3,
- enum=SslManagementType,
- )
- pending_managed_certificate_id: str = proto.Field(
- proto.STRING,
- number=4,
- )
-
-
-class ResourceRecord(proto.Message):
- r"""A DNS resource record.
-
- Attributes:
- name (str):
- Relative name of the object affected by this record. Only
- applicable for ``CNAME`` records. Example: 'www'.
- rrdata (str):
- Data for this record. Values vary by record
- type, as defined in RFC 1035 (section 5) and RFC
- 1034 (section 3.6.1).
- type_ (google.cloud.appengine_admin_v1.types.ResourceRecord.RecordType):
- Resource record type. Example: ``AAAA``.
- """
-
- class RecordType(proto.Enum):
- r"""A resource record type.
-
- Values:
- RECORD_TYPE_UNSPECIFIED (0):
- An unknown resource record.
- A (1):
- An A resource record. Data is an IPv4
- address.
- AAAA (2):
- An AAAA resource record. Data is an IPv6
- address.
- CNAME (3):
- A CNAME resource record. Data is a domain
- name to be aliased.
- """
- RECORD_TYPE_UNSPECIFIED = 0
- A = 1
- AAAA = 2
- CNAME = 3
-
- name: str = proto.Field(
- proto.STRING,
- number=1,
- )
- rrdata: str = proto.Field(
- proto.STRING,
- number=2,
- )
- type_: RecordType = proto.Field(
- proto.ENUM,
- number=3,
- enum=RecordType,
- )
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/google/cloud/appengine_admin_v1/types/firewall.py b/google/cloud/appengine_admin_v1/types/firewall.py
deleted file mode 100644
index 8c7f874..0000000
--- a/google/cloud/appengine_admin_v1/types/firewall.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from __future__ import annotations
-
-from typing import MutableMapping, MutableSequence
-
-import proto # type: ignore
-
-__protobuf__ = proto.module(
- package="google.appengine.v1",
- manifest={
- "FirewallRule",
- },
-)
-
-
-class FirewallRule(proto.Message):
- r"""A single firewall rule that is evaluated against incoming
- traffic and provides an action to take on matched requests.
-
- Attributes:
- priority (int):
- A positive integer between [1, Int32.MaxValue-1] that
- defines the order of rule evaluation. Rules with the lowest
- priority are evaluated first.
-
- A default rule at priority Int32.MaxValue matches all IPv4
- and IPv6 traffic when no previous rule matches. Only the
- action of this rule can be modified by the user.
- action (google.cloud.appengine_admin_v1.types.FirewallRule.Action):
- The action to take on matched requests.
- source_range (str):
- IP address or range, defined using CIDR notation, of
- requests that this rule applies to. You can use the wildcard
- character "*" to match all IPs equivalent to "0/0" and
- "::/0" together. Examples: ``192.168.1.1`` or
- ``192.168.0.0/16`` or ``2001:db8::/32`` or
- ``2001:0db8:0000:0042:0000:8a2e:0370:7334``.
-
- .. raw:: html
-
- Truncation will be silently performed on addresses which are not
- properly truncated. For example, `1.2.3.4/24` is accepted as the same
- address as `1.2.3.0/24`. Similarly, for IPv6, `2001:db8::1/32` is accepted
- as the same address as `2001:db8::/32`.
- description (str):
- An optional string description of this rule.
- This field has a maximum length of 100
- characters.
- """
-
- class Action(proto.Enum):
- r"""Available actions to take on matching requests.
-
- Values:
- UNSPECIFIED_ACTION (0):
- No description available.
- ALLOW (1):
- Matching requests are allowed.
- DENY (2):
- Matching requests are denied.
- """
- UNSPECIFIED_ACTION = 0
- ALLOW = 1
- DENY = 2
-
- priority: int = proto.Field(
- proto.INT32,
- number=1,
- )
- action: Action = proto.Field(
- proto.ENUM,
- number=2,
- enum=Action,
- )
- source_range: str = proto.Field(
- proto.STRING,
- number=3,
- )
- description: str = proto.Field(
- proto.STRING,
- number=4,
- )
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/google/cloud/appengine_admin_v1/types/instance.py b/google/cloud/appengine_admin_v1/types/instance.py
deleted file mode 100644
index 08fb581..0000000
--- a/google/cloud/appengine_admin_v1/types/instance.py
+++ /dev/null
@@ -1,225 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from __future__ import annotations
-
-from typing import MutableMapping, MutableSequence
-
-from google.protobuf import timestamp_pb2 # type: ignore
-import proto # type: ignore
-
-__protobuf__ = proto.module(
- package="google.appengine.v1",
- manifest={
- "Instance",
- },
-)
-
-
-class Instance(proto.Message):
- r"""An Instance resource is the computing unit that App Engine
- uses to automatically scale an application.
-
- Attributes:
- name (str):
- Output only. Full path to the Instance resource in the API.
- Example:
- ``apps/myapp/services/default/versions/v1/instances/instance-1``.
- id (str):
- Output only. Relative name of the instance within the
- version. Example: ``instance-1``.
- app_engine_release (str):
- Output only. App Engine release this instance
- is running on.
- availability (google.cloud.appengine_admin_v1.types.Instance.Availability):
- Output only. Availability of the instance.
- vm_name (str):
- Output only. Name of the virtual machine
- where this instance lives. Only applicable for
- instances in App Engine flexible environment.
- vm_zone_name (str):
- Output only. Zone where the virtual machine
- is located. Only applicable for instances in App
- Engine flexible environment.
- vm_id (str):
- Output only. Virtual machine ID of this
- instance. Only applicable for instances in App
- Engine flexible environment.
- start_time (google.protobuf.timestamp_pb2.Timestamp):
- Output only. Time that this instance was
- started.
- @OutputOnly
- requests (int):
- Output only. Number of requests since this
- instance was started.
- errors (int):
- Output only. Number of errors since this
- instance was started.
- qps (float):
- Output only. Average queries per second (QPS)
- over the last minute.
- average_latency (int):
- Output only. Average latency (ms) over the
- last minute.
- memory_usage (int):
- Output only. Total memory in use (bytes).
- vm_status (str):
- Output only. Status of the virtual machine
- where this instance lives. Only applicable for
- instances in App Engine flexible environment.
- vm_debug_enabled (bool):
- Output only. Whether this instance is in
- debug mode. Only applicable for instances in App
- Engine flexible environment.
- vm_ip (str):
- Output only. The IP address of this instance.
- Only applicable for instances in App Engine
- flexible environment.
- vm_liveness (google.cloud.appengine_admin_v1.types.Instance.Liveness.LivenessState):
- Output only. The liveness health check of
- this instance. Only applicable for instances in
- App Engine flexible environment.
- """
-
- class Availability(proto.Enum):
- r"""Availability of the instance.
-
- Values:
- UNSPECIFIED (0):
- No description available.
- RESIDENT (1):
- No description available.
- DYNAMIC (2):
- No description available.
- """
- UNSPECIFIED = 0
- RESIDENT = 1
- DYNAMIC = 2
-
- class Liveness(proto.Message):
- r"""Wrapper for LivenessState enum."""
-
- class LivenessState(proto.Enum):
- r"""Liveness health check status for Flex instances.
-
- Values:
- LIVENESS_STATE_UNSPECIFIED (0):
- There is no liveness health check for the
- instance. Only applicable for instances in App
- Engine standard environment.
- UNKNOWN (1):
- The health checking system is aware of the
- instance but its health is not known at the
- moment.
- HEALTHY (2):
- The instance is reachable i.e. a connection
- to the application health checking endpoint can
- be established, and conforms to the requirements
- defined by the health check.
- UNHEALTHY (3):
- The instance is reachable, but does not
- conform to the requirements defined by the
- health check.
- DRAINING (4):
- The instance is being drained. The existing
- connections to the instance have time to
- complete, but the new ones are being refused.
- TIMEOUT (5):
- The instance is unreachable i.e. a connection
- to the application health checking endpoint
- cannot be established, or the server does not
- respond within the specified timeout.
- """
- LIVENESS_STATE_UNSPECIFIED = 0
- UNKNOWN = 1
- HEALTHY = 2
- UNHEALTHY = 3
- DRAINING = 4
- TIMEOUT = 5
-
- name: str = proto.Field(
- proto.STRING,
- number=1,
- )
- id: str = proto.Field(
- proto.STRING,
- number=2,
- )
- app_engine_release: str = proto.Field(
- proto.STRING,
- number=3,
- )
- availability: Availability = proto.Field(
- proto.ENUM,
- number=4,
- enum=Availability,
- )
- vm_name: str = proto.Field(
- proto.STRING,
- number=5,
- )
- vm_zone_name: str = proto.Field(
- proto.STRING,
- number=6,
- )
- vm_id: str = proto.Field(
- proto.STRING,
- number=7,
- )
- start_time: timestamp_pb2.Timestamp = proto.Field(
- proto.MESSAGE,
- number=8,
- message=timestamp_pb2.Timestamp,
- )
- requests: int = proto.Field(
- proto.INT32,
- number=9,
- )
- errors: int = proto.Field(
- proto.INT32,
- number=10,
- )
- qps: float = proto.Field(
- proto.FLOAT,
- number=11,
- )
- average_latency: int = proto.Field(
- proto.INT32,
- number=12,
- )
- memory_usage: int = proto.Field(
- proto.INT64,
- number=13,
- )
- vm_status: str = proto.Field(
- proto.STRING,
- number=14,
- )
- vm_debug_enabled: bool = proto.Field(
- proto.BOOL,
- number=15,
- )
- vm_ip: str = proto.Field(
- proto.STRING,
- number=16,
- )
- vm_liveness: Liveness.LivenessState = proto.Field(
- proto.ENUM,
- number=17,
- enum=Liveness.LivenessState,
- )
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/google/cloud/appengine_admin_v1/types/location.py b/google/cloud/appengine_admin_v1/types/location.py
deleted file mode 100644
index b29e518..0000000
--- a/google/cloud/appengine_admin_v1/types/location.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from __future__ import annotations
-
-from typing import MutableMapping, MutableSequence
-
-import proto # type: ignore
-
-__protobuf__ = proto.module(
- package="google.appengine.v1",
- manifest={
- "LocationMetadata",
- },
-)
-
-
-class LocationMetadata(proto.Message):
- r"""Metadata for the given
- [google.cloud.location.Location][google.cloud.location.Location].
-
- Attributes:
- standard_environment_available (bool):
- App Engine standard environment is available
- in the given location.
- @OutputOnly
- flexible_environment_available (bool):
- App Engine flexible environment is available
- in the given location.
- @OutputOnly
- search_api_available (bool):
- Output only. `Search
- API `__
- is available in the given location.
- """
-
- standard_environment_available: bool = proto.Field(
- proto.BOOL,
- number=2,
- )
- flexible_environment_available: bool = proto.Field(
- proto.BOOL,
- number=4,
- )
- search_api_available: bool = proto.Field(
- proto.BOOL,
- number=6,
- )
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/google/cloud/appengine_admin_v1/types/network_settings.py b/google/cloud/appengine_admin_v1/types/network_settings.py
deleted file mode 100644
index 5516fe3..0000000
--- a/google/cloud/appengine_admin_v1/types/network_settings.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from __future__ import annotations
-
-from typing import MutableMapping, MutableSequence
-
-import proto # type: ignore
-
-__protobuf__ = proto.module(
- package="google.appengine.v1",
- manifest={
- "NetworkSettings",
- },
-)
-
-
-class NetworkSettings(proto.Message):
- r"""A NetworkSettings resource is a container for ingress
- settings for a version or service.
-
- Attributes:
- ingress_traffic_allowed (google.cloud.appengine_admin_v1.types.NetworkSettings.IngressTrafficAllowed):
- The ingress settings for version or service.
- """
-
- class IngressTrafficAllowed(proto.Enum):
- r"""If unspecified, INGRESS_TRAFFIC_ALLOWED_ALL will be used.
-
- Values:
- INGRESS_TRAFFIC_ALLOWED_UNSPECIFIED (0):
- Unspecified
- INGRESS_TRAFFIC_ALLOWED_ALL (1):
- Allow HTTP traffic from public and private
- sources.
- INGRESS_TRAFFIC_ALLOWED_INTERNAL_ONLY (2):
- Allow HTTP traffic from only private VPC
- sources.
- INGRESS_TRAFFIC_ALLOWED_INTERNAL_AND_LB (3):
- Allow HTTP traffic from private VPC sources
- and through load balancers.
- """
- INGRESS_TRAFFIC_ALLOWED_UNSPECIFIED = 0
- INGRESS_TRAFFIC_ALLOWED_ALL = 1
- INGRESS_TRAFFIC_ALLOWED_INTERNAL_ONLY = 2
- INGRESS_TRAFFIC_ALLOWED_INTERNAL_AND_LB = 3
-
- ingress_traffic_allowed: IngressTrafficAllowed = proto.Field(
- proto.ENUM,
- number=1,
- enum=IngressTrafficAllowed,
- )
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/google/cloud/appengine_admin_v1/types/operation.py b/google/cloud/appengine_admin_v1/types/operation.py
deleted file mode 100644
index 58e0524..0000000
--- a/google/cloud/appengine_admin_v1/types/operation.py
+++ /dev/null
@@ -1,129 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from __future__ import annotations
-
-from typing import MutableMapping, MutableSequence
-
-from google.protobuf import timestamp_pb2 # type: ignore
-import proto # type: ignore
-
-__protobuf__ = proto.module(
- package="google.appengine.v1",
- manifest={
- "OperationMetadataV1",
- "CreateVersionMetadataV1",
- },
-)
-
-
-class OperationMetadataV1(proto.Message):
- r"""Metadata for the given
- [google.longrunning.Operation][google.longrunning.Operation].
-
-
- .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
-
- Attributes:
- method (str):
- API method that initiated this operation. Example:
- ``google.appengine.v1.Versions.CreateVersion``.
-
- @OutputOnly
- insert_time (google.protobuf.timestamp_pb2.Timestamp):
- Time that this operation was created.
-
- @OutputOnly
- end_time (google.protobuf.timestamp_pb2.Timestamp):
- Time that this operation completed.
-
- @OutputOnly
- user (str):
- User who requested this operation.
-
- @OutputOnly
- target (str):
- Name of the resource that this operation is acting on.
- Example: ``apps/myapp/services/default``.
-
- @OutputOnly
- ephemeral_message (str):
- Ephemeral message that may change every time
- the operation is polled. @OutputOnly
- warning (MutableSequence[str]):
- Durable messages that persist on every
- operation poll. @OutputOnly
- create_version_metadata (google.cloud.appengine_admin_v1.types.CreateVersionMetadataV1):
-
- This field is a member of `oneof`_ ``method_metadata``.
- """
-
- method: str = proto.Field(
- proto.STRING,
- number=1,
- )
- insert_time: timestamp_pb2.Timestamp = proto.Field(
- proto.MESSAGE,
- number=2,
- message=timestamp_pb2.Timestamp,
- )
- end_time: timestamp_pb2.Timestamp = proto.Field(
- proto.MESSAGE,
- number=3,
- message=timestamp_pb2.Timestamp,
- )
- user: str = proto.Field(
- proto.STRING,
- number=4,
- )
- target: str = proto.Field(
- proto.STRING,
- number=5,
- )
- ephemeral_message: str = proto.Field(
- proto.STRING,
- number=6,
- )
- warning: MutableSequence[str] = proto.RepeatedField(
- proto.STRING,
- number=7,
- )
- create_version_metadata: "CreateVersionMetadataV1" = proto.Field(
- proto.MESSAGE,
- number=8,
- oneof="method_metadata",
- message="CreateVersionMetadataV1",
- )
-
-
-class CreateVersionMetadataV1(proto.Message):
- r"""Metadata for the given
- [google.longrunning.Operation][google.longrunning.Operation] during
- a
- [google.appengine.v1.CreateVersionRequest][google.appengine.v1.CreateVersionRequest].
-
- Attributes:
- cloud_build_id (str):
- The Cloud Build ID if one was created as part
- of the version create. @OutputOnly
- """
-
- cloud_build_id: str = proto.Field(
- proto.STRING,
- number=1,
- )
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/google/cloud/appengine_admin_v1/types/service.py b/google/cloud/appengine_admin_v1/types/service.py
deleted file mode 100644
index 1b58295..0000000
--- a/google/cloud/appengine_admin_v1/types/service.py
+++ /dev/null
@@ -1,169 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from __future__ import annotations
-
-from typing import MutableMapping, MutableSequence
-
-import proto # type: ignore
-
-from google.cloud.appengine_admin_v1.types import (
- network_settings as ga_network_settings,
-)
-
-__protobuf__ = proto.module(
- package="google.appengine.v1",
- manifest={
- "Service",
- "TrafficSplit",
- },
-)
-
-
-class Service(proto.Message):
- r"""A Service resource is a logical component of an application
- that can share state and communicate in a secure fashion with
- other services. For example, an application that handles
- customer requests might include separate services to handle
- tasks such as backend data analysis or API requests from mobile
- devices. Each service has a collection of versions that define a
- specific set of code used to implement the functionality of that
- service.
-
- Attributes:
- name (str):
- Full path to the Service resource in the API. Example:
- ``apps/myapp/services/default``.
-
- @OutputOnly
- id (str):
- Relative name of the service within the application.
- Example: ``default``.
-
- @OutputOnly
- split (google.cloud.appengine_admin_v1.types.TrafficSplit):
- Mapping that defines fractional HTTP traffic
- diversion to different versions within the
- service.
- labels (MutableMapping[str, str]):
- A set of labels to apply to this service.
- Labels are key/value pairs that describe the
- service and all resources that belong to it
- (e.g., versions). The labels can be used to
- search and group resources, and are propagated
- to the usage and billing reports, enabling
- fine-grain analysis of costs. An example of
- using labels is to tag resources belonging to
- different environments (e.g., "env=prod",
- "env=qa").
-
- Label keys and values can be no longer than
- 63 characters and can only contain lowercase
- letters, numeric characters, underscores,
- dashes, and international characters. Label keys
- must start with a lowercase letter or an
- international character. Each service can have
- at most 32 labels.
- network_settings (google.cloud.appengine_admin_v1.types.NetworkSettings):
- Ingress settings for this service. Will apply
- to all versions.
- """
-
- name: str = proto.Field(
- proto.STRING,
- number=1,
- )
- id: str = proto.Field(
- proto.STRING,
- number=2,
- )
- split: "TrafficSplit" = proto.Field(
- proto.MESSAGE,
- number=3,
- message="TrafficSplit",
- )
- labels: MutableMapping[str, str] = proto.MapField(
- proto.STRING,
- proto.STRING,
- number=4,
- )
- network_settings: ga_network_settings.NetworkSettings = proto.Field(
- proto.MESSAGE,
- number=6,
- message=ga_network_settings.NetworkSettings,
- )
-
-
-class TrafficSplit(proto.Message):
- r"""Traffic routing configuration for versions within a single
- service. Traffic splits define how traffic directed to the
- service is assigned to versions.
-
- Attributes:
- shard_by (google.cloud.appengine_admin_v1.types.TrafficSplit.ShardBy):
- Mechanism used to determine which version a
- request is sent to. The traffic selection
- algorithm will be stable for either type until
- allocations are changed.
- allocations (MutableMapping[str, float]):
- Mapping from version IDs within the service to fractional
- (0.000, 1] allocations of traffic for that version. Each
- version can be specified only once, but some versions in the
- service may not have any traffic allocation. Services that
- have traffic allocated cannot be deleted until either the
- service is deleted or their traffic allocation is removed.
- Allocations must sum to 1. Up to two decimal place precision
- is supported for IP-based splits and up to three decimal
- places is supported for cookie-based splits.
- """
-
- class ShardBy(proto.Enum):
- r"""Available sharding mechanisms.
-
- Values:
- UNSPECIFIED (0):
- Diversion method unspecified.
- COOKIE (1):
- Diversion based on a specially named cookie,
- "GOOGAPPUID." The cookie must be set by the
- application itself or no diversion will occur.
- IP (2):
- Diversion based on applying the modulus
- operation to a fingerprint of the IP address.
- RANDOM (3):
- Diversion based on weighted random
- assignment. An incoming request is randomly
- routed to a version in the traffic split, with
- probability proportional to the version's
- traffic share.
- """
- UNSPECIFIED = 0
- COOKIE = 1
- IP = 2
- RANDOM = 3
-
- shard_by: ShardBy = proto.Field(
- proto.ENUM,
- number=1,
- enum=ShardBy,
- )
- allocations: MutableMapping[str, float] = proto.MapField(
- proto.STRING,
- proto.DOUBLE,
- number=2,
- )
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/google/cloud/appengine_admin_v1/types/version.py b/google/cloud/appengine_admin_v1/types/version.py
deleted file mode 100644
index ec93455..0000000
--- a/google/cloud/appengine_admin_v1/types/version.py
+++ /dev/null
@@ -1,1089 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from __future__ import annotations
-
-from typing import MutableMapping, MutableSequence
-
-from google.protobuf import duration_pb2 # type: ignore
-from google.protobuf import timestamp_pb2 # type: ignore
-import proto # type: ignore
-
-from google.cloud.appengine_admin_v1.types import app_yaml, deploy
-
-__protobuf__ = proto.module(
- package="google.appengine.v1",
- manifest={
- "InboundServiceType",
- "ServingStatus",
- "Version",
- "EndpointsApiService",
- "AutomaticScaling",
- "BasicScaling",
- "ManualScaling",
- "CpuUtilization",
- "RequestUtilization",
- "DiskUtilization",
- "NetworkUtilization",
- "StandardSchedulerSettings",
- "Network",
- "Volume",
- "Resources",
- "VpcAccessConnector",
- "Entrypoint",
- },
-)
-
-
-class InboundServiceType(proto.Enum):
- r"""Available inbound services.
-
- Values:
- INBOUND_SERVICE_UNSPECIFIED (0):
- Not specified.
- INBOUND_SERVICE_MAIL (1):
- Allows an application to receive mail.
- INBOUND_SERVICE_MAIL_BOUNCE (2):
- Allows an application to receive email-bound
- notifications.
- INBOUND_SERVICE_XMPP_ERROR (3):
- Allows an application to receive error
- stanzas.
- INBOUND_SERVICE_XMPP_MESSAGE (4):
- Allows an application to receive instant
- messages.
- INBOUND_SERVICE_XMPP_SUBSCRIBE (5):
- Allows an application to receive user
- subscription POSTs.
- INBOUND_SERVICE_XMPP_PRESENCE (6):
- Allows an application to receive a user's
- chat presence.
- INBOUND_SERVICE_CHANNEL_PRESENCE (7):
- Registers an application for notifications
- when a client connects or disconnects from a
- channel.
- INBOUND_SERVICE_WARMUP (9):
- Enables warmup requests.
- """
- INBOUND_SERVICE_UNSPECIFIED = 0
- INBOUND_SERVICE_MAIL = 1
- INBOUND_SERVICE_MAIL_BOUNCE = 2
- INBOUND_SERVICE_XMPP_ERROR = 3
- INBOUND_SERVICE_XMPP_MESSAGE = 4
- INBOUND_SERVICE_XMPP_SUBSCRIBE = 5
- INBOUND_SERVICE_XMPP_PRESENCE = 6
- INBOUND_SERVICE_CHANNEL_PRESENCE = 7
- INBOUND_SERVICE_WARMUP = 9
-
-
-class ServingStatus(proto.Enum):
- r"""Run states of a version.
-
- Values:
- SERVING_STATUS_UNSPECIFIED (0):
- Not specified.
- SERVING (1):
- Currently serving. Instances are created
- according to the scaling settings of the
- version.
- STOPPED (2):
- Disabled. No instances will be created and the scaling
- settings are ignored until the state of the version changes
- to ``SERVING``.
- """
- SERVING_STATUS_UNSPECIFIED = 0
- SERVING = 1
- STOPPED = 2
-
-
-class Version(proto.Message):
- r"""A Version resource is a specific set of source code and
- configuration files that are deployed into a service.
-
- This message has `oneof`_ fields (mutually exclusive fields).
- For each oneof, at most one member field can be set at the same time.
- Setting any member of the oneof automatically clears all other
- members.
-
- .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
-
- Attributes:
- name (str):
- Full path to the Version resource in the API. Example:
- ``apps/myapp/services/default/versions/v1``.
-
- @OutputOnly
- id (str):
- Relative name of the version within the service. Example:
- ``v1``. Version names can contain only lowercase letters,
- numbers, or hyphens. Reserved names: "default", "latest",
- and any name with the prefix "ah-".
- automatic_scaling (google.cloud.appengine_admin_v1.types.AutomaticScaling):
- Automatic scaling is based on request rate,
- response latencies, and other application
- metrics. Instances are dynamically created and
- destroyed as needed in order to handle traffic.
-
- This field is a member of `oneof`_ ``scaling``.
- basic_scaling (google.cloud.appengine_admin_v1.types.BasicScaling):
- A service with basic scaling will create an
- instance when the application receives a
- request. The instance will be turned down when
- the app becomes idle. Basic scaling is ideal for
- work that is intermittent or driven by user
- activity.
-
- This field is a member of `oneof`_ ``scaling``.
- manual_scaling (google.cloud.appengine_admin_v1.types.ManualScaling):
- A service with manual scaling runs
- continuously, allowing you to perform complex
- initialization and rely on the state of its
- memory over time. Manually scaled versions are
- sometimes referred to as "backends".
-
- This field is a member of `oneof`_ ``scaling``.
- inbound_services (MutableSequence[google.cloud.appengine_admin_v1.types.InboundServiceType]):
- Before an application can receive email or
- XMPP messages, the application must be
- configured to enable the service.
- instance_class (str):
- Instance class that is used to run this version. Valid
- values are:
-
- - AutomaticScaling: ``F1``, ``F2``, ``F4``, ``F4_1G``
- - ManualScaling or BasicScaling: ``B1``, ``B2``, ``B4``,
- ``B8``, ``B4_1G``
-
- Defaults to ``F1`` for AutomaticScaling and ``B1`` for
- ManualScaling or BasicScaling.
- network (google.cloud.appengine_admin_v1.types.Network):
- Extra network settings.
- Only applicable in the App Engine flexible
- environment.
- zones (MutableSequence[str]):
- The Google Compute Engine zones that are
- supported by this version in the App Engine
- flexible environment. Deprecated.
- resources (google.cloud.appengine_admin_v1.types.Resources):
- Machine resources for this version.
- Only applicable in the App Engine flexible
- environment.
- runtime (str):
- Desired runtime. Example: ``python27``.
- runtime_channel (str):
- The channel of the runtime to use. Only available for some
- runtimes. Defaults to the ``default`` channel.
- threadsafe (bool):
- Whether multiple requests can be dispatched
- to this version at once.
- vm (bool):
- Whether to deploy this version in a container
- on a virtual machine.
- app_engine_apis (bool):
- Allows App Engine second generation runtimes
- to access the legacy bundled services.
- beta_settings (MutableMapping[str, str]):
- Metadata settings that are supplied to this
- version to enable beta runtime features.
- env (str):
- App Engine execution environment for this version.
-
- Defaults to ``standard``.
- serving_status (google.cloud.appengine_admin_v1.types.ServingStatus):
- Current serving status of this version. Only the versions
- with a ``SERVING`` status create instances and can be
- billed.
-
- ``SERVING_STATUS_UNSPECIFIED`` is an invalid value. Defaults
- to ``SERVING``.
- created_by (str):
- Email address of the user who created this
- version.
- @OutputOnly
- create_time (google.protobuf.timestamp_pb2.Timestamp):
- Time that this version was created.
-
- @OutputOnly
- disk_usage_bytes (int):
- Total size in bytes of all the files that are
- included in this version and currently hosted on
- the App Engine disk.
-
- @OutputOnly
- runtime_api_version (str):
- The version of the API in the given runtime
- environment. Please see the app.yaml reference
- for valid values at
- https://cloud.google.com/appengine/docs/standard//config/appref
- runtime_main_executable_path (str):
- The path or name of the app's main
- executable.
- service_account (str):
- The identity that the deployed version will
- run as. Admin API will use the App Engine
- Appspot service account as default if this field
- is neither provided in app.yaml file nor through
- CLI flag.
- handlers (MutableSequence[google.cloud.appengine_admin_v1.types.UrlMap]):
- An ordered list of URL-matching patterns that should be
- applied to incoming requests. The first matching URL handles
- the request and other request handlers are not attempted.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- error_handlers (MutableSequence[google.cloud.appengine_admin_v1.types.ErrorHandler]):
- Custom static error pages. Limited to 10KB per page.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- libraries (MutableSequence[google.cloud.appengine_admin_v1.types.Library]):
- Configuration for third-party Python runtime libraries that
- are required by the application.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- api_config (google.cloud.appengine_admin_v1.types.ApiConfigHandler):
- Serving configuration for `Google Cloud
- Endpoints `__.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- env_variables (MutableMapping[str, str]):
- Environment variables available to the application.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- build_env_variables (MutableMapping[str, str]):
- Environment variables available to the build environment.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- default_expiration (google.protobuf.duration_pb2.Duration):
- Duration that static files should be cached by web proxies
- and browsers. Only applicable if the corresponding
- `StaticFilesHandler `__
- does not specify its own expiration time.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- health_check (google.cloud.appengine_admin_v1.types.HealthCheck):
- Configures health checking for instances. Unhealthy
- instances are stopped and replaced with new instances. Only
- applicable in the App Engine flexible environment.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- readiness_check (google.cloud.appengine_admin_v1.types.ReadinessCheck):
- Configures readiness health checking for instances.
- Unhealthy instances are not put into the backend traffic
- rotation.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- liveness_check (google.cloud.appengine_admin_v1.types.LivenessCheck):
- Configures liveness health checking for instances. Unhealthy
- instances are stopped and replaced with new instances
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- nobuild_files_regex (str):
- Files that match this pattern will not be built into this
- version. Only applicable for Go runtimes.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- deployment (google.cloud.appengine_admin_v1.types.Deployment):
- Code and application artifacts that make up this version.
-
- Only returned in ``GET`` requests if ``view=FULL`` is set.
- version_url (str):
- Serving URL for this version. Example:
-
- "https://myversion-dot-myservice-dot-myapp.appspot.com"
-
- @OutputOnly
- endpoints_api_service (google.cloud.appengine_admin_v1.types.EndpointsApiService):
- Cloud Endpoints configuration.
-
- If endpoints_api_service is set, the Cloud Endpoints
- Extensible Service Proxy will be provided to serve the API
- implemented by the app.
- entrypoint (google.cloud.appengine_admin_v1.types.Entrypoint):
- The entrypoint for the application.
- vpc_access_connector (google.cloud.appengine_admin_v1.types.VpcAccessConnector):
- Enables VPC connectivity for standard apps.
- """
-
- name: str = proto.Field(
- proto.STRING,
- number=1,
- )
- id: str = proto.Field(
- proto.STRING,
- number=2,
- )
- automatic_scaling: "AutomaticScaling" = proto.Field(
- proto.MESSAGE,
- number=3,
- oneof="scaling",
- message="AutomaticScaling",
- )
- basic_scaling: "BasicScaling" = proto.Field(
- proto.MESSAGE,
- number=4,
- oneof="scaling",
- message="BasicScaling",
- )
- manual_scaling: "ManualScaling" = proto.Field(
- proto.MESSAGE,
- number=5,
- oneof="scaling",
- message="ManualScaling",
- )
- inbound_services: MutableSequence["InboundServiceType"] = proto.RepeatedField(
- proto.ENUM,
- number=6,
- enum="InboundServiceType",
- )
- instance_class: str = proto.Field(
- proto.STRING,
- number=7,
- )
- network: "Network" = proto.Field(
- proto.MESSAGE,
- number=8,
- message="Network",
- )
- zones: MutableSequence[str] = proto.RepeatedField(
- proto.STRING,
- number=118,
- )
- resources: "Resources" = proto.Field(
- proto.MESSAGE,
- number=9,
- message="Resources",
- )
- runtime: str = proto.Field(
- proto.STRING,
- number=10,
- )
- runtime_channel: str = proto.Field(
- proto.STRING,
- number=117,
- )
- threadsafe: bool = proto.Field(
- proto.BOOL,
- number=11,
- )
- vm: bool = proto.Field(
- proto.BOOL,
- number=12,
- )
- app_engine_apis: bool = proto.Field(
- proto.BOOL,
- number=128,
- )
- beta_settings: MutableMapping[str, str] = proto.MapField(
- proto.STRING,
- proto.STRING,
- number=13,
- )
- env: str = proto.Field(
- proto.STRING,
- number=14,
- )
- serving_status: "ServingStatus" = proto.Field(
- proto.ENUM,
- number=15,
- enum="ServingStatus",
- )
- created_by: str = proto.Field(
- proto.STRING,
- number=16,
- )
- create_time: timestamp_pb2.Timestamp = proto.Field(
- proto.MESSAGE,
- number=17,
- message=timestamp_pb2.Timestamp,
- )
- disk_usage_bytes: int = proto.Field(
- proto.INT64,
- number=18,
- )
- runtime_api_version: str = proto.Field(
- proto.STRING,
- number=21,
- )
- runtime_main_executable_path: str = proto.Field(
- proto.STRING,
- number=22,
- )
- service_account: str = proto.Field(
- proto.STRING,
- number=127,
- )
- handlers: MutableSequence[app_yaml.UrlMap] = proto.RepeatedField(
- proto.MESSAGE,
- number=100,
- message=app_yaml.UrlMap,
- )
- error_handlers: MutableSequence[app_yaml.ErrorHandler] = proto.RepeatedField(
- proto.MESSAGE,
- number=101,
- message=app_yaml.ErrorHandler,
- )
- libraries: MutableSequence[app_yaml.Library] = proto.RepeatedField(
- proto.MESSAGE,
- number=102,
- message=app_yaml.Library,
- )
- api_config: app_yaml.ApiConfigHandler = proto.Field(
- proto.MESSAGE,
- number=103,
- message=app_yaml.ApiConfigHandler,
- )
- env_variables: MutableMapping[str, str] = proto.MapField(
- proto.STRING,
- proto.STRING,
- number=104,
- )
- build_env_variables: MutableMapping[str, str] = proto.MapField(
- proto.STRING,
- proto.STRING,
- number=125,
- )
- default_expiration: duration_pb2.Duration = proto.Field(
- proto.MESSAGE,
- number=105,
- message=duration_pb2.Duration,
- )
- health_check: app_yaml.HealthCheck = proto.Field(
- proto.MESSAGE,
- number=106,
- message=app_yaml.HealthCheck,
- )
- readiness_check: app_yaml.ReadinessCheck = proto.Field(
- proto.MESSAGE,
- number=112,
- message=app_yaml.ReadinessCheck,
- )
- liveness_check: app_yaml.LivenessCheck = proto.Field(
- proto.MESSAGE,
- number=113,
- message=app_yaml.LivenessCheck,
- )
- nobuild_files_regex: str = proto.Field(
- proto.STRING,
- number=107,
- )
- deployment: deploy.Deployment = proto.Field(
- proto.MESSAGE,
- number=108,
- message=deploy.Deployment,
- )
- version_url: str = proto.Field(
- proto.STRING,
- number=109,
- )
- endpoints_api_service: "EndpointsApiService" = proto.Field(
- proto.MESSAGE,
- number=110,
- message="EndpointsApiService",
- )
- entrypoint: "Entrypoint" = proto.Field(
- proto.MESSAGE,
- number=122,
- message="Entrypoint",
- )
- vpc_access_connector: "VpcAccessConnector" = proto.Field(
- proto.MESSAGE,
- number=121,
- message="VpcAccessConnector",
- )
-
-
-class EndpointsApiService(proto.Message):
- r"""`Cloud Endpoints `__
- configuration. The Endpoints API Service provides tooling for
- serving Open API and gRPC endpoints via an NGINX proxy. Only valid
- for App Engine Flexible environment deployments.
-
- The fields here refer to the name and configuration ID of a
- "service" resource in the `Service Management
- API `__.
-
- Attributes:
- name (str):
- Endpoints service name which is the name of
- the "service" resource in the Service Management
- API. For example
- "myapi.endpoints.myproject.cloud.goog".
- config_id (str):
- Endpoints service configuration ID as specified by the
- Service Management API. For example "2016-09-19r1".
-
- By default, the rollout strategy for Endpoints is
- ``RolloutStrategy.FIXED``. This means that Endpoints starts
- up with a particular configuration ID. When a new
- configuration is rolled out, Endpoints must be given the new
- configuration ID. The ``config_id`` field is used to give
- the configuration ID and is required in this case.
-
- Endpoints also has a rollout strategy called
- ``RolloutStrategy.MANAGED``. When using this, Endpoints
- fetches the latest configuration and does not need the
- configuration ID. In this case, ``config_id`` must be
- omitted.
- rollout_strategy (google.cloud.appengine_admin_v1.types.EndpointsApiService.RolloutStrategy):
- Endpoints rollout strategy. If ``FIXED``, ``config_id`` must
- be specified. If ``MANAGED``, ``config_id`` must be omitted.
- disable_trace_sampling (bool):
- Enable or disable trace sampling. By default,
- this is set to false for enabled.
- """
-
- class RolloutStrategy(proto.Enum):
- r"""Available rollout strategies.
-
- Values:
- UNSPECIFIED_ROLLOUT_STRATEGY (0):
- Not specified. Defaults to ``FIXED``.
- FIXED (1):
- Endpoints service configuration ID will be fixed to the
- configuration ID specified by ``config_id``.
- MANAGED (2):
- Endpoints service configuration ID will be
- updated with each rollout.
- """
- UNSPECIFIED_ROLLOUT_STRATEGY = 0
- FIXED = 1
- MANAGED = 2
-
- name: str = proto.Field(
- proto.STRING,
- number=1,
- )
- config_id: str = proto.Field(
- proto.STRING,
- number=2,
- )
- rollout_strategy: RolloutStrategy = proto.Field(
- proto.ENUM,
- number=3,
- enum=RolloutStrategy,
- )
- disable_trace_sampling: bool = proto.Field(
- proto.BOOL,
- number=4,
- )
-
-
-class AutomaticScaling(proto.Message):
- r"""Automatic scaling is based on request rate, response
- latencies, and other application metrics.
-
- Attributes:
- cool_down_period (google.protobuf.duration_pb2.Duration):
- The time period that the
- `Autoscaler `__
- should wait before it starts collecting information from a
- new instance. This prevents the autoscaler from collecting
- information when the instance is initializing, during which
- the collected usage would not be reliable. Only applicable
- in the App Engine flexible environment.
- cpu_utilization (google.cloud.appengine_admin_v1.types.CpuUtilization):
- Target scaling by CPU usage.
- max_concurrent_requests (int):
- Number of concurrent requests an automatic
- scaling instance can accept before the scheduler
- spawns a new instance.
-
- Defaults to a runtime-specific value.
- max_idle_instances (int):
- Maximum number of idle instances that should
- be maintained for this version.
- max_total_instances (int):
- Maximum number of instances that should be
- started to handle requests for this version.
- max_pending_latency (google.protobuf.duration_pb2.Duration):
- Maximum amount of time that a request should
- wait in the pending queue before starting a new
- instance to handle it.
- min_idle_instances (int):
- Minimum number of idle instances that should
- be maintained for this version. Only applicable
- for the default version of a service.
- min_total_instances (int):
- Minimum number of running instances that
- should be maintained for this version.
- min_pending_latency (google.protobuf.duration_pb2.Duration):
- Minimum amount of time a request should wait
- in the pending queue before starting a new
- instance to handle it.
- request_utilization (google.cloud.appengine_admin_v1.types.RequestUtilization):
- Target scaling by request utilization.
- disk_utilization (google.cloud.appengine_admin_v1.types.DiskUtilization):
- Target scaling by disk usage.
- network_utilization (google.cloud.appengine_admin_v1.types.NetworkUtilization):
- Target scaling by network usage.
- standard_scheduler_settings (google.cloud.appengine_admin_v1.types.StandardSchedulerSettings):
- Scheduler settings for standard environment.
- """
-
- cool_down_period: duration_pb2.Duration = proto.Field(
- proto.MESSAGE,
- number=1,
- message=duration_pb2.Duration,
- )
- cpu_utilization: "CpuUtilization" = proto.Field(
- proto.MESSAGE,
- number=2,
- message="CpuUtilization",
- )
- max_concurrent_requests: int = proto.Field(
- proto.INT32,
- number=3,
- )
- max_idle_instances: int = proto.Field(
- proto.INT32,
- number=4,
- )
- max_total_instances: int = proto.Field(
- proto.INT32,
- number=5,
- )
- max_pending_latency: duration_pb2.Duration = proto.Field(
- proto.MESSAGE,
- number=6,
- message=duration_pb2.Duration,
- )
- min_idle_instances: int = proto.Field(
- proto.INT32,
- number=7,
- )
- min_total_instances: int = proto.Field(
- proto.INT32,
- number=8,
- )
- min_pending_latency: duration_pb2.Duration = proto.Field(
- proto.MESSAGE,
- number=9,
- message=duration_pb2.Duration,
- )
- request_utilization: "RequestUtilization" = proto.Field(
- proto.MESSAGE,
- number=10,
- message="RequestUtilization",
- )
- disk_utilization: "DiskUtilization" = proto.Field(
- proto.MESSAGE,
- number=11,
- message="DiskUtilization",
- )
- network_utilization: "NetworkUtilization" = proto.Field(
- proto.MESSAGE,
- number=12,
- message="NetworkUtilization",
- )
- standard_scheduler_settings: "StandardSchedulerSettings" = proto.Field(
- proto.MESSAGE,
- number=20,
- message="StandardSchedulerSettings",
- )
-
-
-class BasicScaling(proto.Message):
- r"""A service with basic scaling will create an instance when the
- application receives a request. The instance will be turned down
- when the app becomes idle. Basic scaling is ideal for work that
- is intermittent or driven by user activity.
-
- Attributes:
- idle_timeout (google.protobuf.duration_pb2.Duration):
- Duration of time after the last request that
- an instance must wait before the instance is
- shut down.
- max_instances (int):
- Maximum number of instances to create for
- this version.
- """
-
- idle_timeout: duration_pb2.Duration = proto.Field(
- proto.MESSAGE,
- number=1,
- message=duration_pb2.Duration,
- )
- max_instances: int = proto.Field(
- proto.INT32,
- number=2,
- )
-
-
-class ManualScaling(proto.Message):
- r"""A service with manual scaling runs continuously, allowing you
- to perform complex initialization and rely on the state of its
- memory over time.
-
- Attributes:
- instances (int):
- Number of instances to assign to the service at the start.
- This number can later be altered by using the `Modules
- API `__
- ``set_num_instances()`` function.
- """
-
- instances: int = proto.Field(
- proto.INT32,
- number=1,
- )
-
-
-class CpuUtilization(proto.Message):
- r"""Target scaling by CPU usage.
-
- Attributes:
- aggregation_window_length (google.protobuf.duration_pb2.Duration):
- Period of time over which CPU utilization is
- calculated.
- target_utilization (float):
- Target CPU utilization ratio to maintain when
- scaling. Must be between 0 and 1.
- """
-
- aggregation_window_length: duration_pb2.Duration = proto.Field(
- proto.MESSAGE,
- number=1,
- message=duration_pb2.Duration,
- )
- target_utilization: float = proto.Field(
- proto.DOUBLE,
- number=2,
- )
-
-
-class RequestUtilization(proto.Message):
- r"""Target scaling by request utilization.
- Only applicable in the App Engine flexible environment.
-
- Attributes:
- target_request_count_per_second (int):
- Target requests per second.
- target_concurrent_requests (int):
- Target number of concurrent requests.
- """
-
- target_request_count_per_second: int = proto.Field(
- proto.INT32,
- number=1,
- )
- target_concurrent_requests: int = proto.Field(
- proto.INT32,
- number=2,
- )
-
-
-class DiskUtilization(proto.Message):
- r"""Target scaling by disk usage.
- Only applicable in the App Engine flexible environment.
-
- Attributes:
- target_write_bytes_per_second (int):
- Target bytes written per second.
- target_write_ops_per_second (int):
- Target ops written per second.
- target_read_bytes_per_second (int):
- Target bytes read per second.
- target_read_ops_per_second (int):
- Target ops read per seconds.
- """
-
- target_write_bytes_per_second: int = proto.Field(
- proto.INT32,
- number=14,
- )
- target_write_ops_per_second: int = proto.Field(
- proto.INT32,
- number=15,
- )
- target_read_bytes_per_second: int = proto.Field(
- proto.INT32,
- number=16,
- )
- target_read_ops_per_second: int = proto.Field(
- proto.INT32,
- number=17,
- )
-
-
-class NetworkUtilization(proto.Message):
- r"""Target scaling by network usage.
- Only applicable in the App Engine flexible environment.
-
- Attributes:
- target_sent_bytes_per_second (int):
- Target bytes sent per second.
- target_sent_packets_per_second (int):
- Target packets sent per second.
- target_received_bytes_per_second (int):
- Target bytes received per second.
- target_received_packets_per_second (int):
- Target packets received per second.
- """
-
- target_sent_bytes_per_second: int = proto.Field(
- proto.INT32,
- number=1,
- )
- target_sent_packets_per_second: int = proto.Field(
- proto.INT32,
- number=11,
- )
- target_received_bytes_per_second: int = proto.Field(
- proto.INT32,
- number=12,
- )
- target_received_packets_per_second: int = proto.Field(
- proto.INT32,
- number=13,
- )
-
-
-class StandardSchedulerSettings(proto.Message):
- r"""Scheduler settings for standard environment.
-
- Attributes:
- target_cpu_utilization (float):
- Target CPU utilization ratio to maintain when
- scaling.
- target_throughput_utilization (float):
- Target throughput utilization ratio to
- maintain when scaling
- min_instances (int):
- Minimum number of instances to run for this version. Set to
- zero to disable ``min_instances`` configuration.
- max_instances (int):
- Maximum number of instances to run for this version. Set to
- zero to disable ``max_instances`` configuration.
- """
-
- target_cpu_utilization: float = proto.Field(
- proto.DOUBLE,
- number=1,
- )
- target_throughput_utilization: float = proto.Field(
- proto.DOUBLE,
- number=2,
- )
- min_instances: int = proto.Field(
- proto.INT32,
- number=3,
- )
- max_instances: int = proto.Field(
- proto.INT32,
- number=4,
- )
-
-
-class Network(proto.Message):
- r"""Extra network settings.
- Only applicable in the App Engine flexible environment.
-
- Attributes:
- forwarded_ports (MutableSequence[str]):
- List of ports, or port pairs, to forward from
- the virtual machine to the application
- container. Only applicable in the App Engine
- flexible environment.
- instance_tag (str):
- Tag to apply to the instance during creation.
- Only applicable in the App Engine flexible
- environment.
- name (str):
- Google Compute Engine network where the virtual machines are
- created. Specify the short name, not the resource path.
-
- Defaults to ``default``.
- subnetwork_name (str):
- Google Cloud Platform sub-network where the virtual machines
- are created. Specify the short name, not the resource path.
-
- If a subnetwork name is specified, a network name will also
- be required unless it is for the default network.
-
- - If the network that the instance is being created in is a
- Legacy network, then the IP address is allocated from the
- IPv4Range.
- - If the network that the instance is being created in is
- an auto Subnet Mode Network, then only network name
- should be specified (not the subnetwork_name) and the IP
- address is created from the IPCidrRange of the subnetwork
- that exists in that zone for that network.
- - If the network that the instance is being created in is a
- custom Subnet Mode Network, then the subnetwork_name must
- be specified and the IP address is created from the
- IPCidrRange of the subnetwork.
-
- If specified, the subnetwork must exist in the same region
- as the App Engine flexible environment application.
- session_affinity (bool):
- Enable session affinity.
- Only applicable in the App Engine flexible
- environment.
- """
-
- forwarded_ports: MutableSequence[str] = proto.RepeatedField(
- proto.STRING,
- number=1,
- )
- instance_tag: str = proto.Field(
- proto.STRING,
- number=2,
- )
- name: str = proto.Field(
- proto.STRING,
- number=3,
- )
- subnetwork_name: str = proto.Field(
- proto.STRING,
- number=4,
- )
- session_affinity: bool = proto.Field(
- proto.BOOL,
- number=5,
- )
-
-
-class Volume(proto.Message):
- r"""Volumes mounted within the app container.
- Only applicable in the App Engine flexible environment.
-
- Attributes:
- name (str):
- Unique name for the volume.
- volume_type (str):
- Underlying volume type, e.g. 'tmpfs'.
- size_gb (float):
- Volume size in gigabytes.
- """
-
- name: str = proto.Field(
- proto.STRING,
- number=1,
- )
- volume_type: str = proto.Field(
- proto.STRING,
- number=2,
- )
- size_gb: float = proto.Field(
- proto.DOUBLE,
- number=3,
- )
-
-
-class Resources(proto.Message):
- r"""Machine resources for a version.
-
- Attributes:
- cpu (float):
- Number of CPU cores needed.
- disk_gb (float):
- Disk size (GB) needed.
- memory_gb (float):
- Memory (GB) needed.
- volumes (MutableSequence[google.cloud.appengine_admin_v1.types.Volume]):
- User specified volumes.
- kms_key_reference (str):
- The name of the encryption key that is stored
- in Google Cloud KMS. Only should be used by
- Cloud Composer to encrypt the vm disk
- """
-
- cpu: float = proto.Field(
- proto.DOUBLE,
- number=1,
- )
- disk_gb: float = proto.Field(
- proto.DOUBLE,
- number=2,
- )
- memory_gb: float = proto.Field(
- proto.DOUBLE,
- number=3,
- )
- volumes: MutableSequence["Volume"] = proto.RepeatedField(
- proto.MESSAGE,
- number=4,
- message="Volume",
- )
- kms_key_reference: str = proto.Field(
- proto.STRING,
- number=5,
- )
-
-
-class VpcAccessConnector(proto.Message):
- r"""VPC access connector specification.
-
- Attributes:
- name (str):
- Full Serverless VPC Access Connector name
- e.g.
- /projects/my-project/locations/us-central1/connectors/c1.
- egress_setting (google.cloud.appengine_admin_v1.types.VpcAccessConnector.EgressSetting):
- The egress setting for the connector,
- controlling what traffic is diverted through it.
- """
-
- class EgressSetting(proto.Enum):
- r"""Available egress settings.
-
- This controls what traffic is diverted through the VPC Access
- Connector resource. By default PRIVATE_IP_RANGES will be used.
-
- Values:
- EGRESS_SETTING_UNSPECIFIED (0):
- No description available.
- ALL_TRAFFIC (1):
- Force the use of VPC Access for all egress
- traffic from the function.
- PRIVATE_IP_RANGES (2):
- Use the VPC Access Connector for private IP
- space from RFC1918.
- """
- EGRESS_SETTING_UNSPECIFIED = 0
- ALL_TRAFFIC = 1
- PRIVATE_IP_RANGES = 2
-
- name: str = proto.Field(
- proto.STRING,
- number=1,
- )
- egress_setting: EgressSetting = proto.Field(
- proto.ENUM,
- number=2,
- enum=EgressSetting,
- )
-
-
-class Entrypoint(proto.Message):
- r"""The entrypoint for the application.
-
- .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
-
- Attributes:
- shell (str):
- The format should be a shell command that can be fed to
- ``bash -c``.
-
- This field is a member of `oneof`_ ``command``.
- """
-
- shell: str = proto.Field(
- proto.STRING,
- number=1,
- oneof="command",
- )
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/mypy.ini b/mypy.ini
deleted file mode 100644
index 574c5ae..0000000
--- a/mypy.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[mypy]
-python_version = 3.7
-namespace_packages = True
diff --git a/noxfile.py b/noxfile.py
deleted file mode 100644
index 54abbaa..0000000
--- a/noxfile.py
+++ /dev/null
@@ -1,428 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Generated by synthtool. DO NOT EDIT!
-
-from __future__ import absolute_import
-
-import os
-import pathlib
-import re
-import shutil
-from typing import Dict, List
-import warnings
-
-import nox
-
-FLAKE8_VERSION = "flake8==6.1.0"
-BLACK_VERSION = "black[jupyter]==23.7.0"
-ISORT_VERSION = "isort==5.11.0"
-LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
-
-DEFAULT_PYTHON_VERSION = "3.8"
-
-UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.7", "3.8", "3.9", "3.10", "3.11"]
-UNIT_TEST_STANDARD_DEPENDENCIES = [
- "mock",
- "asyncmock",
- "pytest",
- "pytest-cov",
- "pytest-asyncio",
-]
-UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = []
-UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = []
-UNIT_TEST_DEPENDENCIES: List[str] = []
-UNIT_TEST_EXTRAS: List[str] = []
-UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}
-
-SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8"]
-SYSTEM_TEST_STANDARD_DEPENDENCIES: List[str] = [
- "mock",
- "pytest",
- "google-cloud-testutils",
-]
-SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = []
-SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = []
-SYSTEM_TEST_DEPENDENCIES: List[str] = []
-SYSTEM_TEST_EXTRAS: List[str] = []
-SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}
-
-CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
-
-# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
-nox.options.sessions = [
- "unit",
- "system",
- "cover",
- "lint",
- "lint_setup_py",
- "blacken",
- "docs",
- "format",
-]
-
-# Error if a python version is missing
-nox.options.error_on_missing_interpreters = True
-
-
-@nox.session(python=DEFAULT_PYTHON_VERSION)
-def lint(session):
- """Run linters.
-
- Returns a failure if the linters find linting errors or sufficiently
- serious code quality issues.
- """
- session.install(FLAKE8_VERSION, BLACK_VERSION)
- session.run(
- "black",
- "--check",
- *LINT_PATHS,
- )
- session.run("flake8", "google", "tests")
-
-
-@nox.session(python=DEFAULT_PYTHON_VERSION)
-def blacken(session):
- """Run black. Format code to uniform standard."""
- session.install(BLACK_VERSION)
- session.run(
- "black",
- *LINT_PATHS,
- )
-
-
-@nox.session(python=DEFAULT_PYTHON_VERSION)
-def format(session):
- """
- Run isort to sort imports. Then run black
- to format code to uniform standard.
- """
- session.install(BLACK_VERSION, ISORT_VERSION)
- # Use the --fss option to sort imports using strict alphabetical order.
- # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
- session.run(
- "isort",
- "--fss",
- *LINT_PATHS,
- )
- session.run(
- "black",
- *LINT_PATHS,
- )
-
-
-@nox.session(python=DEFAULT_PYTHON_VERSION)
-def lint_setup_py(session):
- """Verify that setup.py is valid (including RST check)."""
- session.install("docutils", "pygments")
- session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
-
-
-def install_unittest_dependencies(session, *constraints):
- standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES
- session.install(*standard_deps, *constraints)
-
- if UNIT_TEST_EXTERNAL_DEPENDENCIES:
- warnings.warn(
- "'unit_test_external_dependencies' is deprecated. Instead, please "
- "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.",
- DeprecationWarning,
- )
- session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints)
-
- if UNIT_TEST_LOCAL_DEPENDENCIES:
- session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints)
-
- if UNIT_TEST_EXTRAS_BY_PYTHON:
- extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, [])
- elif UNIT_TEST_EXTRAS:
- extras = UNIT_TEST_EXTRAS
- else:
- extras = []
-
- if extras:
- session.install("-e", f".[{','.join(extras)}]", *constraints)
- else:
- session.install("-e", ".", *constraints)
-
-
-def default(session):
- # Install all test dependencies, then install this package in-place.
-
- constraints_path = str(
- CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
- )
- install_unittest_dependencies(session, "-c", constraints_path)
-
- # Run py.test against the unit tests.
- session.run(
- "py.test",
- "--quiet",
- f"--junitxml=unit_{session.python}_sponge_log.xml",
- "--cov=google",
- "--cov=tests/unit",
- "--cov-append",
- "--cov-config=.coveragerc",
- "--cov-report=",
- "--cov-fail-under=0",
- os.path.join("tests", "unit"),
- *session.posargs,
- )
-
-
-@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
-def unit(session):
- """Run the unit test suite."""
- default(session)
-
-
-def install_systemtest_dependencies(session, *constraints):
- # Use pre-release gRPC for system tests.
- # Exclude version 1.52.0rc1 which has a known issue.
- # See https://github.com/grpc/grpc/issues/32163
- session.install("--pre", "grpcio!=1.52.0rc1")
-
- session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints)
-
- if SYSTEM_TEST_EXTERNAL_DEPENDENCIES:
- session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints)
-
- if SYSTEM_TEST_LOCAL_DEPENDENCIES:
- session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints)
-
- if SYSTEM_TEST_DEPENDENCIES:
- session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints)
-
- if SYSTEM_TEST_EXTRAS_BY_PYTHON:
- extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, [])
- elif SYSTEM_TEST_EXTRAS:
- extras = SYSTEM_TEST_EXTRAS
- else:
- extras = []
-
- if extras:
- session.install("-e", f".[{','.join(extras)}]", *constraints)
- else:
- session.install("-e", ".", *constraints)
-
-
-@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
-def system(session):
- """Run the system test suite."""
- constraints_path = str(
- CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
- )
- system_test_path = os.path.join("tests", "system.py")
- system_test_folder_path = os.path.join("tests", "system")
-
- # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
- if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
- session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
- # Install pyopenssl for mTLS testing.
- if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
- session.install("pyopenssl")
-
- system_test_exists = os.path.exists(system_test_path)
- system_test_folder_exists = os.path.exists(system_test_folder_path)
- # Sanity check: only run tests if found.
- if not system_test_exists and not system_test_folder_exists:
- session.skip("System tests were not found")
-
- install_systemtest_dependencies(session, "-c", constraints_path)
-
- # Run py.test against the system tests.
- if system_test_exists:
- session.run(
- "py.test",
- "--quiet",
- f"--junitxml=system_{session.python}_sponge_log.xml",
- system_test_path,
- *session.posargs,
- )
- if system_test_folder_exists:
- session.run(
- "py.test",
- "--quiet",
- f"--junitxml=system_{session.python}_sponge_log.xml",
- system_test_folder_path,
- *session.posargs,
- )
-
-
-@nox.session(python=DEFAULT_PYTHON_VERSION)
-def cover(session):
- """Run the final coverage report.
-
- This outputs the coverage report aggregating coverage from the unit
- test runs (not system test runs), and then erases coverage data.
- """
- session.install("coverage", "pytest-cov")
- session.run("coverage", "report", "--show-missing", "--fail-under=100")
-
- session.run("coverage", "erase")
-
-
-@nox.session(python="3.9")
-def docs(session):
- """Build the docs for this library."""
-
- session.install("-e", ".")
- session.install(
- "sphinx==4.0.1",
- "alabaster",
- "recommonmark",
- )
-
- shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
- session.run(
- "sphinx-build",
- "-W", # warnings as errors
- "-T", # show full traceback on exception
- "-N", # no colors
- "-b",
- "html",
- "-d",
- os.path.join("docs", "_build", "doctrees", ""),
- os.path.join("docs", ""),
- os.path.join("docs", "_build", "html", ""),
- )
-
-
-@nox.session(python="3.9")
-def docfx(session):
- """Build the docfx yaml files for this library."""
-
- session.install("-e", ".")
- session.install(
- "gcp-sphinx-docfx-yaml",
- "alabaster",
- "recommonmark",
- )
-
- shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
- session.run(
- "sphinx-build",
- "-T", # show full traceback on exception
- "-N", # no colors
- "-D",
- (
- "extensions=sphinx.ext.autodoc,"
- "sphinx.ext.autosummary,"
- "docfx_yaml.extension,"
- "sphinx.ext.intersphinx,"
- "sphinx.ext.coverage,"
- "sphinx.ext.napoleon,"
- "sphinx.ext.todo,"
- "sphinx.ext.viewcode,"
- "recommonmark"
- ),
- "-b",
- "html",
- "-d",
- os.path.join("docs", "_build", "doctrees", ""),
- os.path.join("docs", ""),
- os.path.join("docs", "_build", "html", ""),
- )
-
-
-@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
-def prerelease_deps(session):
- """Run all tests with prerelease versions of dependencies installed."""
-
- # Install all dependencies
- session.install("-e", ".[all, tests, tracing]")
- unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
- session.install(*unit_deps_all)
- system_deps_all = (
- SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES
- )
- session.install(*system_deps_all)
-
- # Because we test minimum dependency versions on the minimum Python
- # version, the first version we test with in the unit tests sessions has a
- # constraints file containing all dependencies and extras.
- with open(
- CURRENT_DIRECTORY
- / "testing"
- / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt",
- encoding="utf-8",
- ) as constraints_file:
- constraints_text = constraints_file.read()
-
- # Ignore leading whitespace and comment lines.
- constraints_deps = [
- match.group(1)
- for match in re.finditer(
- r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
- )
- ]
-
- session.install(*constraints_deps)
-
- prerel_deps = [
- "protobuf",
- # dependency of grpc
- "six",
- "googleapis-common-protos",
- # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163
- "grpcio!=1.52.0rc1",
- "grpcio-status",
- "google-api-core",
- "google-auth",
- "proto-plus",
- "google-cloud-testutils",
- # dependencies of google-cloud-testutils"
- "click",
- ]
-
- for dep in prerel_deps:
- session.install("--pre", "--no-deps", "--upgrade", dep)
-
- # Remaining dependencies
- other_deps = [
- "requests",
- ]
- session.install(*other_deps)
-
- # Print out prerelease package versions
- session.run(
- "python", "-c", "import google.protobuf; print(google.protobuf.__version__)"
- )
- session.run("python", "-c", "import grpc; print(grpc.__version__)")
- session.run("python", "-c", "import google.auth; print(google.auth.__version__)")
-
- session.run("py.test", "tests/unit")
-
- system_test_path = os.path.join("tests", "system.py")
- system_test_folder_path = os.path.join("tests", "system")
-
- # Only run system tests if found.
- if os.path.exists(system_test_path):
- session.run(
- "py.test",
- "--verbose",
- f"--junitxml=system_{session.python}_sponge_log.xml",
- system_test_path,
- *session.posargs,
- )
- if os.path.exists(system_test_folder_path):
- session.run(
- "py.test",
- "--verbose",
- f"--junitxml=system_{session.python}_sponge_log.xml",
- system_test_folder_path,
- *session.posargs,
- )
diff --git a/owlbot.py b/owlbot.py
deleted file mode 100644
index ce738f0..0000000
--- a/owlbot.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2022 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import json
-from pathlib import Path
-import shutil
-
-import synthtool as s
-import synthtool.gcp as gcp
-from synthtool.languages import python
-
-# ----------------------------------------------------------------------------
-# Copy the generated client from the owl-bot staging directory
-# ----------------------------------------------------------------------------
-
-clean_up_generated_samples = True
-
-# Load the default version defined in .repo-metadata.json.
-default_version = json.load(open(".repo-metadata.json", "rt")).get(
- "default_version"
-)
-
-for library in s.get_staging_dirs(default_version):
- if clean_up_generated_samples:
- shutil.rmtree("samples/generated_samples", ignore_errors=True)
- clean_up_generated_samples = False
- s.move([library], excludes=["**/gapic_version.py"])
-s.remove_staging_dirs()
-
-# ----------------------------------------------------------------------------
-# Add templated files
-# ----------------------------------------------------------------------------
-
-templated_files = gcp.CommonTemplates().py_library(
- cov_level=100,
- microgenerator=True,
- versions=gcp.common.detect_versions(path="./google", default_first=True),
-)
-s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml"])
-
-python.py_samples(skip_readmes=True)
-
-# run format session for all directories which have a noxfile
-for noxfile in Path(".").glob("**/noxfile.py"):
- s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False)
diff --git a/release-please-config.json b/release-please-config.json
deleted file mode 100644
index 1b0eb82..0000000
--- a/release-please-config.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
- "packages": {
- ".": {
- "release-type": "python",
- "extra-files": [
- "google/cloud/appengine_admin/gapic_version.py",
- "google/cloud/appengine_admin_v1/gapic_version.py",
- {
- "type": "json",
- "path": "samples/generated_samples/snippet_metadata_google.appengine.v1.json",
- "jsonpath": "$.clientLibrary.version"
- }
- ]
- }
- },
- "release-type": "python",
- "plugins": [
- {
- "type": "sentence-case"
- }
- ],
- "initial-version": "0.1.0"
-}
diff --git a/renovate.json b/renovate.json
deleted file mode 100644
index 39b2a0e..0000000
--- a/renovate.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "extends": [
- "config:base",
- "group:all",
- ":preserveSemverRanges",
- ":disableDependencyDashboard"
- ],
- "ignorePaths": [".pre-commit-config.yaml", ".kokoro/requirements.txt", "setup.py"],
- "pip_requirements": {
- "fileMatch": ["requirements-test.txt", "samples/[\\S/]*constraints.txt", "samples/[\\S/]*constraints-test.txt"]
- }
-}
diff --git a/samples/generated_samples/appengine_v1_generated_applications_create_application_async.py b/samples/generated_samples/appengine_v1_generated_applications_create_application_async.py
deleted file mode 100644
index e99c685..0000000
--- a/samples/generated_samples/appengine_v1_generated_applications_create_application_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for CreateApplication
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Applications_CreateApplication_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_create_application():
- # Create a client
- client = appengine_admin_v1.ApplicationsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.CreateApplicationRequest(
- )
-
- # Make the request
- operation = client.create_application(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Applications_CreateApplication_async]
diff --git a/samples/generated_samples/appengine_v1_generated_applications_create_application_sync.py b/samples/generated_samples/appengine_v1_generated_applications_create_application_sync.py
deleted file mode 100644
index cd6bed1..0000000
--- a/samples/generated_samples/appengine_v1_generated_applications_create_application_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for CreateApplication
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Applications_CreateApplication_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_create_application():
- # Create a client
- client = appengine_admin_v1.ApplicationsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.CreateApplicationRequest(
- )
-
- # Make the request
- operation = client.create_application(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Applications_CreateApplication_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_applications_get_application_async.py b/samples/generated_samples/appengine_v1_generated_applications_get_application_async.py
deleted file mode 100644
index 3f1d066..0000000
--- a/samples/generated_samples/appengine_v1_generated_applications_get_application_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetApplication
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Applications_GetApplication_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_get_application():
- # Create a client
- client = appengine_admin_v1.ApplicationsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetApplicationRequest(
- )
-
- # Make the request
- response = await client.get_application(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Applications_GetApplication_async]
diff --git a/samples/generated_samples/appengine_v1_generated_applications_get_application_sync.py b/samples/generated_samples/appengine_v1_generated_applications_get_application_sync.py
deleted file mode 100644
index b0d82ce..0000000
--- a/samples/generated_samples/appengine_v1_generated_applications_get_application_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetApplication
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Applications_GetApplication_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_get_application():
- # Create a client
- client = appengine_admin_v1.ApplicationsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetApplicationRequest(
- )
-
- # Make the request
- response = client.get_application(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Applications_GetApplication_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_applications_repair_application_async.py b/samples/generated_samples/appengine_v1_generated_applications_repair_application_async.py
deleted file mode 100644
index 2069686..0000000
--- a/samples/generated_samples/appengine_v1_generated_applications_repair_application_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for RepairApplication
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Applications_RepairApplication_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_repair_application():
- # Create a client
- client = appengine_admin_v1.ApplicationsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.RepairApplicationRequest(
- )
-
- # Make the request
- operation = client.repair_application(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Applications_RepairApplication_async]
diff --git a/samples/generated_samples/appengine_v1_generated_applications_repair_application_sync.py b/samples/generated_samples/appengine_v1_generated_applications_repair_application_sync.py
deleted file mode 100644
index 3ed0078..0000000
--- a/samples/generated_samples/appengine_v1_generated_applications_repair_application_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for RepairApplication
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Applications_RepairApplication_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_repair_application():
- # Create a client
- client = appengine_admin_v1.ApplicationsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.RepairApplicationRequest(
- )
-
- # Make the request
- operation = client.repair_application(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Applications_RepairApplication_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_applications_update_application_async.py b/samples/generated_samples/appengine_v1_generated_applications_update_application_async.py
deleted file mode 100644
index ce44cbd..0000000
--- a/samples/generated_samples/appengine_v1_generated_applications_update_application_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateApplication
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Applications_UpdateApplication_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_update_application():
- # Create a client
- client = appengine_admin_v1.ApplicationsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateApplicationRequest(
- )
-
- # Make the request
- operation = client.update_application(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Applications_UpdateApplication_async]
diff --git a/samples/generated_samples/appengine_v1_generated_applications_update_application_sync.py b/samples/generated_samples/appengine_v1_generated_applications_update_application_sync.py
deleted file mode 100644
index c67e9fc..0000000
--- a/samples/generated_samples/appengine_v1_generated_applications_update_application_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateApplication
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Applications_UpdateApplication_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_update_application():
- # Create a client
- client = appengine_admin_v1.ApplicationsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateApplicationRequest(
- )
-
- # Make the request
- operation = client.update_application(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Applications_UpdateApplication_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_certificates_create_authorized_certificate_async.py b/samples/generated_samples/appengine_v1_generated_authorized_certificates_create_authorized_certificate_async.py
deleted file mode 100644
index 1241846..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_certificates_create_authorized_certificate_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for CreateAuthorizedCertificate
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedCertificates_CreateAuthorizedCertificate_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_create_authorized_certificate():
- # Create a client
- client = appengine_admin_v1.AuthorizedCertificatesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.CreateAuthorizedCertificateRequest(
- )
-
- # Make the request
- response = await client.create_authorized_certificate(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_AuthorizedCertificates_CreateAuthorizedCertificate_async]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_certificates_create_authorized_certificate_sync.py b/samples/generated_samples/appengine_v1_generated_authorized_certificates_create_authorized_certificate_sync.py
deleted file mode 100644
index 015f74c..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_certificates_create_authorized_certificate_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for CreateAuthorizedCertificate
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedCertificates_CreateAuthorizedCertificate_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_create_authorized_certificate():
- # Create a client
- client = appengine_admin_v1.AuthorizedCertificatesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.CreateAuthorizedCertificateRequest(
- )
-
- # Make the request
- response = client.create_authorized_certificate(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_AuthorizedCertificates_CreateAuthorizedCertificate_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_certificates_delete_authorized_certificate_async.py b/samples/generated_samples/appengine_v1_generated_authorized_certificates_delete_authorized_certificate_async.py
deleted file mode 100644
index add2619..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_certificates_delete_authorized_certificate_async.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteAuthorizedCertificate
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedCertificates_DeleteAuthorizedCertificate_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_delete_authorized_certificate():
- # Create a client
- client = appengine_admin_v1.AuthorizedCertificatesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteAuthorizedCertificateRequest(
- )
-
- # Make the request
- await client.delete_authorized_certificate(request=request)
-
-
-# [END appengine_v1_generated_AuthorizedCertificates_DeleteAuthorizedCertificate_async]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_certificates_delete_authorized_certificate_sync.py b/samples/generated_samples/appengine_v1_generated_authorized_certificates_delete_authorized_certificate_sync.py
deleted file mode 100644
index 1b556b2..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_certificates_delete_authorized_certificate_sync.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteAuthorizedCertificate
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedCertificates_DeleteAuthorizedCertificate_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_delete_authorized_certificate():
- # Create a client
- client = appengine_admin_v1.AuthorizedCertificatesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteAuthorizedCertificateRequest(
- )
-
- # Make the request
- client.delete_authorized_certificate(request=request)
-
-
-# [END appengine_v1_generated_AuthorizedCertificates_DeleteAuthorizedCertificate_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_certificates_get_authorized_certificate_async.py b/samples/generated_samples/appengine_v1_generated_authorized_certificates_get_authorized_certificate_async.py
deleted file mode 100644
index f862681..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_certificates_get_authorized_certificate_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetAuthorizedCertificate
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedCertificates_GetAuthorizedCertificate_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_get_authorized_certificate():
- # Create a client
- client = appengine_admin_v1.AuthorizedCertificatesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetAuthorizedCertificateRequest(
- )
-
- # Make the request
- response = await client.get_authorized_certificate(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_AuthorizedCertificates_GetAuthorizedCertificate_async]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_certificates_get_authorized_certificate_sync.py b/samples/generated_samples/appengine_v1_generated_authorized_certificates_get_authorized_certificate_sync.py
deleted file mode 100644
index 492bb9a..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_certificates_get_authorized_certificate_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetAuthorizedCertificate
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedCertificates_GetAuthorizedCertificate_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_get_authorized_certificate():
- # Create a client
- client = appengine_admin_v1.AuthorizedCertificatesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetAuthorizedCertificateRequest(
- )
-
- # Make the request
- response = client.get_authorized_certificate(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_AuthorizedCertificates_GetAuthorizedCertificate_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_certificates_list_authorized_certificates_async.py b/samples/generated_samples/appengine_v1_generated_authorized_certificates_list_authorized_certificates_async.py
deleted file mode 100644
index 7707f15..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_certificates_list_authorized_certificates_async.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListAuthorizedCertificates
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedCertificates_ListAuthorizedCertificates_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_list_authorized_certificates():
- # Create a client
- client = appengine_admin_v1.AuthorizedCertificatesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListAuthorizedCertificatesRequest(
- )
-
- # Make the request
- page_result = client.list_authorized_certificates(request=request)
-
- # Handle the response
- async for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_AuthorizedCertificates_ListAuthorizedCertificates_async]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_certificates_list_authorized_certificates_sync.py b/samples/generated_samples/appengine_v1_generated_authorized_certificates_list_authorized_certificates_sync.py
deleted file mode 100644
index 895e787..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_certificates_list_authorized_certificates_sync.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListAuthorizedCertificates
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedCertificates_ListAuthorizedCertificates_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_list_authorized_certificates():
- # Create a client
- client = appengine_admin_v1.AuthorizedCertificatesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListAuthorizedCertificatesRequest(
- )
-
- # Make the request
- page_result = client.list_authorized_certificates(request=request)
-
- # Handle the response
- for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_AuthorizedCertificates_ListAuthorizedCertificates_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_certificates_update_authorized_certificate_async.py b/samples/generated_samples/appengine_v1_generated_authorized_certificates_update_authorized_certificate_async.py
deleted file mode 100644
index 61f57f8..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_certificates_update_authorized_certificate_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateAuthorizedCertificate
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedCertificates_UpdateAuthorizedCertificate_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_update_authorized_certificate():
- # Create a client
- client = appengine_admin_v1.AuthorizedCertificatesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateAuthorizedCertificateRequest(
- )
-
- # Make the request
- response = await client.update_authorized_certificate(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_AuthorizedCertificates_UpdateAuthorizedCertificate_async]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_certificates_update_authorized_certificate_sync.py b/samples/generated_samples/appengine_v1_generated_authorized_certificates_update_authorized_certificate_sync.py
deleted file mode 100644
index 4eea019..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_certificates_update_authorized_certificate_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateAuthorizedCertificate
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedCertificates_UpdateAuthorizedCertificate_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_update_authorized_certificate():
- # Create a client
- client = appengine_admin_v1.AuthorizedCertificatesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateAuthorizedCertificateRequest(
- )
-
- # Make the request
- response = client.update_authorized_certificate(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_AuthorizedCertificates_UpdateAuthorizedCertificate_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_domains_list_authorized_domains_async.py b/samples/generated_samples/appengine_v1_generated_authorized_domains_list_authorized_domains_async.py
deleted file mode 100644
index 4ddd182..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_domains_list_authorized_domains_async.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListAuthorizedDomains
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedDomains_ListAuthorizedDomains_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_list_authorized_domains():
- # Create a client
- client = appengine_admin_v1.AuthorizedDomainsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListAuthorizedDomainsRequest(
- )
-
- # Make the request
- page_result = client.list_authorized_domains(request=request)
-
- # Handle the response
- async for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_AuthorizedDomains_ListAuthorizedDomains_async]
diff --git a/samples/generated_samples/appengine_v1_generated_authorized_domains_list_authorized_domains_sync.py b/samples/generated_samples/appengine_v1_generated_authorized_domains_list_authorized_domains_sync.py
deleted file mode 100644
index df8e759..0000000
--- a/samples/generated_samples/appengine_v1_generated_authorized_domains_list_authorized_domains_sync.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListAuthorizedDomains
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_AuthorizedDomains_ListAuthorizedDomains_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_list_authorized_domains():
- # Create a client
- client = appengine_admin_v1.AuthorizedDomainsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListAuthorizedDomainsRequest(
- )
-
- # Make the request
- page_result = client.list_authorized_domains(request=request)
-
- # Handle the response
- for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_AuthorizedDomains_ListAuthorizedDomains_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_domain_mappings_create_domain_mapping_async.py b/samples/generated_samples/appengine_v1_generated_domain_mappings_create_domain_mapping_async.py
deleted file mode 100644
index d82e3f0..0000000
--- a/samples/generated_samples/appengine_v1_generated_domain_mappings_create_domain_mapping_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for CreateDomainMapping
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_DomainMappings_CreateDomainMapping_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_create_domain_mapping():
- # Create a client
- client = appengine_admin_v1.DomainMappingsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.CreateDomainMappingRequest(
- )
-
- # Make the request
- operation = client.create_domain_mapping(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_DomainMappings_CreateDomainMapping_async]
diff --git a/samples/generated_samples/appengine_v1_generated_domain_mappings_create_domain_mapping_sync.py b/samples/generated_samples/appengine_v1_generated_domain_mappings_create_domain_mapping_sync.py
deleted file mode 100644
index 67346ef..0000000
--- a/samples/generated_samples/appengine_v1_generated_domain_mappings_create_domain_mapping_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for CreateDomainMapping
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_DomainMappings_CreateDomainMapping_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_create_domain_mapping():
- # Create a client
- client = appengine_admin_v1.DomainMappingsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.CreateDomainMappingRequest(
- )
-
- # Make the request
- operation = client.create_domain_mapping(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_DomainMappings_CreateDomainMapping_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_domain_mappings_delete_domain_mapping_async.py b/samples/generated_samples/appengine_v1_generated_domain_mappings_delete_domain_mapping_async.py
deleted file mode 100644
index 8de281b..0000000
--- a/samples/generated_samples/appengine_v1_generated_domain_mappings_delete_domain_mapping_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteDomainMapping
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_DomainMappings_DeleteDomainMapping_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_delete_domain_mapping():
- # Create a client
- client = appengine_admin_v1.DomainMappingsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteDomainMappingRequest(
- )
-
- # Make the request
- operation = client.delete_domain_mapping(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_DomainMappings_DeleteDomainMapping_async]
diff --git a/samples/generated_samples/appengine_v1_generated_domain_mappings_delete_domain_mapping_sync.py b/samples/generated_samples/appengine_v1_generated_domain_mappings_delete_domain_mapping_sync.py
deleted file mode 100644
index d344193..0000000
--- a/samples/generated_samples/appengine_v1_generated_domain_mappings_delete_domain_mapping_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteDomainMapping
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_DomainMappings_DeleteDomainMapping_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_delete_domain_mapping():
- # Create a client
- client = appengine_admin_v1.DomainMappingsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteDomainMappingRequest(
- )
-
- # Make the request
- operation = client.delete_domain_mapping(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_DomainMappings_DeleteDomainMapping_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_domain_mappings_get_domain_mapping_async.py b/samples/generated_samples/appengine_v1_generated_domain_mappings_get_domain_mapping_async.py
deleted file mode 100644
index 023a83e..0000000
--- a/samples/generated_samples/appengine_v1_generated_domain_mappings_get_domain_mapping_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetDomainMapping
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_DomainMappings_GetDomainMapping_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_get_domain_mapping():
- # Create a client
- client = appengine_admin_v1.DomainMappingsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetDomainMappingRequest(
- )
-
- # Make the request
- response = await client.get_domain_mapping(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_DomainMappings_GetDomainMapping_async]
diff --git a/samples/generated_samples/appengine_v1_generated_domain_mappings_get_domain_mapping_sync.py b/samples/generated_samples/appengine_v1_generated_domain_mappings_get_domain_mapping_sync.py
deleted file mode 100644
index 8eb4691..0000000
--- a/samples/generated_samples/appengine_v1_generated_domain_mappings_get_domain_mapping_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetDomainMapping
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_DomainMappings_GetDomainMapping_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_get_domain_mapping():
- # Create a client
- client = appengine_admin_v1.DomainMappingsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetDomainMappingRequest(
- )
-
- # Make the request
- response = client.get_domain_mapping(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_DomainMappings_GetDomainMapping_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_domain_mappings_list_domain_mappings_async.py b/samples/generated_samples/appengine_v1_generated_domain_mappings_list_domain_mappings_async.py
deleted file mode 100644
index eebf46a..0000000
--- a/samples/generated_samples/appengine_v1_generated_domain_mappings_list_domain_mappings_async.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListDomainMappings
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_DomainMappings_ListDomainMappings_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_list_domain_mappings():
- # Create a client
- client = appengine_admin_v1.DomainMappingsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListDomainMappingsRequest(
- )
-
- # Make the request
- page_result = client.list_domain_mappings(request=request)
-
- # Handle the response
- async for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_DomainMappings_ListDomainMappings_async]
diff --git a/samples/generated_samples/appengine_v1_generated_domain_mappings_list_domain_mappings_sync.py b/samples/generated_samples/appengine_v1_generated_domain_mappings_list_domain_mappings_sync.py
deleted file mode 100644
index 65eea14..0000000
--- a/samples/generated_samples/appengine_v1_generated_domain_mappings_list_domain_mappings_sync.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListDomainMappings
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_DomainMappings_ListDomainMappings_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_list_domain_mappings():
- # Create a client
- client = appengine_admin_v1.DomainMappingsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListDomainMappingsRequest(
- )
-
- # Make the request
- page_result = client.list_domain_mappings(request=request)
-
- # Handle the response
- for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_DomainMappings_ListDomainMappings_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_domain_mappings_update_domain_mapping_async.py b/samples/generated_samples/appengine_v1_generated_domain_mappings_update_domain_mapping_async.py
deleted file mode 100644
index 1305d82..0000000
--- a/samples/generated_samples/appengine_v1_generated_domain_mappings_update_domain_mapping_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateDomainMapping
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_DomainMappings_UpdateDomainMapping_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_update_domain_mapping():
- # Create a client
- client = appengine_admin_v1.DomainMappingsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateDomainMappingRequest(
- )
-
- # Make the request
- operation = client.update_domain_mapping(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_DomainMappings_UpdateDomainMapping_async]
diff --git a/samples/generated_samples/appengine_v1_generated_domain_mappings_update_domain_mapping_sync.py b/samples/generated_samples/appengine_v1_generated_domain_mappings_update_domain_mapping_sync.py
deleted file mode 100644
index 8f8ae4a..0000000
--- a/samples/generated_samples/appengine_v1_generated_domain_mappings_update_domain_mapping_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateDomainMapping
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_DomainMappings_UpdateDomainMapping_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_update_domain_mapping():
- # Create a client
- client = appengine_admin_v1.DomainMappingsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateDomainMappingRequest(
- )
-
- # Make the request
- operation = client.update_domain_mapping(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_DomainMappings_UpdateDomainMapping_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_batch_update_ingress_rules_async.py b/samples/generated_samples/appengine_v1_generated_firewall_batch_update_ingress_rules_async.py
deleted file mode 100644
index 5399783..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_batch_update_ingress_rules_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for BatchUpdateIngressRules
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_BatchUpdateIngressRules_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_batch_update_ingress_rules():
- # Create a client
- client = appengine_admin_v1.FirewallAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.BatchUpdateIngressRulesRequest(
- )
-
- # Make the request
- response = await client.batch_update_ingress_rules(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Firewall_BatchUpdateIngressRules_async]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_batch_update_ingress_rules_sync.py b/samples/generated_samples/appengine_v1_generated_firewall_batch_update_ingress_rules_sync.py
deleted file mode 100644
index d4c8a51..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_batch_update_ingress_rules_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for BatchUpdateIngressRules
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_BatchUpdateIngressRules_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_batch_update_ingress_rules():
- # Create a client
- client = appengine_admin_v1.FirewallClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.BatchUpdateIngressRulesRequest(
- )
-
- # Make the request
- response = client.batch_update_ingress_rules(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Firewall_BatchUpdateIngressRules_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_create_ingress_rule_async.py b/samples/generated_samples/appengine_v1_generated_firewall_create_ingress_rule_async.py
deleted file mode 100644
index fb0afc8..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_create_ingress_rule_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for CreateIngressRule
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_CreateIngressRule_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_create_ingress_rule():
- # Create a client
- client = appengine_admin_v1.FirewallAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.CreateIngressRuleRequest(
- )
-
- # Make the request
- response = await client.create_ingress_rule(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Firewall_CreateIngressRule_async]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_create_ingress_rule_sync.py b/samples/generated_samples/appengine_v1_generated_firewall_create_ingress_rule_sync.py
deleted file mode 100644
index 7ca87c4..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_create_ingress_rule_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for CreateIngressRule
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_CreateIngressRule_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_create_ingress_rule():
- # Create a client
- client = appengine_admin_v1.FirewallClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.CreateIngressRuleRequest(
- )
-
- # Make the request
- response = client.create_ingress_rule(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Firewall_CreateIngressRule_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_delete_ingress_rule_async.py b/samples/generated_samples/appengine_v1_generated_firewall_delete_ingress_rule_async.py
deleted file mode 100644
index 1f68a24..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_delete_ingress_rule_async.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteIngressRule
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_DeleteIngressRule_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_delete_ingress_rule():
- # Create a client
- client = appengine_admin_v1.FirewallAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteIngressRuleRequest(
- )
-
- # Make the request
- await client.delete_ingress_rule(request=request)
-
-
-# [END appengine_v1_generated_Firewall_DeleteIngressRule_async]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_delete_ingress_rule_sync.py b/samples/generated_samples/appengine_v1_generated_firewall_delete_ingress_rule_sync.py
deleted file mode 100644
index 5f70011..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_delete_ingress_rule_sync.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteIngressRule
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_DeleteIngressRule_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_delete_ingress_rule():
- # Create a client
- client = appengine_admin_v1.FirewallClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteIngressRuleRequest(
- )
-
- # Make the request
- client.delete_ingress_rule(request=request)
-
-
-# [END appengine_v1_generated_Firewall_DeleteIngressRule_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_get_ingress_rule_async.py b/samples/generated_samples/appengine_v1_generated_firewall_get_ingress_rule_async.py
deleted file mode 100644
index 4f0a94f..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_get_ingress_rule_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetIngressRule
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_GetIngressRule_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_get_ingress_rule():
- # Create a client
- client = appengine_admin_v1.FirewallAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetIngressRuleRequest(
- )
-
- # Make the request
- response = await client.get_ingress_rule(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Firewall_GetIngressRule_async]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_get_ingress_rule_sync.py b/samples/generated_samples/appengine_v1_generated_firewall_get_ingress_rule_sync.py
deleted file mode 100644
index d6e9e02..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_get_ingress_rule_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetIngressRule
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_GetIngressRule_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_get_ingress_rule():
- # Create a client
- client = appengine_admin_v1.FirewallClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetIngressRuleRequest(
- )
-
- # Make the request
- response = client.get_ingress_rule(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Firewall_GetIngressRule_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_list_ingress_rules_async.py b/samples/generated_samples/appengine_v1_generated_firewall_list_ingress_rules_async.py
deleted file mode 100644
index 1dd86f2..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_list_ingress_rules_async.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListIngressRules
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_ListIngressRules_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_list_ingress_rules():
- # Create a client
- client = appengine_admin_v1.FirewallAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListIngressRulesRequest(
- )
-
- # Make the request
- page_result = client.list_ingress_rules(request=request)
-
- # Handle the response
- async for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_Firewall_ListIngressRules_async]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_list_ingress_rules_sync.py b/samples/generated_samples/appengine_v1_generated_firewall_list_ingress_rules_sync.py
deleted file mode 100644
index 2613e28..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_list_ingress_rules_sync.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListIngressRules
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_ListIngressRules_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_list_ingress_rules():
- # Create a client
- client = appengine_admin_v1.FirewallClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListIngressRulesRequest(
- )
-
- # Make the request
- page_result = client.list_ingress_rules(request=request)
-
- # Handle the response
- for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_Firewall_ListIngressRules_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_update_ingress_rule_async.py b/samples/generated_samples/appengine_v1_generated_firewall_update_ingress_rule_async.py
deleted file mode 100644
index d0fe163..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_update_ingress_rule_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateIngressRule
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_UpdateIngressRule_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_update_ingress_rule():
- # Create a client
- client = appengine_admin_v1.FirewallAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateIngressRuleRequest(
- )
-
- # Make the request
- response = await client.update_ingress_rule(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Firewall_UpdateIngressRule_async]
diff --git a/samples/generated_samples/appengine_v1_generated_firewall_update_ingress_rule_sync.py b/samples/generated_samples/appengine_v1_generated_firewall_update_ingress_rule_sync.py
deleted file mode 100644
index 667bcd3..0000000
--- a/samples/generated_samples/appengine_v1_generated_firewall_update_ingress_rule_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateIngressRule
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Firewall_UpdateIngressRule_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_update_ingress_rule():
- # Create a client
- client = appengine_admin_v1.FirewallClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateIngressRuleRequest(
- )
-
- # Make the request
- response = client.update_ingress_rule(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Firewall_UpdateIngressRule_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_instances_debug_instance_async.py b/samples/generated_samples/appengine_v1_generated_instances_debug_instance_async.py
deleted file mode 100644
index 42d0ffa..0000000
--- a/samples/generated_samples/appengine_v1_generated_instances_debug_instance_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DebugInstance
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Instances_DebugInstance_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_debug_instance():
- # Create a client
- client = appengine_admin_v1.InstancesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DebugInstanceRequest(
- )
-
- # Make the request
- operation = client.debug_instance(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Instances_DebugInstance_async]
diff --git a/samples/generated_samples/appengine_v1_generated_instances_debug_instance_sync.py b/samples/generated_samples/appengine_v1_generated_instances_debug_instance_sync.py
deleted file mode 100644
index e4146de..0000000
--- a/samples/generated_samples/appengine_v1_generated_instances_debug_instance_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DebugInstance
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Instances_DebugInstance_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_debug_instance():
- # Create a client
- client = appengine_admin_v1.InstancesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DebugInstanceRequest(
- )
-
- # Make the request
- operation = client.debug_instance(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Instances_DebugInstance_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_instances_delete_instance_async.py b/samples/generated_samples/appengine_v1_generated_instances_delete_instance_async.py
deleted file mode 100644
index cdca21b..0000000
--- a/samples/generated_samples/appengine_v1_generated_instances_delete_instance_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteInstance
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Instances_DeleteInstance_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_delete_instance():
- # Create a client
- client = appengine_admin_v1.InstancesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteInstanceRequest(
- )
-
- # Make the request
- operation = client.delete_instance(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Instances_DeleteInstance_async]
diff --git a/samples/generated_samples/appengine_v1_generated_instances_delete_instance_sync.py b/samples/generated_samples/appengine_v1_generated_instances_delete_instance_sync.py
deleted file mode 100644
index b7d7725..0000000
--- a/samples/generated_samples/appengine_v1_generated_instances_delete_instance_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteInstance
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Instances_DeleteInstance_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_delete_instance():
- # Create a client
- client = appengine_admin_v1.InstancesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteInstanceRequest(
- )
-
- # Make the request
- operation = client.delete_instance(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Instances_DeleteInstance_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_instances_get_instance_async.py b/samples/generated_samples/appengine_v1_generated_instances_get_instance_async.py
deleted file mode 100644
index f3a0b9f..0000000
--- a/samples/generated_samples/appengine_v1_generated_instances_get_instance_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetInstance
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Instances_GetInstance_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_get_instance():
- # Create a client
- client = appengine_admin_v1.InstancesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetInstanceRequest(
- )
-
- # Make the request
- response = await client.get_instance(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Instances_GetInstance_async]
diff --git a/samples/generated_samples/appengine_v1_generated_instances_get_instance_sync.py b/samples/generated_samples/appengine_v1_generated_instances_get_instance_sync.py
deleted file mode 100644
index 22f90f1..0000000
--- a/samples/generated_samples/appengine_v1_generated_instances_get_instance_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetInstance
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Instances_GetInstance_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_get_instance():
- # Create a client
- client = appengine_admin_v1.InstancesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetInstanceRequest(
- )
-
- # Make the request
- response = client.get_instance(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Instances_GetInstance_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_instances_list_instances_async.py b/samples/generated_samples/appengine_v1_generated_instances_list_instances_async.py
deleted file mode 100644
index 96beea0..0000000
--- a/samples/generated_samples/appengine_v1_generated_instances_list_instances_async.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListInstances
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Instances_ListInstances_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_list_instances():
- # Create a client
- client = appengine_admin_v1.InstancesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListInstancesRequest(
- )
-
- # Make the request
- page_result = client.list_instances(request=request)
-
- # Handle the response
- async for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_Instances_ListInstances_async]
diff --git a/samples/generated_samples/appengine_v1_generated_instances_list_instances_sync.py b/samples/generated_samples/appengine_v1_generated_instances_list_instances_sync.py
deleted file mode 100644
index d4ba864..0000000
--- a/samples/generated_samples/appengine_v1_generated_instances_list_instances_sync.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListInstances
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Instances_ListInstances_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_list_instances():
- # Create a client
- client = appengine_admin_v1.InstancesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListInstancesRequest(
- )
-
- # Make the request
- page_result = client.list_instances(request=request)
-
- # Handle the response
- for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_Instances_ListInstances_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_services_delete_service_async.py b/samples/generated_samples/appengine_v1_generated_services_delete_service_async.py
deleted file mode 100644
index aa89f25..0000000
--- a/samples/generated_samples/appengine_v1_generated_services_delete_service_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteService
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Services_DeleteService_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_delete_service():
- # Create a client
- client = appengine_admin_v1.ServicesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteServiceRequest(
- )
-
- # Make the request
- operation = client.delete_service(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Services_DeleteService_async]
diff --git a/samples/generated_samples/appengine_v1_generated_services_delete_service_sync.py b/samples/generated_samples/appengine_v1_generated_services_delete_service_sync.py
deleted file mode 100644
index 9e852aa..0000000
--- a/samples/generated_samples/appengine_v1_generated_services_delete_service_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteService
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Services_DeleteService_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_delete_service():
- # Create a client
- client = appengine_admin_v1.ServicesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteServiceRequest(
- )
-
- # Make the request
- operation = client.delete_service(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Services_DeleteService_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_services_get_service_async.py b/samples/generated_samples/appengine_v1_generated_services_get_service_async.py
deleted file mode 100644
index f645503..0000000
--- a/samples/generated_samples/appengine_v1_generated_services_get_service_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetService
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Services_GetService_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_get_service():
- # Create a client
- client = appengine_admin_v1.ServicesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetServiceRequest(
- )
-
- # Make the request
- response = await client.get_service(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Services_GetService_async]
diff --git a/samples/generated_samples/appengine_v1_generated_services_get_service_sync.py b/samples/generated_samples/appengine_v1_generated_services_get_service_sync.py
deleted file mode 100644
index 21aa6fa..0000000
--- a/samples/generated_samples/appengine_v1_generated_services_get_service_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetService
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Services_GetService_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_get_service():
- # Create a client
- client = appengine_admin_v1.ServicesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetServiceRequest(
- )
-
- # Make the request
- response = client.get_service(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Services_GetService_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_services_list_services_async.py b/samples/generated_samples/appengine_v1_generated_services_list_services_async.py
deleted file mode 100644
index af5f2ef..0000000
--- a/samples/generated_samples/appengine_v1_generated_services_list_services_async.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListServices
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Services_ListServices_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_list_services():
- # Create a client
- client = appengine_admin_v1.ServicesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListServicesRequest(
- )
-
- # Make the request
- page_result = client.list_services(request=request)
-
- # Handle the response
- async for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_Services_ListServices_async]
diff --git a/samples/generated_samples/appengine_v1_generated_services_list_services_sync.py b/samples/generated_samples/appengine_v1_generated_services_list_services_sync.py
deleted file mode 100644
index 28954e1..0000000
--- a/samples/generated_samples/appengine_v1_generated_services_list_services_sync.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListServices
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Services_ListServices_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_list_services():
- # Create a client
- client = appengine_admin_v1.ServicesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListServicesRequest(
- )
-
- # Make the request
- page_result = client.list_services(request=request)
-
- # Handle the response
- for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_Services_ListServices_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_services_update_service_async.py b/samples/generated_samples/appengine_v1_generated_services_update_service_async.py
deleted file mode 100644
index 6f27d28..0000000
--- a/samples/generated_samples/appengine_v1_generated_services_update_service_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateService
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Services_UpdateService_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_update_service():
- # Create a client
- client = appengine_admin_v1.ServicesAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateServiceRequest(
- )
-
- # Make the request
- operation = client.update_service(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Services_UpdateService_async]
diff --git a/samples/generated_samples/appengine_v1_generated_services_update_service_sync.py b/samples/generated_samples/appengine_v1_generated_services_update_service_sync.py
deleted file mode 100644
index 53284de..0000000
--- a/samples/generated_samples/appengine_v1_generated_services_update_service_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateService
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Services_UpdateService_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_update_service():
- # Create a client
- client = appengine_admin_v1.ServicesClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateServiceRequest(
- )
-
- # Make the request
- operation = client.update_service(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Services_UpdateService_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_versions_create_version_async.py b/samples/generated_samples/appengine_v1_generated_versions_create_version_async.py
deleted file mode 100644
index d942c44..0000000
--- a/samples/generated_samples/appengine_v1_generated_versions_create_version_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for CreateVersion
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Versions_CreateVersion_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_create_version():
- # Create a client
- client = appengine_admin_v1.VersionsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.CreateVersionRequest(
- )
-
- # Make the request
- operation = client.create_version(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Versions_CreateVersion_async]
diff --git a/samples/generated_samples/appengine_v1_generated_versions_create_version_sync.py b/samples/generated_samples/appengine_v1_generated_versions_create_version_sync.py
deleted file mode 100644
index 1b4fa03..0000000
--- a/samples/generated_samples/appengine_v1_generated_versions_create_version_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for CreateVersion
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Versions_CreateVersion_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_create_version():
- # Create a client
- client = appengine_admin_v1.VersionsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.CreateVersionRequest(
- )
-
- # Make the request
- operation = client.create_version(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Versions_CreateVersion_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_versions_delete_version_async.py b/samples/generated_samples/appengine_v1_generated_versions_delete_version_async.py
deleted file mode 100644
index 27e8eee..0000000
--- a/samples/generated_samples/appengine_v1_generated_versions_delete_version_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteVersion
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Versions_DeleteVersion_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_delete_version():
- # Create a client
- client = appengine_admin_v1.VersionsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteVersionRequest(
- )
-
- # Make the request
- operation = client.delete_version(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Versions_DeleteVersion_async]
diff --git a/samples/generated_samples/appengine_v1_generated_versions_delete_version_sync.py b/samples/generated_samples/appengine_v1_generated_versions_delete_version_sync.py
deleted file mode 100644
index 51027cc..0000000
--- a/samples/generated_samples/appengine_v1_generated_versions_delete_version_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for DeleteVersion
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Versions_DeleteVersion_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_delete_version():
- # Create a client
- client = appengine_admin_v1.VersionsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.DeleteVersionRequest(
- )
-
- # Make the request
- operation = client.delete_version(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Versions_DeleteVersion_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_versions_get_version_async.py b/samples/generated_samples/appengine_v1_generated_versions_get_version_async.py
deleted file mode 100644
index c778fd8..0000000
--- a/samples/generated_samples/appengine_v1_generated_versions_get_version_async.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetVersion
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Versions_GetVersion_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_get_version():
- # Create a client
- client = appengine_admin_v1.VersionsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetVersionRequest(
- )
-
- # Make the request
- response = await client.get_version(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Versions_GetVersion_async]
diff --git a/samples/generated_samples/appengine_v1_generated_versions_get_version_sync.py b/samples/generated_samples/appengine_v1_generated_versions_get_version_sync.py
deleted file mode 100644
index 6229a5a..0000000
--- a/samples/generated_samples/appengine_v1_generated_versions_get_version_sync.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for GetVersion
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Versions_GetVersion_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_get_version():
- # Create a client
- client = appengine_admin_v1.VersionsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.GetVersionRequest(
- )
-
- # Make the request
- response = client.get_version(request=request)
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Versions_GetVersion_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_versions_list_versions_async.py b/samples/generated_samples/appengine_v1_generated_versions_list_versions_async.py
deleted file mode 100644
index 386b211..0000000
--- a/samples/generated_samples/appengine_v1_generated_versions_list_versions_async.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListVersions
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Versions_ListVersions_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_list_versions():
- # Create a client
- client = appengine_admin_v1.VersionsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListVersionsRequest(
- )
-
- # Make the request
- page_result = client.list_versions(request=request)
-
- # Handle the response
- async for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_Versions_ListVersions_async]
diff --git a/samples/generated_samples/appengine_v1_generated_versions_list_versions_sync.py b/samples/generated_samples/appengine_v1_generated_versions_list_versions_sync.py
deleted file mode 100644
index d7b2c41..0000000
--- a/samples/generated_samples/appengine_v1_generated_versions_list_versions_sync.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for ListVersions
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Versions_ListVersions_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_list_versions():
- # Create a client
- client = appengine_admin_v1.VersionsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.ListVersionsRequest(
- )
-
- # Make the request
- page_result = client.list_versions(request=request)
-
- # Handle the response
- for response in page_result:
- print(response)
-
-# [END appengine_v1_generated_Versions_ListVersions_sync]
diff --git a/samples/generated_samples/appengine_v1_generated_versions_update_version_async.py b/samples/generated_samples/appengine_v1_generated_versions_update_version_async.py
deleted file mode 100644
index 221717f..0000000
--- a/samples/generated_samples/appengine_v1_generated_versions_update_version_async.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateVersion
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Versions_UpdateVersion_async]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-async def sample_update_version():
- # Create a client
- client = appengine_admin_v1.VersionsAsyncClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateVersionRequest(
- )
-
- # Make the request
- operation = client.update_version(request=request)
-
- print("Waiting for operation to complete...")
-
- response = (await operation).result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Versions_UpdateVersion_async]
diff --git a/samples/generated_samples/appengine_v1_generated_versions_update_version_sync.py b/samples/generated_samples/appengine_v1_generated_versions_update_version_sync.py
deleted file mode 100644
index bba0d50..0000000
--- a/samples/generated_samples/appengine_v1_generated_versions_update_version_sync.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Generated code. DO NOT EDIT!
-#
-# Snippet for UpdateVersion
-# NOTE: This snippet has been automatically generated for illustrative purposes only.
-# It may require modifications to work in your environment.
-
-# To install the latest published package dependency, execute the following:
-# python3 -m pip install google-cloud-appengine-admin
-
-
-# [START appengine_v1_generated_Versions_UpdateVersion_sync]
-# This snippet has been automatically generated and should be regarded as a
-# code template only.
-# It will require modifications to work:
-# - It may require correct/in-range values for request initialization.
-# - It may require specifying regional endpoints when creating the service
-# client as shown in:
-# https://googleapis.dev/python/google-api-core/latest/client_options.html
-from google.cloud import appengine_admin_v1
-
-
-def sample_update_version():
- # Create a client
- client = appengine_admin_v1.VersionsClient()
-
- # Initialize request argument(s)
- request = appengine_admin_v1.UpdateVersionRequest(
- )
-
- # Make the request
- operation = client.update_version(request=request)
-
- print("Waiting for operation to complete...")
-
- response = operation.result()
-
- # Handle the response
- print(response)
-
-# [END appengine_v1_generated_Versions_UpdateVersion_sync]
diff --git a/samples/generated_samples/snippet_metadata_google.appengine.v1.json b/samples/generated_samples/snippet_metadata_google.appengine.v1.json
deleted file mode 100644
index fb8cbf5..0000000
--- a/samples/generated_samples/snippet_metadata_google.appengine.v1.json
+++ /dev/null
@@ -1,5213 +0,0 @@
-{
- "clientLibrary": {
- "apis": [
- {
- "id": "google.appengine.v1",
- "version": "v1"
- }
- ],
- "language": "PYTHON",
- "name": "google-cloud-appengine-admin",
- "version": "0.1.0"
- },
- "snippets": [
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsAsyncClient",
- "shortName": "ApplicationsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsAsyncClient.create_application",
- "method": {
- "fullName": "google.appengine.v1.Applications.CreateApplication",
- "service": {
- "fullName": "google.appengine.v1.Applications",
- "shortName": "Applications"
- },
- "shortName": "CreateApplication"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.CreateApplicationRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "create_application"
- },
- "description": "Sample for CreateApplication",
- "file": "appengine_v1_generated_applications_create_application_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Applications_CreateApplication_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_applications_create_application_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsClient",
- "shortName": "ApplicationsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsClient.create_application",
- "method": {
- "fullName": "google.appengine.v1.Applications.CreateApplication",
- "service": {
- "fullName": "google.appengine.v1.Applications",
- "shortName": "Applications"
- },
- "shortName": "CreateApplication"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.CreateApplicationRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "create_application"
- },
- "description": "Sample for CreateApplication",
- "file": "appengine_v1_generated_applications_create_application_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Applications_CreateApplication_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_applications_create_application_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsAsyncClient",
- "shortName": "ApplicationsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsAsyncClient.get_application",
- "method": {
- "fullName": "google.appengine.v1.Applications.GetApplication",
- "service": {
- "fullName": "google.appengine.v1.Applications",
- "shortName": "Applications"
- },
- "shortName": "GetApplication"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetApplicationRequest"
- },
- {
- "name": "name",
- "type": "str"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.Application",
- "shortName": "get_application"
- },
- "description": "Sample for GetApplication",
- "file": "appengine_v1_generated_applications_get_application_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Applications_GetApplication_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_applications_get_application_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsClient",
- "shortName": "ApplicationsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsClient.get_application",
- "method": {
- "fullName": "google.appengine.v1.Applications.GetApplication",
- "service": {
- "fullName": "google.appengine.v1.Applications",
- "shortName": "Applications"
- },
- "shortName": "GetApplication"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetApplicationRequest"
- },
- {
- "name": "name",
- "type": "str"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.Application",
- "shortName": "get_application"
- },
- "description": "Sample for GetApplication",
- "file": "appengine_v1_generated_applications_get_application_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Applications_GetApplication_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_applications_get_application_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsAsyncClient",
- "shortName": "ApplicationsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsAsyncClient.repair_application",
- "method": {
- "fullName": "google.appengine.v1.Applications.RepairApplication",
- "service": {
- "fullName": "google.appengine.v1.Applications",
- "shortName": "Applications"
- },
- "shortName": "RepairApplication"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.RepairApplicationRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "repair_application"
- },
- "description": "Sample for RepairApplication",
- "file": "appengine_v1_generated_applications_repair_application_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Applications_RepairApplication_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_applications_repair_application_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsClient",
- "shortName": "ApplicationsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsClient.repair_application",
- "method": {
- "fullName": "google.appengine.v1.Applications.RepairApplication",
- "service": {
- "fullName": "google.appengine.v1.Applications",
- "shortName": "Applications"
- },
- "shortName": "RepairApplication"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.RepairApplicationRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "repair_application"
- },
- "description": "Sample for RepairApplication",
- "file": "appengine_v1_generated_applications_repair_application_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Applications_RepairApplication_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_applications_repair_application_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsAsyncClient",
- "shortName": "ApplicationsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsAsyncClient.update_application",
- "method": {
- "fullName": "google.appengine.v1.Applications.UpdateApplication",
- "service": {
- "fullName": "google.appengine.v1.Applications",
- "shortName": "Applications"
- },
- "shortName": "UpdateApplication"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateApplicationRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "update_application"
- },
- "description": "Sample for UpdateApplication",
- "file": "appengine_v1_generated_applications_update_application_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Applications_UpdateApplication_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_applications_update_application_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsClient",
- "shortName": "ApplicationsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ApplicationsClient.update_application",
- "method": {
- "fullName": "google.appengine.v1.Applications.UpdateApplication",
- "service": {
- "fullName": "google.appengine.v1.Applications",
- "shortName": "Applications"
- },
- "shortName": "UpdateApplication"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateApplicationRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "update_application"
- },
- "description": "Sample for UpdateApplication",
- "file": "appengine_v1_generated_applications_update_application_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Applications_UpdateApplication_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_applications_update_application_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesAsyncClient",
- "shortName": "AuthorizedCertificatesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesAsyncClient.create_authorized_certificate",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedCertificates.CreateAuthorizedCertificate",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedCertificates",
- "shortName": "AuthorizedCertificates"
- },
- "shortName": "CreateAuthorizedCertificate"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.CreateAuthorizedCertificateRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate",
- "shortName": "create_authorized_certificate"
- },
- "description": "Sample for CreateAuthorizedCertificate",
- "file": "appengine_v1_generated_authorized_certificates_create_authorized_certificate_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedCertificates_CreateAuthorizedCertificate_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_certificates_create_authorized_certificate_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesClient",
- "shortName": "AuthorizedCertificatesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesClient.create_authorized_certificate",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedCertificates.CreateAuthorizedCertificate",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedCertificates",
- "shortName": "AuthorizedCertificates"
- },
- "shortName": "CreateAuthorizedCertificate"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.CreateAuthorizedCertificateRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate",
- "shortName": "create_authorized_certificate"
- },
- "description": "Sample for CreateAuthorizedCertificate",
- "file": "appengine_v1_generated_authorized_certificates_create_authorized_certificate_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedCertificates_CreateAuthorizedCertificate_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_certificates_create_authorized_certificate_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesAsyncClient",
- "shortName": "AuthorizedCertificatesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesAsyncClient.delete_authorized_certificate",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedCertificates.DeleteAuthorizedCertificate",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedCertificates",
- "shortName": "AuthorizedCertificates"
- },
- "shortName": "DeleteAuthorizedCertificate"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteAuthorizedCertificateRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "shortName": "delete_authorized_certificate"
- },
- "description": "Sample for DeleteAuthorizedCertificate",
- "file": "appengine_v1_generated_authorized_certificates_delete_authorized_certificate_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedCertificates_DeleteAuthorizedCertificate_async",
- "segments": [
- {
- "end": 48,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 48,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 49,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_certificates_delete_authorized_certificate_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesClient",
- "shortName": "AuthorizedCertificatesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesClient.delete_authorized_certificate",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedCertificates.DeleteAuthorizedCertificate",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedCertificates",
- "shortName": "AuthorizedCertificates"
- },
- "shortName": "DeleteAuthorizedCertificate"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteAuthorizedCertificateRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "shortName": "delete_authorized_certificate"
- },
- "description": "Sample for DeleteAuthorizedCertificate",
- "file": "appengine_v1_generated_authorized_certificates_delete_authorized_certificate_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedCertificates_DeleteAuthorizedCertificate_sync",
- "segments": [
- {
- "end": 48,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 48,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 49,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_certificates_delete_authorized_certificate_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesAsyncClient",
- "shortName": "AuthorizedCertificatesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesAsyncClient.get_authorized_certificate",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedCertificates.GetAuthorizedCertificate",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedCertificates",
- "shortName": "AuthorizedCertificates"
- },
- "shortName": "GetAuthorizedCertificate"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetAuthorizedCertificateRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate",
- "shortName": "get_authorized_certificate"
- },
- "description": "Sample for GetAuthorizedCertificate",
- "file": "appengine_v1_generated_authorized_certificates_get_authorized_certificate_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedCertificates_GetAuthorizedCertificate_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_certificates_get_authorized_certificate_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesClient",
- "shortName": "AuthorizedCertificatesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesClient.get_authorized_certificate",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedCertificates.GetAuthorizedCertificate",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedCertificates",
- "shortName": "AuthorizedCertificates"
- },
- "shortName": "GetAuthorizedCertificate"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetAuthorizedCertificateRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate",
- "shortName": "get_authorized_certificate"
- },
- "description": "Sample for GetAuthorizedCertificate",
- "file": "appengine_v1_generated_authorized_certificates_get_authorized_certificate_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedCertificates_GetAuthorizedCertificate_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_certificates_get_authorized_certificate_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesAsyncClient",
- "shortName": "AuthorizedCertificatesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesAsyncClient.list_authorized_certificates",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedCertificates.ListAuthorizedCertificates",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedCertificates",
- "shortName": "AuthorizedCertificates"
- },
- "shortName": "ListAuthorizedCertificates"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListAuthorizedCertificatesRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.authorized_certificates.pagers.ListAuthorizedCertificatesAsyncPager",
- "shortName": "list_authorized_certificates"
- },
- "description": "Sample for ListAuthorizedCertificates",
- "file": "appengine_v1_generated_authorized_certificates_list_authorized_certificates_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedCertificates_ListAuthorizedCertificates_async",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_certificates_list_authorized_certificates_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesClient",
- "shortName": "AuthorizedCertificatesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesClient.list_authorized_certificates",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedCertificates.ListAuthorizedCertificates",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedCertificates",
- "shortName": "AuthorizedCertificates"
- },
- "shortName": "ListAuthorizedCertificates"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListAuthorizedCertificatesRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.authorized_certificates.pagers.ListAuthorizedCertificatesPager",
- "shortName": "list_authorized_certificates"
- },
- "description": "Sample for ListAuthorizedCertificates",
- "file": "appengine_v1_generated_authorized_certificates_list_authorized_certificates_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedCertificates_ListAuthorizedCertificates_sync",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_certificates_list_authorized_certificates_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesAsyncClient",
- "shortName": "AuthorizedCertificatesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesAsyncClient.update_authorized_certificate",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedCertificates.UpdateAuthorizedCertificate",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedCertificates",
- "shortName": "AuthorizedCertificates"
- },
- "shortName": "UpdateAuthorizedCertificate"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateAuthorizedCertificateRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate",
- "shortName": "update_authorized_certificate"
- },
- "description": "Sample for UpdateAuthorizedCertificate",
- "file": "appengine_v1_generated_authorized_certificates_update_authorized_certificate_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedCertificates_UpdateAuthorizedCertificate_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_certificates_update_authorized_certificate_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesClient",
- "shortName": "AuthorizedCertificatesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedCertificatesClient.update_authorized_certificate",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedCertificates.UpdateAuthorizedCertificate",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedCertificates",
- "shortName": "AuthorizedCertificates"
- },
- "shortName": "UpdateAuthorizedCertificate"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateAuthorizedCertificateRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate",
- "shortName": "update_authorized_certificate"
- },
- "description": "Sample for UpdateAuthorizedCertificate",
- "file": "appengine_v1_generated_authorized_certificates_update_authorized_certificate_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedCertificates_UpdateAuthorizedCertificate_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_certificates_update_authorized_certificate_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedDomainsAsyncClient",
- "shortName": "AuthorizedDomainsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedDomainsAsyncClient.list_authorized_domains",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedDomains.ListAuthorizedDomains",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedDomains",
- "shortName": "AuthorizedDomains"
- },
- "shortName": "ListAuthorizedDomains"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListAuthorizedDomainsRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.authorized_domains.pagers.ListAuthorizedDomainsAsyncPager",
- "shortName": "list_authorized_domains"
- },
- "description": "Sample for ListAuthorizedDomains",
- "file": "appengine_v1_generated_authorized_domains_list_authorized_domains_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedDomains_ListAuthorizedDomains_async",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_domains_list_authorized_domains_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedDomainsClient",
- "shortName": "AuthorizedDomainsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.AuthorizedDomainsClient.list_authorized_domains",
- "method": {
- "fullName": "google.appengine.v1.AuthorizedDomains.ListAuthorizedDomains",
- "service": {
- "fullName": "google.appengine.v1.AuthorizedDomains",
- "shortName": "AuthorizedDomains"
- },
- "shortName": "ListAuthorizedDomains"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListAuthorizedDomainsRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.authorized_domains.pagers.ListAuthorizedDomainsPager",
- "shortName": "list_authorized_domains"
- },
- "description": "Sample for ListAuthorizedDomains",
- "file": "appengine_v1_generated_authorized_domains_list_authorized_domains_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_AuthorizedDomains_ListAuthorizedDomains_sync",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_authorized_domains_list_authorized_domains_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsAsyncClient",
- "shortName": "DomainMappingsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsAsyncClient.create_domain_mapping",
- "method": {
- "fullName": "google.appengine.v1.DomainMappings.CreateDomainMapping",
- "service": {
- "fullName": "google.appengine.v1.DomainMappings",
- "shortName": "DomainMappings"
- },
- "shortName": "CreateDomainMapping"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.CreateDomainMappingRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "create_domain_mapping"
- },
- "description": "Sample for CreateDomainMapping",
- "file": "appengine_v1_generated_domain_mappings_create_domain_mapping_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_DomainMappings_CreateDomainMapping_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_domain_mappings_create_domain_mapping_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsClient",
- "shortName": "DomainMappingsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsClient.create_domain_mapping",
- "method": {
- "fullName": "google.appengine.v1.DomainMappings.CreateDomainMapping",
- "service": {
- "fullName": "google.appengine.v1.DomainMappings",
- "shortName": "DomainMappings"
- },
- "shortName": "CreateDomainMapping"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.CreateDomainMappingRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "create_domain_mapping"
- },
- "description": "Sample for CreateDomainMapping",
- "file": "appengine_v1_generated_domain_mappings_create_domain_mapping_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_DomainMappings_CreateDomainMapping_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_domain_mappings_create_domain_mapping_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsAsyncClient",
- "shortName": "DomainMappingsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsAsyncClient.delete_domain_mapping",
- "method": {
- "fullName": "google.appengine.v1.DomainMappings.DeleteDomainMapping",
- "service": {
- "fullName": "google.appengine.v1.DomainMappings",
- "shortName": "DomainMappings"
- },
- "shortName": "DeleteDomainMapping"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteDomainMappingRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "delete_domain_mapping"
- },
- "description": "Sample for DeleteDomainMapping",
- "file": "appengine_v1_generated_domain_mappings_delete_domain_mapping_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_DomainMappings_DeleteDomainMapping_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_domain_mappings_delete_domain_mapping_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsClient",
- "shortName": "DomainMappingsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsClient.delete_domain_mapping",
- "method": {
- "fullName": "google.appengine.v1.DomainMappings.DeleteDomainMapping",
- "service": {
- "fullName": "google.appengine.v1.DomainMappings",
- "shortName": "DomainMappings"
- },
- "shortName": "DeleteDomainMapping"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteDomainMappingRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "delete_domain_mapping"
- },
- "description": "Sample for DeleteDomainMapping",
- "file": "appengine_v1_generated_domain_mappings_delete_domain_mapping_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_DomainMappings_DeleteDomainMapping_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_domain_mappings_delete_domain_mapping_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsAsyncClient",
- "shortName": "DomainMappingsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsAsyncClient.get_domain_mapping",
- "method": {
- "fullName": "google.appengine.v1.DomainMappings.GetDomainMapping",
- "service": {
- "fullName": "google.appengine.v1.DomainMappings",
- "shortName": "DomainMappings"
- },
- "shortName": "GetDomainMapping"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetDomainMappingRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.DomainMapping",
- "shortName": "get_domain_mapping"
- },
- "description": "Sample for GetDomainMapping",
- "file": "appengine_v1_generated_domain_mappings_get_domain_mapping_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_DomainMappings_GetDomainMapping_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_domain_mappings_get_domain_mapping_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsClient",
- "shortName": "DomainMappingsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsClient.get_domain_mapping",
- "method": {
- "fullName": "google.appengine.v1.DomainMappings.GetDomainMapping",
- "service": {
- "fullName": "google.appengine.v1.DomainMappings",
- "shortName": "DomainMappings"
- },
- "shortName": "GetDomainMapping"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetDomainMappingRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.DomainMapping",
- "shortName": "get_domain_mapping"
- },
- "description": "Sample for GetDomainMapping",
- "file": "appengine_v1_generated_domain_mappings_get_domain_mapping_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_DomainMappings_GetDomainMapping_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_domain_mappings_get_domain_mapping_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsAsyncClient",
- "shortName": "DomainMappingsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsAsyncClient.list_domain_mappings",
- "method": {
- "fullName": "google.appengine.v1.DomainMappings.ListDomainMappings",
- "service": {
- "fullName": "google.appengine.v1.DomainMappings",
- "shortName": "DomainMappings"
- },
- "shortName": "ListDomainMappings"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListDomainMappingsRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.domain_mappings.pagers.ListDomainMappingsAsyncPager",
- "shortName": "list_domain_mappings"
- },
- "description": "Sample for ListDomainMappings",
- "file": "appengine_v1_generated_domain_mappings_list_domain_mappings_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_DomainMappings_ListDomainMappings_async",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_domain_mappings_list_domain_mappings_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsClient",
- "shortName": "DomainMappingsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsClient.list_domain_mappings",
- "method": {
- "fullName": "google.appengine.v1.DomainMappings.ListDomainMappings",
- "service": {
- "fullName": "google.appengine.v1.DomainMappings",
- "shortName": "DomainMappings"
- },
- "shortName": "ListDomainMappings"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListDomainMappingsRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.domain_mappings.pagers.ListDomainMappingsPager",
- "shortName": "list_domain_mappings"
- },
- "description": "Sample for ListDomainMappings",
- "file": "appengine_v1_generated_domain_mappings_list_domain_mappings_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_DomainMappings_ListDomainMappings_sync",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_domain_mappings_list_domain_mappings_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsAsyncClient",
- "shortName": "DomainMappingsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsAsyncClient.update_domain_mapping",
- "method": {
- "fullName": "google.appengine.v1.DomainMappings.UpdateDomainMapping",
- "service": {
- "fullName": "google.appengine.v1.DomainMappings",
- "shortName": "DomainMappings"
- },
- "shortName": "UpdateDomainMapping"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateDomainMappingRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "update_domain_mapping"
- },
- "description": "Sample for UpdateDomainMapping",
- "file": "appengine_v1_generated_domain_mappings_update_domain_mapping_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_DomainMappings_UpdateDomainMapping_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_domain_mappings_update_domain_mapping_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsClient",
- "shortName": "DomainMappingsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.DomainMappingsClient.update_domain_mapping",
- "method": {
- "fullName": "google.appengine.v1.DomainMappings.UpdateDomainMapping",
- "service": {
- "fullName": "google.appengine.v1.DomainMappings",
- "shortName": "DomainMappings"
- },
- "shortName": "UpdateDomainMapping"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateDomainMappingRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "update_domain_mapping"
- },
- "description": "Sample for UpdateDomainMapping",
- "file": "appengine_v1_generated_domain_mappings_update_domain_mapping_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_DomainMappings_UpdateDomainMapping_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_domain_mappings_update_domain_mapping_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient",
- "shortName": "FirewallAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient.batch_update_ingress_rules",
- "method": {
- "fullName": "google.appengine.v1.Firewall.BatchUpdateIngressRules",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "BatchUpdateIngressRules"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.BatchUpdateIngressRulesRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.BatchUpdateIngressRulesResponse",
- "shortName": "batch_update_ingress_rules"
- },
- "description": "Sample for BatchUpdateIngressRules",
- "file": "appengine_v1_generated_firewall_batch_update_ingress_rules_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_BatchUpdateIngressRules_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_batch_update_ingress_rules_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient",
- "shortName": "FirewallClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient.batch_update_ingress_rules",
- "method": {
- "fullName": "google.appengine.v1.Firewall.BatchUpdateIngressRules",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "BatchUpdateIngressRules"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.BatchUpdateIngressRulesRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.BatchUpdateIngressRulesResponse",
- "shortName": "batch_update_ingress_rules"
- },
- "description": "Sample for BatchUpdateIngressRules",
- "file": "appengine_v1_generated_firewall_batch_update_ingress_rules_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_BatchUpdateIngressRules_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_batch_update_ingress_rules_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient",
- "shortName": "FirewallAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient.create_ingress_rule",
- "method": {
- "fullName": "google.appengine.v1.Firewall.CreateIngressRule",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "CreateIngressRule"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.CreateIngressRuleRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule",
- "shortName": "create_ingress_rule"
- },
- "description": "Sample for CreateIngressRule",
- "file": "appengine_v1_generated_firewall_create_ingress_rule_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_CreateIngressRule_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_create_ingress_rule_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient",
- "shortName": "FirewallClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient.create_ingress_rule",
- "method": {
- "fullName": "google.appengine.v1.Firewall.CreateIngressRule",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "CreateIngressRule"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.CreateIngressRuleRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule",
- "shortName": "create_ingress_rule"
- },
- "description": "Sample for CreateIngressRule",
- "file": "appengine_v1_generated_firewall_create_ingress_rule_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_CreateIngressRule_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_create_ingress_rule_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient",
- "shortName": "FirewallAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient.delete_ingress_rule",
- "method": {
- "fullName": "google.appengine.v1.Firewall.DeleteIngressRule",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "DeleteIngressRule"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteIngressRuleRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "shortName": "delete_ingress_rule"
- },
- "description": "Sample for DeleteIngressRule",
- "file": "appengine_v1_generated_firewall_delete_ingress_rule_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_DeleteIngressRule_async",
- "segments": [
- {
- "end": 48,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 48,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 49,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_delete_ingress_rule_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient",
- "shortName": "FirewallClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient.delete_ingress_rule",
- "method": {
- "fullName": "google.appengine.v1.Firewall.DeleteIngressRule",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "DeleteIngressRule"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteIngressRuleRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "shortName": "delete_ingress_rule"
- },
- "description": "Sample for DeleteIngressRule",
- "file": "appengine_v1_generated_firewall_delete_ingress_rule_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_DeleteIngressRule_sync",
- "segments": [
- {
- "end": 48,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 48,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 49,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_delete_ingress_rule_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient",
- "shortName": "FirewallAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient.get_ingress_rule",
- "method": {
- "fullName": "google.appengine.v1.Firewall.GetIngressRule",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "GetIngressRule"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetIngressRuleRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule",
- "shortName": "get_ingress_rule"
- },
- "description": "Sample for GetIngressRule",
- "file": "appengine_v1_generated_firewall_get_ingress_rule_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_GetIngressRule_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_get_ingress_rule_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient",
- "shortName": "FirewallClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient.get_ingress_rule",
- "method": {
- "fullName": "google.appengine.v1.Firewall.GetIngressRule",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "GetIngressRule"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetIngressRuleRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule",
- "shortName": "get_ingress_rule"
- },
- "description": "Sample for GetIngressRule",
- "file": "appengine_v1_generated_firewall_get_ingress_rule_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_GetIngressRule_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_get_ingress_rule_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient",
- "shortName": "FirewallAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient.list_ingress_rules",
- "method": {
- "fullName": "google.appengine.v1.Firewall.ListIngressRules",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "ListIngressRules"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListIngressRulesRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.firewall.pagers.ListIngressRulesAsyncPager",
- "shortName": "list_ingress_rules"
- },
- "description": "Sample for ListIngressRules",
- "file": "appengine_v1_generated_firewall_list_ingress_rules_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_ListIngressRules_async",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_list_ingress_rules_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient",
- "shortName": "FirewallClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient.list_ingress_rules",
- "method": {
- "fullName": "google.appengine.v1.Firewall.ListIngressRules",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "ListIngressRules"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListIngressRulesRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.firewall.pagers.ListIngressRulesPager",
- "shortName": "list_ingress_rules"
- },
- "description": "Sample for ListIngressRules",
- "file": "appengine_v1_generated_firewall_list_ingress_rules_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_ListIngressRules_sync",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_list_ingress_rules_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient",
- "shortName": "FirewallAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallAsyncClient.update_ingress_rule",
- "method": {
- "fullName": "google.appengine.v1.Firewall.UpdateIngressRule",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "UpdateIngressRule"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateIngressRuleRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule",
- "shortName": "update_ingress_rule"
- },
- "description": "Sample for UpdateIngressRule",
- "file": "appengine_v1_generated_firewall_update_ingress_rule_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_UpdateIngressRule_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_update_ingress_rule_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient",
- "shortName": "FirewallClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.FirewallClient.update_ingress_rule",
- "method": {
- "fullName": "google.appengine.v1.Firewall.UpdateIngressRule",
- "service": {
- "fullName": "google.appengine.v1.Firewall",
- "shortName": "Firewall"
- },
- "shortName": "UpdateIngressRule"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateIngressRuleRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule",
- "shortName": "update_ingress_rule"
- },
- "description": "Sample for UpdateIngressRule",
- "file": "appengine_v1_generated_firewall_update_ingress_rule_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Firewall_UpdateIngressRule_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_firewall_update_ingress_rule_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.InstancesAsyncClient",
- "shortName": "InstancesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.InstancesAsyncClient.debug_instance",
- "method": {
- "fullName": "google.appengine.v1.Instances.DebugInstance",
- "service": {
- "fullName": "google.appengine.v1.Instances",
- "shortName": "Instances"
- },
- "shortName": "DebugInstance"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DebugInstanceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "debug_instance"
- },
- "description": "Sample for DebugInstance",
- "file": "appengine_v1_generated_instances_debug_instance_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Instances_DebugInstance_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_instances_debug_instance_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.InstancesClient",
- "shortName": "InstancesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.InstancesClient.debug_instance",
- "method": {
- "fullName": "google.appengine.v1.Instances.DebugInstance",
- "service": {
- "fullName": "google.appengine.v1.Instances",
- "shortName": "Instances"
- },
- "shortName": "DebugInstance"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DebugInstanceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "debug_instance"
- },
- "description": "Sample for DebugInstance",
- "file": "appengine_v1_generated_instances_debug_instance_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Instances_DebugInstance_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_instances_debug_instance_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.InstancesAsyncClient",
- "shortName": "InstancesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.InstancesAsyncClient.delete_instance",
- "method": {
- "fullName": "google.appengine.v1.Instances.DeleteInstance",
- "service": {
- "fullName": "google.appengine.v1.Instances",
- "shortName": "Instances"
- },
- "shortName": "DeleteInstance"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteInstanceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "delete_instance"
- },
- "description": "Sample for DeleteInstance",
- "file": "appengine_v1_generated_instances_delete_instance_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Instances_DeleteInstance_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_instances_delete_instance_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.InstancesClient",
- "shortName": "InstancesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.InstancesClient.delete_instance",
- "method": {
- "fullName": "google.appengine.v1.Instances.DeleteInstance",
- "service": {
- "fullName": "google.appengine.v1.Instances",
- "shortName": "Instances"
- },
- "shortName": "DeleteInstance"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteInstanceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "delete_instance"
- },
- "description": "Sample for DeleteInstance",
- "file": "appengine_v1_generated_instances_delete_instance_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Instances_DeleteInstance_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_instances_delete_instance_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.InstancesAsyncClient",
- "shortName": "InstancesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.InstancesAsyncClient.get_instance",
- "method": {
- "fullName": "google.appengine.v1.Instances.GetInstance",
- "service": {
- "fullName": "google.appengine.v1.Instances",
- "shortName": "Instances"
- },
- "shortName": "GetInstance"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetInstanceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.Instance",
- "shortName": "get_instance"
- },
- "description": "Sample for GetInstance",
- "file": "appengine_v1_generated_instances_get_instance_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Instances_GetInstance_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_instances_get_instance_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.InstancesClient",
- "shortName": "InstancesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.InstancesClient.get_instance",
- "method": {
- "fullName": "google.appengine.v1.Instances.GetInstance",
- "service": {
- "fullName": "google.appengine.v1.Instances",
- "shortName": "Instances"
- },
- "shortName": "GetInstance"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetInstanceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.Instance",
- "shortName": "get_instance"
- },
- "description": "Sample for GetInstance",
- "file": "appengine_v1_generated_instances_get_instance_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Instances_GetInstance_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_instances_get_instance_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.InstancesAsyncClient",
- "shortName": "InstancesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.InstancesAsyncClient.list_instances",
- "method": {
- "fullName": "google.appengine.v1.Instances.ListInstances",
- "service": {
- "fullName": "google.appengine.v1.Instances",
- "shortName": "Instances"
- },
- "shortName": "ListInstances"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListInstancesRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.instances.pagers.ListInstancesAsyncPager",
- "shortName": "list_instances"
- },
- "description": "Sample for ListInstances",
- "file": "appengine_v1_generated_instances_list_instances_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Instances_ListInstances_async",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_instances_list_instances_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.InstancesClient",
- "shortName": "InstancesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.InstancesClient.list_instances",
- "method": {
- "fullName": "google.appengine.v1.Instances.ListInstances",
- "service": {
- "fullName": "google.appengine.v1.Instances",
- "shortName": "Instances"
- },
- "shortName": "ListInstances"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListInstancesRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.instances.pagers.ListInstancesPager",
- "shortName": "list_instances"
- },
- "description": "Sample for ListInstances",
- "file": "appengine_v1_generated_instances_list_instances_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Instances_ListInstances_sync",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_instances_list_instances_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ServicesAsyncClient",
- "shortName": "ServicesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ServicesAsyncClient.delete_service",
- "method": {
- "fullName": "google.appengine.v1.Services.DeleteService",
- "service": {
- "fullName": "google.appengine.v1.Services",
- "shortName": "Services"
- },
- "shortName": "DeleteService"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteServiceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "delete_service"
- },
- "description": "Sample for DeleteService",
- "file": "appengine_v1_generated_services_delete_service_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Services_DeleteService_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_services_delete_service_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ServicesClient",
- "shortName": "ServicesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ServicesClient.delete_service",
- "method": {
- "fullName": "google.appengine.v1.Services.DeleteService",
- "service": {
- "fullName": "google.appengine.v1.Services",
- "shortName": "Services"
- },
- "shortName": "DeleteService"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteServiceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "delete_service"
- },
- "description": "Sample for DeleteService",
- "file": "appengine_v1_generated_services_delete_service_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Services_DeleteService_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_services_delete_service_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ServicesAsyncClient",
- "shortName": "ServicesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ServicesAsyncClient.get_service",
- "method": {
- "fullName": "google.appengine.v1.Services.GetService",
- "service": {
- "fullName": "google.appengine.v1.Services",
- "shortName": "Services"
- },
- "shortName": "GetService"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetServiceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.Service",
- "shortName": "get_service"
- },
- "description": "Sample for GetService",
- "file": "appengine_v1_generated_services_get_service_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Services_GetService_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_services_get_service_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ServicesClient",
- "shortName": "ServicesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ServicesClient.get_service",
- "method": {
- "fullName": "google.appengine.v1.Services.GetService",
- "service": {
- "fullName": "google.appengine.v1.Services",
- "shortName": "Services"
- },
- "shortName": "GetService"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetServiceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.Service",
- "shortName": "get_service"
- },
- "description": "Sample for GetService",
- "file": "appengine_v1_generated_services_get_service_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Services_GetService_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_services_get_service_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ServicesAsyncClient",
- "shortName": "ServicesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ServicesAsyncClient.list_services",
- "method": {
- "fullName": "google.appengine.v1.Services.ListServices",
- "service": {
- "fullName": "google.appengine.v1.Services",
- "shortName": "Services"
- },
- "shortName": "ListServices"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListServicesRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.services.pagers.ListServicesAsyncPager",
- "shortName": "list_services"
- },
- "description": "Sample for ListServices",
- "file": "appengine_v1_generated_services_list_services_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Services_ListServices_async",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_services_list_services_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ServicesClient",
- "shortName": "ServicesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ServicesClient.list_services",
- "method": {
- "fullName": "google.appengine.v1.Services.ListServices",
- "service": {
- "fullName": "google.appengine.v1.Services",
- "shortName": "Services"
- },
- "shortName": "ListServices"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListServicesRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.services.pagers.ListServicesPager",
- "shortName": "list_services"
- },
- "description": "Sample for ListServices",
- "file": "appengine_v1_generated_services_list_services_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Services_ListServices_sync",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_services_list_services_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ServicesAsyncClient",
- "shortName": "ServicesAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ServicesAsyncClient.update_service",
- "method": {
- "fullName": "google.appengine.v1.Services.UpdateService",
- "service": {
- "fullName": "google.appengine.v1.Services",
- "shortName": "Services"
- },
- "shortName": "UpdateService"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateServiceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "update_service"
- },
- "description": "Sample for UpdateService",
- "file": "appengine_v1_generated_services_update_service_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Services_UpdateService_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_services_update_service_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.ServicesClient",
- "shortName": "ServicesClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.ServicesClient.update_service",
- "method": {
- "fullName": "google.appengine.v1.Services.UpdateService",
- "service": {
- "fullName": "google.appengine.v1.Services",
- "shortName": "Services"
- },
- "shortName": "UpdateService"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateServiceRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "update_service"
- },
- "description": "Sample for UpdateService",
- "file": "appengine_v1_generated_services_update_service_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Services_UpdateService_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_services_update_service_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.VersionsAsyncClient",
- "shortName": "VersionsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.VersionsAsyncClient.create_version",
- "method": {
- "fullName": "google.appengine.v1.Versions.CreateVersion",
- "service": {
- "fullName": "google.appengine.v1.Versions",
- "shortName": "Versions"
- },
- "shortName": "CreateVersion"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.CreateVersionRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "create_version"
- },
- "description": "Sample for CreateVersion",
- "file": "appengine_v1_generated_versions_create_version_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Versions_CreateVersion_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_versions_create_version_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.VersionsClient",
- "shortName": "VersionsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.VersionsClient.create_version",
- "method": {
- "fullName": "google.appengine.v1.Versions.CreateVersion",
- "service": {
- "fullName": "google.appengine.v1.Versions",
- "shortName": "Versions"
- },
- "shortName": "CreateVersion"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.CreateVersionRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "create_version"
- },
- "description": "Sample for CreateVersion",
- "file": "appengine_v1_generated_versions_create_version_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Versions_CreateVersion_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_versions_create_version_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.VersionsAsyncClient",
- "shortName": "VersionsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.VersionsAsyncClient.delete_version",
- "method": {
- "fullName": "google.appengine.v1.Versions.DeleteVersion",
- "service": {
- "fullName": "google.appengine.v1.Versions",
- "shortName": "Versions"
- },
- "shortName": "DeleteVersion"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteVersionRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "delete_version"
- },
- "description": "Sample for DeleteVersion",
- "file": "appengine_v1_generated_versions_delete_version_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Versions_DeleteVersion_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_versions_delete_version_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.VersionsClient",
- "shortName": "VersionsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.VersionsClient.delete_version",
- "method": {
- "fullName": "google.appengine.v1.Versions.DeleteVersion",
- "service": {
- "fullName": "google.appengine.v1.Versions",
- "shortName": "Versions"
- },
- "shortName": "DeleteVersion"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.DeleteVersionRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "delete_version"
- },
- "description": "Sample for DeleteVersion",
- "file": "appengine_v1_generated_versions_delete_version_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Versions_DeleteVersion_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_versions_delete_version_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.VersionsAsyncClient",
- "shortName": "VersionsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.VersionsAsyncClient.get_version",
- "method": {
- "fullName": "google.appengine.v1.Versions.GetVersion",
- "service": {
- "fullName": "google.appengine.v1.Versions",
- "shortName": "Versions"
- },
- "shortName": "GetVersion"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetVersionRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.Version",
- "shortName": "get_version"
- },
- "description": "Sample for GetVersion",
- "file": "appengine_v1_generated_versions_get_version_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Versions_GetVersion_async",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_versions_get_version_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.VersionsClient",
- "shortName": "VersionsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.VersionsClient.get_version",
- "method": {
- "fullName": "google.appengine.v1.Versions.GetVersion",
- "service": {
- "fullName": "google.appengine.v1.Versions",
- "shortName": "Versions"
- },
- "shortName": "GetVersion"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.GetVersionRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.types.Version",
- "shortName": "get_version"
- },
- "description": "Sample for GetVersion",
- "file": "appengine_v1_generated_versions_get_version_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Versions_GetVersion_sync",
- "segments": [
- {
- "end": 50,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 50,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 51,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_versions_get_version_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.VersionsAsyncClient",
- "shortName": "VersionsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.VersionsAsyncClient.list_versions",
- "method": {
- "fullName": "google.appengine.v1.Versions.ListVersions",
- "service": {
- "fullName": "google.appengine.v1.Versions",
- "shortName": "Versions"
- },
- "shortName": "ListVersions"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListVersionsRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.versions.pagers.ListVersionsAsyncPager",
- "shortName": "list_versions"
- },
- "description": "Sample for ListVersions",
- "file": "appengine_v1_generated_versions_list_versions_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Versions_ListVersions_async",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_versions_list_versions_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.VersionsClient",
- "shortName": "VersionsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.VersionsClient.list_versions",
- "method": {
- "fullName": "google.appengine.v1.Versions.ListVersions",
- "service": {
- "fullName": "google.appengine.v1.Versions",
- "shortName": "Versions"
- },
- "shortName": "ListVersions"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.ListVersionsRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.cloud.appengine_admin_v1.services.versions.pagers.ListVersionsPager",
- "shortName": "list_versions"
- },
- "description": "Sample for ListVersions",
- "file": "appengine_v1_generated_versions_list_versions_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Versions_ListVersions_sync",
- "segments": [
- {
- "end": 51,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 51,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 47,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 52,
- "start": 48,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_versions_list_versions_sync.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "async": true,
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.VersionsAsyncClient",
- "shortName": "VersionsAsyncClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.VersionsAsyncClient.update_version",
- "method": {
- "fullName": "google.appengine.v1.Versions.UpdateVersion",
- "service": {
- "fullName": "google.appengine.v1.Versions",
- "shortName": "Versions"
- },
- "shortName": "UpdateVersion"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateVersionRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation_async.AsyncOperation",
- "shortName": "update_version"
- },
- "description": "Sample for UpdateVersion",
- "file": "appengine_v1_generated_versions_update_version_async.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Versions_UpdateVersion_async",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_versions_update_version_async.py"
- },
- {
- "canonical": true,
- "clientMethod": {
- "client": {
- "fullName": "google.cloud.appengine_admin_v1.VersionsClient",
- "shortName": "VersionsClient"
- },
- "fullName": "google.cloud.appengine_admin_v1.VersionsClient.update_version",
- "method": {
- "fullName": "google.appengine.v1.Versions.UpdateVersion",
- "service": {
- "fullName": "google.appengine.v1.Versions",
- "shortName": "Versions"
- },
- "shortName": "UpdateVersion"
- },
- "parameters": [
- {
- "name": "request",
- "type": "google.cloud.appengine_admin_v1.types.UpdateVersionRequest"
- },
- {
- "name": "retry",
- "type": "google.api_core.retry.Retry"
- },
- {
- "name": "timeout",
- "type": "float"
- },
- {
- "name": "metadata",
- "type": "Sequence[Tuple[str, str]"
- }
- ],
- "resultType": "google.api_core.operation.Operation",
- "shortName": "update_version"
- },
- "description": "Sample for UpdateVersion",
- "file": "appengine_v1_generated_versions_update_version_sync.py",
- "language": "PYTHON",
- "origin": "API_DEFINITION",
- "regionTag": "appengine_v1_generated_Versions_UpdateVersion_sync",
- "segments": [
- {
- "end": 54,
- "start": 27,
- "type": "FULL"
- },
- {
- "end": 54,
- "start": 27,
- "type": "SHORT"
- },
- {
- "end": 40,
- "start": 38,
- "type": "CLIENT_INITIALIZATION"
- },
- {
- "end": 44,
- "start": 41,
- "type": "REQUEST_INITIALIZATION"
- },
- {
- "end": 51,
- "start": 45,
- "type": "REQUEST_EXECUTION"
- },
- {
- "end": 55,
- "start": 52,
- "type": "RESPONSE_HANDLING"
- }
- ],
- "title": "appengine_v1_generated_versions_update_version_sync.py"
- }
- ]
-}
diff --git a/scripts/decrypt-secrets.sh b/scripts/decrypt-secrets.sh
deleted file mode 100755
index 0018b42..0000000
--- a/scripts/decrypt-secrets.sh
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/bash
-
-# Copyright 2023 Google LLC All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-ROOT=$( dirname "$DIR" )
-
-# Work from the project root.
-cd $ROOT
-
-# Prevent it from overriding files.
-# We recommend that sample authors use their own service account files and cloud project.
-# In that case, they are supposed to prepare these files by themselves.
-if [[ -f "testing/test-env.sh" ]] || \
- [[ -f "testing/service-account.json" ]] || \
- [[ -f "testing/client-secrets.json" ]]; then
- echo "One or more target files exist, aborting."
- exit 1
-fi
-
-# Use SECRET_MANAGER_PROJECT if set, fallback to cloud-devrel-kokoro-resources.
-PROJECT_ID="${SECRET_MANAGER_PROJECT:-cloud-devrel-kokoro-resources}"
-
-gcloud secrets versions access latest --secret="python-docs-samples-test-env" \
- --project="${PROJECT_ID}" \
- > testing/test-env.sh
-gcloud secrets versions access latest \
- --secret="python-docs-samples-service-account" \
- --project="${PROJECT_ID}" \
- > testing/service-account.json
-gcloud secrets versions access latest \
- --secret="python-docs-samples-client-secrets" \
- --project="${PROJECT_ID}" \
- > testing/client-secrets.json
diff --git a/scripts/fixup_appengine_admin_v1_keywords.py b/scripts/fixup_appengine_admin_v1_keywords.py
deleted file mode 100644
index afd7802..0000000
--- a/scripts/fixup_appengine_admin_v1_keywords.py
+++ /dev/null
@@ -1,209 +0,0 @@
-#! /usr/bin/env python3
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import argparse
-import os
-import libcst as cst
-import pathlib
-import sys
-from typing import (Any, Callable, Dict, List, Sequence, Tuple)
-
-
-def partition(
- predicate: Callable[[Any], bool],
- iterator: Sequence[Any]
-) -> Tuple[List[Any], List[Any]]:
- """A stable, out-of-place partition."""
- results = ([], [])
-
- for i in iterator:
- results[int(predicate(i))].append(i)
-
- # Returns trueList, falseList
- return results[1], results[0]
-
-
-class appengine_adminCallTransformer(cst.CSTTransformer):
- CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
- METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
- 'batch_update_ingress_rules': ('name', 'ingress_rules', ),
- 'create_application': ('application', ),
- 'create_authorized_certificate': ('parent', 'certificate', ),
- 'create_domain_mapping': ('parent', 'domain_mapping', 'override_strategy', ),
- 'create_ingress_rule': ('parent', 'rule', ),
- 'create_version': ('parent', 'version', ),
- 'debug_instance': ('name', 'ssh_key', ),
- 'delete_authorized_certificate': ('name', ),
- 'delete_domain_mapping': ('name', ),
- 'delete_ingress_rule': ('name', ),
- 'delete_instance': ('name', ),
- 'delete_service': ('name', ),
- 'delete_version': ('name', ),
- 'get_application': ('name', ),
- 'get_authorized_certificate': ('name', 'view', ),
- 'get_domain_mapping': ('name', ),
- 'get_ingress_rule': ('name', ),
- 'get_instance': ('name', ),
- 'get_service': ('name', ),
- 'get_version': ('name', 'view', ),
- 'list_authorized_certificates': ('parent', 'view', 'page_size', 'page_token', ),
- 'list_authorized_domains': ('parent', 'page_size', 'page_token', ),
- 'list_domain_mappings': ('parent', 'page_size', 'page_token', ),
- 'list_ingress_rules': ('parent', 'page_size', 'page_token', 'matching_address', ),
- 'list_instances': ('parent', 'page_size', 'page_token', ),
- 'list_services': ('parent', 'page_size', 'page_token', ),
- 'list_versions': ('parent', 'view', 'page_size', 'page_token', ),
- 'repair_application': ('name', ),
- 'update_application': ('name', 'application', 'update_mask', ),
- 'update_authorized_certificate': ('name', 'certificate', 'update_mask', ),
- 'update_domain_mapping': ('name', 'domain_mapping', 'update_mask', ),
- 'update_ingress_rule': ('name', 'rule', 'update_mask', ),
- 'update_service': ('name', 'service', 'update_mask', 'migrate_traffic', ),
- 'update_version': ('name', 'version', 'update_mask', ),
- }
-
- def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
- try:
- key = original.func.attr.value
- kword_params = self.METHOD_TO_PARAMS[key]
- except (AttributeError, KeyError):
- # Either not a method from the API or too convoluted to be sure.
- return updated
-
- # If the existing code is valid, keyword args come after positional args.
- # Therefore, all positional args must map to the first parameters.
- args, kwargs = partition(lambda a: not bool(a.keyword), updated.args)
- if any(k.keyword.value == "request" for k in kwargs):
- # We've already fixed this file, don't fix it again.
- return updated
-
- kwargs, ctrl_kwargs = partition(
- lambda a: a.keyword.value not in self.CTRL_PARAMS,
- kwargs
- )
-
- args, ctrl_args = args[:len(kword_params)], args[len(kword_params):]
- ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl))
- for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS))
-
- request_arg = cst.Arg(
- value=cst.Dict([
- cst.DictElement(
- cst.SimpleString("'{}'".format(name)),
-cst.Element(value=arg.value)
- )
- # Note: the args + kwargs looks silly, but keep in mind that
- # the control parameters had to be stripped out, and that
- # those could have been passed positionally or by keyword.
- for name, arg in zip(kword_params, args + kwargs)]),
- keyword=cst.Name("request")
- )
-
- return updated.with_changes(
- args=[request_arg] + ctrl_kwargs
- )
-
-
-def fix_files(
- in_dir: pathlib.Path,
- out_dir: pathlib.Path,
- *,
- transformer=appengine_adminCallTransformer(),
-):
- """Duplicate the input dir to the output dir, fixing file method calls.
-
- Preconditions:
- * in_dir is a real directory
- * out_dir is a real, empty directory
- """
- pyfile_gen = (
- pathlib.Path(os.path.join(root, f))
- for root, _, files in os.walk(in_dir)
- for f in files if os.path.splitext(f)[1] == ".py"
- )
-
- for fpath in pyfile_gen:
- with open(fpath, 'r') as f:
- src = f.read()
-
- # Parse the code and insert method call fixes.
- tree = cst.parse_module(src)
- updated = tree.visit(transformer)
-
- # Create the path and directory structure for the new file.
- updated_path = out_dir.joinpath(fpath.relative_to(in_dir))
- updated_path.parent.mkdir(parents=True, exist_ok=True)
-
- # Generate the updated source file at the corresponding path.
- with open(updated_path, 'w') as f:
- f.write(updated.code)
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(
- description="""Fix up source that uses the appengine_admin client library.
-
-The existing sources are NOT overwritten but are copied to output_dir with changes made.
-
-Note: This tool operates at a best-effort level at converting positional
- parameters in client method calls to keyword based parameters.
- Cases where it WILL FAIL include
- A) * or ** expansion in a method call.
- B) Calls via function or method alias (includes free function calls)
- C) Indirect or dispatched calls (e.g. the method is looked up dynamically)
-
- These all constitute false negatives. The tool will also detect false
- positives when an API method shares a name with another method.
-""")
- parser.add_argument(
- '-d',
- '--input-directory',
- required=True,
- dest='input_dir',
- help='the input directory to walk for python files to fix up',
- )
- parser.add_argument(
- '-o',
- '--output-directory',
- required=True,
- dest='output_dir',
- help='the directory to output files fixed via un-flattening',
- )
- args = parser.parse_args()
- input_dir = pathlib.Path(args.input_dir)
- output_dir = pathlib.Path(args.output_dir)
- if not input_dir.is_dir():
- print(
- f"input directory '{input_dir}' does not exist or is not a directory",
- file=sys.stderr,
- )
- sys.exit(-1)
-
- if not output_dir.is_dir():
- print(
- f"output directory '{output_dir}' does not exist or is not a directory",
- file=sys.stderr,
- )
- sys.exit(-1)
-
- if os.listdir(output_dir):
- print(
- f"output directory '{output_dir}' is not empty",
- file=sys.stderr,
- )
- sys.exit(-1)
-
- fix_files(input_dir, output_dir)
diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py
deleted file mode 100644
index 1acc119..0000000
--- a/scripts/readme-gen/readme_gen.py
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Generates READMEs using configuration defined in yaml."""
-
-import argparse
-import io
-import os
-import subprocess
-
-import jinja2
-import yaml
-
-
-jinja_env = jinja2.Environment(
- trim_blocks=True,
- loader=jinja2.FileSystemLoader(
- os.path.abspath(os.path.join(os.path.dirname(__file__), "templates"))
- ),
- autoescape=True,
-)
-
-README_TMPL = jinja_env.get_template("README.tmpl.rst")
-
-
-def get_help(file):
- return subprocess.check_output(["python", file, "--help"]).decode()
-
-
-def main():
- parser = argparse.ArgumentParser()
- parser.add_argument("source")
- parser.add_argument("--destination", default="README.rst")
-
- args = parser.parse_args()
-
- source = os.path.abspath(args.source)
- root = os.path.dirname(source)
- destination = os.path.join(root, args.destination)
-
- jinja_env.globals["get_help"] = get_help
-
- with io.open(source, "r") as f:
- config = yaml.load(f)
-
- # This allows get_help to execute in the right directory.
- os.chdir(root)
-
- output = README_TMPL.render(config)
-
- with io.open(destination, "w") as f:
- f.write(output)
-
-
-if __name__ == "__main__":
- main()
diff --git a/scripts/readme-gen/templates/README.tmpl.rst b/scripts/readme-gen/templates/README.tmpl.rst
deleted file mode 100644
index 4fd2397..0000000
--- a/scripts/readme-gen/templates/README.tmpl.rst
+++ /dev/null
@@ -1,87 +0,0 @@
-{# The following line is a lie. BUT! Once jinja2 is done with it, it will
- become truth! #}
-.. This file is automatically generated. Do not edit this file directly.
-
-{{product.name}} Python Samples
-===============================================================================
-
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor={{folder}}/README.rst
-
-
-This directory contains samples for {{product.name}}. {{product.description}}
-
-{{description}}
-
-.. _{{product.name}}: {{product.url}}
-
-{% if required_api_url %}
-To run the sample, you need to enable the API at: {{required_api_url}}
-{% endif %}
-
-{% if required_role %}
-To run the sample, you need to have `{{required_role}}` role.
-{% endif %}
-
-{{other_required_steps}}
-
-{% if setup %}
-Setup
--------------------------------------------------------------------------------
-
-{% for section in setup %}
-
-{% include section + '.tmpl.rst' %}
-
-{% endfor %}
-{% endif %}
-
-{% if samples %}
-Samples
--------------------------------------------------------------------------------
-
-{% for sample in samples %}
-{{sample.name}}
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-{% if not sample.hide_cloudshell_button %}
-.. image:: https://gstatic.com/cloudssh/images/open-btn.png
- :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor={{folder}}/{{sample.file}},{{folder}}/README.rst
-{% endif %}
-
-
-{{sample.description}}
-
-To run this sample:
-
-.. code-block:: bash
-
- $ python {{sample.file}}
-{% if sample.show_help %}
-
- {{get_help(sample.file)|indent}}
-{% endif %}
-
-
-{% endfor %}
-{% endif %}
-
-{% if cloud_client_library %}
-
-The client library
--------------------------------------------------------------------------------
-
-This sample uses the `Google Cloud Client Library for Python`_.
-You can read the documentation for more details on API usage and use GitHub
-to `browse the source`_ and `report issues`_.
-
-.. _Google Cloud Client Library for Python:
- https://googlecloudplatform.github.io/google-cloud-python/
-.. _browse the source:
- https://github.com/GoogleCloudPlatform/google-cloud-python
-.. _report issues:
- https://github.com/GoogleCloudPlatform/google-cloud-python/issues
-
-{% endif %}
-
-.. _Google Cloud SDK: https://cloud.google.com/sdk/
\ No newline at end of file
diff --git a/scripts/readme-gen/templates/auth.tmpl.rst b/scripts/readme-gen/templates/auth.tmpl.rst
deleted file mode 100644
index 1446b94..0000000
--- a/scripts/readme-gen/templates/auth.tmpl.rst
+++ /dev/null
@@ -1,9 +0,0 @@
-Authentication
-++++++++++++++
-
-This sample requires you to have authentication setup. Refer to the
-`Authentication Getting Started Guide`_ for instructions on setting up
-credentials for applications.
-
-.. _Authentication Getting Started Guide:
- https://cloud.google.com/docs/authentication/getting-started
diff --git a/scripts/readme-gen/templates/auth_api_key.tmpl.rst b/scripts/readme-gen/templates/auth_api_key.tmpl.rst
deleted file mode 100644
index 11957ce..0000000
--- a/scripts/readme-gen/templates/auth_api_key.tmpl.rst
+++ /dev/null
@@ -1,14 +0,0 @@
-Authentication
-++++++++++++++
-
-Authentication for this service is done via an `API Key`_. To obtain an API
-Key:
-
-1. Open the `Cloud Platform Console`_
-2. Make sure that billing is enabled for your project.
-3. From the **Credentials** page, create a new **API Key** or use an existing
- one for your project.
-
-.. _API Key:
- https://developers.google.com/api-client-library/python/guide/aaa_apikeys
-.. _Cloud Console: https://console.cloud.google.com/project?_
diff --git a/scripts/readme-gen/templates/install_deps.tmpl.rst b/scripts/readme-gen/templates/install_deps.tmpl.rst
deleted file mode 100644
index 6f069c6..0000000
--- a/scripts/readme-gen/templates/install_deps.tmpl.rst
+++ /dev/null
@@ -1,29 +0,0 @@
-Install Dependencies
-++++++++++++++++++++
-
-#. Clone python-docs-samples and change directory to the sample directory you want to use.
-
- .. code-block:: bash
-
- $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
-
-#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.
-
- .. _Python Development Environment Setup Guide:
- https://cloud.google.com/python/setup
-
-#. Create a virtualenv. Samples are compatible with Python 3.7+.
-
- .. code-block:: bash
-
- $ virtualenv env
- $ source env/bin/activate
-
-#. Install the dependencies needed to run the samples.
-
- .. code-block:: bash
-
- $ pip install -r requirements.txt
-
-.. _pip: https://pip.pypa.io/
-.. _virtualenv: https://virtualenv.pypa.io/
diff --git a/scripts/readme-gen/templates/install_portaudio.tmpl.rst b/scripts/readme-gen/templates/install_portaudio.tmpl.rst
deleted file mode 100644
index 5ea33d1..0000000
--- a/scripts/readme-gen/templates/install_portaudio.tmpl.rst
+++ /dev/null
@@ -1,35 +0,0 @@
-Install PortAudio
-+++++++++++++++++
-
-Install `PortAudio`_. This is required by the `PyAudio`_ library to stream
-audio from your computer's microphone. PyAudio depends on PortAudio for cross-platform compatibility, and is installed differently depending on the
-platform.
-
-* For Mac OS X, you can use `Homebrew`_::
-
- brew install portaudio
-
- **Note**: if you encounter an error when running `pip install` that indicates
- it can't find `portaudio.h`, try running `pip install` with the following
- flags::
-
- pip install --global-option='build_ext' \
- --global-option='-I/usr/local/include' \
- --global-option='-L/usr/local/lib' \
- pyaudio
-
-* For Debian / Ubuntu Linux::
-
- apt-get install portaudio19-dev python-all-dev
-
-* Windows may work without having to install PortAudio explicitly (it will get
- installed with PyAudio).
-
-For more details, see the `PyAudio installation`_ page.
-
-
-.. _PyAudio: https://people.csail.mit.edu/hubert/pyaudio/
-.. _PortAudio: http://www.portaudio.com/
-.. _PyAudio installation:
- https://people.csail.mit.edu/hubert/pyaudio/#downloads
-.. _Homebrew: http://brew.sh
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 0523500..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Generated by synthtool. DO NOT EDIT!
-[bdist_wheel]
-universal = 1
diff --git a/setup.py b/setup.py
deleted file mode 100644
index 7c98d2b..0000000
--- a/setup.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import io
-import os
-
-import setuptools # type: ignore
-
-package_root = os.path.abspath(os.path.dirname(__file__))
-
-name = "google-cloud-appengine-admin"
-
-
-description = "Google Cloud Appengine Admin API client library"
-
-version = {}
-with open(
- os.path.join(package_root, "google/cloud/appengine_admin/gapic_version.py")
-) as fp:
- exec(fp.read(), version)
-version = version["__version__"]
-
-if version[0] == "0":
- release_status = "Development Status :: 4 - Beta"
-else:
- release_status = "Development Status :: 5 - Production/Stable"
-
-dependencies = [
- "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*",
- "proto-plus >= 1.22.0, <2.0.0dev",
- "proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'",
- "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
-]
-url = "https://github.com/googleapis/python-appengine-admin"
-
-package_root = os.path.abspath(os.path.dirname(__file__))
-
-readme_filename = os.path.join(package_root, "README.rst")
-with io.open(readme_filename, encoding="utf-8") as readme_file:
- readme = readme_file.read()
-
-packages = [
- package
- for package in setuptools.PEP420PackageFinder.find()
- if package.startswith("google")
-]
-
-namespaces = ["google", "google.cloud"]
-
-setuptools.setup(
- name=name,
- version=version,
- description=description,
- long_description=readme,
- author="Google LLC",
- author_email="googleapis-packages@google.com",
- license="Apache 2.0",
- url=url,
- classifiers=[
- release_status,
- "Intended Audience :: Developers",
- "License :: OSI Approved :: Apache Software License",
- "Programming Language :: Python",
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.7",
- "Programming Language :: Python :: 3.8",
- "Programming Language :: Python :: 3.9",
- "Programming Language :: Python :: 3.10",
- "Programming Language :: Python :: 3.11",
- "Operating System :: OS Independent",
- "Topic :: Internet",
- ],
- platforms="Posix; MacOS X; Windows",
- packages=packages,
- python_requires=">=3.7",
- namespace_packages=namespaces,
- install_requires=dependencies,
- include_package_data=True,
- zip_safe=False,
-)
diff --git a/testing/.gitignore b/testing/.gitignore
deleted file mode 100644
index b05fbd6..0000000
--- a/testing/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-test-env.sh
-service-account.json
-client-secrets.json
\ No newline at end of file
diff --git a/testing/constraints-3.10.txt b/testing/constraints-3.10.txt
deleted file mode 100644
index ed7f9ae..0000000
--- a/testing/constraints-3.10.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-# This constraints file is required for unit tests.
-# List all library dependencies and extras in this file.
-google-api-core
-proto-plus
-protobuf
diff --git a/testing/constraints-3.11.txt b/testing/constraints-3.11.txt
deleted file mode 100644
index ed7f9ae..0000000
--- a/testing/constraints-3.11.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-# This constraints file is required for unit tests.
-# List all library dependencies and extras in this file.
-google-api-core
-proto-plus
-protobuf
diff --git a/testing/constraints-3.12.txt b/testing/constraints-3.12.txt
deleted file mode 100644
index ed7f9ae..0000000
--- a/testing/constraints-3.12.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-# This constraints file is required for unit tests.
-# List all library dependencies and extras in this file.
-google-api-core
-proto-plus
-protobuf
diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt
deleted file mode 100644
index 6c44adf..0000000
--- a/testing/constraints-3.7.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# This constraints file is used to check that lower bounds
-# are correct in setup.py
-# List all library dependencies and extras in this file.
-# Pin the version to the lower bound.
-# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev",
-# Then this file should have google-cloud-foo==1.14.0
-google-api-core==1.34.0
-proto-plus==1.22.0
-protobuf==3.19.5
diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt
deleted file mode 100644
index ed7f9ae..0000000
--- a/testing/constraints-3.8.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-# This constraints file is required for unit tests.
-# List all library dependencies and extras in this file.
-google-api-core
-proto-plus
-protobuf
diff --git a/testing/constraints-3.9.txt b/testing/constraints-3.9.txt
deleted file mode 100644
index ed7f9ae..0000000
--- a/testing/constraints-3.9.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- coding: utf-8 -*-
-# This constraints file is required for unit tests.
-# List all library dependencies and extras in this file.
-google-api-core
-proto-plus
-protobuf
diff --git a/tests/__init__.py b/tests/__init__.py
deleted file mode 100644
index 89a37dc..0000000
--- a/tests/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
deleted file mode 100644
index 89a37dc..0000000
--- a/tests/unit/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
diff --git a/tests/unit/gapic/__init__.py b/tests/unit/gapic/__init__.py
deleted file mode 100644
index 89a37dc..0000000
--- a/tests/unit/gapic/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
diff --git a/tests/unit/gapic/appengine_admin_v1/__init__.py b/tests/unit/gapic/appengine_admin_v1/__init__.py
deleted file mode 100644
index 89a37dc..0000000
--- a/tests/unit/gapic/appengine_admin_v1/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
diff --git a/tests/unit/gapic/appengine_admin_v1/test_applications.py b/tests/unit/gapic/appengine_admin_v1/test_applications.py
deleted file mode 100644
index e68ba7c..0000000
--- a/tests/unit/gapic/appengine_admin_v1/test_applications.py
+++ /dev/null
@@ -1,2950 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import os
-
-# try/except added for compatibility with python < 3.8
-try:
- from unittest import mock
- from unittest.mock import AsyncMock # pragma: NO COVER
-except ImportError: # pragma: NO COVER
- import mock
-
-from collections.abc import Iterable
-import json
-import math
-
-from google.api_core import (
- future,
- gapic_v1,
- grpc_helpers,
- grpc_helpers_async,
- operation,
- operations_v1,
- path_template,
-)
-from google.api_core import client_options
-from google.api_core import exceptions as core_exceptions
-from google.api_core import operation_async # type: ignore
-import google.auth
-from google.auth import credentials as ga_credentials
-from google.auth.exceptions import MutualTLSChannelError
-from google.longrunning import operations_pb2 # type: ignore
-from google.oauth2 import service_account
-from google.protobuf import duration_pb2 # type: ignore
-from google.protobuf import field_mask_pb2 # type: ignore
-from google.protobuf import json_format
-import grpc
-from grpc.experimental import aio
-from proto.marshal.rules import wrappers
-from proto.marshal.rules.dates import DurationRule, TimestampRule
-import pytest
-from requests import PreparedRequest, Request, Response
-from requests.sessions import Session
-
-from google.cloud.appengine_admin_v1.services.applications import (
- ApplicationsAsyncClient,
- ApplicationsClient,
- transports,
-)
-from google.cloud.appengine_admin_v1.types import appengine, application
-from google.cloud.appengine_admin_v1.types import operation as ga_operation
-
-
-def client_cert_source_callback():
- return b"cert bytes", b"key bytes"
-
-
-# If default endpoint is localhost, then default mtls endpoint will be the same.
-# This method modifies the default endpoint so the client can produce a different
-# mtls endpoint for endpoint testing purposes.
-def modify_default_endpoint(client):
- return (
- "foo.googleapis.com"
- if ("localhost" in client.DEFAULT_ENDPOINT)
- else client.DEFAULT_ENDPOINT
- )
-
-
-def test__get_default_mtls_endpoint():
- api_endpoint = "example.googleapis.com"
- api_mtls_endpoint = "example.mtls.googleapis.com"
- sandbox_endpoint = "example.sandbox.googleapis.com"
- sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
- non_googleapi = "api.example.com"
-
- assert ApplicationsClient._get_default_mtls_endpoint(None) is None
- assert (
- ApplicationsClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint
- )
- assert (
- ApplicationsClient._get_default_mtls_endpoint(api_mtls_endpoint)
- == api_mtls_endpoint
- )
- assert (
- ApplicationsClient._get_default_mtls_endpoint(sandbox_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- ApplicationsClient._get_default_mtls_endpoint(sandbox_mtls_endpoint)
- == sandbox_mtls_endpoint
- )
- assert ApplicationsClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (ApplicationsClient, "grpc"),
- (ApplicationsAsyncClient, "grpc_asyncio"),
- (ApplicationsClient, "rest"),
- ],
-)
-def test_applications_client_from_service_account_info(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_info"
- ) as factory:
- factory.return_value = creds
- info = {"valid": True}
- client = client_class.from_service_account_info(info, transport=transport_name)
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,transport_name",
- [
- (transports.ApplicationsGrpcTransport, "grpc"),
- (transports.ApplicationsGrpcAsyncIOTransport, "grpc_asyncio"),
- (transports.ApplicationsRestTransport, "rest"),
- ],
-)
-def test_applications_client_service_account_always_use_jwt(
- transport_class, transport_name
-):
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=True)
- use_jwt.assert_called_once_with(True)
-
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=False)
- use_jwt.assert_not_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (ApplicationsClient, "grpc"),
- (ApplicationsAsyncClient, "grpc_asyncio"),
- (ApplicationsClient, "rest"),
- ],
-)
-def test_applications_client_from_service_account_file(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_file"
- ) as factory:
- factory.return_value = creds
- client = client_class.from_service_account_file(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- client = client_class.from_service_account_json(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-def test_applications_client_get_transport_class():
- transport = ApplicationsClient.get_transport_class()
- available_transports = [
- transports.ApplicationsGrpcTransport,
- transports.ApplicationsRestTransport,
- ]
- assert transport in available_transports
-
- transport = ApplicationsClient.get_transport_class("grpc")
- assert transport == transports.ApplicationsGrpcTransport
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (ApplicationsClient, transports.ApplicationsGrpcTransport, "grpc"),
- (
- ApplicationsAsyncClient,
- transports.ApplicationsGrpcAsyncIOTransport,
- "grpc_asyncio",
- ),
- (ApplicationsClient, transports.ApplicationsRestTransport, "rest"),
- ],
-)
-@mock.patch.object(
- ApplicationsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ApplicationsClient)
-)
-@mock.patch.object(
- ApplicationsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(ApplicationsAsyncClient),
-)
-def test_applications_client_client_options(
- client_class, transport_class, transport_name
-):
- # Check that if channel is provided we won't create a new one.
- with mock.patch.object(ApplicationsClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
- client = client_class(transport=transport)
- gtc.assert_not_called()
-
- # Check that if channel is provided via str we will create a new one.
- with mock.patch.object(ApplicationsClient, "get_transport_class") as gtc:
- client = client_class(transport=transport_name)
- gtc.assert_called()
-
- # Check the case api_endpoint is provided.
- options = client_options.ClientOptions(api_endpoint="squid.clam.whelk")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name, client_options=options)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_MTLS_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
- # unsupported value.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
- with pytest.raises(MutualTLSChannelError):
- client = client_class(transport=transport_name)
-
- # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
- ):
- with pytest.raises(ValueError):
- client = client_class(transport=transport_name)
-
- # Check the case quota_project_id is provided
- options = client_options.ClientOptions(quota_project_id="octopus")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id="octopus",
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
- # Check the case api_endpoint is provided
- options = client_options.ClientOptions(
- api_audience="https://language.googleapis.com"
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience="https://language.googleapis.com",
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,use_client_cert_env",
- [
- (ApplicationsClient, transports.ApplicationsGrpcTransport, "grpc", "true"),
- (
- ApplicationsAsyncClient,
- transports.ApplicationsGrpcAsyncIOTransport,
- "grpc_asyncio",
- "true",
- ),
- (ApplicationsClient, transports.ApplicationsGrpcTransport, "grpc", "false"),
- (
- ApplicationsAsyncClient,
- transports.ApplicationsGrpcAsyncIOTransport,
- "grpc_asyncio",
- "false",
- ),
- (ApplicationsClient, transports.ApplicationsRestTransport, "rest", "true"),
- (ApplicationsClient, transports.ApplicationsRestTransport, "rest", "false"),
- ],
-)
-@mock.patch.object(
- ApplicationsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ApplicationsClient)
-)
-@mock.patch.object(
- ApplicationsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(ApplicationsAsyncClient),
-)
-@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"})
-def test_applications_client_mtls_env_auto(
- client_class, transport_class, transport_name, use_client_cert_env
-):
- # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default
- # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists.
-
- # Check the case client_cert_source is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- options = client_options.ClientOptions(
- client_cert_source=client_cert_source_callback
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
-
- if use_client_cert_env == "false":
- expected_client_cert_source = None
- expected_host = client.DEFAULT_ENDPOINT
- else:
- expected_client_cert_source = client_cert_source_callback
- expected_host = client.DEFAULT_MTLS_ENDPOINT
-
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case ADC client cert is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=client_cert_source_callback,
- ):
- if use_client_cert_env == "false":
- expected_host = client.DEFAULT_ENDPOINT
- expected_client_cert_source = None
- else:
- expected_host = client.DEFAULT_MTLS_ENDPOINT
- expected_client_cert_source = client_cert_source_callback
-
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case client_cert_source and ADC client cert are not provided.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize("client_class", [ApplicationsClient, ApplicationsAsyncClient])
-@mock.patch.object(
- ApplicationsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ApplicationsClient)
-)
-@mock.patch.object(
- ApplicationsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(ApplicationsAsyncClient),
-)
-def test_applications_client_get_mtls_endpoint_and_cert_source(client_class):
- mock_client_cert_source = mock.Mock()
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source == mock_client_cert_source
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
- mock_client_cert_source = mock.Mock()
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=mock_client_cert_source,
- ):
- (
- api_endpoint,
- cert_source,
- ) = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source == mock_client_cert_source
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (ApplicationsClient, transports.ApplicationsGrpcTransport, "grpc"),
- (
- ApplicationsAsyncClient,
- transports.ApplicationsGrpcAsyncIOTransport,
- "grpc_asyncio",
- ),
- (ApplicationsClient, transports.ApplicationsRestTransport, "rest"),
- ],
-)
-def test_applications_client_client_options_scopes(
- client_class, transport_class, transport_name
-):
- # Check the case scopes are provided.
- options = client_options.ClientOptions(
- scopes=["1", "2"],
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=["1", "2"],
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (
- ApplicationsClient,
- transports.ApplicationsGrpcTransport,
- "grpc",
- grpc_helpers,
- ),
- (
- ApplicationsAsyncClient,
- transports.ApplicationsGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- (ApplicationsClient, transports.ApplicationsRestTransport, "rest", None),
- ],
-)
-def test_applications_client_client_options_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-def test_applications_client_client_options_from_dict():
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.applications.transports.ApplicationsGrpcTransport.__init__"
- ) as grpc_transport:
- grpc_transport.return_value = None
- client = ApplicationsClient(client_options={"api_endpoint": "squid.clam.whelk"})
- grpc_transport.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (
- ApplicationsClient,
- transports.ApplicationsGrpcTransport,
- "grpc",
- grpc_helpers,
- ),
- (
- ApplicationsAsyncClient,
- transports.ApplicationsGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- ],
-)
-def test_applications_client_create_channel_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # test that the credentials from file are saved and used as the credentials.
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel"
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- file_creds = ga_credentials.AnonymousCredentials()
- load_creds.return_value = (file_creds, None)
- adc.return_value = (creds, None)
- client = client_class(client_options=options, transport=transport_name)
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=file_creds,
- credentials_file=None,
- quota_project_id=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=None,
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetApplicationRequest,
- dict,
- ],
-)
-def test_get_application(request_type, transport: str = "grpc"):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_application), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = application.Application(
- name="name_value",
- id="id_value",
- auth_domain="auth_domain_value",
- location_id="location_id_value",
- code_bucket="code_bucket_value",
- serving_status=application.Application.ServingStatus.SERVING,
- default_hostname="default_hostname_value",
- default_bucket="default_bucket_value",
- service_account="service_account_value",
- gcr_domain="gcr_domain_value",
- database_type=application.Application.DatabaseType.CLOUD_DATASTORE,
- )
- response = client.get_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetApplicationRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, application.Application)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.auth_domain == "auth_domain_value"
- assert response.location_id == "location_id_value"
- assert response.code_bucket == "code_bucket_value"
- assert response.serving_status == application.Application.ServingStatus.SERVING
- assert response.default_hostname == "default_hostname_value"
- assert response.default_bucket == "default_bucket_value"
- assert response.service_account == "service_account_value"
- assert response.gcr_domain == "gcr_domain_value"
- assert (
- response.database_type == application.Application.DatabaseType.CLOUD_DATASTORE
- )
-
-
-def test_get_application_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_application), "__call__") as call:
- client.get_application()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetApplicationRequest()
-
-
-@pytest.mark.asyncio
-async def test_get_application_async(
- transport: str = "grpc_asyncio", request_type=appengine.GetApplicationRequest
-):
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_application), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- application.Application(
- name="name_value",
- id="id_value",
- auth_domain="auth_domain_value",
- location_id="location_id_value",
- code_bucket="code_bucket_value",
- serving_status=application.Application.ServingStatus.SERVING,
- default_hostname="default_hostname_value",
- default_bucket="default_bucket_value",
- service_account="service_account_value",
- gcr_domain="gcr_domain_value",
- database_type=application.Application.DatabaseType.CLOUD_DATASTORE,
- )
- )
- response = await client.get_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetApplicationRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, application.Application)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.auth_domain == "auth_domain_value"
- assert response.location_id == "location_id_value"
- assert response.code_bucket == "code_bucket_value"
- assert response.serving_status == application.Application.ServingStatus.SERVING
- assert response.default_hostname == "default_hostname_value"
- assert response.default_bucket == "default_bucket_value"
- assert response.service_account == "service_account_value"
- assert response.gcr_domain == "gcr_domain_value"
- assert (
- response.database_type == application.Application.DatabaseType.CLOUD_DATASTORE
- )
-
-
-@pytest.mark.asyncio
-async def test_get_application_async_from_dict():
- await test_get_application_async(request_type=dict)
-
-
-def test_get_application_field_headers():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetApplicationRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_application), "__call__") as call:
- call.return_value = application.Application()
- client.get_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_get_application_field_headers_async():
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetApplicationRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_application), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- application.Application()
- )
- await client.get_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-def test_get_application_flattened():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_application), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = application.Application()
- # Call the method with a truthy value for each flattened field,
- # using the keyword arguments to the method.
- client.get_application(
- name="name_value",
- )
-
- # Establish that the underlying call was made with the expected
- # request object values.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- arg = args[0].name
- mock_val = "name_value"
- assert arg == mock_val
-
-
-def test_get_application_flattened_error():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Attempting to call a method with both a request object and flattened
- # fields is an error.
- with pytest.raises(ValueError):
- client.get_application(
- appengine.GetApplicationRequest(),
- name="name_value",
- )
-
-
-@pytest.mark.asyncio
-async def test_get_application_flattened_async():
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_application), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = application.Application()
-
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- application.Application()
- )
- # Call the method with a truthy value for each flattened field,
- # using the keyword arguments to the method.
- response = await client.get_application(
- name="name_value",
- )
-
- # Establish that the underlying call was made with the expected
- # request object values.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- arg = args[0].name
- mock_val = "name_value"
- assert arg == mock_val
-
-
-@pytest.mark.asyncio
-async def test_get_application_flattened_error_async():
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Attempting to call a method with both a request object and flattened
- # fields is an error.
- with pytest.raises(ValueError):
- await client.get_application(
- appengine.GetApplicationRequest(),
- name="name_value",
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.CreateApplicationRequest,
- dict,
- ],
-)
-def test_create_application(request_type, transport: str = "grpc"):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_application), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.create_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateApplicationRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_create_application_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_application), "__call__"
- ) as call:
- client.create_application()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateApplicationRequest()
-
-
-@pytest.mark.asyncio
-async def test_create_application_async(
- transport: str = "grpc_asyncio", request_type=appengine.CreateApplicationRequest
-):
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_application), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.create_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateApplicationRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_create_application_async_from_dict():
- await test_create_application_async(request_type=dict)
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateApplicationRequest,
- dict,
- ],
-)
-def test_update_application(request_type, transport: str = "grpc"):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_application), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.update_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateApplicationRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_update_application_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_application), "__call__"
- ) as call:
- client.update_application()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateApplicationRequest()
-
-
-@pytest.mark.asyncio
-async def test_update_application_async(
- transport: str = "grpc_asyncio", request_type=appengine.UpdateApplicationRequest
-):
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_application), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.update_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateApplicationRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_update_application_async_from_dict():
- await test_update_application_async(request_type=dict)
-
-
-def test_update_application_field_headers():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateApplicationRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_application), "__call__"
- ) as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.update_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_update_application_field_headers_async():
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateApplicationRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_application), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.update_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.RepairApplicationRequest,
- dict,
- ],
-)
-def test_repair_application(request_type, transport: str = "grpc"):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.repair_application), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.repair_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.RepairApplicationRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_repair_application_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.repair_application), "__call__"
- ) as call:
- client.repair_application()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.RepairApplicationRequest()
-
-
-@pytest.mark.asyncio
-async def test_repair_application_async(
- transport: str = "grpc_asyncio", request_type=appengine.RepairApplicationRequest
-):
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.repair_application), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.repair_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.RepairApplicationRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_repair_application_async_from_dict():
- await test_repair_application_async(request_type=dict)
-
-
-def test_repair_application_field_headers():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.RepairApplicationRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.repair_application), "__call__"
- ) as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.repair_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_repair_application_field_headers_async():
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.RepairApplicationRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.repair_application), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.repair_application(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetApplicationRequest,
- dict,
- ],
-)
-def test_get_application_rest(request_type):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = application.Application(
- name="name_value",
- id="id_value",
- auth_domain="auth_domain_value",
- location_id="location_id_value",
- code_bucket="code_bucket_value",
- serving_status=application.Application.ServingStatus.SERVING,
- default_hostname="default_hostname_value",
- default_bucket="default_bucket_value",
- service_account="service_account_value",
- gcr_domain="gcr_domain_value",
- database_type=application.Application.DatabaseType.CLOUD_DATASTORE,
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = application.Application.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.get_application(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, application.Application)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.auth_domain == "auth_domain_value"
- assert response.location_id == "location_id_value"
- assert response.code_bucket == "code_bucket_value"
- assert response.serving_status == application.Application.ServingStatus.SERVING
- assert response.default_hostname == "default_hostname_value"
- assert response.default_bucket == "default_bucket_value"
- assert response.service_account == "service_account_value"
- assert response.gcr_domain == "gcr_domain_value"
- assert (
- response.database_type == application.Application.DatabaseType.CLOUD_DATASTORE
- )
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_get_application_rest_interceptors(null_interceptor):
- transport = transports.ApplicationsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.ApplicationsRestInterceptor(),
- )
- client = ApplicationsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.ApplicationsRestInterceptor, "post_get_application"
- ) as post, mock.patch.object(
- transports.ApplicationsRestInterceptor, "pre_get_application"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.GetApplicationRequest.pb(
- appengine.GetApplicationRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = application.Application.to_json(
- application.Application()
- )
-
- request = appengine.GetApplicationRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = application.Application()
-
- client.get_application(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_get_application_rest_bad_request(
- transport: str = "rest", request_type=appengine.GetApplicationRequest
-):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.get_application(request)
-
-
-def test_get_application_rest_flattened():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = application.Application()
-
- # get arguments that satisfy an http rule for this method
- sample_request = {"name": "apps/sample1"}
-
- # get truthy value for each flattened field
- mock_args = dict(
- name="name_value",
- )
- mock_args.update(sample_request)
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = application.Application.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
-
- client.get_application(**mock_args)
-
- # Establish that the underlying call was made with the expected
- # request object values.
- assert len(req.mock_calls) == 1
- _, args, _ = req.mock_calls[0]
- assert path_template.validate(
- "%s/v1/{name=apps/*}" % client.transport._host, args[1]
- )
-
-
-def test_get_application_rest_flattened_error(transport: str = "rest"):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Attempting to call a method with both a request object and flattened
- # fields is an error.
- with pytest.raises(ValueError):
- client.get_application(
- appengine.GetApplicationRequest(),
- name="name_value",
- )
-
-
-def test_get_application_rest_error():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.CreateApplicationRequest,
- dict,
- ],
-)
-def test_create_application_rest(request_type):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {}
- request_init["application"] = {
- "name": "name_value",
- "id": "id_value",
- "dispatch_rules": [
- {"domain": "domain_value", "path": "path_value", "service": "service_value"}
- ],
- "auth_domain": "auth_domain_value",
- "location_id": "location_id_value",
- "code_bucket": "code_bucket_value",
- "default_cookie_expiration": {"seconds": 751, "nanos": 543},
- "serving_status": 1,
- "default_hostname": "default_hostname_value",
- "default_bucket": "default_bucket_value",
- "service_account": "service_account_value",
- "iap": {
- "enabled": True,
- "oauth2_client_id": "oauth2_client_id_value",
- "oauth2_client_secret": "oauth2_client_secret_value",
- "oauth2_client_secret_sha256": "oauth2_client_secret_sha256_value",
- },
- "gcr_domain": "gcr_domain_value",
- "database_type": 1,
- "feature_settings": {
- "split_health_checks": True,
- "use_container_optimized_os": True,
- },
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.CreateApplicationRequest.meta.fields["application"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["application"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["application"][field])):
- del request_init["application"][field][i][subfield]
- else:
- del request_init["application"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.create_application(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_create_application_rest_interceptors(null_interceptor):
- transport = transports.ApplicationsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.ApplicationsRestInterceptor(),
- )
- client = ApplicationsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.ApplicationsRestInterceptor, "post_create_application"
- ) as post, mock.patch.object(
- transports.ApplicationsRestInterceptor, "pre_create_application"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.CreateApplicationRequest.pb(
- appengine.CreateApplicationRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.CreateApplicationRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.create_application(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_create_application_rest_bad_request(
- transport: str = "rest", request_type=appengine.CreateApplicationRequest
-):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.create_application(request)
-
-
-def test_create_application_rest_error():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateApplicationRequest,
- dict,
- ],
-)
-def test_update_application_rest(request_type):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1"}
- request_init["application"] = {
- "name": "name_value",
- "id": "id_value",
- "dispatch_rules": [
- {"domain": "domain_value", "path": "path_value", "service": "service_value"}
- ],
- "auth_domain": "auth_domain_value",
- "location_id": "location_id_value",
- "code_bucket": "code_bucket_value",
- "default_cookie_expiration": {"seconds": 751, "nanos": 543},
- "serving_status": 1,
- "default_hostname": "default_hostname_value",
- "default_bucket": "default_bucket_value",
- "service_account": "service_account_value",
- "iap": {
- "enabled": True,
- "oauth2_client_id": "oauth2_client_id_value",
- "oauth2_client_secret": "oauth2_client_secret_value",
- "oauth2_client_secret_sha256": "oauth2_client_secret_sha256_value",
- },
- "gcr_domain": "gcr_domain_value",
- "database_type": 1,
- "feature_settings": {
- "split_health_checks": True,
- "use_container_optimized_os": True,
- },
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.UpdateApplicationRequest.meta.fields["application"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["application"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["application"][field])):
- del request_init["application"][field][i][subfield]
- else:
- del request_init["application"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.update_application(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_update_application_rest_interceptors(null_interceptor):
- transport = transports.ApplicationsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.ApplicationsRestInterceptor(),
- )
- client = ApplicationsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.ApplicationsRestInterceptor, "post_update_application"
- ) as post, mock.patch.object(
- transports.ApplicationsRestInterceptor, "pre_update_application"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.UpdateApplicationRequest.pb(
- appengine.UpdateApplicationRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.UpdateApplicationRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.update_application(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_update_application_rest_bad_request(
- transport: str = "rest", request_type=appengine.UpdateApplicationRequest
-):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.update_application(request)
-
-
-def test_update_application_rest_error():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.RepairApplicationRequest,
- dict,
- ],
-)
-def test_repair_application_rest(request_type):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.repair_application(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_repair_application_rest_interceptors(null_interceptor):
- transport = transports.ApplicationsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.ApplicationsRestInterceptor(),
- )
- client = ApplicationsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.ApplicationsRestInterceptor, "post_repair_application"
- ) as post, mock.patch.object(
- transports.ApplicationsRestInterceptor, "pre_repair_application"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.RepairApplicationRequest.pb(
- appengine.RepairApplicationRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.RepairApplicationRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.repair_application(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_repair_application_rest_bad_request(
- transport: str = "rest", request_type=appengine.RepairApplicationRequest
-):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.repair_application(request)
-
-
-def test_repair_application_rest_error():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-def test_credentials_transport_error():
- # It is an error to provide credentials and a transport instance.
- transport = transports.ApplicationsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # It is an error to provide a credentials file and a transport instance.
- transport = transports.ApplicationsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = ApplicationsClient(
- client_options={"credentials_file": "credentials.json"},
- transport=transport,
- )
-
- # It is an error to provide an api_key and a transport instance.
- transport = transports.ApplicationsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = ApplicationsClient(
- client_options=options,
- transport=transport,
- )
-
- # It is an error to provide an api_key and a credential.
- options = mock.Mock()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = ApplicationsClient(
- client_options=options, credentials=ga_credentials.AnonymousCredentials()
- )
-
- # It is an error to provide scopes and a transport instance.
- transport = transports.ApplicationsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = ApplicationsClient(
- client_options={"scopes": ["1", "2"]},
- transport=transport,
- )
-
-
-def test_transport_instance():
- # A client may be instantiated with a custom transport instance.
- transport = transports.ApplicationsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- client = ApplicationsClient(transport=transport)
- assert client.transport is transport
-
-
-def test_transport_get_channel():
- # A client may be instantiated with a custom transport instance.
- transport = transports.ApplicationsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
- transport = transports.ApplicationsGrpcAsyncIOTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.ApplicationsGrpcTransport,
- transports.ApplicationsGrpcAsyncIOTransport,
- transports.ApplicationsRestTransport,
- ],
-)
-def test_transport_adc(transport_class):
- # Test default credentials are used if not provided.
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class()
- adc.assert_called_once()
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "rest",
- ],
-)
-def test_transport_kind(transport_name):
- transport = ApplicationsClient.get_transport_class(transport_name)(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert transport.kind == transport_name
-
-
-def test_transport_grpc_default():
- # A client should use the gRPC transport by default.
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert isinstance(
- client.transport,
- transports.ApplicationsGrpcTransport,
- )
-
-
-def test_applications_base_transport_error():
- # Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(core_exceptions.DuplicateCredentialArgs):
- transport = transports.ApplicationsTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- credentials_file="credentials.json",
- )
-
-
-def test_applications_base_transport():
- # Instantiate the base transport.
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.applications.transports.ApplicationsTransport.__init__"
- ) as Transport:
- Transport.return_value = None
- transport = transports.ApplicationsTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Every method on the transport should just blindly
- # raise NotImplementedError.
- methods = (
- "get_application",
- "create_application",
- "update_application",
- "repair_application",
- )
- for method in methods:
- with pytest.raises(NotImplementedError):
- getattr(transport, method)(request=object())
-
- with pytest.raises(NotImplementedError):
- transport.close()
-
- # Additionally, the LRO client (a property) should
- # also raise NotImplementedError
- with pytest.raises(NotImplementedError):
- transport.operations_client
-
- # Catch all for all remaining methods and properties
- remainder = [
- "kind",
- ]
- for r in remainder:
- with pytest.raises(NotImplementedError):
- getattr(transport, r)()
-
-
-def test_applications_base_transport_with_credentials_file():
- # Instantiate the base transport with a credentials file
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch(
- "google.cloud.appengine_admin_v1.services.applications.transports.ApplicationsTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.ApplicationsTransport(
- credentials_file="credentials.json",
- quota_project_id="octopus",
- )
- load_creds.assert_called_once_with(
- "credentials.json",
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-def test_applications_base_transport_with_adc():
- # Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
- "google.cloud.appengine_admin_v1.services.applications.transports.ApplicationsTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.ApplicationsTransport()
- adc.assert_called_once()
-
-
-def test_applications_auth_adc():
- # If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- ApplicationsClient()
- adc.assert_called_once_with(
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id=None,
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.ApplicationsGrpcTransport,
- transports.ApplicationsGrpcAsyncIOTransport,
- ],
-)
-def test_applications_transport_auth_adc(transport_class):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
- adc.assert_called_once_with(
- scopes=["1", "2"],
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.ApplicationsGrpcTransport,
- transports.ApplicationsGrpcAsyncIOTransport,
- transports.ApplicationsRestTransport,
- ],
-)
-def test_applications_transport_auth_gdch_credentials(transport_class):
- host = "https://language.com"
- api_audience_tests = [None, "https://language2.com"]
- api_audience_expect = [host, "https://language2.com"]
- for t, e in zip(api_audience_tests, api_audience_expect):
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- gdch_mock = mock.MagicMock()
- type(gdch_mock).with_gdch_audience = mock.PropertyMock(
- return_value=gdch_mock
- )
- adc.return_value = (gdch_mock, None)
- transport_class(host=host, api_audience=t)
- gdch_mock.with_gdch_audience.assert_called_once_with(e)
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.ApplicationsGrpcTransport, grpc_helpers),
- (transports.ApplicationsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-def test_applications_transport_create_channel(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=["1", "2"],
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [transports.ApplicationsGrpcTransport, transports.ApplicationsGrpcAsyncIOTransport],
-)
-def test_applications_grpc_transport_client_cert_source_for_mtls(transport_class):
- cred = ga_credentials.AnonymousCredentials()
-
- # Check ssl_channel_credentials is used if provided.
- with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
- mock_ssl_channel_creds = mock.Mock()
- transport_class(
- host="squid.clam.whelk",
- credentials=cred,
- ssl_channel_credentials=mock_ssl_channel_creds,
- )
- mock_create_channel.assert_called_once_with(
- "squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_channel_creds,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
- # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls
- # is used.
- with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()):
- with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred:
- transport_class(
- credentials=cred,
- client_cert_source_for_mtls=client_cert_source_callback,
- )
- expected_cert, expected_key = client_cert_source_callback()
- mock_ssl_cred.assert_called_once_with(
- certificate_chain=expected_cert, private_key=expected_key
- )
-
-
-def test_applications_http_transport_client_cert_source_for_mtls():
- cred = ga_credentials.AnonymousCredentials()
- with mock.patch(
- "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"
- ) as mock_configure_mtls_channel:
- transports.ApplicationsRestTransport(
- credentials=cred, client_cert_source_for_mtls=client_cert_source_callback
- )
- mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback)
-
-
-def test_applications_rest_lro_client():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.AbstractOperationsClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_applications_host_no_port(transport_name):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_applications_host_with_port(transport_name):
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com:8000"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:8000"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com:8000"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "rest",
- ],
-)
-def test_applications_client_transport_session_collision(transport_name):
- creds1 = ga_credentials.AnonymousCredentials()
- creds2 = ga_credentials.AnonymousCredentials()
- client1 = ApplicationsClient(
- credentials=creds1,
- transport=transport_name,
- )
- client2 = ApplicationsClient(
- credentials=creds2,
- transport=transport_name,
- )
- session1 = client1.transport.get_application._session
- session2 = client2.transport.get_application._session
- assert session1 != session2
- session1 = client1.transport.create_application._session
- session2 = client2.transport.create_application._session
- assert session1 != session2
- session1 = client1.transport.update_application._session
- session2 = client2.transport.update_application._session
- assert session1 != session2
- session1 = client1.transport.repair_application._session
- session2 = client2.transport.repair_application._session
- assert session1 != session2
-
-
-def test_applications_grpc_transport_channel():
- channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.ApplicationsGrpcTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-def test_applications_grpc_asyncio_transport_channel():
- channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.ApplicationsGrpcAsyncIOTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [transports.ApplicationsGrpcTransport, transports.ApplicationsGrpcAsyncIOTransport],
-)
-def test_applications_transport_channel_mtls_with_client_cert_source(transport_class):
- with mock.patch(
- "grpc.ssl_channel_credentials", autospec=True
- ) as grpc_ssl_channel_cred:
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_ssl_cred = mock.Mock()
- grpc_ssl_channel_cred.return_value = mock_ssl_cred
-
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
-
- cred = ga_credentials.AnonymousCredentials()
- with pytest.warns(DeprecationWarning):
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (cred, None)
- transport = transport_class(
- host="squid.clam.whelk",
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=client_cert_source_callback,
- )
- adc.assert_called_once()
-
- grpc_ssl_channel_cred.assert_called_once_with(
- certificate_chain=b"cert bytes", private_key=b"key bytes"
- )
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
- assert transport._ssl_channel_credentials == mock_ssl_cred
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [transports.ApplicationsGrpcTransport, transports.ApplicationsGrpcAsyncIOTransport],
-)
-def test_applications_transport_channel_mtls_with_adc(transport_class):
- mock_ssl_cred = mock.Mock()
- with mock.patch.multiple(
- "google.auth.transport.grpc.SslCredentials",
- __init__=mock.Mock(return_value=None),
- ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
- ):
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
- mock_cred = mock.Mock()
-
- with pytest.warns(DeprecationWarning):
- transport = transport_class(
- host="squid.clam.whelk",
- credentials=mock_cred,
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=None,
- )
-
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=mock_cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
-
-
-def test_applications_grpc_lro_client():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.OperationsClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-def test_applications_grpc_lro_async_client():
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.OperationsAsyncClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-def test_common_billing_account_path():
- billing_account = "squid"
- expected = "billingAccounts/{billing_account}".format(
- billing_account=billing_account,
- )
- actual = ApplicationsClient.common_billing_account_path(billing_account)
- assert expected == actual
-
-
-def test_parse_common_billing_account_path():
- expected = {
- "billing_account": "clam",
- }
- path = ApplicationsClient.common_billing_account_path(**expected)
-
- # Check that the path construction is reversible.
- actual = ApplicationsClient.parse_common_billing_account_path(path)
- assert expected == actual
-
-
-def test_common_folder_path():
- folder = "whelk"
- expected = "folders/{folder}".format(
- folder=folder,
- )
- actual = ApplicationsClient.common_folder_path(folder)
- assert expected == actual
-
-
-def test_parse_common_folder_path():
- expected = {
- "folder": "octopus",
- }
- path = ApplicationsClient.common_folder_path(**expected)
-
- # Check that the path construction is reversible.
- actual = ApplicationsClient.parse_common_folder_path(path)
- assert expected == actual
-
-
-def test_common_organization_path():
- organization = "oyster"
- expected = "organizations/{organization}".format(
- organization=organization,
- )
- actual = ApplicationsClient.common_organization_path(organization)
- assert expected == actual
-
-
-def test_parse_common_organization_path():
- expected = {
- "organization": "nudibranch",
- }
- path = ApplicationsClient.common_organization_path(**expected)
-
- # Check that the path construction is reversible.
- actual = ApplicationsClient.parse_common_organization_path(path)
- assert expected == actual
-
-
-def test_common_project_path():
- project = "cuttlefish"
- expected = "projects/{project}".format(
- project=project,
- )
- actual = ApplicationsClient.common_project_path(project)
- assert expected == actual
-
-
-def test_parse_common_project_path():
- expected = {
- "project": "mussel",
- }
- path = ApplicationsClient.common_project_path(**expected)
-
- # Check that the path construction is reversible.
- actual = ApplicationsClient.parse_common_project_path(path)
- assert expected == actual
-
-
-def test_common_location_path():
- project = "winkle"
- location = "nautilus"
- expected = "projects/{project}/locations/{location}".format(
- project=project,
- location=location,
- )
- actual = ApplicationsClient.common_location_path(project, location)
- assert expected == actual
-
-
-def test_parse_common_location_path():
- expected = {
- "project": "scallop",
- "location": "abalone",
- }
- path = ApplicationsClient.common_location_path(**expected)
-
- # Check that the path construction is reversible.
- actual = ApplicationsClient.parse_common_location_path(path)
- assert expected == actual
-
-
-def test_client_with_default_client_info():
- client_info = gapic_v1.client_info.ClientInfo()
-
- with mock.patch.object(
- transports.ApplicationsTransport, "_prep_wrapped_messages"
- ) as prep:
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
- with mock.patch.object(
- transports.ApplicationsTransport, "_prep_wrapped_messages"
- ) as prep:
- transport_class = ApplicationsClient.get_transport_class()
- transport = transport_class(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
-
-@pytest.mark.asyncio
-async def test_transport_close_async():
- client = ApplicationsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- with mock.patch.object(
- type(getattr(client.transport, "grpc_channel")), "close"
- ) as close:
- async with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_transport_close():
- transports = {
- "rest": "_session",
- "grpc": "_grpc_channel",
- }
-
- for transport, close_name in transports.items():
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- with mock.patch.object(
- type(getattr(client.transport, close_name)), "close"
- ) as close:
- with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_client_ctx():
- transports = [
- "rest",
- "grpc",
- ]
- for transport in transports:
- client = ApplicationsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- # Test client calls underlying transport.
- with mock.patch.object(type(client.transport), "close") as close:
- close.assert_not_called()
- with client:
- pass
- close.assert_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class",
- [
- (ApplicationsClient, transports.ApplicationsGrpcTransport),
- (ApplicationsAsyncClient, transports.ApplicationsGrpcAsyncIOTransport),
- ],
-)
-def test_api_key_credentials(client_class, transport_class):
- with mock.patch.object(
- google.auth._default, "get_api_key_credentials", create=True
- ) as get_api_key_credentials:
- mock_cred = mock.Mock()
- get_api_key_credentials.return_value = mock_cred
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options)
- patched.assert_called_once_with(
- credentials=mock_cred,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
diff --git a/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py b/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py
deleted file mode 100644
index 16099a0..0000000
--- a/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py
+++ /dev/null
@@ -1,3469 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import os
-
-# try/except added for compatibility with python < 3.8
-try:
- from unittest import mock
- from unittest.mock import AsyncMock # pragma: NO COVER
-except ImportError: # pragma: NO COVER
- import mock
-
-from collections.abc import Iterable
-import json
-import math
-
-from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template
-from google.api_core import client_options
-from google.api_core import exceptions as core_exceptions
-import google.auth
-from google.auth import credentials as ga_credentials
-from google.auth.exceptions import MutualTLSChannelError
-from google.oauth2 import service_account
-from google.protobuf import field_mask_pb2 # type: ignore
-from google.protobuf import json_format
-from google.protobuf import timestamp_pb2 # type: ignore
-import grpc
-from grpc.experimental import aio
-from proto.marshal.rules import wrappers
-from proto.marshal.rules.dates import DurationRule, TimestampRule
-import pytest
-from requests import PreparedRequest, Request, Response
-from requests.sessions import Session
-
-from google.cloud.appengine_admin_v1.services.authorized_certificates import (
- AuthorizedCertificatesAsyncClient,
- AuthorizedCertificatesClient,
- pagers,
- transports,
-)
-from google.cloud.appengine_admin_v1.types import appengine, certificate
-
-
-def client_cert_source_callback():
- return b"cert bytes", b"key bytes"
-
-
-# If default endpoint is localhost, then default mtls endpoint will be the same.
-# This method modifies the default endpoint so the client can produce a different
-# mtls endpoint for endpoint testing purposes.
-def modify_default_endpoint(client):
- return (
- "foo.googleapis.com"
- if ("localhost" in client.DEFAULT_ENDPOINT)
- else client.DEFAULT_ENDPOINT
- )
-
-
-def test__get_default_mtls_endpoint():
- api_endpoint = "example.googleapis.com"
- api_mtls_endpoint = "example.mtls.googleapis.com"
- sandbox_endpoint = "example.sandbox.googleapis.com"
- sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
- non_googleapi = "api.example.com"
-
- assert AuthorizedCertificatesClient._get_default_mtls_endpoint(None) is None
- assert (
- AuthorizedCertificatesClient._get_default_mtls_endpoint(api_endpoint)
- == api_mtls_endpoint
- )
- assert (
- AuthorizedCertificatesClient._get_default_mtls_endpoint(api_mtls_endpoint)
- == api_mtls_endpoint
- )
- assert (
- AuthorizedCertificatesClient._get_default_mtls_endpoint(sandbox_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- AuthorizedCertificatesClient._get_default_mtls_endpoint(sandbox_mtls_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- AuthorizedCertificatesClient._get_default_mtls_endpoint(non_googleapi)
- == non_googleapi
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (AuthorizedCertificatesClient, "grpc"),
- (AuthorizedCertificatesAsyncClient, "grpc_asyncio"),
- (AuthorizedCertificatesClient, "rest"),
- ],
-)
-def test_authorized_certificates_client_from_service_account_info(
- client_class, transport_name
-):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_info"
- ) as factory:
- factory.return_value = creds
- info = {"valid": True}
- client = client_class.from_service_account_info(info, transport=transport_name)
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,transport_name",
- [
- (transports.AuthorizedCertificatesGrpcTransport, "grpc"),
- (transports.AuthorizedCertificatesGrpcAsyncIOTransport, "grpc_asyncio"),
- (transports.AuthorizedCertificatesRestTransport, "rest"),
- ],
-)
-def test_authorized_certificates_client_service_account_always_use_jwt(
- transport_class, transport_name
-):
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=True)
- use_jwt.assert_called_once_with(True)
-
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=False)
- use_jwt.assert_not_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (AuthorizedCertificatesClient, "grpc"),
- (AuthorizedCertificatesAsyncClient, "grpc_asyncio"),
- (AuthorizedCertificatesClient, "rest"),
- ],
-)
-def test_authorized_certificates_client_from_service_account_file(
- client_class, transport_name
-):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_file"
- ) as factory:
- factory.return_value = creds
- client = client_class.from_service_account_file(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- client = client_class.from_service_account_json(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-def test_authorized_certificates_client_get_transport_class():
- transport = AuthorizedCertificatesClient.get_transport_class()
- available_transports = [
- transports.AuthorizedCertificatesGrpcTransport,
- transports.AuthorizedCertificatesRestTransport,
- ]
- assert transport in available_transports
-
- transport = AuthorizedCertificatesClient.get_transport_class("grpc")
- assert transport == transports.AuthorizedCertificatesGrpcTransport
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesGrpcTransport,
- "grpc",
- ),
- (
- AuthorizedCertificatesAsyncClient,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- "grpc_asyncio",
- ),
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesRestTransport,
- "rest",
- ),
- ],
-)
-@mock.patch.object(
- AuthorizedCertificatesClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedCertificatesClient),
-)
-@mock.patch.object(
- AuthorizedCertificatesAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedCertificatesAsyncClient),
-)
-def test_authorized_certificates_client_client_options(
- client_class, transport_class, transport_name
-):
- # Check that if channel is provided we won't create a new one.
- with mock.patch.object(AuthorizedCertificatesClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
- client = client_class(transport=transport)
- gtc.assert_not_called()
-
- # Check that if channel is provided via str we will create a new one.
- with mock.patch.object(AuthorizedCertificatesClient, "get_transport_class") as gtc:
- client = client_class(transport=transport_name)
- gtc.assert_called()
-
- # Check the case api_endpoint is provided.
- options = client_options.ClientOptions(api_endpoint="squid.clam.whelk")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name, client_options=options)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_MTLS_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
- # unsupported value.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
- with pytest.raises(MutualTLSChannelError):
- client = client_class(transport=transport_name)
-
- # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
- ):
- with pytest.raises(ValueError):
- client = client_class(transport=transport_name)
-
- # Check the case quota_project_id is provided
- options = client_options.ClientOptions(quota_project_id="octopus")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id="octopus",
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
- # Check the case api_endpoint is provided
- options = client_options.ClientOptions(
- api_audience="https://language.googleapis.com"
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience="https://language.googleapis.com",
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,use_client_cert_env",
- [
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesGrpcTransport,
- "grpc",
- "true",
- ),
- (
- AuthorizedCertificatesAsyncClient,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- "grpc_asyncio",
- "true",
- ),
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesGrpcTransport,
- "grpc",
- "false",
- ),
- (
- AuthorizedCertificatesAsyncClient,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- "grpc_asyncio",
- "false",
- ),
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesRestTransport,
- "rest",
- "true",
- ),
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesRestTransport,
- "rest",
- "false",
- ),
- ],
-)
-@mock.patch.object(
- AuthorizedCertificatesClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedCertificatesClient),
-)
-@mock.patch.object(
- AuthorizedCertificatesAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedCertificatesAsyncClient),
-)
-@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"})
-def test_authorized_certificates_client_mtls_env_auto(
- client_class, transport_class, transport_name, use_client_cert_env
-):
- # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default
- # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists.
-
- # Check the case client_cert_source is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- options = client_options.ClientOptions(
- client_cert_source=client_cert_source_callback
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
-
- if use_client_cert_env == "false":
- expected_client_cert_source = None
- expected_host = client.DEFAULT_ENDPOINT
- else:
- expected_client_cert_source = client_cert_source_callback
- expected_host = client.DEFAULT_MTLS_ENDPOINT
-
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case ADC client cert is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=client_cert_source_callback,
- ):
- if use_client_cert_env == "false":
- expected_host = client.DEFAULT_ENDPOINT
- expected_client_cert_source = None
- else:
- expected_host = client.DEFAULT_MTLS_ENDPOINT
- expected_client_cert_source = client_cert_source_callback
-
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case client_cert_source and ADC client cert are not provided.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class", [AuthorizedCertificatesClient, AuthorizedCertificatesAsyncClient]
-)
-@mock.patch.object(
- AuthorizedCertificatesClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedCertificatesClient),
-)
-@mock.patch.object(
- AuthorizedCertificatesAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedCertificatesAsyncClient),
-)
-def test_authorized_certificates_client_get_mtls_endpoint_and_cert_source(client_class):
- mock_client_cert_source = mock.Mock()
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source == mock_client_cert_source
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
- mock_client_cert_source = mock.Mock()
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=mock_client_cert_source,
- ):
- (
- api_endpoint,
- cert_source,
- ) = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source == mock_client_cert_source
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesGrpcTransport,
- "grpc",
- ),
- (
- AuthorizedCertificatesAsyncClient,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- "grpc_asyncio",
- ),
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesRestTransport,
- "rest",
- ),
- ],
-)
-def test_authorized_certificates_client_client_options_scopes(
- client_class, transport_class, transport_name
-):
- # Check the case scopes are provided.
- options = client_options.ClientOptions(
- scopes=["1", "2"],
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=["1", "2"],
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesGrpcTransport,
- "grpc",
- grpc_helpers,
- ),
- (
- AuthorizedCertificatesAsyncClient,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesRestTransport,
- "rest",
- None,
- ),
- ],
-)
-def test_authorized_certificates_client_client_options_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-def test_authorized_certificates_client_client_options_from_dict():
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.authorized_certificates.transports.AuthorizedCertificatesGrpcTransport.__init__"
- ) as grpc_transport:
- grpc_transport.return_value = None
- client = AuthorizedCertificatesClient(
- client_options={"api_endpoint": "squid.clam.whelk"}
- )
- grpc_transport.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (
- AuthorizedCertificatesClient,
- transports.AuthorizedCertificatesGrpcTransport,
- "grpc",
- grpc_helpers,
- ),
- (
- AuthorizedCertificatesAsyncClient,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- ],
-)
-def test_authorized_certificates_client_create_channel_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # test that the credentials from file are saved and used as the credentials.
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel"
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- file_creds = ga_credentials.AnonymousCredentials()
- load_creds.return_value = (file_creds, None)
- adc.return_value = (creds, None)
- client = client_class(client_options=options, transport=transport_name)
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=file_creds,
- credentials_file=None,
- quota_project_id=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=None,
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListAuthorizedCertificatesRequest,
- dict,
- ],
-)
-def test_list_authorized_certificates(request_type, transport: str = "grpc"):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_certificates), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = appengine.ListAuthorizedCertificatesResponse(
- next_page_token="next_page_token_value",
- )
- response = client.list_authorized_certificates(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListAuthorizedCertificatesRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListAuthorizedCertificatesPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-def test_list_authorized_certificates_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_certificates), "__call__"
- ) as call:
- client.list_authorized_certificates()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListAuthorizedCertificatesRequest()
-
-
-@pytest.mark.asyncio
-async def test_list_authorized_certificates_async(
- transport: str = "grpc_asyncio",
- request_type=appengine.ListAuthorizedCertificatesRequest,
-):
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_certificates), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListAuthorizedCertificatesResponse(
- next_page_token="next_page_token_value",
- )
- )
- response = await client.list_authorized_certificates(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListAuthorizedCertificatesRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListAuthorizedCertificatesAsyncPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.asyncio
-async def test_list_authorized_certificates_async_from_dict():
- await test_list_authorized_certificates_async(request_type=dict)
-
-
-def test_list_authorized_certificates_field_headers():
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListAuthorizedCertificatesRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_certificates), "__call__"
- ) as call:
- call.return_value = appengine.ListAuthorizedCertificatesResponse()
- client.list_authorized_certificates(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_list_authorized_certificates_field_headers_async():
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListAuthorizedCertificatesRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_certificates), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListAuthorizedCertificatesResponse()
- )
- await client.list_authorized_certificates(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-def test_list_authorized_certificates_pager(transport_name: str = "grpc"):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_certificates), "__call__"
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- ],
- next_page_token="abc",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[],
- next_page_token="def",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- ],
- ),
- RuntimeError,
- )
-
- metadata = ()
- metadata = tuple(metadata) + (
- gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)),
- )
- pager = client.list_authorized_certificates(request={})
-
- assert pager._metadata == metadata
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, certificate.AuthorizedCertificate) for i in results)
-
-
-def test_list_authorized_certificates_pages(transport_name: str = "grpc"):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_certificates), "__call__"
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- ],
- next_page_token="abc",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[],
- next_page_token="def",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- ],
- ),
- RuntimeError,
- )
- pages = list(client.list_authorized_certificates(request={}).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.asyncio
-async def test_list_authorized_certificates_async_pager():
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_certificates),
- "__call__",
- new_callable=mock.AsyncMock,
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- ],
- next_page_token="abc",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[],
- next_page_token="def",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- ],
- ),
- RuntimeError,
- )
- async_pager = await client.list_authorized_certificates(
- request={},
- )
- assert async_pager.next_page_token == "abc"
- responses = []
- async for response in async_pager: # pragma: no branch
- responses.append(response)
-
- assert len(responses) == 6
- assert all(isinstance(i, certificate.AuthorizedCertificate) for i in responses)
-
-
-@pytest.mark.asyncio
-async def test_list_authorized_certificates_async_pages():
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_certificates),
- "__call__",
- new_callable=mock.AsyncMock,
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- ],
- next_page_token="abc",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[],
- next_page_token="def",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- ],
- ),
- RuntimeError,
- )
- pages = []
- # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
- # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
- async for page_ in ( # pragma: no branch
- await client.list_authorized_certificates(request={})
- ).pages:
- pages.append(page_)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetAuthorizedCertificateRequest,
- dict,
- ],
-)
-def test_get_authorized_certificate(request_type, transport: str = "grpc"):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.get_authorized_certificate), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = certificate.AuthorizedCertificate(
- name="name_value",
- id="id_value",
- display_name="display_name_value",
- domain_names=["domain_names_value"],
- visible_domain_mappings=["visible_domain_mappings_value"],
- domain_mappings_count=2238,
- )
- response = client.get_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetAuthorizedCertificateRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, certificate.AuthorizedCertificate)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.display_name == "display_name_value"
- assert response.domain_names == ["domain_names_value"]
- assert response.visible_domain_mappings == ["visible_domain_mappings_value"]
- assert response.domain_mappings_count == 2238
-
-
-def test_get_authorized_certificate_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.get_authorized_certificate), "__call__"
- ) as call:
- client.get_authorized_certificate()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetAuthorizedCertificateRequest()
-
-
-@pytest.mark.asyncio
-async def test_get_authorized_certificate_async(
- transport: str = "grpc_asyncio",
- request_type=appengine.GetAuthorizedCertificateRequest,
-):
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.get_authorized_certificate), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- certificate.AuthorizedCertificate(
- name="name_value",
- id="id_value",
- display_name="display_name_value",
- domain_names=["domain_names_value"],
- visible_domain_mappings=["visible_domain_mappings_value"],
- domain_mappings_count=2238,
- )
- )
- response = await client.get_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetAuthorizedCertificateRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, certificate.AuthorizedCertificate)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.display_name == "display_name_value"
- assert response.domain_names == ["domain_names_value"]
- assert response.visible_domain_mappings == ["visible_domain_mappings_value"]
- assert response.domain_mappings_count == 2238
-
-
-@pytest.mark.asyncio
-async def test_get_authorized_certificate_async_from_dict():
- await test_get_authorized_certificate_async(request_type=dict)
-
-
-def test_get_authorized_certificate_field_headers():
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetAuthorizedCertificateRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.get_authorized_certificate), "__call__"
- ) as call:
- call.return_value = certificate.AuthorizedCertificate()
- client.get_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_get_authorized_certificate_field_headers_async():
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetAuthorizedCertificateRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.get_authorized_certificate), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- certificate.AuthorizedCertificate()
- )
- await client.get_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.CreateAuthorizedCertificateRequest,
- dict,
- ],
-)
-def test_create_authorized_certificate(request_type, transport: str = "grpc"):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_authorized_certificate), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = certificate.AuthorizedCertificate(
- name="name_value",
- id="id_value",
- display_name="display_name_value",
- domain_names=["domain_names_value"],
- visible_domain_mappings=["visible_domain_mappings_value"],
- domain_mappings_count=2238,
- )
- response = client.create_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateAuthorizedCertificateRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, certificate.AuthorizedCertificate)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.display_name == "display_name_value"
- assert response.domain_names == ["domain_names_value"]
- assert response.visible_domain_mappings == ["visible_domain_mappings_value"]
- assert response.domain_mappings_count == 2238
-
-
-def test_create_authorized_certificate_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_authorized_certificate), "__call__"
- ) as call:
- client.create_authorized_certificate()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateAuthorizedCertificateRequest()
-
-
-@pytest.mark.asyncio
-async def test_create_authorized_certificate_async(
- transport: str = "grpc_asyncio",
- request_type=appengine.CreateAuthorizedCertificateRequest,
-):
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_authorized_certificate), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- certificate.AuthorizedCertificate(
- name="name_value",
- id="id_value",
- display_name="display_name_value",
- domain_names=["domain_names_value"],
- visible_domain_mappings=["visible_domain_mappings_value"],
- domain_mappings_count=2238,
- )
- )
- response = await client.create_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateAuthorizedCertificateRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, certificate.AuthorizedCertificate)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.display_name == "display_name_value"
- assert response.domain_names == ["domain_names_value"]
- assert response.visible_domain_mappings == ["visible_domain_mappings_value"]
- assert response.domain_mappings_count == 2238
-
-
-@pytest.mark.asyncio
-async def test_create_authorized_certificate_async_from_dict():
- await test_create_authorized_certificate_async(request_type=dict)
-
-
-def test_create_authorized_certificate_field_headers():
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.CreateAuthorizedCertificateRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_authorized_certificate), "__call__"
- ) as call:
- call.return_value = certificate.AuthorizedCertificate()
- client.create_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_create_authorized_certificate_field_headers_async():
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.CreateAuthorizedCertificateRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_authorized_certificate), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- certificate.AuthorizedCertificate()
- )
- await client.create_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateAuthorizedCertificateRequest,
- dict,
- ],
-)
-def test_update_authorized_certificate(request_type, transport: str = "grpc"):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_authorized_certificate), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = certificate.AuthorizedCertificate(
- name="name_value",
- id="id_value",
- display_name="display_name_value",
- domain_names=["domain_names_value"],
- visible_domain_mappings=["visible_domain_mappings_value"],
- domain_mappings_count=2238,
- )
- response = client.update_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateAuthorizedCertificateRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, certificate.AuthorizedCertificate)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.display_name == "display_name_value"
- assert response.domain_names == ["domain_names_value"]
- assert response.visible_domain_mappings == ["visible_domain_mappings_value"]
- assert response.domain_mappings_count == 2238
-
-
-def test_update_authorized_certificate_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_authorized_certificate), "__call__"
- ) as call:
- client.update_authorized_certificate()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateAuthorizedCertificateRequest()
-
-
-@pytest.mark.asyncio
-async def test_update_authorized_certificate_async(
- transport: str = "grpc_asyncio",
- request_type=appengine.UpdateAuthorizedCertificateRequest,
-):
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_authorized_certificate), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- certificate.AuthorizedCertificate(
- name="name_value",
- id="id_value",
- display_name="display_name_value",
- domain_names=["domain_names_value"],
- visible_domain_mappings=["visible_domain_mappings_value"],
- domain_mappings_count=2238,
- )
- )
- response = await client.update_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateAuthorizedCertificateRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, certificate.AuthorizedCertificate)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.display_name == "display_name_value"
- assert response.domain_names == ["domain_names_value"]
- assert response.visible_domain_mappings == ["visible_domain_mappings_value"]
- assert response.domain_mappings_count == 2238
-
-
-@pytest.mark.asyncio
-async def test_update_authorized_certificate_async_from_dict():
- await test_update_authorized_certificate_async(request_type=dict)
-
-
-def test_update_authorized_certificate_field_headers():
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateAuthorizedCertificateRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_authorized_certificate), "__call__"
- ) as call:
- call.return_value = certificate.AuthorizedCertificate()
- client.update_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_update_authorized_certificate_field_headers_async():
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateAuthorizedCertificateRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_authorized_certificate), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- certificate.AuthorizedCertificate()
- )
- await client.update_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteAuthorizedCertificateRequest,
- dict,
- ],
-)
-def test_delete_authorized_certificate(request_type, transport: str = "grpc"):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_authorized_certificate), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = None
- response = client.delete_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteAuthorizedCertificateRequest()
-
- # Establish that the response is the type that we expect.
- assert response is None
-
-
-def test_delete_authorized_certificate_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_authorized_certificate), "__call__"
- ) as call:
- client.delete_authorized_certificate()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteAuthorizedCertificateRequest()
-
-
-@pytest.mark.asyncio
-async def test_delete_authorized_certificate_async(
- transport: str = "grpc_asyncio",
- request_type=appengine.DeleteAuthorizedCertificateRequest,
-):
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_authorized_certificate), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
- response = await client.delete_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteAuthorizedCertificateRequest()
-
- # Establish that the response is the type that we expect.
- assert response is None
-
-
-@pytest.mark.asyncio
-async def test_delete_authorized_certificate_async_from_dict():
- await test_delete_authorized_certificate_async(request_type=dict)
-
-
-def test_delete_authorized_certificate_field_headers():
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteAuthorizedCertificateRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_authorized_certificate), "__call__"
- ) as call:
- call.return_value = None
- client.delete_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_delete_authorized_certificate_field_headers_async():
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteAuthorizedCertificateRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_authorized_certificate), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
- await client.delete_authorized_certificate(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListAuthorizedCertificatesRequest,
- dict,
- ],
-)
-def test_list_authorized_certificates_rest(request_type):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = appengine.ListAuthorizedCertificatesResponse(
- next_page_token="next_page_token_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = appengine.ListAuthorizedCertificatesResponse.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.list_authorized_certificates(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListAuthorizedCertificatesPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_list_authorized_certificates_rest_interceptors(null_interceptor):
- transport = transports.AuthorizedCertificatesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.AuthorizedCertificatesRestInterceptor(),
- )
- client = AuthorizedCertificatesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.AuthorizedCertificatesRestInterceptor,
- "post_list_authorized_certificates",
- ) as post, mock.patch.object(
- transports.AuthorizedCertificatesRestInterceptor,
- "pre_list_authorized_certificates",
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.ListAuthorizedCertificatesRequest.pb(
- appengine.ListAuthorizedCertificatesRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = (
- appengine.ListAuthorizedCertificatesResponse.to_json(
- appengine.ListAuthorizedCertificatesResponse()
- )
- )
-
- request = appengine.ListAuthorizedCertificatesRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = appengine.ListAuthorizedCertificatesResponse()
-
- client.list_authorized_certificates(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_list_authorized_certificates_rest_bad_request(
- transport: str = "rest", request_type=appengine.ListAuthorizedCertificatesRequest
-):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.list_authorized_certificates(request)
-
-
-def test_list_authorized_certificates_rest_pager(transport: str = "rest"):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(Session, "request") as req:
- # TODO(kbandes): remove this mock unless there's a good reason for it.
- # with mock.patch.object(path_template, 'transcode') as transcode:
- # Set the response as a series of pages
- response = (
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- ],
- next_page_token="abc",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[],
- next_page_token="def",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListAuthorizedCertificatesResponse(
- certificates=[
- certificate.AuthorizedCertificate(),
- certificate.AuthorizedCertificate(),
- ],
- ),
- )
- # Two responses for two calls
- response = response + response
-
- # Wrap the values into proper Response objs
- response = tuple(
- appengine.ListAuthorizedCertificatesResponse.to_json(x) for x in response
- )
- return_values = tuple(Response() for i in response)
- for return_val, response_val in zip(return_values, response):
- return_val._content = response_val.encode("UTF-8")
- return_val.status_code = 200
- req.side_effect = return_values
-
- sample_request = {"parent": "apps/sample1"}
-
- pager = client.list_authorized_certificates(request=sample_request)
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, certificate.AuthorizedCertificate) for i in results)
-
- pages = list(client.list_authorized_certificates(request=sample_request).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetAuthorizedCertificateRequest,
- dict,
- ],
-)
-def test_get_authorized_certificate_rest(request_type):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/authorizedCertificates/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = certificate.AuthorizedCertificate(
- name="name_value",
- id="id_value",
- display_name="display_name_value",
- domain_names=["domain_names_value"],
- visible_domain_mappings=["visible_domain_mappings_value"],
- domain_mappings_count=2238,
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = certificate.AuthorizedCertificate.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.get_authorized_certificate(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, certificate.AuthorizedCertificate)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.display_name == "display_name_value"
- assert response.domain_names == ["domain_names_value"]
- assert response.visible_domain_mappings == ["visible_domain_mappings_value"]
- assert response.domain_mappings_count == 2238
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_get_authorized_certificate_rest_interceptors(null_interceptor):
- transport = transports.AuthorizedCertificatesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.AuthorizedCertificatesRestInterceptor(),
- )
- client = AuthorizedCertificatesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.AuthorizedCertificatesRestInterceptor,
- "post_get_authorized_certificate",
- ) as post, mock.patch.object(
- transports.AuthorizedCertificatesRestInterceptor,
- "pre_get_authorized_certificate",
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.GetAuthorizedCertificateRequest.pb(
- appengine.GetAuthorizedCertificateRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = certificate.AuthorizedCertificate.to_json(
- certificate.AuthorizedCertificate()
- )
-
- request = appengine.GetAuthorizedCertificateRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = certificate.AuthorizedCertificate()
-
- client.get_authorized_certificate(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_get_authorized_certificate_rest_bad_request(
- transport: str = "rest", request_type=appengine.GetAuthorizedCertificateRequest
-):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/authorizedCertificates/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.get_authorized_certificate(request)
-
-
-def test_get_authorized_certificate_rest_error():
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.CreateAuthorizedCertificateRequest,
- dict,
- ],
-)
-def test_create_authorized_certificate_rest(request_type):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request_init["certificate"] = {
- "name": "name_value",
- "id": "id_value",
- "display_name": "display_name_value",
- "domain_names": ["domain_names_value1", "domain_names_value2"],
- "expire_time": {"seconds": 751, "nanos": 543},
- "certificate_raw_data": {
- "public_certificate": "public_certificate_value",
- "private_key": "private_key_value",
- },
- "managed_certificate": {"last_renewal_time": {}, "status": 1},
- "visible_domain_mappings": [
- "visible_domain_mappings_value1",
- "visible_domain_mappings_value2",
- ],
- "domain_mappings_count": 2238,
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.CreateAuthorizedCertificateRequest.meta.fields["certificate"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["certificate"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["certificate"][field])):
- del request_init["certificate"][field][i][subfield]
- else:
- del request_init["certificate"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = certificate.AuthorizedCertificate(
- name="name_value",
- id="id_value",
- display_name="display_name_value",
- domain_names=["domain_names_value"],
- visible_domain_mappings=["visible_domain_mappings_value"],
- domain_mappings_count=2238,
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = certificate.AuthorizedCertificate.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.create_authorized_certificate(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, certificate.AuthorizedCertificate)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.display_name == "display_name_value"
- assert response.domain_names == ["domain_names_value"]
- assert response.visible_domain_mappings == ["visible_domain_mappings_value"]
- assert response.domain_mappings_count == 2238
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_create_authorized_certificate_rest_interceptors(null_interceptor):
- transport = transports.AuthorizedCertificatesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.AuthorizedCertificatesRestInterceptor(),
- )
- client = AuthorizedCertificatesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.AuthorizedCertificatesRestInterceptor,
- "post_create_authorized_certificate",
- ) as post, mock.patch.object(
- transports.AuthorizedCertificatesRestInterceptor,
- "pre_create_authorized_certificate",
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.CreateAuthorizedCertificateRequest.pb(
- appengine.CreateAuthorizedCertificateRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = certificate.AuthorizedCertificate.to_json(
- certificate.AuthorizedCertificate()
- )
-
- request = appengine.CreateAuthorizedCertificateRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = certificate.AuthorizedCertificate()
-
- client.create_authorized_certificate(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_create_authorized_certificate_rest_bad_request(
- transport: str = "rest", request_type=appengine.CreateAuthorizedCertificateRequest
-):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.create_authorized_certificate(request)
-
-
-def test_create_authorized_certificate_rest_error():
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateAuthorizedCertificateRequest,
- dict,
- ],
-)
-def test_update_authorized_certificate_rest(request_type):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/authorizedCertificates/sample2"}
- request_init["certificate"] = {
- "name": "name_value",
- "id": "id_value",
- "display_name": "display_name_value",
- "domain_names": ["domain_names_value1", "domain_names_value2"],
- "expire_time": {"seconds": 751, "nanos": 543},
- "certificate_raw_data": {
- "public_certificate": "public_certificate_value",
- "private_key": "private_key_value",
- },
- "managed_certificate": {"last_renewal_time": {}, "status": 1},
- "visible_domain_mappings": [
- "visible_domain_mappings_value1",
- "visible_domain_mappings_value2",
- ],
- "domain_mappings_count": 2238,
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.UpdateAuthorizedCertificateRequest.meta.fields["certificate"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["certificate"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["certificate"][field])):
- del request_init["certificate"][field][i][subfield]
- else:
- del request_init["certificate"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = certificate.AuthorizedCertificate(
- name="name_value",
- id="id_value",
- display_name="display_name_value",
- domain_names=["domain_names_value"],
- visible_domain_mappings=["visible_domain_mappings_value"],
- domain_mappings_count=2238,
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = certificate.AuthorizedCertificate.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.update_authorized_certificate(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, certificate.AuthorizedCertificate)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.display_name == "display_name_value"
- assert response.domain_names == ["domain_names_value"]
- assert response.visible_domain_mappings == ["visible_domain_mappings_value"]
- assert response.domain_mappings_count == 2238
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_update_authorized_certificate_rest_interceptors(null_interceptor):
- transport = transports.AuthorizedCertificatesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.AuthorizedCertificatesRestInterceptor(),
- )
- client = AuthorizedCertificatesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.AuthorizedCertificatesRestInterceptor,
- "post_update_authorized_certificate",
- ) as post, mock.patch.object(
- transports.AuthorizedCertificatesRestInterceptor,
- "pre_update_authorized_certificate",
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.UpdateAuthorizedCertificateRequest.pb(
- appengine.UpdateAuthorizedCertificateRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = certificate.AuthorizedCertificate.to_json(
- certificate.AuthorizedCertificate()
- )
-
- request = appengine.UpdateAuthorizedCertificateRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = certificate.AuthorizedCertificate()
-
- client.update_authorized_certificate(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_update_authorized_certificate_rest_bad_request(
- transport: str = "rest", request_type=appengine.UpdateAuthorizedCertificateRequest
-):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/authorizedCertificates/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.update_authorized_certificate(request)
-
-
-def test_update_authorized_certificate_rest_error():
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteAuthorizedCertificateRequest,
- dict,
- ],
-)
-def test_delete_authorized_certificate_rest(request_type):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/authorizedCertificates/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = None
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = ""
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.delete_authorized_certificate(request)
-
- # Establish that the response is the type that we expect.
- assert response is None
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_delete_authorized_certificate_rest_interceptors(null_interceptor):
- transport = transports.AuthorizedCertificatesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.AuthorizedCertificatesRestInterceptor(),
- )
- client = AuthorizedCertificatesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.AuthorizedCertificatesRestInterceptor,
- "pre_delete_authorized_certificate",
- ) as pre:
- pre.assert_not_called()
- pb_message = appengine.DeleteAuthorizedCertificateRequest.pb(
- appengine.DeleteAuthorizedCertificateRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
-
- request = appengine.DeleteAuthorizedCertificateRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
-
- client.delete_authorized_certificate(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
-
-
-def test_delete_authorized_certificate_rest_bad_request(
- transport: str = "rest", request_type=appengine.DeleteAuthorizedCertificateRequest
-):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/authorizedCertificates/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.delete_authorized_certificate(request)
-
-
-def test_delete_authorized_certificate_rest_error():
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-def test_credentials_transport_error():
- # It is an error to provide credentials and a transport instance.
- transport = transports.AuthorizedCertificatesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # It is an error to provide a credentials file and a transport instance.
- transport = transports.AuthorizedCertificatesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = AuthorizedCertificatesClient(
- client_options={"credentials_file": "credentials.json"},
- transport=transport,
- )
-
- # It is an error to provide an api_key and a transport instance.
- transport = transports.AuthorizedCertificatesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = AuthorizedCertificatesClient(
- client_options=options,
- transport=transport,
- )
-
- # It is an error to provide an api_key and a credential.
- options = mock.Mock()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = AuthorizedCertificatesClient(
- client_options=options, credentials=ga_credentials.AnonymousCredentials()
- )
-
- # It is an error to provide scopes and a transport instance.
- transport = transports.AuthorizedCertificatesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = AuthorizedCertificatesClient(
- client_options={"scopes": ["1", "2"]},
- transport=transport,
- )
-
-
-def test_transport_instance():
- # A client may be instantiated with a custom transport instance.
- transport = transports.AuthorizedCertificatesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- client = AuthorizedCertificatesClient(transport=transport)
- assert client.transport is transport
-
-
-def test_transport_get_channel():
- # A client may be instantiated with a custom transport instance.
- transport = transports.AuthorizedCertificatesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
- transport = transports.AuthorizedCertificatesGrpcAsyncIOTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedCertificatesGrpcTransport,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- transports.AuthorizedCertificatesRestTransport,
- ],
-)
-def test_transport_adc(transport_class):
- # Test default credentials are used if not provided.
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class()
- adc.assert_called_once()
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "rest",
- ],
-)
-def test_transport_kind(transport_name):
- transport = AuthorizedCertificatesClient.get_transport_class(transport_name)(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert transport.kind == transport_name
-
-
-def test_transport_grpc_default():
- # A client should use the gRPC transport by default.
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert isinstance(
- client.transport,
- transports.AuthorizedCertificatesGrpcTransport,
- )
-
-
-def test_authorized_certificates_base_transport_error():
- # Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(core_exceptions.DuplicateCredentialArgs):
- transport = transports.AuthorizedCertificatesTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- credentials_file="credentials.json",
- )
-
-
-def test_authorized_certificates_base_transport():
- # Instantiate the base transport.
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.authorized_certificates.transports.AuthorizedCertificatesTransport.__init__"
- ) as Transport:
- Transport.return_value = None
- transport = transports.AuthorizedCertificatesTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Every method on the transport should just blindly
- # raise NotImplementedError.
- methods = (
- "list_authorized_certificates",
- "get_authorized_certificate",
- "create_authorized_certificate",
- "update_authorized_certificate",
- "delete_authorized_certificate",
- )
- for method in methods:
- with pytest.raises(NotImplementedError):
- getattr(transport, method)(request=object())
-
- with pytest.raises(NotImplementedError):
- transport.close()
-
- # Catch all for all remaining methods and properties
- remainder = [
- "kind",
- ]
- for r in remainder:
- with pytest.raises(NotImplementedError):
- getattr(transport, r)()
-
-
-def test_authorized_certificates_base_transport_with_credentials_file():
- # Instantiate the base transport with a credentials file
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch(
- "google.cloud.appengine_admin_v1.services.authorized_certificates.transports.AuthorizedCertificatesTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.AuthorizedCertificatesTransport(
- credentials_file="credentials.json",
- quota_project_id="octopus",
- )
- load_creds.assert_called_once_with(
- "credentials.json",
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-def test_authorized_certificates_base_transport_with_adc():
- # Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
- "google.cloud.appengine_admin_v1.services.authorized_certificates.transports.AuthorizedCertificatesTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.AuthorizedCertificatesTransport()
- adc.assert_called_once()
-
-
-def test_authorized_certificates_auth_adc():
- # If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- AuthorizedCertificatesClient()
- adc.assert_called_once_with(
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id=None,
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedCertificatesGrpcTransport,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- ],
-)
-def test_authorized_certificates_transport_auth_adc(transport_class):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
- adc.assert_called_once_with(
- scopes=["1", "2"],
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedCertificatesGrpcTransport,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- transports.AuthorizedCertificatesRestTransport,
- ],
-)
-def test_authorized_certificates_transport_auth_gdch_credentials(transport_class):
- host = "https://language.com"
- api_audience_tests = [None, "https://language2.com"]
- api_audience_expect = [host, "https://language2.com"]
- for t, e in zip(api_audience_tests, api_audience_expect):
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- gdch_mock = mock.MagicMock()
- type(gdch_mock).with_gdch_audience = mock.PropertyMock(
- return_value=gdch_mock
- )
- adc.return_value = (gdch_mock, None)
- transport_class(host=host, api_audience=t)
- gdch_mock.with_gdch_audience.assert_called_once_with(e)
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.AuthorizedCertificatesGrpcTransport, grpc_helpers),
- (transports.AuthorizedCertificatesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-def test_authorized_certificates_transport_create_channel(
- transport_class, grpc_helpers
-):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=["1", "2"],
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedCertificatesGrpcTransport,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- ],
-)
-def test_authorized_certificates_grpc_transport_client_cert_source_for_mtls(
- transport_class,
-):
- cred = ga_credentials.AnonymousCredentials()
-
- # Check ssl_channel_credentials is used if provided.
- with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
- mock_ssl_channel_creds = mock.Mock()
- transport_class(
- host="squid.clam.whelk",
- credentials=cred,
- ssl_channel_credentials=mock_ssl_channel_creds,
- )
- mock_create_channel.assert_called_once_with(
- "squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_channel_creds,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
- # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls
- # is used.
- with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()):
- with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred:
- transport_class(
- credentials=cred,
- client_cert_source_for_mtls=client_cert_source_callback,
- )
- expected_cert, expected_key = client_cert_source_callback()
- mock_ssl_cred.assert_called_once_with(
- certificate_chain=expected_cert, private_key=expected_key
- )
-
-
-def test_authorized_certificates_http_transport_client_cert_source_for_mtls():
- cred = ga_credentials.AnonymousCredentials()
- with mock.patch(
- "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"
- ) as mock_configure_mtls_channel:
- transports.AuthorizedCertificatesRestTransport(
- credentials=cred, client_cert_source_for_mtls=client_cert_source_callback
- )
- mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback)
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_authorized_certificates_host_no_port(transport_name):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_authorized_certificates_host_with_port(transport_name):
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com:8000"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:8000"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com:8000"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "rest",
- ],
-)
-def test_authorized_certificates_client_transport_session_collision(transport_name):
- creds1 = ga_credentials.AnonymousCredentials()
- creds2 = ga_credentials.AnonymousCredentials()
- client1 = AuthorizedCertificatesClient(
- credentials=creds1,
- transport=transport_name,
- )
- client2 = AuthorizedCertificatesClient(
- credentials=creds2,
- transport=transport_name,
- )
- session1 = client1.transport.list_authorized_certificates._session
- session2 = client2.transport.list_authorized_certificates._session
- assert session1 != session2
- session1 = client1.transport.get_authorized_certificate._session
- session2 = client2.transport.get_authorized_certificate._session
- assert session1 != session2
- session1 = client1.transport.create_authorized_certificate._session
- session2 = client2.transport.create_authorized_certificate._session
- assert session1 != session2
- session1 = client1.transport.update_authorized_certificate._session
- session2 = client2.transport.update_authorized_certificate._session
- assert session1 != session2
- session1 = client1.transport.delete_authorized_certificate._session
- session2 = client2.transport.delete_authorized_certificate._session
- assert session1 != session2
-
-
-def test_authorized_certificates_grpc_transport_channel():
- channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.AuthorizedCertificatesGrpcTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-def test_authorized_certificates_grpc_asyncio_transport_channel():
- channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.AuthorizedCertificatesGrpcAsyncIOTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedCertificatesGrpcTransport,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- ],
-)
-def test_authorized_certificates_transport_channel_mtls_with_client_cert_source(
- transport_class,
-):
- with mock.patch(
- "grpc.ssl_channel_credentials", autospec=True
- ) as grpc_ssl_channel_cred:
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_ssl_cred = mock.Mock()
- grpc_ssl_channel_cred.return_value = mock_ssl_cred
-
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
-
- cred = ga_credentials.AnonymousCredentials()
- with pytest.warns(DeprecationWarning):
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (cred, None)
- transport = transport_class(
- host="squid.clam.whelk",
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=client_cert_source_callback,
- )
- adc.assert_called_once()
-
- grpc_ssl_channel_cred.assert_called_once_with(
- certificate_chain=b"cert bytes", private_key=b"key bytes"
- )
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
- assert transport._ssl_channel_credentials == mock_ssl_cred
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedCertificatesGrpcTransport,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- ],
-)
-def test_authorized_certificates_transport_channel_mtls_with_adc(transport_class):
- mock_ssl_cred = mock.Mock()
- with mock.patch.multiple(
- "google.auth.transport.grpc.SslCredentials",
- __init__=mock.Mock(return_value=None),
- ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
- ):
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
- mock_cred = mock.Mock()
-
- with pytest.warns(DeprecationWarning):
- transport = transport_class(
- host="squid.clam.whelk",
- credentials=mock_cred,
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=None,
- )
-
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=mock_cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
-
-
-def test_common_billing_account_path():
- billing_account = "squid"
- expected = "billingAccounts/{billing_account}".format(
- billing_account=billing_account,
- )
- actual = AuthorizedCertificatesClient.common_billing_account_path(billing_account)
- assert expected == actual
-
-
-def test_parse_common_billing_account_path():
- expected = {
- "billing_account": "clam",
- }
- path = AuthorizedCertificatesClient.common_billing_account_path(**expected)
-
- # Check that the path construction is reversible.
- actual = AuthorizedCertificatesClient.parse_common_billing_account_path(path)
- assert expected == actual
-
-
-def test_common_folder_path():
- folder = "whelk"
- expected = "folders/{folder}".format(
- folder=folder,
- )
- actual = AuthorizedCertificatesClient.common_folder_path(folder)
- assert expected == actual
-
-
-def test_parse_common_folder_path():
- expected = {
- "folder": "octopus",
- }
- path = AuthorizedCertificatesClient.common_folder_path(**expected)
-
- # Check that the path construction is reversible.
- actual = AuthorizedCertificatesClient.parse_common_folder_path(path)
- assert expected == actual
-
-
-def test_common_organization_path():
- organization = "oyster"
- expected = "organizations/{organization}".format(
- organization=organization,
- )
- actual = AuthorizedCertificatesClient.common_organization_path(organization)
- assert expected == actual
-
-
-def test_parse_common_organization_path():
- expected = {
- "organization": "nudibranch",
- }
- path = AuthorizedCertificatesClient.common_organization_path(**expected)
-
- # Check that the path construction is reversible.
- actual = AuthorizedCertificatesClient.parse_common_organization_path(path)
- assert expected == actual
-
-
-def test_common_project_path():
- project = "cuttlefish"
- expected = "projects/{project}".format(
- project=project,
- )
- actual = AuthorizedCertificatesClient.common_project_path(project)
- assert expected == actual
-
-
-def test_parse_common_project_path():
- expected = {
- "project": "mussel",
- }
- path = AuthorizedCertificatesClient.common_project_path(**expected)
-
- # Check that the path construction is reversible.
- actual = AuthorizedCertificatesClient.parse_common_project_path(path)
- assert expected == actual
-
-
-def test_common_location_path():
- project = "winkle"
- location = "nautilus"
- expected = "projects/{project}/locations/{location}".format(
- project=project,
- location=location,
- )
- actual = AuthorizedCertificatesClient.common_location_path(project, location)
- assert expected == actual
-
-
-def test_parse_common_location_path():
- expected = {
- "project": "scallop",
- "location": "abalone",
- }
- path = AuthorizedCertificatesClient.common_location_path(**expected)
-
- # Check that the path construction is reversible.
- actual = AuthorizedCertificatesClient.parse_common_location_path(path)
- assert expected == actual
-
-
-def test_client_with_default_client_info():
- client_info = gapic_v1.client_info.ClientInfo()
-
- with mock.patch.object(
- transports.AuthorizedCertificatesTransport, "_prep_wrapped_messages"
- ) as prep:
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
- with mock.patch.object(
- transports.AuthorizedCertificatesTransport, "_prep_wrapped_messages"
- ) as prep:
- transport_class = AuthorizedCertificatesClient.get_transport_class()
- transport = transport_class(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
-
-@pytest.mark.asyncio
-async def test_transport_close_async():
- client = AuthorizedCertificatesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- with mock.patch.object(
- type(getattr(client.transport, "grpc_channel")), "close"
- ) as close:
- async with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_transport_close():
- transports = {
- "rest": "_session",
- "grpc": "_grpc_channel",
- }
-
- for transport, close_name in transports.items():
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- with mock.patch.object(
- type(getattr(client.transport, close_name)), "close"
- ) as close:
- with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_client_ctx():
- transports = [
- "rest",
- "grpc",
- ]
- for transport in transports:
- client = AuthorizedCertificatesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- # Test client calls underlying transport.
- with mock.patch.object(type(client.transport), "close") as close:
- close.assert_not_called()
- with client:
- pass
- close.assert_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class",
- [
- (AuthorizedCertificatesClient, transports.AuthorizedCertificatesGrpcTransport),
- (
- AuthorizedCertificatesAsyncClient,
- transports.AuthorizedCertificatesGrpcAsyncIOTransport,
- ),
- ],
-)
-def test_api_key_credentials(client_class, transport_class):
- with mock.patch.object(
- google.auth._default, "get_api_key_credentials", create=True
- ) as get_api_key_credentials:
- mock_cred = mock.Mock()
- get_api_key_credentials.return_value = mock_cred
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options)
- patched.assert_called_once_with(
- credentials=mock_cred,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
diff --git a/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py b/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py
deleted file mode 100644
index 044ec94..0000000
--- a/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py
+++ /dev/null
@@ -1,2030 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import os
-
-# try/except added for compatibility with python < 3.8
-try:
- from unittest import mock
- from unittest.mock import AsyncMock # pragma: NO COVER
-except ImportError: # pragma: NO COVER
- import mock
-
-from collections.abc import Iterable
-import json
-import math
-
-from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template
-from google.api_core import client_options
-from google.api_core import exceptions as core_exceptions
-import google.auth
-from google.auth import credentials as ga_credentials
-from google.auth.exceptions import MutualTLSChannelError
-from google.oauth2 import service_account
-from google.protobuf import json_format
-import grpc
-from grpc.experimental import aio
-from proto.marshal.rules import wrappers
-from proto.marshal.rules.dates import DurationRule, TimestampRule
-import pytest
-from requests import PreparedRequest, Request, Response
-from requests.sessions import Session
-
-from google.cloud.appengine_admin_v1.services.authorized_domains import (
- AuthorizedDomainsAsyncClient,
- AuthorizedDomainsClient,
- pagers,
- transports,
-)
-from google.cloud.appengine_admin_v1.types import appengine, domain
-
-
-def client_cert_source_callback():
- return b"cert bytes", b"key bytes"
-
-
-# If default endpoint is localhost, then default mtls endpoint will be the same.
-# This method modifies the default endpoint so the client can produce a different
-# mtls endpoint for endpoint testing purposes.
-def modify_default_endpoint(client):
- return (
- "foo.googleapis.com"
- if ("localhost" in client.DEFAULT_ENDPOINT)
- else client.DEFAULT_ENDPOINT
- )
-
-
-def test__get_default_mtls_endpoint():
- api_endpoint = "example.googleapis.com"
- api_mtls_endpoint = "example.mtls.googleapis.com"
- sandbox_endpoint = "example.sandbox.googleapis.com"
- sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
- non_googleapi = "api.example.com"
-
- assert AuthorizedDomainsClient._get_default_mtls_endpoint(None) is None
- assert (
- AuthorizedDomainsClient._get_default_mtls_endpoint(api_endpoint)
- == api_mtls_endpoint
- )
- assert (
- AuthorizedDomainsClient._get_default_mtls_endpoint(api_mtls_endpoint)
- == api_mtls_endpoint
- )
- assert (
- AuthorizedDomainsClient._get_default_mtls_endpoint(sandbox_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- AuthorizedDomainsClient._get_default_mtls_endpoint(sandbox_mtls_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- AuthorizedDomainsClient._get_default_mtls_endpoint(non_googleapi)
- == non_googleapi
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (AuthorizedDomainsClient, "grpc"),
- (AuthorizedDomainsAsyncClient, "grpc_asyncio"),
- (AuthorizedDomainsClient, "rest"),
- ],
-)
-def test_authorized_domains_client_from_service_account_info(
- client_class, transport_name
-):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_info"
- ) as factory:
- factory.return_value = creds
- info = {"valid": True}
- client = client_class.from_service_account_info(info, transport=transport_name)
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,transport_name",
- [
- (transports.AuthorizedDomainsGrpcTransport, "grpc"),
- (transports.AuthorizedDomainsGrpcAsyncIOTransport, "grpc_asyncio"),
- (transports.AuthorizedDomainsRestTransport, "rest"),
- ],
-)
-def test_authorized_domains_client_service_account_always_use_jwt(
- transport_class, transport_name
-):
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=True)
- use_jwt.assert_called_once_with(True)
-
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=False)
- use_jwt.assert_not_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (AuthorizedDomainsClient, "grpc"),
- (AuthorizedDomainsAsyncClient, "grpc_asyncio"),
- (AuthorizedDomainsClient, "rest"),
- ],
-)
-def test_authorized_domains_client_from_service_account_file(
- client_class, transport_name
-):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_file"
- ) as factory:
- factory.return_value = creds
- client = client_class.from_service_account_file(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- client = client_class.from_service_account_json(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-def test_authorized_domains_client_get_transport_class():
- transport = AuthorizedDomainsClient.get_transport_class()
- available_transports = [
- transports.AuthorizedDomainsGrpcTransport,
- transports.AuthorizedDomainsRestTransport,
- ]
- assert transport in available_transports
-
- transport = AuthorizedDomainsClient.get_transport_class("grpc")
- assert transport == transports.AuthorizedDomainsGrpcTransport
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (AuthorizedDomainsClient, transports.AuthorizedDomainsGrpcTransport, "grpc"),
- (
- AuthorizedDomainsAsyncClient,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- "grpc_asyncio",
- ),
- (AuthorizedDomainsClient, transports.AuthorizedDomainsRestTransport, "rest"),
- ],
-)
-@mock.patch.object(
- AuthorizedDomainsClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedDomainsClient),
-)
-@mock.patch.object(
- AuthorizedDomainsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedDomainsAsyncClient),
-)
-def test_authorized_domains_client_client_options(
- client_class, transport_class, transport_name
-):
- # Check that if channel is provided we won't create a new one.
- with mock.patch.object(AuthorizedDomainsClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
- client = client_class(transport=transport)
- gtc.assert_not_called()
-
- # Check that if channel is provided via str we will create a new one.
- with mock.patch.object(AuthorizedDomainsClient, "get_transport_class") as gtc:
- client = client_class(transport=transport_name)
- gtc.assert_called()
-
- # Check the case api_endpoint is provided.
- options = client_options.ClientOptions(api_endpoint="squid.clam.whelk")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name, client_options=options)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_MTLS_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
- # unsupported value.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
- with pytest.raises(MutualTLSChannelError):
- client = client_class(transport=transport_name)
-
- # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
- ):
- with pytest.raises(ValueError):
- client = client_class(transport=transport_name)
-
- # Check the case quota_project_id is provided
- options = client_options.ClientOptions(quota_project_id="octopus")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id="octopus",
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
- # Check the case api_endpoint is provided
- options = client_options.ClientOptions(
- api_audience="https://language.googleapis.com"
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience="https://language.googleapis.com",
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,use_client_cert_env",
- [
- (
- AuthorizedDomainsClient,
- transports.AuthorizedDomainsGrpcTransport,
- "grpc",
- "true",
- ),
- (
- AuthorizedDomainsAsyncClient,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- "grpc_asyncio",
- "true",
- ),
- (
- AuthorizedDomainsClient,
- transports.AuthorizedDomainsGrpcTransport,
- "grpc",
- "false",
- ),
- (
- AuthorizedDomainsAsyncClient,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- "grpc_asyncio",
- "false",
- ),
- (
- AuthorizedDomainsClient,
- transports.AuthorizedDomainsRestTransport,
- "rest",
- "true",
- ),
- (
- AuthorizedDomainsClient,
- transports.AuthorizedDomainsRestTransport,
- "rest",
- "false",
- ),
- ],
-)
-@mock.patch.object(
- AuthorizedDomainsClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedDomainsClient),
-)
-@mock.patch.object(
- AuthorizedDomainsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedDomainsAsyncClient),
-)
-@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"})
-def test_authorized_domains_client_mtls_env_auto(
- client_class, transport_class, transport_name, use_client_cert_env
-):
- # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default
- # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists.
-
- # Check the case client_cert_source is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- options = client_options.ClientOptions(
- client_cert_source=client_cert_source_callback
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
-
- if use_client_cert_env == "false":
- expected_client_cert_source = None
- expected_host = client.DEFAULT_ENDPOINT
- else:
- expected_client_cert_source = client_cert_source_callback
- expected_host = client.DEFAULT_MTLS_ENDPOINT
-
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case ADC client cert is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=client_cert_source_callback,
- ):
- if use_client_cert_env == "false":
- expected_host = client.DEFAULT_ENDPOINT
- expected_client_cert_source = None
- else:
- expected_host = client.DEFAULT_MTLS_ENDPOINT
- expected_client_cert_source = client_cert_source_callback
-
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case client_cert_source and ADC client cert are not provided.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class", [AuthorizedDomainsClient, AuthorizedDomainsAsyncClient]
-)
-@mock.patch.object(
- AuthorizedDomainsClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedDomainsClient),
-)
-@mock.patch.object(
- AuthorizedDomainsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(AuthorizedDomainsAsyncClient),
-)
-def test_authorized_domains_client_get_mtls_endpoint_and_cert_source(client_class):
- mock_client_cert_source = mock.Mock()
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source == mock_client_cert_source
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
- mock_client_cert_source = mock.Mock()
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=mock_client_cert_source,
- ):
- (
- api_endpoint,
- cert_source,
- ) = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source == mock_client_cert_source
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (AuthorizedDomainsClient, transports.AuthorizedDomainsGrpcTransport, "grpc"),
- (
- AuthorizedDomainsAsyncClient,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- "grpc_asyncio",
- ),
- (AuthorizedDomainsClient, transports.AuthorizedDomainsRestTransport, "rest"),
- ],
-)
-def test_authorized_domains_client_client_options_scopes(
- client_class, transport_class, transport_name
-):
- # Check the case scopes are provided.
- options = client_options.ClientOptions(
- scopes=["1", "2"],
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=["1", "2"],
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (
- AuthorizedDomainsClient,
- transports.AuthorizedDomainsGrpcTransport,
- "grpc",
- grpc_helpers,
- ),
- (
- AuthorizedDomainsAsyncClient,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- (
- AuthorizedDomainsClient,
- transports.AuthorizedDomainsRestTransport,
- "rest",
- None,
- ),
- ],
-)
-def test_authorized_domains_client_client_options_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-def test_authorized_domains_client_client_options_from_dict():
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.authorized_domains.transports.AuthorizedDomainsGrpcTransport.__init__"
- ) as grpc_transport:
- grpc_transport.return_value = None
- client = AuthorizedDomainsClient(
- client_options={"api_endpoint": "squid.clam.whelk"}
- )
- grpc_transport.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (
- AuthorizedDomainsClient,
- transports.AuthorizedDomainsGrpcTransport,
- "grpc",
- grpc_helpers,
- ),
- (
- AuthorizedDomainsAsyncClient,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- ],
-)
-def test_authorized_domains_client_create_channel_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # test that the credentials from file are saved and used as the credentials.
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel"
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- file_creds = ga_credentials.AnonymousCredentials()
- load_creds.return_value = (file_creds, None)
- adc.return_value = (creds, None)
- client = client_class(client_options=options, transport=transport_name)
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=file_creds,
- credentials_file=None,
- quota_project_id=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=None,
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListAuthorizedDomainsRequest,
- dict,
- ],
-)
-def test_list_authorized_domains(request_type, transport: str = "grpc"):
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_domains), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = appengine.ListAuthorizedDomainsResponse(
- next_page_token="next_page_token_value",
- )
- response = client.list_authorized_domains(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListAuthorizedDomainsRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListAuthorizedDomainsPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-def test_list_authorized_domains_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_domains), "__call__"
- ) as call:
- client.list_authorized_domains()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListAuthorizedDomainsRequest()
-
-
-@pytest.mark.asyncio
-async def test_list_authorized_domains_async(
- transport: str = "grpc_asyncio", request_type=appengine.ListAuthorizedDomainsRequest
-):
- client = AuthorizedDomainsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_domains), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListAuthorizedDomainsResponse(
- next_page_token="next_page_token_value",
- )
- )
- response = await client.list_authorized_domains(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListAuthorizedDomainsRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListAuthorizedDomainsAsyncPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.asyncio
-async def test_list_authorized_domains_async_from_dict():
- await test_list_authorized_domains_async(request_type=dict)
-
-
-def test_list_authorized_domains_field_headers():
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListAuthorizedDomainsRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_domains), "__call__"
- ) as call:
- call.return_value = appengine.ListAuthorizedDomainsResponse()
- client.list_authorized_domains(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_list_authorized_domains_field_headers_async():
- client = AuthorizedDomainsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListAuthorizedDomainsRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_domains), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListAuthorizedDomainsResponse()
- )
- await client.list_authorized_domains(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-def test_list_authorized_domains_pager(transport_name: str = "grpc"):
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_domains), "__call__"
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- ],
- next_page_token="abc",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[],
- next_page_token="def",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- ],
- ),
- RuntimeError,
- )
-
- metadata = ()
- metadata = tuple(metadata) + (
- gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)),
- )
- pager = client.list_authorized_domains(request={})
-
- assert pager._metadata == metadata
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, domain.AuthorizedDomain) for i in results)
-
-
-def test_list_authorized_domains_pages(transport_name: str = "grpc"):
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_domains), "__call__"
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- ],
- next_page_token="abc",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[],
- next_page_token="def",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- ],
- ),
- RuntimeError,
- )
- pages = list(client.list_authorized_domains(request={}).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.asyncio
-async def test_list_authorized_domains_async_pager():
- client = AuthorizedDomainsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_domains),
- "__call__",
- new_callable=mock.AsyncMock,
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- ],
- next_page_token="abc",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[],
- next_page_token="def",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- ],
- ),
- RuntimeError,
- )
- async_pager = await client.list_authorized_domains(
- request={},
- )
- assert async_pager.next_page_token == "abc"
- responses = []
- async for response in async_pager: # pragma: no branch
- responses.append(response)
-
- assert len(responses) == 6
- assert all(isinstance(i, domain.AuthorizedDomain) for i in responses)
-
-
-@pytest.mark.asyncio
-async def test_list_authorized_domains_async_pages():
- client = AuthorizedDomainsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_authorized_domains),
- "__call__",
- new_callable=mock.AsyncMock,
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- ],
- next_page_token="abc",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[],
- next_page_token="def",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- ],
- ),
- RuntimeError,
- )
- pages = []
- # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
- # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
- async for page_ in ( # pragma: no branch
- await client.list_authorized_domains(request={})
- ).pages:
- pages.append(page_)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListAuthorizedDomainsRequest,
- dict,
- ],
-)
-def test_list_authorized_domains_rest(request_type):
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = appengine.ListAuthorizedDomainsResponse(
- next_page_token="next_page_token_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = appengine.ListAuthorizedDomainsResponse.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.list_authorized_domains(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListAuthorizedDomainsPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_list_authorized_domains_rest_interceptors(null_interceptor):
- transport = transports.AuthorizedDomainsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.AuthorizedDomainsRestInterceptor(),
- )
- client = AuthorizedDomainsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.AuthorizedDomainsRestInterceptor, "post_list_authorized_domains"
- ) as post, mock.patch.object(
- transports.AuthorizedDomainsRestInterceptor, "pre_list_authorized_domains"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.ListAuthorizedDomainsRequest.pb(
- appengine.ListAuthorizedDomainsRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = appengine.ListAuthorizedDomainsResponse.to_json(
- appengine.ListAuthorizedDomainsResponse()
- )
-
- request = appengine.ListAuthorizedDomainsRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = appengine.ListAuthorizedDomainsResponse()
-
- client.list_authorized_domains(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_list_authorized_domains_rest_bad_request(
- transport: str = "rest", request_type=appengine.ListAuthorizedDomainsRequest
-):
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.list_authorized_domains(request)
-
-
-def test_list_authorized_domains_rest_pager(transport: str = "rest"):
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(Session, "request") as req:
- # TODO(kbandes): remove this mock unless there's a good reason for it.
- # with mock.patch.object(path_template, 'transcode') as transcode:
- # Set the response as a series of pages
- response = (
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- ],
- next_page_token="abc",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[],
- next_page_token="def",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListAuthorizedDomainsResponse(
- domains=[
- domain.AuthorizedDomain(),
- domain.AuthorizedDomain(),
- ],
- ),
- )
- # Two responses for two calls
- response = response + response
-
- # Wrap the values into proper Response objs
- response = tuple(
- appengine.ListAuthorizedDomainsResponse.to_json(x) for x in response
- )
- return_values = tuple(Response() for i in response)
- for return_val, response_val in zip(return_values, response):
- return_val._content = response_val.encode("UTF-8")
- return_val.status_code = 200
- req.side_effect = return_values
-
- sample_request = {"parent": "apps/sample1"}
-
- pager = client.list_authorized_domains(request=sample_request)
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, domain.AuthorizedDomain) for i in results)
-
- pages = list(client.list_authorized_domains(request=sample_request).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-def test_credentials_transport_error():
- # It is an error to provide credentials and a transport instance.
- transport = transports.AuthorizedDomainsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # It is an error to provide a credentials file and a transport instance.
- transport = transports.AuthorizedDomainsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = AuthorizedDomainsClient(
- client_options={"credentials_file": "credentials.json"},
- transport=transport,
- )
-
- # It is an error to provide an api_key and a transport instance.
- transport = transports.AuthorizedDomainsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = AuthorizedDomainsClient(
- client_options=options,
- transport=transport,
- )
-
- # It is an error to provide an api_key and a credential.
- options = mock.Mock()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = AuthorizedDomainsClient(
- client_options=options, credentials=ga_credentials.AnonymousCredentials()
- )
-
- # It is an error to provide scopes and a transport instance.
- transport = transports.AuthorizedDomainsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = AuthorizedDomainsClient(
- client_options={"scopes": ["1", "2"]},
- transport=transport,
- )
-
-
-def test_transport_instance():
- # A client may be instantiated with a custom transport instance.
- transport = transports.AuthorizedDomainsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- client = AuthorizedDomainsClient(transport=transport)
- assert client.transport is transport
-
-
-def test_transport_get_channel():
- # A client may be instantiated with a custom transport instance.
- transport = transports.AuthorizedDomainsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
- transport = transports.AuthorizedDomainsGrpcAsyncIOTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedDomainsGrpcTransport,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- transports.AuthorizedDomainsRestTransport,
- ],
-)
-def test_transport_adc(transport_class):
- # Test default credentials are used if not provided.
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class()
- adc.assert_called_once()
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "rest",
- ],
-)
-def test_transport_kind(transport_name):
- transport = AuthorizedDomainsClient.get_transport_class(transport_name)(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert transport.kind == transport_name
-
-
-def test_transport_grpc_default():
- # A client should use the gRPC transport by default.
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert isinstance(
- client.transport,
- transports.AuthorizedDomainsGrpcTransport,
- )
-
-
-def test_authorized_domains_base_transport_error():
- # Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(core_exceptions.DuplicateCredentialArgs):
- transport = transports.AuthorizedDomainsTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- credentials_file="credentials.json",
- )
-
-
-def test_authorized_domains_base_transport():
- # Instantiate the base transport.
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.authorized_domains.transports.AuthorizedDomainsTransport.__init__"
- ) as Transport:
- Transport.return_value = None
- transport = transports.AuthorizedDomainsTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Every method on the transport should just blindly
- # raise NotImplementedError.
- methods = ("list_authorized_domains",)
- for method in methods:
- with pytest.raises(NotImplementedError):
- getattr(transport, method)(request=object())
-
- with pytest.raises(NotImplementedError):
- transport.close()
-
- # Catch all for all remaining methods and properties
- remainder = [
- "kind",
- ]
- for r in remainder:
- with pytest.raises(NotImplementedError):
- getattr(transport, r)()
-
-
-def test_authorized_domains_base_transport_with_credentials_file():
- # Instantiate the base transport with a credentials file
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch(
- "google.cloud.appengine_admin_v1.services.authorized_domains.transports.AuthorizedDomainsTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.AuthorizedDomainsTransport(
- credentials_file="credentials.json",
- quota_project_id="octopus",
- )
- load_creds.assert_called_once_with(
- "credentials.json",
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-def test_authorized_domains_base_transport_with_adc():
- # Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
- "google.cloud.appengine_admin_v1.services.authorized_domains.transports.AuthorizedDomainsTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.AuthorizedDomainsTransport()
- adc.assert_called_once()
-
-
-def test_authorized_domains_auth_adc():
- # If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- AuthorizedDomainsClient()
- adc.assert_called_once_with(
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id=None,
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedDomainsGrpcTransport,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- ],
-)
-def test_authorized_domains_transport_auth_adc(transport_class):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
- adc.assert_called_once_with(
- scopes=["1", "2"],
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedDomainsGrpcTransport,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- transports.AuthorizedDomainsRestTransport,
- ],
-)
-def test_authorized_domains_transport_auth_gdch_credentials(transport_class):
- host = "https://language.com"
- api_audience_tests = [None, "https://language2.com"]
- api_audience_expect = [host, "https://language2.com"]
- for t, e in zip(api_audience_tests, api_audience_expect):
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- gdch_mock = mock.MagicMock()
- type(gdch_mock).with_gdch_audience = mock.PropertyMock(
- return_value=gdch_mock
- )
- adc.return_value = (gdch_mock, None)
- transport_class(host=host, api_audience=t)
- gdch_mock.with_gdch_audience.assert_called_once_with(e)
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.AuthorizedDomainsGrpcTransport, grpc_helpers),
- (transports.AuthorizedDomainsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-def test_authorized_domains_transport_create_channel(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=["1", "2"],
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedDomainsGrpcTransport,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- ],
-)
-def test_authorized_domains_grpc_transport_client_cert_source_for_mtls(transport_class):
- cred = ga_credentials.AnonymousCredentials()
-
- # Check ssl_channel_credentials is used if provided.
- with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
- mock_ssl_channel_creds = mock.Mock()
- transport_class(
- host="squid.clam.whelk",
- credentials=cred,
- ssl_channel_credentials=mock_ssl_channel_creds,
- )
- mock_create_channel.assert_called_once_with(
- "squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_channel_creds,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
- # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls
- # is used.
- with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()):
- with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred:
- transport_class(
- credentials=cred,
- client_cert_source_for_mtls=client_cert_source_callback,
- )
- expected_cert, expected_key = client_cert_source_callback()
- mock_ssl_cred.assert_called_once_with(
- certificate_chain=expected_cert, private_key=expected_key
- )
-
-
-def test_authorized_domains_http_transport_client_cert_source_for_mtls():
- cred = ga_credentials.AnonymousCredentials()
- with mock.patch(
- "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"
- ) as mock_configure_mtls_channel:
- transports.AuthorizedDomainsRestTransport(
- credentials=cred, client_cert_source_for_mtls=client_cert_source_callback
- )
- mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback)
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_authorized_domains_host_no_port(transport_name):
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_authorized_domains_host_with_port(transport_name):
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com:8000"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:8000"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com:8000"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "rest",
- ],
-)
-def test_authorized_domains_client_transport_session_collision(transport_name):
- creds1 = ga_credentials.AnonymousCredentials()
- creds2 = ga_credentials.AnonymousCredentials()
- client1 = AuthorizedDomainsClient(
- credentials=creds1,
- transport=transport_name,
- )
- client2 = AuthorizedDomainsClient(
- credentials=creds2,
- transport=transport_name,
- )
- session1 = client1.transport.list_authorized_domains._session
- session2 = client2.transport.list_authorized_domains._session
- assert session1 != session2
-
-
-def test_authorized_domains_grpc_transport_channel():
- channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.AuthorizedDomainsGrpcTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-def test_authorized_domains_grpc_asyncio_transport_channel():
- channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.AuthorizedDomainsGrpcAsyncIOTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedDomainsGrpcTransport,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- ],
-)
-def test_authorized_domains_transport_channel_mtls_with_client_cert_source(
- transport_class,
-):
- with mock.patch(
- "grpc.ssl_channel_credentials", autospec=True
- ) as grpc_ssl_channel_cred:
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_ssl_cred = mock.Mock()
- grpc_ssl_channel_cred.return_value = mock_ssl_cred
-
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
-
- cred = ga_credentials.AnonymousCredentials()
- with pytest.warns(DeprecationWarning):
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (cred, None)
- transport = transport_class(
- host="squid.clam.whelk",
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=client_cert_source_callback,
- )
- adc.assert_called_once()
-
- grpc_ssl_channel_cred.assert_called_once_with(
- certificate_chain=b"cert bytes", private_key=b"key bytes"
- )
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
- assert transport._ssl_channel_credentials == mock_ssl_cred
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.AuthorizedDomainsGrpcTransport,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- ],
-)
-def test_authorized_domains_transport_channel_mtls_with_adc(transport_class):
- mock_ssl_cred = mock.Mock()
- with mock.patch.multiple(
- "google.auth.transport.grpc.SslCredentials",
- __init__=mock.Mock(return_value=None),
- ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
- ):
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
- mock_cred = mock.Mock()
-
- with pytest.warns(DeprecationWarning):
- transport = transport_class(
- host="squid.clam.whelk",
- credentials=mock_cred,
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=None,
- )
-
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=mock_cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
-
-
-def test_common_billing_account_path():
- billing_account = "squid"
- expected = "billingAccounts/{billing_account}".format(
- billing_account=billing_account,
- )
- actual = AuthorizedDomainsClient.common_billing_account_path(billing_account)
- assert expected == actual
-
-
-def test_parse_common_billing_account_path():
- expected = {
- "billing_account": "clam",
- }
- path = AuthorizedDomainsClient.common_billing_account_path(**expected)
-
- # Check that the path construction is reversible.
- actual = AuthorizedDomainsClient.parse_common_billing_account_path(path)
- assert expected == actual
-
-
-def test_common_folder_path():
- folder = "whelk"
- expected = "folders/{folder}".format(
- folder=folder,
- )
- actual = AuthorizedDomainsClient.common_folder_path(folder)
- assert expected == actual
-
-
-def test_parse_common_folder_path():
- expected = {
- "folder": "octopus",
- }
- path = AuthorizedDomainsClient.common_folder_path(**expected)
-
- # Check that the path construction is reversible.
- actual = AuthorizedDomainsClient.parse_common_folder_path(path)
- assert expected == actual
-
-
-def test_common_organization_path():
- organization = "oyster"
- expected = "organizations/{organization}".format(
- organization=organization,
- )
- actual = AuthorizedDomainsClient.common_organization_path(organization)
- assert expected == actual
-
-
-def test_parse_common_organization_path():
- expected = {
- "organization": "nudibranch",
- }
- path = AuthorizedDomainsClient.common_organization_path(**expected)
-
- # Check that the path construction is reversible.
- actual = AuthorizedDomainsClient.parse_common_organization_path(path)
- assert expected == actual
-
-
-def test_common_project_path():
- project = "cuttlefish"
- expected = "projects/{project}".format(
- project=project,
- )
- actual = AuthorizedDomainsClient.common_project_path(project)
- assert expected == actual
-
-
-def test_parse_common_project_path():
- expected = {
- "project": "mussel",
- }
- path = AuthorizedDomainsClient.common_project_path(**expected)
-
- # Check that the path construction is reversible.
- actual = AuthorizedDomainsClient.parse_common_project_path(path)
- assert expected == actual
-
-
-def test_common_location_path():
- project = "winkle"
- location = "nautilus"
- expected = "projects/{project}/locations/{location}".format(
- project=project,
- location=location,
- )
- actual = AuthorizedDomainsClient.common_location_path(project, location)
- assert expected == actual
-
-
-def test_parse_common_location_path():
- expected = {
- "project": "scallop",
- "location": "abalone",
- }
- path = AuthorizedDomainsClient.common_location_path(**expected)
-
- # Check that the path construction is reversible.
- actual = AuthorizedDomainsClient.parse_common_location_path(path)
- assert expected == actual
-
-
-def test_client_with_default_client_info():
- client_info = gapic_v1.client_info.ClientInfo()
-
- with mock.patch.object(
- transports.AuthorizedDomainsTransport, "_prep_wrapped_messages"
- ) as prep:
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
- with mock.patch.object(
- transports.AuthorizedDomainsTransport, "_prep_wrapped_messages"
- ) as prep:
- transport_class = AuthorizedDomainsClient.get_transport_class()
- transport = transport_class(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
-
-@pytest.mark.asyncio
-async def test_transport_close_async():
- client = AuthorizedDomainsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- with mock.patch.object(
- type(getattr(client.transport, "grpc_channel")), "close"
- ) as close:
- async with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_transport_close():
- transports = {
- "rest": "_session",
- "grpc": "_grpc_channel",
- }
-
- for transport, close_name in transports.items():
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- with mock.patch.object(
- type(getattr(client.transport, close_name)), "close"
- ) as close:
- with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_client_ctx():
- transports = [
- "rest",
- "grpc",
- ]
- for transport in transports:
- client = AuthorizedDomainsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- # Test client calls underlying transport.
- with mock.patch.object(type(client.transport), "close") as close:
- close.assert_not_called()
- with client:
- pass
- close.assert_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class",
- [
- (AuthorizedDomainsClient, transports.AuthorizedDomainsGrpcTransport),
- (
- AuthorizedDomainsAsyncClient,
- transports.AuthorizedDomainsGrpcAsyncIOTransport,
- ),
- ],
-)
-def test_api_key_credentials(client_class, transport_class):
- with mock.patch.object(
- google.auth._default, "get_api_key_credentials", create=True
- ) as get_api_key_credentials:
- mock_cred = mock.Mock()
- get_api_key_credentials.return_value = mock_cred
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options)
- patched.assert_called_once_with(
- credentials=mock_cred,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
diff --git a/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py b/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py
deleted file mode 100644
index 5e2ff40..0000000
--- a/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py
+++ /dev/null
@@ -1,3369 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import os
-
-# try/except added for compatibility with python < 3.8
-try:
- from unittest import mock
- from unittest.mock import AsyncMock # pragma: NO COVER
-except ImportError: # pragma: NO COVER
- import mock
-
-from collections.abc import Iterable
-import json
-import math
-
-from google.api_core import (
- future,
- gapic_v1,
- grpc_helpers,
- grpc_helpers_async,
- operation,
- operations_v1,
- path_template,
-)
-from google.api_core import client_options
-from google.api_core import exceptions as core_exceptions
-from google.api_core import operation_async # type: ignore
-import google.auth
-from google.auth import credentials as ga_credentials
-from google.auth.exceptions import MutualTLSChannelError
-from google.longrunning import operations_pb2 # type: ignore
-from google.oauth2 import service_account
-from google.protobuf import empty_pb2 # type: ignore
-from google.protobuf import field_mask_pb2 # type: ignore
-from google.protobuf import json_format
-import grpc
-from grpc.experimental import aio
-from proto.marshal.rules import wrappers
-from proto.marshal.rules.dates import DurationRule, TimestampRule
-import pytest
-from requests import PreparedRequest, Request, Response
-from requests.sessions import Session
-
-from google.cloud.appengine_admin_v1.services.domain_mappings import (
- DomainMappingsAsyncClient,
- DomainMappingsClient,
- pagers,
- transports,
-)
-from google.cloud.appengine_admin_v1.types import appengine, domain_mapping
-from google.cloud.appengine_admin_v1.types import operation as ga_operation
-
-
-def client_cert_source_callback():
- return b"cert bytes", b"key bytes"
-
-
-# If default endpoint is localhost, then default mtls endpoint will be the same.
-# This method modifies the default endpoint so the client can produce a different
-# mtls endpoint for endpoint testing purposes.
-def modify_default_endpoint(client):
- return (
- "foo.googleapis.com"
- if ("localhost" in client.DEFAULT_ENDPOINT)
- else client.DEFAULT_ENDPOINT
- )
-
-
-def test__get_default_mtls_endpoint():
- api_endpoint = "example.googleapis.com"
- api_mtls_endpoint = "example.mtls.googleapis.com"
- sandbox_endpoint = "example.sandbox.googleapis.com"
- sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
- non_googleapi = "api.example.com"
-
- assert DomainMappingsClient._get_default_mtls_endpoint(None) is None
- assert (
- DomainMappingsClient._get_default_mtls_endpoint(api_endpoint)
- == api_mtls_endpoint
- )
- assert (
- DomainMappingsClient._get_default_mtls_endpoint(api_mtls_endpoint)
- == api_mtls_endpoint
- )
- assert (
- DomainMappingsClient._get_default_mtls_endpoint(sandbox_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- DomainMappingsClient._get_default_mtls_endpoint(sandbox_mtls_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- DomainMappingsClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (DomainMappingsClient, "grpc"),
- (DomainMappingsAsyncClient, "grpc_asyncio"),
- (DomainMappingsClient, "rest"),
- ],
-)
-def test_domain_mappings_client_from_service_account_info(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_info"
- ) as factory:
- factory.return_value = creds
- info = {"valid": True}
- client = client_class.from_service_account_info(info, transport=transport_name)
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,transport_name",
- [
- (transports.DomainMappingsGrpcTransport, "grpc"),
- (transports.DomainMappingsGrpcAsyncIOTransport, "grpc_asyncio"),
- (transports.DomainMappingsRestTransport, "rest"),
- ],
-)
-def test_domain_mappings_client_service_account_always_use_jwt(
- transport_class, transport_name
-):
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=True)
- use_jwt.assert_called_once_with(True)
-
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=False)
- use_jwt.assert_not_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (DomainMappingsClient, "grpc"),
- (DomainMappingsAsyncClient, "grpc_asyncio"),
- (DomainMappingsClient, "rest"),
- ],
-)
-def test_domain_mappings_client_from_service_account_file(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_file"
- ) as factory:
- factory.return_value = creds
- client = client_class.from_service_account_file(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- client = client_class.from_service_account_json(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-def test_domain_mappings_client_get_transport_class():
- transport = DomainMappingsClient.get_transport_class()
- available_transports = [
- transports.DomainMappingsGrpcTransport,
- transports.DomainMappingsRestTransport,
- ]
- assert transport in available_transports
-
- transport = DomainMappingsClient.get_transport_class("grpc")
- assert transport == transports.DomainMappingsGrpcTransport
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (DomainMappingsClient, transports.DomainMappingsGrpcTransport, "grpc"),
- (
- DomainMappingsAsyncClient,
- transports.DomainMappingsGrpcAsyncIOTransport,
- "grpc_asyncio",
- ),
- (DomainMappingsClient, transports.DomainMappingsRestTransport, "rest"),
- ],
-)
-@mock.patch.object(
- DomainMappingsClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(DomainMappingsClient),
-)
-@mock.patch.object(
- DomainMappingsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(DomainMappingsAsyncClient),
-)
-def test_domain_mappings_client_client_options(
- client_class, transport_class, transport_name
-):
- # Check that if channel is provided we won't create a new one.
- with mock.patch.object(DomainMappingsClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
- client = client_class(transport=transport)
- gtc.assert_not_called()
-
- # Check that if channel is provided via str we will create a new one.
- with mock.patch.object(DomainMappingsClient, "get_transport_class") as gtc:
- client = client_class(transport=transport_name)
- gtc.assert_called()
-
- # Check the case api_endpoint is provided.
- options = client_options.ClientOptions(api_endpoint="squid.clam.whelk")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name, client_options=options)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_MTLS_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
- # unsupported value.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
- with pytest.raises(MutualTLSChannelError):
- client = client_class(transport=transport_name)
-
- # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
- ):
- with pytest.raises(ValueError):
- client = client_class(transport=transport_name)
-
- # Check the case quota_project_id is provided
- options = client_options.ClientOptions(quota_project_id="octopus")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id="octopus",
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
- # Check the case api_endpoint is provided
- options = client_options.ClientOptions(
- api_audience="https://language.googleapis.com"
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience="https://language.googleapis.com",
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,use_client_cert_env",
- [
- (DomainMappingsClient, transports.DomainMappingsGrpcTransport, "grpc", "true"),
- (
- DomainMappingsAsyncClient,
- transports.DomainMappingsGrpcAsyncIOTransport,
- "grpc_asyncio",
- "true",
- ),
- (DomainMappingsClient, transports.DomainMappingsGrpcTransport, "grpc", "false"),
- (
- DomainMappingsAsyncClient,
- transports.DomainMappingsGrpcAsyncIOTransport,
- "grpc_asyncio",
- "false",
- ),
- (DomainMappingsClient, transports.DomainMappingsRestTransport, "rest", "true"),
- (DomainMappingsClient, transports.DomainMappingsRestTransport, "rest", "false"),
- ],
-)
-@mock.patch.object(
- DomainMappingsClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(DomainMappingsClient),
-)
-@mock.patch.object(
- DomainMappingsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(DomainMappingsAsyncClient),
-)
-@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"})
-def test_domain_mappings_client_mtls_env_auto(
- client_class, transport_class, transport_name, use_client_cert_env
-):
- # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default
- # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists.
-
- # Check the case client_cert_source is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- options = client_options.ClientOptions(
- client_cert_source=client_cert_source_callback
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
-
- if use_client_cert_env == "false":
- expected_client_cert_source = None
- expected_host = client.DEFAULT_ENDPOINT
- else:
- expected_client_cert_source = client_cert_source_callback
- expected_host = client.DEFAULT_MTLS_ENDPOINT
-
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case ADC client cert is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=client_cert_source_callback,
- ):
- if use_client_cert_env == "false":
- expected_host = client.DEFAULT_ENDPOINT
- expected_client_cert_source = None
- else:
- expected_host = client.DEFAULT_MTLS_ENDPOINT
- expected_client_cert_source = client_cert_source_callback
-
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case client_cert_source and ADC client cert are not provided.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class", [DomainMappingsClient, DomainMappingsAsyncClient]
-)
-@mock.patch.object(
- DomainMappingsClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(DomainMappingsClient),
-)
-@mock.patch.object(
- DomainMappingsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(DomainMappingsAsyncClient),
-)
-def test_domain_mappings_client_get_mtls_endpoint_and_cert_source(client_class):
- mock_client_cert_source = mock.Mock()
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source == mock_client_cert_source
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
- mock_client_cert_source = mock.Mock()
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=mock_client_cert_source,
- ):
- (
- api_endpoint,
- cert_source,
- ) = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source == mock_client_cert_source
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (DomainMappingsClient, transports.DomainMappingsGrpcTransport, "grpc"),
- (
- DomainMappingsAsyncClient,
- transports.DomainMappingsGrpcAsyncIOTransport,
- "grpc_asyncio",
- ),
- (DomainMappingsClient, transports.DomainMappingsRestTransport, "rest"),
- ],
-)
-def test_domain_mappings_client_client_options_scopes(
- client_class, transport_class, transport_name
-):
- # Check the case scopes are provided.
- options = client_options.ClientOptions(
- scopes=["1", "2"],
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=["1", "2"],
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (
- DomainMappingsClient,
- transports.DomainMappingsGrpcTransport,
- "grpc",
- grpc_helpers,
- ),
- (
- DomainMappingsAsyncClient,
- transports.DomainMappingsGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- (DomainMappingsClient, transports.DomainMappingsRestTransport, "rest", None),
- ],
-)
-def test_domain_mappings_client_client_options_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-def test_domain_mappings_client_client_options_from_dict():
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.domain_mappings.transports.DomainMappingsGrpcTransport.__init__"
- ) as grpc_transport:
- grpc_transport.return_value = None
- client = DomainMappingsClient(
- client_options={"api_endpoint": "squid.clam.whelk"}
- )
- grpc_transport.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (
- DomainMappingsClient,
- transports.DomainMappingsGrpcTransport,
- "grpc",
- grpc_helpers,
- ),
- (
- DomainMappingsAsyncClient,
- transports.DomainMappingsGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- ],
-)
-def test_domain_mappings_client_create_channel_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # test that the credentials from file are saved and used as the credentials.
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel"
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- file_creds = ga_credentials.AnonymousCredentials()
- load_creds.return_value = (file_creds, None)
- adc.return_value = (creds, None)
- client = client_class(client_options=options, transport=transport_name)
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=file_creds,
- credentials_file=None,
- quota_project_id=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=None,
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListDomainMappingsRequest,
- dict,
- ],
-)
-def test_list_domain_mappings(request_type, transport: str = "grpc"):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_domain_mappings), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = appengine.ListDomainMappingsResponse(
- next_page_token="next_page_token_value",
- )
- response = client.list_domain_mappings(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListDomainMappingsRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListDomainMappingsPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-def test_list_domain_mappings_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_domain_mappings), "__call__"
- ) as call:
- client.list_domain_mappings()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListDomainMappingsRequest()
-
-
-@pytest.mark.asyncio
-async def test_list_domain_mappings_async(
- transport: str = "grpc_asyncio", request_type=appengine.ListDomainMappingsRequest
-):
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_domain_mappings), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListDomainMappingsResponse(
- next_page_token="next_page_token_value",
- )
- )
- response = await client.list_domain_mappings(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListDomainMappingsRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListDomainMappingsAsyncPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.asyncio
-async def test_list_domain_mappings_async_from_dict():
- await test_list_domain_mappings_async(request_type=dict)
-
-
-def test_list_domain_mappings_field_headers():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListDomainMappingsRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_domain_mappings), "__call__"
- ) as call:
- call.return_value = appengine.ListDomainMappingsResponse()
- client.list_domain_mappings(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_list_domain_mappings_field_headers_async():
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListDomainMappingsRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_domain_mappings), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListDomainMappingsResponse()
- )
- await client.list_domain_mappings(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-def test_list_domain_mappings_pager(transport_name: str = "grpc"):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_domain_mappings), "__call__"
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- ],
- next_page_token="abc",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[],
- next_page_token="def",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- ],
- ),
- RuntimeError,
- )
-
- metadata = ()
- metadata = tuple(metadata) + (
- gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)),
- )
- pager = client.list_domain_mappings(request={})
-
- assert pager._metadata == metadata
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, domain_mapping.DomainMapping) for i in results)
-
-
-def test_list_domain_mappings_pages(transport_name: str = "grpc"):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_domain_mappings), "__call__"
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- ],
- next_page_token="abc",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[],
- next_page_token="def",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- ],
- ),
- RuntimeError,
- )
- pages = list(client.list_domain_mappings(request={}).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.asyncio
-async def test_list_domain_mappings_async_pager():
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_domain_mappings),
- "__call__",
- new_callable=mock.AsyncMock,
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- ],
- next_page_token="abc",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[],
- next_page_token="def",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- ],
- ),
- RuntimeError,
- )
- async_pager = await client.list_domain_mappings(
- request={},
- )
- assert async_pager.next_page_token == "abc"
- responses = []
- async for response in async_pager: # pragma: no branch
- responses.append(response)
-
- assert len(responses) == 6
- assert all(isinstance(i, domain_mapping.DomainMapping) for i in responses)
-
-
-@pytest.mark.asyncio
-async def test_list_domain_mappings_async_pages():
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_domain_mappings),
- "__call__",
- new_callable=mock.AsyncMock,
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- ],
- next_page_token="abc",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[],
- next_page_token="def",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- ],
- ),
- RuntimeError,
- )
- pages = []
- # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
- # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
- async for page_ in ( # pragma: no branch
- await client.list_domain_mappings(request={})
- ).pages:
- pages.append(page_)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetDomainMappingRequest,
- dict,
- ],
-)
-def test_get_domain_mapping(request_type, transport: str = "grpc"):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.get_domain_mapping), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = domain_mapping.DomainMapping(
- name="name_value",
- id="id_value",
- )
- response = client.get_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetDomainMappingRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, domain_mapping.DomainMapping)
- assert response.name == "name_value"
- assert response.id == "id_value"
-
-
-def test_get_domain_mapping_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.get_domain_mapping), "__call__"
- ) as call:
- client.get_domain_mapping()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetDomainMappingRequest()
-
-
-@pytest.mark.asyncio
-async def test_get_domain_mapping_async(
- transport: str = "grpc_asyncio", request_type=appengine.GetDomainMappingRequest
-):
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.get_domain_mapping), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- domain_mapping.DomainMapping(
- name="name_value",
- id="id_value",
- )
- )
- response = await client.get_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetDomainMappingRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, domain_mapping.DomainMapping)
- assert response.name == "name_value"
- assert response.id == "id_value"
-
-
-@pytest.mark.asyncio
-async def test_get_domain_mapping_async_from_dict():
- await test_get_domain_mapping_async(request_type=dict)
-
-
-def test_get_domain_mapping_field_headers():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetDomainMappingRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.get_domain_mapping), "__call__"
- ) as call:
- call.return_value = domain_mapping.DomainMapping()
- client.get_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_get_domain_mapping_field_headers_async():
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetDomainMappingRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.get_domain_mapping), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- domain_mapping.DomainMapping()
- )
- await client.get_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.CreateDomainMappingRequest,
- dict,
- ],
-)
-def test_create_domain_mapping(request_type, transport: str = "grpc"):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_domain_mapping), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.create_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateDomainMappingRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_create_domain_mapping_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_domain_mapping), "__call__"
- ) as call:
- client.create_domain_mapping()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateDomainMappingRequest()
-
-
-@pytest.mark.asyncio
-async def test_create_domain_mapping_async(
- transport: str = "grpc_asyncio", request_type=appengine.CreateDomainMappingRequest
-):
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_domain_mapping), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.create_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateDomainMappingRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_create_domain_mapping_async_from_dict():
- await test_create_domain_mapping_async(request_type=dict)
-
-
-def test_create_domain_mapping_field_headers():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.CreateDomainMappingRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_domain_mapping), "__call__"
- ) as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.create_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_create_domain_mapping_field_headers_async():
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.CreateDomainMappingRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_domain_mapping), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.create_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateDomainMappingRequest,
- dict,
- ],
-)
-def test_update_domain_mapping(request_type, transport: str = "grpc"):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_domain_mapping), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.update_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateDomainMappingRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_update_domain_mapping_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_domain_mapping), "__call__"
- ) as call:
- client.update_domain_mapping()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateDomainMappingRequest()
-
-
-@pytest.mark.asyncio
-async def test_update_domain_mapping_async(
- transport: str = "grpc_asyncio", request_type=appengine.UpdateDomainMappingRequest
-):
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_domain_mapping), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.update_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateDomainMappingRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_update_domain_mapping_async_from_dict():
- await test_update_domain_mapping_async(request_type=dict)
-
-
-def test_update_domain_mapping_field_headers():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateDomainMappingRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_domain_mapping), "__call__"
- ) as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.update_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_update_domain_mapping_field_headers_async():
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateDomainMappingRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_domain_mapping), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.update_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteDomainMappingRequest,
- dict,
- ],
-)
-def test_delete_domain_mapping(request_type, transport: str = "grpc"):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_domain_mapping), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.delete_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteDomainMappingRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_delete_domain_mapping_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_domain_mapping), "__call__"
- ) as call:
- client.delete_domain_mapping()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteDomainMappingRequest()
-
-
-@pytest.mark.asyncio
-async def test_delete_domain_mapping_async(
- transport: str = "grpc_asyncio", request_type=appengine.DeleteDomainMappingRequest
-):
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_domain_mapping), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.delete_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteDomainMappingRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_delete_domain_mapping_async_from_dict():
- await test_delete_domain_mapping_async(request_type=dict)
-
-
-def test_delete_domain_mapping_field_headers():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteDomainMappingRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_domain_mapping), "__call__"
- ) as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.delete_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_delete_domain_mapping_field_headers_async():
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteDomainMappingRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_domain_mapping), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.delete_domain_mapping(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListDomainMappingsRequest,
- dict,
- ],
-)
-def test_list_domain_mappings_rest(request_type):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = appengine.ListDomainMappingsResponse(
- next_page_token="next_page_token_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = appengine.ListDomainMappingsResponse.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.list_domain_mappings(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListDomainMappingsPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_list_domain_mappings_rest_interceptors(null_interceptor):
- transport = transports.DomainMappingsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.DomainMappingsRestInterceptor(),
- )
- client = DomainMappingsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.DomainMappingsRestInterceptor, "post_list_domain_mappings"
- ) as post, mock.patch.object(
- transports.DomainMappingsRestInterceptor, "pre_list_domain_mappings"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.ListDomainMappingsRequest.pb(
- appengine.ListDomainMappingsRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = appengine.ListDomainMappingsResponse.to_json(
- appengine.ListDomainMappingsResponse()
- )
-
- request = appengine.ListDomainMappingsRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = appengine.ListDomainMappingsResponse()
-
- client.list_domain_mappings(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_list_domain_mappings_rest_bad_request(
- transport: str = "rest", request_type=appengine.ListDomainMappingsRequest
-):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.list_domain_mappings(request)
-
-
-def test_list_domain_mappings_rest_pager(transport: str = "rest"):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(Session, "request") as req:
- # TODO(kbandes): remove this mock unless there's a good reason for it.
- # with mock.patch.object(path_template, 'transcode') as transcode:
- # Set the response as a series of pages
- response = (
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- ],
- next_page_token="abc",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[],
- next_page_token="def",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListDomainMappingsResponse(
- domain_mappings=[
- domain_mapping.DomainMapping(),
- domain_mapping.DomainMapping(),
- ],
- ),
- )
- # Two responses for two calls
- response = response + response
-
- # Wrap the values into proper Response objs
- response = tuple(
- appengine.ListDomainMappingsResponse.to_json(x) for x in response
- )
- return_values = tuple(Response() for i in response)
- for return_val, response_val in zip(return_values, response):
- return_val._content = response_val.encode("UTF-8")
- return_val.status_code = 200
- req.side_effect = return_values
-
- sample_request = {"parent": "apps/sample1"}
-
- pager = client.list_domain_mappings(request=sample_request)
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, domain_mapping.DomainMapping) for i in results)
-
- pages = list(client.list_domain_mappings(request=sample_request).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetDomainMappingRequest,
- dict,
- ],
-)
-def test_get_domain_mapping_rest(request_type):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/domainMappings/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = domain_mapping.DomainMapping(
- name="name_value",
- id="id_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = domain_mapping.DomainMapping.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.get_domain_mapping(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, domain_mapping.DomainMapping)
- assert response.name == "name_value"
- assert response.id == "id_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_get_domain_mapping_rest_interceptors(null_interceptor):
- transport = transports.DomainMappingsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.DomainMappingsRestInterceptor(),
- )
- client = DomainMappingsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.DomainMappingsRestInterceptor, "post_get_domain_mapping"
- ) as post, mock.patch.object(
- transports.DomainMappingsRestInterceptor, "pre_get_domain_mapping"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.GetDomainMappingRequest.pb(
- appengine.GetDomainMappingRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = domain_mapping.DomainMapping.to_json(
- domain_mapping.DomainMapping()
- )
-
- request = appengine.GetDomainMappingRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = domain_mapping.DomainMapping()
-
- client.get_domain_mapping(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_get_domain_mapping_rest_bad_request(
- transport: str = "rest", request_type=appengine.GetDomainMappingRequest
-):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/domainMappings/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.get_domain_mapping(request)
-
-
-def test_get_domain_mapping_rest_error():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.CreateDomainMappingRequest,
- dict,
- ],
-)
-def test_create_domain_mapping_rest(request_type):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request_init["domain_mapping"] = {
- "name": "name_value",
- "id": "id_value",
- "ssl_settings": {
- "certificate_id": "certificate_id_value",
- "ssl_management_type": 1,
- "pending_managed_certificate_id": "pending_managed_certificate_id_value",
- },
- "resource_records": [
- {"name": "name_value", "rrdata": "rrdata_value", "type_": 1}
- ],
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.CreateDomainMappingRequest.meta.fields["domain_mapping"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["domain_mapping"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["domain_mapping"][field])):
- del request_init["domain_mapping"][field][i][subfield]
- else:
- del request_init["domain_mapping"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.create_domain_mapping(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_create_domain_mapping_rest_interceptors(null_interceptor):
- transport = transports.DomainMappingsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.DomainMappingsRestInterceptor(),
- )
- client = DomainMappingsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.DomainMappingsRestInterceptor, "post_create_domain_mapping"
- ) as post, mock.patch.object(
- transports.DomainMappingsRestInterceptor, "pre_create_domain_mapping"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.CreateDomainMappingRequest.pb(
- appengine.CreateDomainMappingRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.CreateDomainMappingRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.create_domain_mapping(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_create_domain_mapping_rest_bad_request(
- transport: str = "rest", request_type=appengine.CreateDomainMappingRequest
-):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.create_domain_mapping(request)
-
-
-def test_create_domain_mapping_rest_error():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateDomainMappingRequest,
- dict,
- ],
-)
-def test_update_domain_mapping_rest(request_type):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/domainMappings/sample2"}
- request_init["domain_mapping"] = {
- "name": "name_value",
- "id": "id_value",
- "ssl_settings": {
- "certificate_id": "certificate_id_value",
- "ssl_management_type": 1,
- "pending_managed_certificate_id": "pending_managed_certificate_id_value",
- },
- "resource_records": [
- {"name": "name_value", "rrdata": "rrdata_value", "type_": 1}
- ],
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.UpdateDomainMappingRequest.meta.fields["domain_mapping"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["domain_mapping"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["domain_mapping"][field])):
- del request_init["domain_mapping"][field][i][subfield]
- else:
- del request_init["domain_mapping"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.update_domain_mapping(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_update_domain_mapping_rest_interceptors(null_interceptor):
- transport = transports.DomainMappingsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.DomainMappingsRestInterceptor(),
- )
- client = DomainMappingsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.DomainMappingsRestInterceptor, "post_update_domain_mapping"
- ) as post, mock.patch.object(
- transports.DomainMappingsRestInterceptor, "pre_update_domain_mapping"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.UpdateDomainMappingRequest.pb(
- appengine.UpdateDomainMappingRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.UpdateDomainMappingRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.update_domain_mapping(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_update_domain_mapping_rest_bad_request(
- transport: str = "rest", request_type=appengine.UpdateDomainMappingRequest
-):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/domainMappings/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.update_domain_mapping(request)
-
-
-def test_update_domain_mapping_rest_error():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteDomainMappingRequest,
- dict,
- ],
-)
-def test_delete_domain_mapping_rest(request_type):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/domainMappings/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.delete_domain_mapping(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_delete_domain_mapping_rest_interceptors(null_interceptor):
- transport = transports.DomainMappingsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None
- if null_interceptor
- else transports.DomainMappingsRestInterceptor(),
- )
- client = DomainMappingsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.DomainMappingsRestInterceptor, "post_delete_domain_mapping"
- ) as post, mock.patch.object(
- transports.DomainMappingsRestInterceptor, "pre_delete_domain_mapping"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.DeleteDomainMappingRequest.pb(
- appengine.DeleteDomainMappingRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.DeleteDomainMappingRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.delete_domain_mapping(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_delete_domain_mapping_rest_bad_request(
- transport: str = "rest", request_type=appengine.DeleteDomainMappingRequest
-):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/domainMappings/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.delete_domain_mapping(request)
-
-
-def test_delete_domain_mapping_rest_error():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-def test_credentials_transport_error():
- # It is an error to provide credentials and a transport instance.
- transport = transports.DomainMappingsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # It is an error to provide a credentials file and a transport instance.
- transport = transports.DomainMappingsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = DomainMappingsClient(
- client_options={"credentials_file": "credentials.json"},
- transport=transport,
- )
-
- # It is an error to provide an api_key and a transport instance.
- transport = transports.DomainMappingsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = DomainMappingsClient(
- client_options=options,
- transport=transport,
- )
-
- # It is an error to provide an api_key and a credential.
- options = mock.Mock()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = DomainMappingsClient(
- client_options=options, credentials=ga_credentials.AnonymousCredentials()
- )
-
- # It is an error to provide scopes and a transport instance.
- transport = transports.DomainMappingsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = DomainMappingsClient(
- client_options={"scopes": ["1", "2"]},
- transport=transport,
- )
-
-
-def test_transport_instance():
- # A client may be instantiated with a custom transport instance.
- transport = transports.DomainMappingsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- client = DomainMappingsClient(transport=transport)
- assert client.transport is transport
-
-
-def test_transport_get_channel():
- # A client may be instantiated with a custom transport instance.
- transport = transports.DomainMappingsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
- transport = transports.DomainMappingsGrpcAsyncIOTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.DomainMappingsGrpcTransport,
- transports.DomainMappingsGrpcAsyncIOTransport,
- transports.DomainMappingsRestTransport,
- ],
-)
-def test_transport_adc(transport_class):
- # Test default credentials are used if not provided.
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class()
- adc.assert_called_once()
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "rest",
- ],
-)
-def test_transport_kind(transport_name):
- transport = DomainMappingsClient.get_transport_class(transport_name)(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert transport.kind == transport_name
-
-
-def test_transport_grpc_default():
- # A client should use the gRPC transport by default.
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert isinstance(
- client.transport,
- transports.DomainMappingsGrpcTransport,
- )
-
-
-def test_domain_mappings_base_transport_error():
- # Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(core_exceptions.DuplicateCredentialArgs):
- transport = transports.DomainMappingsTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- credentials_file="credentials.json",
- )
-
-
-def test_domain_mappings_base_transport():
- # Instantiate the base transport.
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.domain_mappings.transports.DomainMappingsTransport.__init__"
- ) as Transport:
- Transport.return_value = None
- transport = transports.DomainMappingsTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Every method on the transport should just blindly
- # raise NotImplementedError.
- methods = (
- "list_domain_mappings",
- "get_domain_mapping",
- "create_domain_mapping",
- "update_domain_mapping",
- "delete_domain_mapping",
- )
- for method in methods:
- with pytest.raises(NotImplementedError):
- getattr(transport, method)(request=object())
-
- with pytest.raises(NotImplementedError):
- transport.close()
-
- # Additionally, the LRO client (a property) should
- # also raise NotImplementedError
- with pytest.raises(NotImplementedError):
- transport.operations_client
-
- # Catch all for all remaining methods and properties
- remainder = [
- "kind",
- ]
- for r in remainder:
- with pytest.raises(NotImplementedError):
- getattr(transport, r)()
-
-
-def test_domain_mappings_base_transport_with_credentials_file():
- # Instantiate the base transport with a credentials file
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch(
- "google.cloud.appengine_admin_v1.services.domain_mappings.transports.DomainMappingsTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.DomainMappingsTransport(
- credentials_file="credentials.json",
- quota_project_id="octopus",
- )
- load_creds.assert_called_once_with(
- "credentials.json",
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-def test_domain_mappings_base_transport_with_adc():
- # Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
- "google.cloud.appengine_admin_v1.services.domain_mappings.transports.DomainMappingsTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.DomainMappingsTransport()
- adc.assert_called_once()
-
-
-def test_domain_mappings_auth_adc():
- # If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- DomainMappingsClient()
- adc.assert_called_once_with(
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id=None,
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.DomainMappingsGrpcTransport,
- transports.DomainMappingsGrpcAsyncIOTransport,
- ],
-)
-def test_domain_mappings_transport_auth_adc(transport_class):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
- adc.assert_called_once_with(
- scopes=["1", "2"],
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.DomainMappingsGrpcTransport,
- transports.DomainMappingsGrpcAsyncIOTransport,
- transports.DomainMappingsRestTransport,
- ],
-)
-def test_domain_mappings_transport_auth_gdch_credentials(transport_class):
- host = "https://language.com"
- api_audience_tests = [None, "https://language2.com"]
- api_audience_expect = [host, "https://language2.com"]
- for t, e in zip(api_audience_tests, api_audience_expect):
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- gdch_mock = mock.MagicMock()
- type(gdch_mock).with_gdch_audience = mock.PropertyMock(
- return_value=gdch_mock
- )
- adc.return_value = (gdch_mock, None)
- transport_class(host=host, api_audience=t)
- gdch_mock.with_gdch_audience.assert_called_once_with(e)
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.DomainMappingsGrpcTransport, grpc_helpers),
- (transports.DomainMappingsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-def test_domain_mappings_transport_create_channel(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=["1", "2"],
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.DomainMappingsGrpcTransport,
- transports.DomainMappingsGrpcAsyncIOTransport,
- ],
-)
-def test_domain_mappings_grpc_transport_client_cert_source_for_mtls(transport_class):
- cred = ga_credentials.AnonymousCredentials()
-
- # Check ssl_channel_credentials is used if provided.
- with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
- mock_ssl_channel_creds = mock.Mock()
- transport_class(
- host="squid.clam.whelk",
- credentials=cred,
- ssl_channel_credentials=mock_ssl_channel_creds,
- )
- mock_create_channel.assert_called_once_with(
- "squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_channel_creds,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
- # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls
- # is used.
- with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()):
- with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred:
- transport_class(
- credentials=cred,
- client_cert_source_for_mtls=client_cert_source_callback,
- )
- expected_cert, expected_key = client_cert_source_callback()
- mock_ssl_cred.assert_called_once_with(
- certificate_chain=expected_cert, private_key=expected_key
- )
-
-
-def test_domain_mappings_http_transport_client_cert_source_for_mtls():
- cred = ga_credentials.AnonymousCredentials()
- with mock.patch(
- "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"
- ) as mock_configure_mtls_channel:
- transports.DomainMappingsRestTransport(
- credentials=cred, client_cert_source_for_mtls=client_cert_source_callback
- )
- mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback)
-
-
-def test_domain_mappings_rest_lro_client():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.AbstractOperationsClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_domain_mappings_host_no_port(transport_name):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_domain_mappings_host_with_port(transport_name):
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com:8000"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:8000"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com:8000"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "rest",
- ],
-)
-def test_domain_mappings_client_transport_session_collision(transport_name):
- creds1 = ga_credentials.AnonymousCredentials()
- creds2 = ga_credentials.AnonymousCredentials()
- client1 = DomainMappingsClient(
- credentials=creds1,
- transport=transport_name,
- )
- client2 = DomainMappingsClient(
- credentials=creds2,
- transport=transport_name,
- )
- session1 = client1.transport.list_domain_mappings._session
- session2 = client2.transport.list_domain_mappings._session
- assert session1 != session2
- session1 = client1.transport.get_domain_mapping._session
- session2 = client2.transport.get_domain_mapping._session
- assert session1 != session2
- session1 = client1.transport.create_domain_mapping._session
- session2 = client2.transport.create_domain_mapping._session
- assert session1 != session2
- session1 = client1.transport.update_domain_mapping._session
- session2 = client2.transport.update_domain_mapping._session
- assert session1 != session2
- session1 = client1.transport.delete_domain_mapping._session
- session2 = client2.transport.delete_domain_mapping._session
- assert session1 != session2
-
-
-def test_domain_mappings_grpc_transport_channel():
- channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.DomainMappingsGrpcTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-def test_domain_mappings_grpc_asyncio_transport_channel():
- channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.DomainMappingsGrpcAsyncIOTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.DomainMappingsGrpcTransport,
- transports.DomainMappingsGrpcAsyncIOTransport,
- ],
-)
-def test_domain_mappings_transport_channel_mtls_with_client_cert_source(
- transport_class,
-):
- with mock.patch(
- "grpc.ssl_channel_credentials", autospec=True
- ) as grpc_ssl_channel_cred:
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_ssl_cred = mock.Mock()
- grpc_ssl_channel_cred.return_value = mock_ssl_cred
-
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
-
- cred = ga_credentials.AnonymousCredentials()
- with pytest.warns(DeprecationWarning):
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (cred, None)
- transport = transport_class(
- host="squid.clam.whelk",
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=client_cert_source_callback,
- )
- adc.assert_called_once()
-
- grpc_ssl_channel_cred.assert_called_once_with(
- certificate_chain=b"cert bytes", private_key=b"key bytes"
- )
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
- assert transport._ssl_channel_credentials == mock_ssl_cred
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.DomainMappingsGrpcTransport,
- transports.DomainMappingsGrpcAsyncIOTransport,
- ],
-)
-def test_domain_mappings_transport_channel_mtls_with_adc(transport_class):
- mock_ssl_cred = mock.Mock()
- with mock.patch.multiple(
- "google.auth.transport.grpc.SslCredentials",
- __init__=mock.Mock(return_value=None),
- ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
- ):
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
- mock_cred = mock.Mock()
-
- with pytest.warns(DeprecationWarning):
- transport = transport_class(
- host="squid.clam.whelk",
- credentials=mock_cred,
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=None,
- )
-
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=mock_cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
-
-
-def test_domain_mappings_grpc_lro_client():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.OperationsClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-def test_domain_mappings_grpc_lro_async_client():
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.OperationsAsyncClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-def test_common_billing_account_path():
- billing_account = "squid"
- expected = "billingAccounts/{billing_account}".format(
- billing_account=billing_account,
- )
- actual = DomainMappingsClient.common_billing_account_path(billing_account)
- assert expected == actual
-
-
-def test_parse_common_billing_account_path():
- expected = {
- "billing_account": "clam",
- }
- path = DomainMappingsClient.common_billing_account_path(**expected)
-
- # Check that the path construction is reversible.
- actual = DomainMappingsClient.parse_common_billing_account_path(path)
- assert expected == actual
-
-
-def test_common_folder_path():
- folder = "whelk"
- expected = "folders/{folder}".format(
- folder=folder,
- )
- actual = DomainMappingsClient.common_folder_path(folder)
- assert expected == actual
-
-
-def test_parse_common_folder_path():
- expected = {
- "folder": "octopus",
- }
- path = DomainMappingsClient.common_folder_path(**expected)
-
- # Check that the path construction is reversible.
- actual = DomainMappingsClient.parse_common_folder_path(path)
- assert expected == actual
-
-
-def test_common_organization_path():
- organization = "oyster"
- expected = "organizations/{organization}".format(
- organization=organization,
- )
- actual = DomainMappingsClient.common_organization_path(organization)
- assert expected == actual
-
-
-def test_parse_common_organization_path():
- expected = {
- "organization": "nudibranch",
- }
- path = DomainMappingsClient.common_organization_path(**expected)
-
- # Check that the path construction is reversible.
- actual = DomainMappingsClient.parse_common_organization_path(path)
- assert expected == actual
-
-
-def test_common_project_path():
- project = "cuttlefish"
- expected = "projects/{project}".format(
- project=project,
- )
- actual = DomainMappingsClient.common_project_path(project)
- assert expected == actual
-
-
-def test_parse_common_project_path():
- expected = {
- "project": "mussel",
- }
- path = DomainMappingsClient.common_project_path(**expected)
-
- # Check that the path construction is reversible.
- actual = DomainMappingsClient.parse_common_project_path(path)
- assert expected == actual
-
-
-def test_common_location_path():
- project = "winkle"
- location = "nautilus"
- expected = "projects/{project}/locations/{location}".format(
- project=project,
- location=location,
- )
- actual = DomainMappingsClient.common_location_path(project, location)
- assert expected == actual
-
-
-def test_parse_common_location_path():
- expected = {
- "project": "scallop",
- "location": "abalone",
- }
- path = DomainMappingsClient.common_location_path(**expected)
-
- # Check that the path construction is reversible.
- actual = DomainMappingsClient.parse_common_location_path(path)
- assert expected == actual
-
-
-def test_client_with_default_client_info():
- client_info = gapic_v1.client_info.ClientInfo()
-
- with mock.patch.object(
- transports.DomainMappingsTransport, "_prep_wrapped_messages"
- ) as prep:
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
- with mock.patch.object(
- transports.DomainMappingsTransport, "_prep_wrapped_messages"
- ) as prep:
- transport_class = DomainMappingsClient.get_transport_class()
- transport = transport_class(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
-
-@pytest.mark.asyncio
-async def test_transport_close_async():
- client = DomainMappingsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- with mock.patch.object(
- type(getattr(client.transport, "grpc_channel")), "close"
- ) as close:
- async with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_transport_close():
- transports = {
- "rest": "_session",
- "grpc": "_grpc_channel",
- }
-
- for transport, close_name in transports.items():
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- with mock.patch.object(
- type(getattr(client.transport, close_name)), "close"
- ) as close:
- with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_client_ctx():
- transports = [
- "rest",
- "grpc",
- ]
- for transport in transports:
- client = DomainMappingsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- # Test client calls underlying transport.
- with mock.patch.object(type(client.transport), "close") as close:
- close.assert_not_called()
- with client:
- pass
- close.assert_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class",
- [
- (DomainMappingsClient, transports.DomainMappingsGrpcTransport),
- (DomainMappingsAsyncClient, transports.DomainMappingsGrpcAsyncIOTransport),
- ],
-)
-def test_api_key_credentials(client_class, transport_class):
- with mock.patch.object(
- google.auth._default, "get_api_key_credentials", create=True
- ) as get_api_key_credentials:
- mock_cred = mock.Mock()
- get_api_key_credentials.return_value = mock_cred
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options)
- patched.assert_called_once_with(
- credentials=mock_cred,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
diff --git a/tests/unit/gapic/appengine_admin_v1/test_firewall.py b/tests/unit/gapic/appengine_admin_v1/test_firewall.py
deleted file mode 100644
index ba7381b..0000000
--- a/tests/unit/gapic/appengine_admin_v1/test_firewall.py
+++ /dev/null
@@ -1,3556 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import os
-
-# try/except added for compatibility with python < 3.8
-try:
- from unittest import mock
- from unittest.mock import AsyncMock # pragma: NO COVER
-except ImportError: # pragma: NO COVER
- import mock
-
-from collections.abc import Iterable
-import json
-import math
-
-from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template
-from google.api_core import client_options
-from google.api_core import exceptions as core_exceptions
-import google.auth
-from google.auth import credentials as ga_credentials
-from google.auth.exceptions import MutualTLSChannelError
-from google.oauth2 import service_account
-from google.protobuf import field_mask_pb2 # type: ignore
-from google.protobuf import json_format
-import grpc
-from grpc.experimental import aio
-from proto.marshal.rules import wrappers
-from proto.marshal.rules.dates import DurationRule, TimestampRule
-import pytest
-from requests import PreparedRequest, Request, Response
-from requests.sessions import Session
-
-from google.cloud.appengine_admin_v1.services.firewall import (
- FirewallAsyncClient,
- FirewallClient,
- pagers,
- transports,
-)
-from google.cloud.appengine_admin_v1.types import appengine, firewall
-
-
-def client_cert_source_callback():
- return b"cert bytes", b"key bytes"
-
-
-# If default endpoint is localhost, then default mtls endpoint will be the same.
-# This method modifies the default endpoint so the client can produce a different
-# mtls endpoint for endpoint testing purposes.
-def modify_default_endpoint(client):
- return (
- "foo.googleapis.com"
- if ("localhost" in client.DEFAULT_ENDPOINT)
- else client.DEFAULT_ENDPOINT
- )
-
-
-def test__get_default_mtls_endpoint():
- api_endpoint = "example.googleapis.com"
- api_mtls_endpoint = "example.mtls.googleapis.com"
- sandbox_endpoint = "example.sandbox.googleapis.com"
- sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
- non_googleapi = "api.example.com"
-
- assert FirewallClient._get_default_mtls_endpoint(None) is None
- assert FirewallClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint
- assert (
- FirewallClient._get_default_mtls_endpoint(api_mtls_endpoint)
- == api_mtls_endpoint
- )
- assert (
- FirewallClient._get_default_mtls_endpoint(sandbox_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- FirewallClient._get_default_mtls_endpoint(sandbox_mtls_endpoint)
- == sandbox_mtls_endpoint
- )
- assert FirewallClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (FirewallClient, "grpc"),
- (FirewallAsyncClient, "grpc_asyncio"),
- (FirewallClient, "rest"),
- ],
-)
-def test_firewall_client_from_service_account_info(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_info"
- ) as factory:
- factory.return_value = creds
- info = {"valid": True}
- client = client_class.from_service_account_info(info, transport=transport_name)
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,transport_name",
- [
- (transports.FirewallGrpcTransport, "grpc"),
- (transports.FirewallGrpcAsyncIOTransport, "grpc_asyncio"),
- (transports.FirewallRestTransport, "rest"),
- ],
-)
-def test_firewall_client_service_account_always_use_jwt(
- transport_class, transport_name
-):
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=True)
- use_jwt.assert_called_once_with(True)
-
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=False)
- use_jwt.assert_not_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (FirewallClient, "grpc"),
- (FirewallAsyncClient, "grpc_asyncio"),
- (FirewallClient, "rest"),
- ],
-)
-def test_firewall_client_from_service_account_file(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_file"
- ) as factory:
- factory.return_value = creds
- client = client_class.from_service_account_file(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- client = client_class.from_service_account_json(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-def test_firewall_client_get_transport_class():
- transport = FirewallClient.get_transport_class()
- available_transports = [
- transports.FirewallGrpcTransport,
- transports.FirewallRestTransport,
- ]
- assert transport in available_transports
-
- transport = FirewallClient.get_transport_class("grpc")
- assert transport == transports.FirewallGrpcTransport
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (FirewallClient, transports.FirewallGrpcTransport, "grpc"),
- (FirewallAsyncClient, transports.FirewallGrpcAsyncIOTransport, "grpc_asyncio"),
- (FirewallClient, transports.FirewallRestTransport, "rest"),
- ],
-)
-@mock.patch.object(
- FirewallClient, "DEFAULT_ENDPOINT", modify_default_endpoint(FirewallClient)
-)
-@mock.patch.object(
- FirewallAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(FirewallAsyncClient),
-)
-def test_firewall_client_client_options(client_class, transport_class, transport_name):
- # Check that if channel is provided we won't create a new one.
- with mock.patch.object(FirewallClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
- client = client_class(transport=transport)
- gtc.assert_not_called()
-
- # Check that if channel is provided via str we will create a new one.
- with mock.patch.object(FirewallClient, "get_transport_class") as gtc:
- client = client_class(transport=transport_name)
- gtc.assert_called()
-
- # Check the case api_endpoint is provided.
- options = client_options.ClientOptions(api_endpoint="squid.clam.whelk")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name, client_options=options)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_MTLS_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
- # unsupported value.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
- with pytest.raises(MutualTLSChannelError):
- client = client_class(transport=transport_name)
-
- # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
- ):
- with pytest.raises(ValueError):
- client = client_class(transport=transport_name)
-
- # Check the case quota_project_id is provided
- options = client_options.ClientOptions(quota_project_id="octopus")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id="octopus",
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
- # Check the case api_endpoint is provided
- options = client_options.ClientOptions(
- api_audience="https://language.googleapis.com"
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience="https://language.googleapis.com",
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,use_client_cert_env",
- [
- (FirewallClient, transports.FirewallGrpcTransport, "grpc", "true"),
- (
- FirewallAsyncClient,
- transports.FirewallGrpcAsyncIOTransport,
- "grpc_asyncio",
- "true",
- ),
- (FirewallClient, transports.FirewallGrpcTransport, "grpc", "false"),
- (
- FirewallAsyncClient,
- transports.FirewallGrpcAsyncIOTransport,
- "grpc_asyncio",
- "false",
- ),
- (FirewallClient, transports.FirewallRestTransport, "rest", "true"),
- (FirewallClient, transports.FirewallRestTransport, "rest", "false"),
- ],
-)
-@mock.patch.object(
- FirewallClient, "DEFAULT_ENDPOINT", modify_default_endpoint(FirewallClient)
-)
-@mock.patch.object(
- FirewallAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(FirewallAsyncClient),
-)
-@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"})
-def test_firewall_client_mtls_env_auto(
- client_class, transport_class, transport_name, use_client_cert_env
-):
- # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default
- # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists.
-
- # Check the case client_cert_source is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- options = client_options.ClientOptions(
- client_cert_source=client_cert_source_callback
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
-
- if use_client_cert_env == "false":
- expected_client_cert_source = None
- expected_host = client.DEFAULT_ENDPOINT
- else:
- expected_client_cert_source = client_cert_source_callback
- expected_host = client.DEFAULT_MTLS_ENDPOINT
-
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case ADC client cert is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=client_cert_source_callback,
- ):
- if use_client_cert_env == "false":
- expected_host = client.DEFAULT_ENDPOINT
- expected_client_cert_source = None
- else:
- expected_host = client.DEFAULT_MTLS_ENDPOINT
- expected_client_cert_source = client_cert_source_callback
-
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case client_cert_source and ADC client cert are not provided.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize("client_class", [FirewallClient, FirewallAsyncClient])
-@mock.patch.object(
- FirewallClient, "DEFAULT_ENDPOINT", modify_default_endpoint(FirewallClient)
-)
-@mock.patch.object(
- FirewallAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(FirewallAsyncClient),
-)
-def test_firewall_client_get_mtls_endpoint_and_cert_source(client_class):
- mock_client_cert_source = mock.Mock()
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source == mock_client_cert_source
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
- mock_client_cert_source = mock.Mock()
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=mock_client_cert_source,
- ):
- (
- api_endpoint,
- cert_source,
- ) = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source == mock_client_cert_source
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (FirewallClient, transports.FirewallGrpcTransport, "grpc"),
- (FirewallAsyncClient, transports.FirewallGrpcAsyncIOTransport, "grpc_asyncio"),
- (FirewallClient, transports.FirewallRestTransport, "rest"),
- ],
-)
-def test_firewall_client_client_options_scopes(
- client_class, transport_class, transport_name
-):
- # Check the case scopes are provided.
- options = client_options.ClientOptions(
- scopes=["1", "2"],
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=["1", "2"],
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (FirewallClient, transports.FirewallGrpcTransport, "grpc", grpc_helpers),
- (
- FirewallAsyncClient,
- transports.FirewallGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- (FirewallClient, transports.FirewallRestTransport, "rest", None),
- ],
-)
-def test_firewall_client_client_options_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-def test_firewall_client_client_options_from_dict():
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.firewall.transports.FirewallGrpcTransport.__init__"
- ) as grpc_transport:
- grpc_transport.return_value = None
- client = FirewallClient(client_options={"api_endpoint": "squid.clam.whelk"})
- grpc_transport.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (FirewallClient, transports.FirewallGrpcTransport, "grpc", grpc_helpers),
- (
- FirewallAsyncClient,
- transports.FirewallGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- ],
-)
-def test_firewall_client_create_channel_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # test that the credentials from file are saved and used as the credentials.
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel"
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- file_creds = ga_credentials.AnonymousCredentials()
- load_creds.return_value = (file_creds, None)
- adc.return_value = (creds, None)
- client = client_class(client_options=options, transport=transport_name)
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=file_creds,
- credentials_file=None,
- quota_project_id=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=None,
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListIngressRulesRequest,
- dict,
- ],
-)
-def test_list_ingress_rules(request_type, transport: str = "grpc"):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_ingress_rules), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = appengine.ListIngressRulesResponse(
- next_page_token="next_page_token_value",
- )
- response = client.list_ingress_rules(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListIngressRulesRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListIngressRulesPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-def test_list_ingress_rules_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_ingress_rules), "__call__"
- ) as call:
- client.list_ingress_rules()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListIngressRulesRequest()
-
-
-@pytest.mark.asyncio
-async def test_list_ingress_rules_async(
- transport: str = "grpc_asyncio", request_type=appengine.ListIngressRulesRequest
-):
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_ingress_rules), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListIngressRulesResponse(
- next_page_token="next_page_token_value",
- )
- )
- response = await client.list_ingress_rules(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListIngressRulesRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListIngressRulesAsyncPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.asyncio
-async def test_list_ingress_rules_async_from_dict():
- await test_list_ingress_rules_async(request_type=dict)
-
-
-def test_list_ingress_rules_field_headers():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListIngressRulesRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_ingress_rules), "__call__"
- ) as call:
- call.return_value = appengine.ListIngressRulesResponse()
- client.list_ingress_rules(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_list_ingress_rules_field_headers_async():
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListIngressRulesRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_ingress_rules), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListIngressRulesResponse()
- )
- await client.list_ingress_rules(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-def test_list_ingress_rules_pager(transport_name: str = "grpc"):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_ingress_rules), "__call__"
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- ],
- next_page_token="abc",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[],
- next_page_token="def",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- ],
- ),
- RuntimeError,
- )
-
- metadata = ()
- metadata = tuple(metadata) + (
- gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)),
- )
- pager = client.list_ingress_rules(request={})
-
- assert pager._metadata == metadata
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, firewall.FirewallRule) for i in results)
-
-
-def test_list_ingress_rules_pages(transport_name: str = "grpc"):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_ingress_rules), "__call__"
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- ],
- next_page_token="abc",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[],
- next_page_token="def",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- ],
- ),
- RuntimeError,
- )
- pages = list(client.list_ingress_rules(request={}).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.asyncio
-async def test_list_ingress_rules_async_pager():
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_ingress_rules),
- "__call__",
- new_callable=mock.AsyncMock,
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- ],
- next_page_token="abc",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[],
- next_page_token="def",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- ],
- ),
- RuntimeError,
- )
- async_pager = await client.list_ingress_rules(
- request={},
- )
- assert async_pager.next_page_token == "abc"
- responses = []
- async for response in async_pager: # pragma: no branch
- responses.append(response)
-
- assert len(responses) == 6
- assert all(isinstance(i, firewall.FirewallRule) for i in responses)
-
-
-@pytest.mark.asyncio
-async def test_list_ingress_rules_async_pages():
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_ingress_rules),
- "__call__",
- new_callable=mock.AsyncMock,
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- ],
- next_page_token="abc",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[],
- next_page_token="def",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- ],
- ),
- RuntimeError,
- )
- pages = []
- # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
- # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
- async for page_ in ( # pragma: no branch
- await client.list_ingress_rules(request={})
- ).pages:
- pages.append(page_)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.BatchUpdateIngressRulesRequest,
- dict,
- ],
-)
-def test_batch_update_ingress_rules(request_type, transport: str = "grpc"):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.batch_update_ingress_rules), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = appengine.BatchUpdateIngressRulesResponse()
- response = client.batch_update_ingress_rules(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.BatchUpdateIngressRulesRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, appengine.BatchUpdateIngressRulesResponse)
-
-
-def test_batch_update_ingress_rules_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.batch_update_ingress_rules), "__call__"
- ) as call:
- client.batch_update_ingress_rules()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.BatchUpdateIngressRulesRequest()
-
-
-@pytest.mark.asyncio
-async def test_batch_update_ingress_rules_async(
- transport: str = "grpc_asyncio",
- request_type=appengine.BatchUpdateIngressRulesRequest,
-):
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.batch_update_ingress_rules), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.BatchUpdateIngressRulesResponse()
- )
- response = await client.batch_update_ingress_rules(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.BatchUpdateIngressRulesRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, appengine.BatchUpdateIngressRulesResponse)
-
-
-@pytest.mark.asyncio
-async def test_batch_update_ingress_rules_async_from_dict():
- await test_batch_update_ingress_rules_async(request_type=dict)
-
-
-def test_batch_update_ingress_rules_field_headers():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.BatchUpdateIngressRulesRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.batch_update_ingress_rules), "__call__"
- ) as call:
- call.return_value = appengine.BatchUpdateIngressRulesResponse()
- client.batch_update_ingress_rules(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_batch_update_ingress_rules_field_headers_async():
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.BatchUpdateIngressRulesRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.batch_update_ingress_rules), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.BatchUpdateIngressRulesResponse()
- )
- await client.batch_update_ingress_rules(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.CreateIngressRuleRequest,
- dict,
- ],
-)
-def test_create_ingress_rule(request_type, transport: str = "grpc"):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_ingress_rule), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = firewall.FirewallRule(
- priority=898,
- action=firewall.FirewallRule.Action.ALLOW,
- source_range="source_range_value",
- description="description_value",
- )
- response = client.create_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateIngressRuleRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, firewall.FirewallRule)
- assert response.priority == 898
- assert response.action == firewall.FirewallRule.Action.ALLOW
- assert response.source_range == "source_range_value"
- assert response.description == "description_value"
-
-
-def test_create_ingress_rule_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_ingress_rule), "__call__"
- ) as call:
- client.create_ingress_rule()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateIngressRuleRequest()
-
-
-@pytest.mark.asyncio
-async def test_create_ingress_rule_async(
- transport: str = "grpc_asyncio", request_type=appengine.CreateIngressRuleRequest
-):
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_ingress_rule), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- firewall.FirewallRule(
- priority=898,
- action=firewall.FirewallRule.Action.ALLOW,
- source_range="source_range_value",
- description="description_value",
- )
- )
- response = await client.create_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateIngressRuleRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, firewall.FirewallRule)
- assert response.priority == 898
- assert response.action == firewall.FirewallRule.Action.ALLOW
- assert response.source_range == "source_range_value"
- assert response.description == "description_value"
-
-
-@pytest.mark.asyncio
-async def test_create_ingress_rule_async_from_dict():
- await test_create_ingress_rule_async(request_type=dict)
-
-
-def test_create_ingress_rule_field_headers():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.CreateIngressRuleRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_ingress_rule), "__call__"
- ) as call:
- call.return_value = firewall.FirewallRule()
- client.create_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_create_ingress_rule_field_headers_async():
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.CreateIngressRuleRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.create_ingress_rule), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- firewall.FirewallRule()
- )
- await client.create_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetIngressRuleRequest,
- dict,
- ],
-)
-def test_get_ingress_rule(request_type, transport: str = "grpc"):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_ingress_rule), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = firewall.FirewallRule(
- priority=898,
- action=firewall.FirewallRule.Action.ALLOW,
- source_range="source_range_value",
- description="description_value",
- )
- response = client.get_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetIngressRuleRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, firewall.FirewallRule)
- assert response.priority == 898
- assert response.action == firewall.FirewallRule.Action.ALLOW
- assert response.source_range == "source_range_value"
- assert response.description == "description_value"
-
-
-def test_get_ingress_rule_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_ingress_rule), "__call__") as call:
- client.get_ingress_rule()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetIngressRuleRequest()
-
-
-@pytest.mark.asyncio
-async def test_get_ingress_rule_async(
- transport: str = "grpc_asyncio", request_type=appengine.GetIngressRuleRequest
-):
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_ingress_rule), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- firewall.FirewallRule(
- priority=898,
- action=firewall.FirewallRule.Action.ALLOW,
- source_range="source_range_value",
- description="description_value",
- )
- )
- response = await client.get_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetIngressRuleRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, firewall.FirewallRule)
- assert response.priority == 898
- assert response.action == firewall.FirewallRule.Action.ALLOW
- assert response.source_range == "source_range_value"
- assert response.description == "description_value"
-
-
-@pytest.mark.asyncio
-async def test_get_ingress_rule_async_from_dict():
- await test_get_ingress_rule_async(request_type=dict)
-
-
-def test_get_ingress_rule_field_headers():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetIngressRuleRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_ingress_rule), "__call__") as call:
- call.return_value = firewall.FirewallRule()
- client.get_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_get_ingress_rule_field_headers_async():
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetIngressRuleRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_ingress_rule), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- firewall.FirewallRule()
- )
- await client.get_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateIngressRuleRequest,
- dict,
- ],
-)
-def test_update_ingress_rule(request_type, transport: str = "grpc"):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_ingress_rule), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = firewall.FirewallRule(
- priority=898,
- action=firewall.FirewallRule.Action.ALLOW,
- source_range="source_range_value",
- description="description_value",
- )
- response = client.update_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateIngressRuleRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, firewall.FirewallRule)
- assert response.priority == 898
- assert response.action == firewall.FirewallRule.Action.ALLOW
- assert response.source_range == "source_range_value"
- assert response.description == "description_value"
-
-
-def test_update_ingress_rule_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_ingress_rule), "__call__"
- ) as call:
- client.update_ingress_rule()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateIngressRuleRequest()
-
-
-@pytest.mark.asyncio
-async def test_update_ingress_rule_async(
- transport: str = "grpc_asyncio", request_type=appengine.UpdateIngressRuleRequest
-):
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_ingress_rule), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- firewall.FirewallRule(
- priority=898,
- action=firewall.FirewallRule.Action.ALLOW,
- source_range="source_range_value",
- description="description_value",
- )
- )
- response = await client.update_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateIngressRuleRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, firewall.FirewallRule)
- assert response.priority == 898
- assert response.action == firewall.FirewallRule.Action.ALLOW
- assert response.source_range == "source_range_value"
- assert response.description == "description_value"
-
-
-@pytest.mark.asyncio
-async def test_update_ingress_rule_async_from_dict():
- await test_update_ingress_rule_async(request_type=dict)
-
-
-def test_update_ingress_rule_field_headers():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateIngressRuleRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_ingress_rule), "__call__"
- ) as call:
- call.return_value = firewall.FirewallRule()
- client.update_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_update_ingress_rule_field_headers_async():
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateIngressRuleRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.update_ingress_rule), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- firewall.FirewallRule()
- )
- await client.update_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteIngressRuleRequest,
- dict,
- ],
-)
-def test_delete_ingress_rule(request_type, transport: str = "grpc"):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_ingress_rule), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = None
- response = client.delete_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteIngressRuleRequest()
-
- # Establish that the response is the type that we expect.
- assert response is None
-
-
-def test_delete_ingress_rule_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_ingress_rule), "__call__"
- ) as call:
- client.delete_ingress_rule()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteIngressRuleRequest()
-
-
-@pytest.mark.asyncio
-async def test_delete_ingress_rule_async(
- transport: str = "grpc_asyncio", request_type=appengine.DeleteIngressRuleRequest
-):
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_ingress_rule), "__call__"
- ) as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
- response = await client.delete_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteIngressRuleRequest()
-
- # Establish that the response is the type that we expect.
- assert response is None
-
-
-@pytest.mark.asyncio
-async def test_delete_ingress_rule_async_from_dict():
- await test_delete_ingress_rule_async(request_type=dict)
-
-
-def test_delete_ingress_rule_field_headers():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteIngressRuleRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_ingress_rule), "__call__"
- ) as call:
- call.return_value = None
- client.delete_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_delete_ingress_rule_field_headers_async():
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteIngressRuleRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.delete_ingress_rule), "__call__"
- ) as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None)
- await client.delete_ingress_rule(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListIngressRulesRequest,
- dict,
- ],
-)
-def test_list_ingress_rules_rest(request_type):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = appengine.ListIngressRulesResponse(
- next_page_token="next_page_token_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = appengine.ListIngressRulesResponse.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.list_ingress_rules(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListIngressRulesPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_list_ingress_rules_rest_interceptors(null_interceptor):
- transport = transports.FirewallRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.FirewallRestInterceptor(),
- )
- client = FirewallClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.FirewallRestInterceptor, "post_list_ingress_rules"
- ) as post, mock.patch.object(
- transports.FirewallRestInterceptor, "pre_list_ingress_rules"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.ListIngressRulesRequest.pb(
- appengine.ListIngressRulesRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = appengine.ListIngressRulesResponse.to_json(
- appengine.ListIngressRulesResponse()
- )
-
- request = appengine.ListIngressRulesRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = appengine.ListIngressRulesResponse()
-
- client.list_ingress_rules(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_list_ingress_rules_rest_bad_request(
- transport: str = "rest", request_type=appengine.ListIngressRulesRequest
-):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.list_ingress_rules(request)
-
-
-def test_list_ingress_rules_rest_pager(transport: str = "rest"):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(Session, "request") as req:
- # TODO(kbandes): remove this mock unless there's a good reason for it.
- # with mock.patch.object(path_template, 'transcode') as transcode:
- # Set the response as a series of pages
- response = (
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- ],
- next_page_token="abc",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[],
- next_page_token="def",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListIngressRulesResponse(
- ingress_rules=[
- firewall.FirewallRule(),
- firewall.FirewallRule(),
- ],
- ),
- )
- # Two responses for two calls
- response = response + response
-
- # Wrap the values into proper Response objs
- response = tuple(
- appengine.ListIngressRulesResponse.to_json(x) for x in response
- )
- return_values = tuple(Response() for i in response)
- for return_val, response_val in zip(return_values, response):
- return_val._content = response_val.encode("UTF-8")
- return_val.status_code = 200
- req.side_effect = return_values
-
- sample_request = {"parent": "apps/sample1"}
-
- pager = client.list_ingress_rules(request=sample_request)
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, firewall.FirewallRule) for i in results)
-
- pages = list(client.list_ingress_rules(request=sample_request).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.BatchUpdateIngressRulesRequest,
- dict,
- ],
-)
-def test_batch_update_ingress_rules_rest(request_type):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/firewall/ingressRules"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = appengine.BatchUpdateIngressRulesResponse()
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = appengine.BatchUpdateIngressRulesResponse.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.batch_update_ingress_rules(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, appengine.BatchUpdateIngressRulesResponse)
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_batch_update_ingress_rules_rest_interceptors(null_interceptor):
- transport = transports.FirewallRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.FirewallRestInterceptor(),
- )
- client = FirewallClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.FirewallRestInterceptor, "post_batch_update_ingress_rules"
- ) as post, mock.patch.object(
- transports.FirewallRestInterceptor, "pre_batch_update_ingress_rules"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.BatchUpdateIngressRulesRequest.pb(
- appengine.BatchUpdateIngressRulesRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = appengine.BatchUpdateIngressRulesResponse.to_json(
- appengine.BatchUpdateIngressRulesResponse()
- )
-
- request = appengine.BatchUpdateIngressRulesRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = appengine.BatchUpdateIngressRulesResponse()
-
- client.batch_update_ingress_rules(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_batch_update_ingress_rules_rest_bad_request(
- transport: str = "rest", request_type=appengine.BatchUpdateIngressRulesRequest
-):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/firewall/ingressRules"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.batch_update_ingress_rules(request)
-
-
-def test_batch_update_ingress_rules_rest_error():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.CreateIngressRuleRequest,
- dict,
- ],
-)
-def test_create_ingress_rule_rest(request_type):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request_init["rule"] = {
- "priority": 898,
- "action": 1,
- "source_range": "source_range_value",
- "description": "description_value",
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.CreateIngressRuleRequest.meta.fields["rule"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["rule"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["rule"][field])):
- del request_init["rule"][field][i][subfield]
- else:
- del request_init["rule"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = firewall.FirewallRule(
- priority=898,
- action=firewall.FirewallRule.Action.ALLOW,
- source_range="source_range_value",
- description="description_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = firewall.FirewallRule.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.create_ingress_rule(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, firewall.FirewallRule)
- assert response.priority == 898
- assert response.action == firewall.FirewallRule.Action.ALLOW
- assert response.source_range == "source_range_value"
- assert response.description == "description_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_create_ingress_rule_rest_interceptors(null_interceptor):
- transport = transports.FirewallRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.FirewallRestInterceptor(),
- )
- client = FirewallClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.FirewallRestInterceptor, "post_create_ingress_rule"
- ) as post, mock.patch.object(
- transports.FirewallRestInterceptor, "pre_create_ingress_rule"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.CreateIngressRuleRequest.pb(
- appengine.CreateIngressRuleRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = firewall.FirewallRule.to_json(
- firewall.FirewallRule()
- )
-
- request = appengine.CreateIngressRuleRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = firewall.FirewallRule()
-
- client.create_ingress_rule(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_create_ingress_rule_rest_bad_request(
- transport: str = "rest", request_type=appengine.CreateIngressRuleRequest
-):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.create_ingress_rule(request)
-
-
-def test_create_ingress_rule_rest_error():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetIngressRuleRequest,
- dict,
- ],
-)
-def test_get_ingress_rule_rest(request_type):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/firewall/ingressRules/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = firewall.FirewallRule(
- priority=898,
- action=firewall.FirewallRule.Action.ALLOW,
- source_range="source_range_value",
- description="description_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = firewall.FirewallRule.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.get_ingress_rule(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, firewall.FirewallRule)
- assert response.priority == 898
- assert response.action == firewall.FirewallRule.Action.ALLOW
- assert response.source_range == "source_range_value"
- assert response.description == "description_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_get_ingress_rule_rest_interceptors(null_interceptor):
- transport = transports.FirewallRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.FirewallRestInterceptor(),
- )
- client = FirewallClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.FirewallRestInterceptor, "post_get_ingress_rule"
- ) as post, mock.patch.object(
- transports.FirewallRestInterceptor, "pre_get_ingress_rule"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.GetIngressRuleRequest.pb(
- appengine.GetIngressRuleRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = firewall.FirewallRule.to_json(
- firewall.FirewallRule()
- )
-
- request = appengine.GetIngressRuleRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = firewall.FirewallRule()
-
- client.get_ingress_rule(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_get_ingress_rule_rest_bad_request(
- transport: str = "rest", request_type=appengine.GetIngressRuleRequest
-):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/firewall/ingressRules/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.get_ingress_rule(request)
-
-
-def test_get_ingress_rule_rest_error():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateIngressRuleRequest,
- dict,
- ],
-)
-def test_update_ingress_rule_rest(request_type):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/firewall/ingressRules/sample2"}
- request_init["rule"] = {
- "priority": 898,
- "action": 1,
- "source_range": "source_range_value",
- "description": "description_value",
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.UpdateIngressRuleRequest.meta.fields["rule"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["rule"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["rule"][field])):
- del request_init["rule"][field][i][subfield]
- else:
- del request_init["rule"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = firewall.FirewallRule(
- priority=898,
- action=firewall.FirewallRule.Action.ALLOW,
- source_range="source_range_value",
- description="description_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = firewall.FirewallRule.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.update_ingress_rule(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, firewall.FirewallRule)
- assert response.priority == 898
- assert response.action == firewall.FirewallRule.Action.ALLOW
- assert response.source_range == "source_range_value"
- assert response.description == "description_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_update_ingress_rule_rest_interceptors(null_interceptor):
- transport = transports.FirewallRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.FirewallRestInterceptor(),
- )
- client = FirewallClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.FirewallRestInterceptor, "post_update_ingress_rule"
- ) as post, mock.patch.object(
- transports.FirewallRestInterceptor, "pre_update_ingress_rule"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.UpdateIngressRuleRequest.pb(
- appengine.UpdateIngressRuleRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = firewall.FirewallRule.to_json(
- firewall.FirewallRule()
- )
-
- request = appengine.UpdateIngressRuleRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = firewall.FirewallRule()
-
- client.update_ingress_rule(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_update_ingress_rule_rest_bad_request(
- transport: str = "rest", request_type=appengine.UpdateIngressRuleRequest
-):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/firewall/ingressRules/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.update_ingress_rule(request)
-
-
-def test_update_ingress_rule_rest_error():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteIngressRuleRequest,
- dict,
- ],
-)
-def test_delete_ingress_rule_rest(request_type):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/firewall/ingressRules/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = None
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = ""
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.delete_ingress_rule(request)
-
- # Establish that the response is the type that we expect.
- assert response is None
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_delete_ingress_rule_rest_interceptors(null_interceptor):
- transport = transports.FirewallRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.FirewallRestInterceptor(),
- )
- client = FirewallClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.FirewallRestInterceptor, "pre_delete_ingress_rule"
- ) as pre:
- pre.assert_not_called()
- pb_message = appengine.DeleteIngressRuleRequest.pb(
- appengine.DeleteIngressRuleRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
-
- request = appengine.DeleteIngressRuleRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
-
- client.delete_ingress_rule(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
-
-
-def test_delete_ingress_rule_rest_bad_request(
- transport: str = "rest", request_type=appengine.DeleteIngressRuleRequest
-):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/firewall/ingressRules/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.delete_ingress_rule(request)
-
-
-def test_delete_ingress_rule_rest_error():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-def test_credentials_transport_error():
- # It is an error to provide credentials and a transport instance.
- transport = transports.FirewallGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # It is an error to provide a credentials file and a transport instance.
- transport = transports.FirewallGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = FirewallClient(
- client_options={"credentials_file": "credentials.json"},
- transport=transport,
- )
-
- # It is an error to provide an api_key and a transport instance.
- transport = transports.FirewallGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = FirewallClient(
- client_options=options,
- transport=transport,
- )
-
- # It is an error to provide an api_key and a credential.
- options = mock.Mock()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = FirewallClient(
- client_options=options, credentials=ga_credentials.AnonymousCredentials()
- )
-
- # It is an error to provide scopes and a transport instance.
- transport = transports.FirewallGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = FirewallClient(
- client_options={"scopes": ["1", "2"]},
- transport=transport,
- )
-
-
-def test_transport_instance():
- # A client may be instantiated with a custom transport instance.
- transport = transports.FirewallGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- client = FirewallClient(transport=transport)
- assert client.transport is transport
-
-
-def test_transport_get_channel():
- # A client may be instantiated with a custom transport instance.
- transport = transports.FirewallGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
- transport = transports.FirewallGrpcAsyncIOTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.FirewallGrpcTransport,
- transports.FirewallGrpcAsyncIOTransport,
- transports.FirewallRestTransport,
- ],
-)
-def test_transport_adc(transport_class):
- # Test default credentials are used if not provided.
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class()
- adc.assert_called_once()
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "rest",
- ],
-)
-def test_transport_kind(transport_name):
- transport = FirewallClient.get_transport_class(transport_name)(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert transport.kind == transport_name
-
-
-def test_transport_grpc_default():
- # A client should use the gRPC transport by default.
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert isinstance(
- client.transport,
- transports.FirewallGrpcTransport,
- )
-
-
-def test_firewall_base_transport_error():
- # Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(core_exceptions.DuplicateCredentialArgs):
- transport = transports.FirewallTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- credentials_file="credentials.json",
- )
-
-
-def test_firewall_base_transport():
- # Instantiate the base transport.
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.firewall.transports.FirewallTransport.__init__"
- ) as Transport:
- Transport.return_value = None
- transport = transports.FirewallTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Every method on the transport should just blindly
- # raise NotImplementedError.
- methods = (
- "list_ingress_rules",
- "batch_update_ingress_rules",
- "create_ingress_rule",
- "get_ingress_rule",
- "update_ingress_rule",
- "delete_ingress_rule",
- )
- for method in methods:
- with pytest.raises(NotImplementedError):
- getattr(transport, method)(request=object())
-
- with pytest.raises(NotImplementedError):
- transport.close()
-
- # Catch all for all remaining methods and properties
- remainder = [
- "kind",
- ]
- for r in remainder:
- with pytest.raises(NotImplementedError):
- getattr(transport, r)()
-
-
-def test_firewall_base_transport_with_credentials_file():
- # Instantiate the base transport with a credentials file
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch(
- "google.cloud.appengine_admin_v1.services.firewall.transports.FirewallTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.FirewallTransport(
- credentials_file="credentials.json",
- quota_project_id="octopus",
- )
- load_creds.assert_called_once_with(
- "credentials.json",
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-def test_firewall_base_transport_with_adc():
- # Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
- "google.cloud.appengine_admin_v1.services.firewall.transports.FirewallTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.FirewallTransport()
- adc.assert_called_once()
-
-
-def test_firewall_auth_adc():
- # If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- FirewallClient()
- adc.assert_called_once_with(
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id=None,
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.FirewallGrpcTransport,
- transports.FirewallGrpcAsyncIOTransport,
- ],
-)
-def test_firewall_transport_auth_adc(transport_class):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
- adc.assert_called_once_with(
- scopes=["1", "2"],
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.FirewallGrpcTransport,
- transports.FirewallGrpcAsyncIOTransport,
- transports.FirewallRestTransport,
- ],
-)
-def test_firewall_transport_auth_gdch_credentials(transport_class):
- host = "https://language.com"
- api_audience_tests = [None, "https://language2.com"]
- api_audience_expect = [host, "https://language2.com"]
- for t, e in zip(api_audience_tests, api_audience_expect):
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- gdch_mock = mock.MagicMock()
- type(gdch_mock).with_gdch_audience = mock.PropertyMock(
- return_value=gdch_mock
- )
- adc.return_value = (gdch_mock, None)
- transport_class(host=host, api_audience=t)
- gdch_mock.with_gdch_audience.assert_called_once_with(e)
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.FirewallGrpcTransport, grpc_helpers),
- (transports.FirewallGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-def test_firewall_transport_create_channel(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=["1", "2"],
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [transports.FirewallGrpcTransport, transports.FirewallGrpcAsyncIOTransport],
-)
-def test_firewall_grpc_transport_client_cert_source_for_mtls(transport_class):
- cred = ga_credentials.AnonymousCredentials()
-
- # Check ssl_channel_credentials is used if provided.
- with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
- mock_ssl_channel_creds = mock.Mock()
- transport_class(
- host="squid.clam.whelk",
- credentials=cred,
- ssl_channel_credentials=mock_ssl_channel_creds,
- )
- mock_create_channel.assert_called_once_with(
- "squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_channel_creds,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
- # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls
- # is used.
- with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()):
- with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred:
- transport_class(
- credentials=cred,
- client_cert_source_for_mtls=client_cert_source_callback,
- )
- expected_cert, expected_key = client_cert_source_callback()
- mock_ssl_cred.assert_called_once_with(
- certificate_chain=expected_cert, private_key=expected_key
- )
-
-
-def test_firewall_http_transport_client_cert_source_for_mtls():
- cred = ga_credentials.AnonymousCredentials()
- with mock.patch(
- "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"
- ) as mock_configure_mtls_channel:
- transports.FirewallRestTransport(
- credentials=cred, client_cert_source_for_mtls=client_cert_source_callback
- )
- mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback)
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_firewall_host_no_port(transport_name):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_firewall_host_with_port(transport_name):
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com:8000"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:8000"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com:8000"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "rest",
- ],
-)
-def test_firewall_client_transport_session_collision(transport_name):
- creds1 = ga_credentials.AnonymousCredentials()
- creds2 = ga_credentials.AnonymousCredentials()
- client1 = FirewallClient(
- credentials=creds1,
- transport=transport_name,
- )
- client2 = FirewallClient(
- credentials=creds2,
- transport=transport_name,
- )
- session1 = client1.transport.list_ingress_rules._session
- session2 = client2.transport.list_ingress_rules._session
- assert session1 != session2
- session1 = client1.transport.batch_update_ingress_rules._session
- session2 = client2.transport.batch_update_ingress_rules._session
- assert session1 != session2
- session1 = client1.transport.create_ingress_rule._session
- session2 = client2.transport.create_ingress_rule._session
- assert session1 != session2
- session1 = client1.transport.get_ingress_rule._session
- session2 = client2.transport.get_ingress_rule._session
- assert session1 != session2
- session1 = client1.transport.update_ingress_rule._session
- session2 = client2.transport.update_ingress_rule._session
- assert session1 != session2
- session1 = client1.transport.delete_ingress_rule._session
- session2 = client2.transport.delete_ingress_rule._session
- assert session1 != session2
-
-
-def test_firewall_grpc_transport_channel():
- channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.FirewallGrpcTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-def test_firewall_grpc_asyncio_transport_channel():
- channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.FirewallGrpcAsyncIOTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [transports.FirewallGrpcTransport, transports.FirewallGrpcAsyncIOTransport],
-)
-def test_firewall_transport_channel_mtls_with_client_cert_source(transport_class):
- with mock.patch(
- "grpc.ssl_channel_credentials", autospec=True
- ) as grpc_ssl_channel_cred:
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_ssl_cred = mock.Mock()
- grpc_ssl_channel_cred.return_value = mock_ssl_cred
-
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
-
- cred = ga_credentials.AnonymousCredentials()
- with pytest.warns(DeprecationWarning):
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (cred, None)
- transport = transport_class(
- host="squid.clam.whelk",
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=client_cert_source_callback,
- )
- adc.assert_called_once()
-
- grpc_ssl_channel_cred.assert_called_once_with(
- certificate_chain=b"cert bytes", private_key=b"key bytes"
- )
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
- assert transport._ssl_channel_credentials == mock_ssl_cred
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [transports.FirewallGrpcTransport, transports.FirewallGrpcAsyncIOTransport],
-)
-def test_firewall_transport_channel_mtls_with_adc(transport_class):
- mock_ssl_cred = mock.Mock()
- with mock.patch.multiple(
- "google.auth.transport.grpc.SslCredentials",
- __init__=mock.Mock(return_value=None),
- ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
- ):
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
- mock_cred = mock.Mock()
-
- with pytest.warns(DeprecationWarning):
- transport = transport_class(
- host="squid.clam.whelk",
- credentials=mock_cred,
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=None,
- )
-
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=mock_cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
-
-
-def test_common_billing_account_path():
- billing_account = "squid"
- expected = "billingAccounts/{billing_account}".format(
- billing_account=billing_account,
- )
- actual = FirewallClient.common_billing_account_path(billing_account)
- assert expected == actual
-
-
-def test_parse_common_billing_account_path():
- expected = {
- "billing_account": "clam",
- }
- path = FirewallClient.common_billing_account_path(**expected)
-
- # Check that the path construction is reversible.
- actual = FirewallClient.parse_common_billing_account_path(path)
- assert expected == actual
-
-
-def test_common_folder_path():
- folder = "whelk"
- expected = "folders/{folder}".format(
- folder=folder,
- )
- actual = FirewallClient.common_folder_path(folder)
- assert expected == actual
-
-
-def test_parse_common_folder_path():
- expected = {
- "folder": "octopus",
- }
- path = FirewallClient.common_folder_path(**expected)
-
- # Check that the path construction is reversible.
- actual = FirewallClient.parse_common_folder_path(path)
- assert expected == actual
-
-
-def test_common_organization_path():
- organization = "oyster"
- expected = "organizations/{organization}".format(
- organization=organization,
- )
- actual = FirewallClient.common_organization_path(organization)
- assert expected == actual
-
-
-def test_parse_common_organization_path():
- expected = {
- "organization": "nudibranch",
- }
- path = FirewallClient.common_organization_path(**expected)
-
- # Check that the path construction is reversible.
- actual = FirewallClient.parse_common_organization_path(path)
- assert expected == actual
-
-
-def test_common_project_path():
- project = "cuttlefish"
- expected = "projects/{project}".format(
- project=project,
- )
- actual = FirewallClient.common_project_path(project)
- assert expected == actual
-
-
-def test_parse_common_project_path():
- expected = {
- "project": "mussel",
- }
- path = FirewallClient.common_project_path(**expected)
-
- # Check that the path construction is reversible.
- actual = FirewallClient.parse_common_project_path(path)
- assert expected == actual
-
-
-def test_common_location_path():
- project = "winkle"
- location = "nautilus"
- expected = "projects/{project}/locations/{location}".format(
- project=project,
- location=location,
- )
- actual = FirewallClient.common_location_path(project, location)
- assert expected == actual
-
-
-def test_parse_common_location_path():
- expected = {
- "project": "scallop",
- "location": "abalone",
- }
- path = FirewallClient.common_location_path(**expected)
-
- # Check that the path construction is reversible.
- actual = FirewallClient.parse_common_location_path(path)
- assert expected == actual
-
-
-def test_client_with_default_client_info():
- client_info = gapic_v1.client_info.ClientInfo()
-
- with mock.patch.object(
- transports.FirewallTransport, "_prep_wrapped_messages"
- ) as prep:
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
- with mock.patch.object(
- transports.FirewallTransport, "_prep_wrapped_messages"
- ) as prep:
- transport_class = FirewallClient.get_transport_class()
- transport = transport_class(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
-
-@pytest.mark.asyncio
-async def test_transport_close_async():
- client = FirewallAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- with mock.patch.object(
- type(getattr(client.transport, "grpc_channel")), "close"
- ) as close:
- async with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_transport_close():
- transports = {
- "rest": "_session",
- "grpc": "_grpc_channel",
- }
-
- for transport, close_name in transports.items():
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- with mock.patch.object(
- type(getattr(client.transport, close_name)), "close"
- ) as close:
- with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_client_ctx():
- transports = [
- "rest",
- "grpc",
- ]
- for transport in transports:
- client = FirewallClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- # Test client calls underlying transport.
- with mock.patch.object(type(client.transport), "close") as close:
- close.assert_not_called()
- with client:
- pass
- close.assert_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class",
- [
- (FirewallClient, transports.FirewallGrpcTransport),
- (FirewallAsyncClient, transports.FirewallGrpcAsyncIOTransport),
- ],
-)
-def test_api_key_credentials(client_class, transport_class):
- with mock.patch.object(
- google.auth._default, "get_api_key_credentials", create=True
- ) as get_api_key_credentials:
- mock_cred = mock.Mock()
- get_api_key_credentials.return_value = mock_cred
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options)
- patched.assert_called_once_with(
- credentials=mock_cred,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
diff --git a/tests/unit/gapic/appengine_admin_v1/test_instances.py b/tests/unit/gapic/appengine_admin_v1/test_instances.py
deleted file mode 100644
index 4a001e7..0000000
--- a/tests/unit/gapic/appengine_admin_v1/test_instances.py
+++ /dev/null
@@ -1,2950 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import os
-
-# try/except added for compatibility with python < 3.8
-try:
- from unittest import mock
- from unittest.mock import AsyncMock # pragma: NO COVER
-except ImportError: # pragma: NO COVER
- import mock
-
-from collections.abc import Iterable
-import json
-import math
-
-from google.api_core import (
- future,
- gapic_v1,
- grpc_helpers,
- grpc_helpers_async,
- operation,
- operations_v1,
- path_template,
-)
-from google.api_core import client_options
-from google.api_core import exceptions as core_exceptions
-from google.api_core import operation_async # type: ignore
-import google.auth
-from google.auth import credentials as ga_credentials
-from google.auth.exceptions import MutualTLSChannelError
-from google.longrunning import operations_pb2 # type: ignore
-from google.oauth2 import service_account
-from google.protobuf import empty_pb2 # type: ignore
-from google.protobuf import json_format
-from google.protobuf import timestamp_pb2 # type: ignore
-import grpc
-from grpc.experimental import aio
-from proto.marshal.rules import wrappers
-from proto.marshal.rules.dates import DurationRule, TimestampRule
-import pytest
-from requests import PreparedRequest, Request, Response
-from requests.sessions import Session
-
-from google.cloud.appengine_admin_v1.services.instances import (
- InstancesAsyncClient,
- InstancesClient,
- pagers,
- transports,
-)
-from google.cloud.appengine_admin_v1.types import appengine, instance
-from google.cloud.appengine_admin_v1.types import operation as ga_operation
-
-
-def client_cert_source_callback():
- return b"cert bytes", b"key bytes"
-
-
-# If default endpoint is localhost, then default mtls endpoint will be the same.
-# This method modifies the default endpoint so the client can produce a different
-# mtls endpoint for endpoint testing purposes.
-def modify_default_endpoint(client):
- return (
- "foo.googleapis.com"
- if ("localhost" in client.DEFAULT_ENDPOINT)
- else client.DEFAULT_ENDPOINT
- )
-
-
-def test__get_default_mtls_endpoint():
- api_endpoint = "example.googleapis.com"
- api_mtls_endpoint = "example.mtls.googleapis.com"
- sandbox_endpoint = "example.sandbox.googleapis.com"
- sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
- non_googleapi = "api.example.com"
-
- assert InstancesClient._get_default_mtls_endpoint(None) is None
- assert InstancesClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint
- assert (
- InstancesClient._get_default_mtls_endpoint(api_mtls_endpoint)
- == api_mtls_endpoint
- )
- assert (
- InstancesClient._get_default_mtls_endpoint(sandbox_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- InstancesClient._get_default_mtls_endpoint(sandbox_mtls_endpoint)
- == sandbox_mtls_endpoint
- )
- assert InstancesClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (InstancesClient, "grpc"),
- (InstancesAsyncClient, "grpc_asyncio"),
- (InstancesClient, "rest"),
- ],
-)
-def test_instances_client_from_service_account_info(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_info"
- ) as factory:
- factory.return_value = creds
- info = {"valid": True}
- client = client_class.from_service_account_info(info, transport=transport_name)
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,transport_name",
- [
- (transports.InstancesGrpcTransport, "grpc"),
- (transports.InstancesGrpcAsyncIOTransport, "grpc_asyncio"),
- (transports.InstancesRestTransport, "rest"),
- ],
-)
-def test_instances_client_service_account_always_use_jwt(
- transport_class, transport_name
-):
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=True)
- use_jwt.assert_called_once_with(True)
-
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=False)
- use_jwt.assert_not_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (InstancesClient, "grpc"),
- (InstancesAsyncClient, "grpc_asyncio"),
- (InstancesClient, "rest"),
- ],
-)
-def test_instances_client_from_service_account_file(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_file"
- ) as factory:
- factory.return_value = creds
- client = client_class.from_service_account_file(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- client = client_class.from_service_account_json(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-def test_instances_client_get_transport_class():
- transport = InstancesClient.get_transport_class()
- available_transports = [
- transports.InstancesGrpcTransport,
- transports.InstancesRestTransport,
- ]
- assert transport in available_transports
-
- transport = InstancesClient.get_transport_class("grpc")
- assert transport == transports.InstancesGrpcTransport
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (InstancesClient, transports.InstancesGrpcTransport, "grpc"),
- (
- InstancesAsyncClient,
- transports.InstancesGrpcAsyncIOTransport,
- "grpc_asyncio",
- ),
- (InstancesClient, transports.InstancesRestTransport, "rest"),
- ],
-)
-@mock.patch.object(
- InstancesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(InstancesClient)
-)
-@mock.patch.object(
- InstancesAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(InstancesAsyncClient),
-)
-def test_instances_client_client_options(client_class, transport_class, transport_name):
- # Check that if channel is provided we won't create a new one.
- with mock.patch.object(InstancesClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
- client = client_class(transport=transport)
- gtc.assert_not_called()
-
- # Check that if channel is provided via str we will create a new one.
- with mock.patch.object(InstancesClient, "get_transport_class") as gtc:
- client = client_class(transport=transport_name)
- gtc.assert_called()
-
- # Check the case api_endpoint is provided.
- options = client_options.ClientOptions(api_endpoint="squid.clam.whelk")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name, client_options=options)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_MTLS_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
- # unsupported value.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
- with pytest.raises(MutualTLSChannelError):
- client = client_class(transport=transport_name)
-
- # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
- ):
- with pytest.raises(ValueError):
- client = client_class(transport=transport_name)
-
- # Check the case quota_project_id is provided
- options = client_options.ClientOptions(quota_project_id="octopus")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id="octopus",
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
- # Check the case api_endpoint is provided
- options = client_options.ClientOptions(
- api_audience="https://language.googleapis.com"
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience="https://language.googleapis.com",
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,use_client_cert_env",
- [
- (InstancesClient, transports.InstancesGrpcTransport, "grpc", "true"),
- (
- InstancesAsyncClient,
- transports.InstancesGrpcAsyncIOTransport,
- "grpc_asyncio",
- "true",
- ),
- (InstancesClient, transports.InstancesGrpcTransport, "grpc", "false"),
- (
- InstancesAsyncClient,
- transports.InstancesGrpcAsyncIOTransport,
- "grpc_asyncio",
- "false",
- ),
- (InstancesClient, transports.InstancesRestTransport, "rest", "true"),
- (InstancesClient, transports.InstancesRestTransport, "rest", "false"),
- ],
-)
-@mock.patch.object(
- InstancesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(InstancesClient)
-)
-@mock.patch.object(
- InstancesAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(InstancesAsyncClient),
-)
-@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"})
-def test_instances_client_mtls_env_auto(
- client_class, transport_class, transport_name, use_client_cert_env
-):
- # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default
- # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists.
-
- # Check the case client_cert_source is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- options = client_options.ClientOptions(
- client_cert_source=client_cert_source_callback
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
-
- if use_client_cert_env == "false":
- expected_client_cert_source = None
- expected_host = client.DEFAULT_ENDPOINT
- else:
- expected_client_cert_source = client_cert_source_callback
- expected_host = client.DEFAULT_MTLS_ENDPOINT
-
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case ADC client cert is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=client_cert_source_callback,
- ):
- if use_client_cert_env == "false":
- expected_host = client.DEFAULT_ENDPOINT
- expected_client_cert_source = None
- else:
- expected_host = client.DEFAULT_MTLS_ENDPOINT
- expected_client_cert_source = client_cert_source_callback
-
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case client_cert_source and ADC client cert are not provided.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize("client_class", [InstancesClient, InstancesAsyncClient])
-@mock.patch.object(
- InstancesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(InstancesClient)
-)
-@mock.patch.object(
- InstancesAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(InstancesAsyncClient),
-)
-def test_instances_client_get_mtls_endpoint_and_cert_source(client_class):
- mock_client_cert_source = mock.Mock()
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source == mock_client_cert_source
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
- mock_client_cert_source = mock.Mock()
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=mock_client_cert_source,
- ):
- (
- api_endpoint,
- cert_source,
- ) = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source == mock_client_cert_source
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (InstancesClient, transports.InstancesGrpcTransport, "grpc"),
- (
- InstancesAsyncClient,
- transports.InstancesGrpcAsyncIOTransport,
- "grpc_asyncio",
- ),
- (InstancesClient, transports.InstancesRestTransport, "rest"),
- ],
-)
-def test_instances_client_client_options_scopes(
- client_class, transport_class, transport_name
-):
- # Check the case scopes are provided.
- options = client_options.ClientOptions(
- scopes=["1", "2"],
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=["1", "2"],
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (InstancesClient, transports.InstancesGrpcTransport, "grpc", grpc_helpers),
- (
- InstancesAsyncClient,
- transports.InstancesGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- (InstancesClient, transports.InstancesRestTransport, "rest", None),
- ],
-)
-def test_instances_client_client_options_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-def test_instances_client_client_options_from_dict():
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.instances.transports.InstancesGrpcTransport.__init__"
- ) as grpc_transport:
- grpc_transport.return_value = None
- client = InstancesClient(client_options={"api_endpoint": "squid.clam.whelk"})
- grpc_transport.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (InstancesClient, transports.InstancesGrpcTransport, "grpc", grpc_helpers),
- (
- InstancesAsyncClient,
- transports.InstancesGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- ],
-)
-def test_instances_client_create_channel_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # test that the credentials from file are saved and used as the credentials.
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel"
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- file_creds = ga_credentials.AnonymousCredentials()
- load_creds.return_value = (file_creds, None)
- adc.return_value = (creds, None)
- client = client_class(client_options=options, transport=transport_name)
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=file_creds,
- credentials_file=None,
- quota_project_id=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=None,
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListInstancesRequest,
- dict,
- ],
-)
-def test_list_instances(request_type, transport: str = "grpc"):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = appengine.ListInstancesResponse(
- next_page_token="next_page_token_value",
- )
- response = client.list_instances(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListInstancesRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListInstancesPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-def test_list_instances_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
- client.list_instances()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListInstancesRequest()
-
-
-@pytest.mark.asyncio
-async def test_list_instances_async(
- transport: str = "grpc_asyncio", request_type=appengine.ListInstancesRequest
-):
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListInstancesResponse(
- next_page_token="next_page_token_value",
- )
- )
- response = await client.list_instances(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListInstancesRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListInstancesAsyncPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.asyncio
-async def test_list_instances_async_from_dict():
- await test_list_instances_async(request_type=dict)
-
-
-def test_list_instances_field_headers():
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListInstancesRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
- call.return_value = appengine.ListInstancesResponse()
- client.list_instances(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_list_instances_field_headers_async():
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListInstancesRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListInstancesResponse()
- )
- await client.list_instances(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-def test_list_instances_pager(transport_name: str = "grpc"):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- instance.Instance(),
- instance.Instance(),
- ],
- next_page_token="abc",
- ),
- appengine.ListInstancesResponse(
- instances=[],
- next_page_token="def",
- ),
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- instance.Instance(),
- ],
- ),
- RuntimeError,
- )
-
- metadata = ()
- metadata = tuple(metadata) + (
- gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)),
- )
- pager = client.list_instances(request={})
-
- assert pager._metadata == metadata
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, instance.Instance) for i in results)
-
-
-def test_list_instances_pages(transport_name: str = "grpc"):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- instance.Instance(),
- instance.Instance(),
- ],
- next_page_token="abc",
- ),
- appengine.ListInstancesResponse(
- instances=[],
- next_page_token="def",
- ),
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- instance.Instance(),
- ],
- ),
- RuntimeError,
- )
- pages = list(client.list_instances(request={}).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.asyncio
-async def test_list_instances_async_pager():
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_instances), "__call__", new_callable=mock.AsyncMock
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- instance.Instance(),
- instance.Instance(),
- ],
- next_page_token="abc",
- ),
- appengine.ListInstancesResponse(
- instances=[],
- next_page_token="def",
- ),
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- instance.Instance(),
- ],
- ),
- RuntimeError,
- )
- async_pager = await client.list_instances(
- request={},
- )
- assert async_pager.next_page_token == "abc"
- responses = []
- async for response in async_pager: # pragma: no branch
- responses.append(response)
-
- assert len(responses) == 6
- assert all(isinstance(i, instance.Instance) for i in responses)
-
-
-@pytest.mark.asyncio
-async def test_list_instances_async_pages():
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_instances), "__call__", new_callable=mock.AsyncMock
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- instance.Instance(),
- instance.Instance(),
- ],
- next_page_token="abc",
- ),
- appengine.ListInstancesResponse(
- instances=[],
- next_page_token="def",
- ),
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- instance.Instance(),
- ],
- ),
- RuntimeError,
- )
- pages = []
- # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
- # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
- async for page_ in ( # pragma: no branch
- await client.list_instances(request={})
- ).pages:
- pages.append(page_)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetInstanceRequest,
- dict,
- ],
-)
-def test_get_instance(request_type, transport: str = "grpc"):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_instance), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = instance.Instance(
- name="name_value",
- id="id_value",
- app_engine_release="app_engine_release_value",
- availability=instance.Instance.Availability.RESIDENT,
- vm_name="vm_name_value",
- vm_zone_name="vm_zone_name_value",
- vm_id="vm_id_value",
- requests=892,
- errors=669,
- qps=0.34,
- average_latency=1578,
- memory_usage=1293,
- vm_status="vm_status_value",
- vm_debug_enabled=True,
- vm_ip="vm_ip_value",
- vm_liveness=instance.Instance.Liveness.LivenessState.UNKNOWN,
- )
- response = client.get_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetInstanceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, instance.Instance)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.app_engine_release == "app_engine_release_value"
- assert response.availability == instance.Instance.Availability.RESIDENT
- assert response.vm_name == "vm_name_value"
- assert response.vm_zone_name == "vm_zone_name_value"
- assert response.vm_id == "vm_id_value"
- assert response.requests == 892
- assert response.errors == 669
- assert math.isclose(response.qps, 0.34, rel_tol=1e-6)
- assert response.average_latency == 1578
- assert response.memory_usage == 1293
- assert response.vm_status == "vm_status_value"
- assert response.vm_debug_enabled is True
- assert response.vm_ip == "vm_ip_value"
- assert response.vm_liveness == instance.Instance.Liveness.LivenessState.UNKNOWN
-
-
-def test_get_instance_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_instance), "__call__") as call:
- client.get_instance()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetInstanceRequest()
-
-
-@pytest.mark.asyncio
-async def test_get_instance_async(
- transport: str = "grpc_asyncio", request_type=appengine.GetInstanceRequest
-):
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_instance), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- instance.Instance(
- name="name_value",
- id="id_value",
- app_engine_release="app_engine_release_value",
- availability=instance.Instance.Availability.RESIDENT,
- vm_name="vm_name_value",
- vm_zone_name="vm_zone_name_value",
- vm_id="vm_id_value",
- requests=892,
- errors=669,
- qps=0.34,
- average_latency=1578,
- memory_usage=1293,
- vm_status="vm_status_value",
- vm_debug_enabled=True,
- vm_ip="vm_ip_value",
- vm_liveness=instance.Instance.Liveness.LivenessState.UNKNOWN,
- )
- )
- response = await client.get_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetInstanceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, instance.Instance)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.app_engine_release == "app_engine_release_value"
- assert response.availability == instance.Instance.Availability.RESIDENT
- assert response.vm_name == "vm_name_value"
- assert response.vm_zone_name == "vm_zone_name_value"
- assert response.vm_id == "vm_id_value"
- assert response.requests == 892
- assert response.errors == 669
- assert math.isclose(response.qps, 0.34, rel_tol=1e-6)
- assert response.average_latency == 1578
- assert response.memory_usage == 1293
- assert response.vm_status == "vm_status_value"
- assert response.vm_debug_enabled is True
- assert response.vm_ip == "vm_ip_value"
- assert response.vm_liveness == instance.Instance.Liveness.LivenessState.UNKNOWN
-
-
-@pytest.mark.asyncio
-async def test_get_instance_async_from_dict():
- await test_get_instance_async(request_type=dict)
-
-
-def test_get_instance_field_headers():
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetInstanceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_instance), "__call__") as call:
- call.return_value = instance.Instance()
- client.get_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_get_instance_field_headers_async():
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetInstanceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_instance), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(instance.Instance())
- await client.get_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteInstanceRequest,
- dict,
- ],
-)
-def test_delete_instance(request_type, transport: str = "grpc"):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_instance), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.delete_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteInstanceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_delete_instance_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_instance), "__call__") as call:
- client.delete_instance()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteInstanceRequest()
-
-
-@pytest.mark.asyncio
-async def test_delete_instance_async(
- transport: str = "grpc_asyncio", request_type=appengine.DeleteInstanceRequest
-):
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_instance), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.delete_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteInstanceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_delete_instance_async_from_dict():
- await test_delete_instance_async(request_type=dict)
-
-
-def test_delete_instance_field_headers():
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteInstanceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_instance), "__call__") as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.delete_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_delete_instance_field_headers_async():
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteInstanceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_instance), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.delete_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DebugInstanceRequest,
- dict,
- ],
-)
-def test_debug_instance(request_type, transport: str = "grpc"):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.debug_instance), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.debug_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DebugInstanceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_debug_instance_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.debug_instance), "__call__") as call:
- client.debug_instance()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DebugInstanceRequest()
-
-
-@pytest.mark.asyncio
-async def test_debug_instance_async(
- transport: str = "grpc_asyncio", request_type=appengine.DebugInstanceRequest
-):
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.debug_instance), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.debug_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DebugInstanceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_debug_instance_async_from_dict():
- await test_debug_instance_async(request_type=dict)
-
-
-def test_debug_instance_field_headers():
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DebugInstanceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.debug_instance), "__call__") as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.debug_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_debug_instance_field_headers_async():
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DebugInstanceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.debug_instance), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.debug_instance(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListInstancesRequest,
- dict,
- ],
-)
-def test_list_instances_rest(request_type):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1/services/sample2/versions/sample3"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = appengine.ListInstancesResponse(
- next_page_token="next_page_token_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = appengine.ListInstancesResponse.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.list_instances(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListInstancesPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_list_instances_rest_interceptors(null_interceptor):
- transport = transports.InstancesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.InstancesRestInterceptor(),
- )
- client = InstancesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.InstancesRestInterceptor, "post_list_instances"
- ) as post, mock.patch.object(
- transports.InstancesRestInterceptor, "pre_list_instances"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.ListInstancesRequest.pb(appengine.ListInstancesRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = appengine.ListInstancesResponse.to_json(
- appengine.ListInstancesResponse()
- )
-
- request = appengine.ListInstancesRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = appengine.ListInstancesResponse()
-
- client.list_instances(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_list_instances_rest_bad_request(
- transport: str = "rest", request_type=appengine.ListInstancesRequest
-):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1/services/sample2/versions/sample3"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.list_instances(request)
-
-
-def test_list_instances_rest_pager(transport: str = "rest"):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(Session, "request") as req:
- # TODO(kbandes): remove this mock unless there's a good reason for it.
- # with mock.patch.object(path_template, 'transcode') as transcode:
- # Set the response as a series of pages
- response = (
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- instance.Instance(),
- instance.Instance(),
- ],
- next_page_token="abc",
- ),
- appengine.ListInstancesResponse(
- instances=[],
- next_page_token="def",
- ),
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListInstancesResponse(
- instances=[
- instance.Instance(),
- instance.Instance(),
- ],
- ),
- )
- # Two responses for two calls
- response = response + response
-
- # Wrap the values into proper Response objs
- response = tuple(appengine.ListInstancesResponse.to_json(x) for x in response)
- return_values = tuple(Response() for i in response)
- for return_val, response_val in zip(return_values, response):
- return_val._content = response_val.encode("UTF-8")
- return_val.status_code = 200
- req.side_effect = return_values
-
- sample_request = {"parent": "apps/sample1/services/sample2/versions/sample3"}
-
- pager = client.list_instances(request=sample_request)
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, instance.Instance) for i in results)
-
- pages = list(client.list_instances(request=sample_request).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetInstanceRequest,
- dict,
- ],
-)
-def test_get_instance_rest(request_type):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {
- "name": "apps/sample1/services/sample2/versions/sample3/instances/sample4"
- }
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = instance.Instance(
- name="name_value",
- id="id_value",
- app_engine_release="app_engine_release_value",
- availability=instance.Instance.Availability.RESIDENT,
- vm_name="vm_name_value",
- vm_zone_name="vm_zone_name_value",
- vm_id="vm_id_value",
- requests=892,
- errors=669,
- qps=0.34,
- average_latency=1578,
- memory_usage=1293,
- vm_status="vm_status_value",
- vm_debug_enabled=True,
- vm_ip="vm_ip_value",
- vm_liveness=instance.Instance.Liveness.LivenessState.UNKNOWN,
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = instance.Instance.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.get_instance(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, instance.Instance)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.app_engine_release == "app_engine_release_value"
- assert response.availability == instance.Instance.Availability.RESIDENT
- assert response.vm_name == "vm_name_value"
- assert response.vm_zone_name == "vm_zone_name_value"
- assert response.vm_id == "vm_id_value"
- assert response.requests == 892
- assert response.errors == 669
- assert math.isclose(response.qps, 0.34, rel_tol=1e-6)
- assert response.average_latency == 1578
- assert response.memory_usage == 1293
- assert response.vm_status == "vm_status_value"
- assert response.vm_debug_enabled is True
- assert response.vm_ip == "vm_ip_value"
- assert response.vm_liveness == instance.Instance.Liveness.LivenessState.UNKNOWN
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_get_instance_rest_interceptors(null_interceptor):
- transport = transports.InstancesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.InstancesRestInterceptor(),
- )
- client = InstancesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.InstancesRestInterceptor, "post_get_instance"
- ) as post, mock.patch.object(
- transports.InstancesRestInterceptor, "pre_get_instance"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.GetInstanceRequest.pb(appengine.GetInstanceRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = instance.Instance.to_json(instance.Instance())
-
- request = appengine.GetInstanceRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = instance.Instance()
-
- client.get_instance(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_get_instance_rest_bad_request(
- transport: str = "rest", request_type=appengine.GetInstanceRequest
-):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {
- "name": "apps/sample1/services/sample2/versions/sample3/instances/sample4"
- }
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.get_instance(request)
-
-
-def test_get_instance_rest_error():
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteInstanceRequest,
- dict,
- ],
-)
-def test_delete_instance_rest(request_type):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {
- "name": "apps/sample1/services/sample2/versions/sample3/instances/sample4"
- }
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.delete_instance(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_delete_instance_rest_interceptors(null_interceptor):
- transport = transports.InstancesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.InstancesRestInterceptor(),
- )
- client = InstancesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.InstancesRestInterceptor, "post_delete_instance"
- ) as post, mock.patch.object(
- transports.InstancesRestInterceptor, "pre_delete_instance"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.DeleteInstanceRequest.pb(
- appengine.DeleteInstanceRequest()
- )
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.DeleteInstanceRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.delete_instance(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_delete_instance_rest_bad_request(
- transport: str = "rest", request_type=appengine.DeleteInstanceRequest
-):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {
- "name": "apps/sample1/services/sample2/versions/sample3/instances/sample4"
- }
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.delete_instance(request)
-
-
-def test_delete_instance_rest_error():
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DebugInstanceRequest,
- dict,
- ],
-)
-def test_debug_instance_rest(request_type):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {
- "name": "apps/sample1/services/sample2/versions/sample3/instances/sample4"
- }
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.debug_instance(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_debug_instance_rest_interceptors(null_interceptor):
- transport = transports.InstancesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.InstancesRestInterceptor(),
- )
- client = InstancesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.InstancesRestInterceptor, "post_debug_instance"
- ) as post, mock.patch.object(
- transports.InstancesRestInterceptor, "pre_debug_instance"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.DebugInstanceRequest.pb(appengine.DebugInstanceRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.DebugInstanceRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.debug_instance(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_debug_instance_rest_bad_request(
- transport: str = "rest", request_type=appengine.DebugInstanceRequest
-):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {
- "name": "apps/sample1/services/sample2/versions/sample3/instances/sample4"
- }
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.debug_instance(request)
-
-
-def test_debug_instance_rest_error():
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-def test_credentials_transport_error():
- # It is an error to provide credentials and a transport instance.
- transport = transports.InstancesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # It is an error to provide a credentials file and a transport instance.
- transport = transports.InstancesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = InstancesClient(
- client_options={"credentials_file": "credentials.json"},
- transport=transport,
- )
-
- # It is an error to provide an api_key and a transport instance.
- transport = transports.InstancesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = InstancesClient(
- client_options=options,
- transport=transport,
- )
-
- # It is an error to provide an api_key and a credential.
- options = mock.Mock()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = InstancesClient(
- client_options=options, credentials=ga_credentials.AnonymousCredentials()
- )
-
- # It is an error to provide scopes and a transport instance.
- transport = transports.InstancesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = InstancesClient(
- client_options={"scopes": ["1", "2"]},
- transport=transport,
- )
-
-
-def test_transport_instance():
- # A client may be instantiated with a custom transport instance.
- transport = transports.InstancesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- client = InstancesClient(transport=transport)
- assert client.transport is transport
-
-
-def test_transport_get_channel():
- # A client may be instantiated with a custom transport instance.
- transport = transports.InstancesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
- transport = transports.InstancesGrpcAsyncIOTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.InstancesGrpcTransport,
- transports.InstancesGrpcAsyncIOTransport,
- transports.InstancesRestTransport,
- ],
-)
-def test_transport_adc(transport_class):
- # Test default credentials are used if not provided.
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class()
- adc.assert_called_once()
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "rest",
- ],
-)
-def test_transport_kind(transport_name):
- transport = InstancesClient.get_transport_class(transport_name)(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert transport.kind == transport_name
-
-
-def test_transport_grpc_default():
- # A client should use the gRPC transport by default.
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert isinstance(
- client.transport,
- transports.InstancesGrpcTransport,
- )
-
-
-def test_instances_base_transport_error():
- # Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(core_exceptions.DuplicateCredentialArgs):
- transport = transports.InstancesTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- credentials_file="credentials.json",
- )
-
-
-def test_instances_base_transport():
- # Instantiate the base transport.
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.instances.transports.InstancesTransport.__init__"
- ) as Transport:
- Transport.return_value = None
- transport = transports.InstancesTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Every method on the transport should just blindly
- # raise NotImplementedError.
- methods = (
- "list_instances",
- "get_instance",
- "delete_instance",
- "debug_instance",
- )
- for method in methods:
- with pytest.raises(NotImplementedError):
- getattr(transport, method)(request=object())
-
- with pytest.raises(NotImplementedError):
- transport.close()
-
- # Additionally, the LRO client (a property) should
- # also raise NotImplementedError
- with pytest.raises(NotImplementedError):
- transport.operations_client
-
- # Catch all for all remaining methods and properties
- remainder = [
- "kind",
- ]
- for r in remainder:
- with pytest.raises(NotImplementedError):
- getattr(transport, r)()
-
-
-def test_instances_base_transport_with_credentials_file():
- # Instantiate the base transport with a credentials file
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch(
- "google.cloud.appengine_admin_v1.services.instances.transports.InstancesTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.InstancesTransport(
- credentials_file="credentials.json",
- quota_project_id="octopus",
- )
- load_creds.assert_called_once_with(
- "credentials.json",
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-def test_instances_base_transport_with_adc():
- # Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
- "google.cloud.appengine_admin_v1.services.instances.transports.InstancesTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.InstancesTransport()
- adc.assert_called_once()
-
-
-def test_instances_auth_adc():
- # If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- InstancesClient()
- adc.assert_called_once_with(
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id=None,
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.InstancesGrpcTransport,
- transports.InstancesGrpcAsyncIOTransport,
- ],
-)
-def test_instances_transport_auth_adc(transport_class):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
- adc.assert_called_once_with(
- scopes=["1", "2"],
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.InstancesGrpcTransport,
- transports.InstancesGrpcAsyncIOTransport,
- transports.InstancesRestTransport,
- ],
-)
-def test_instances_transport_auth_gdch_credentials(transport_class):
- host = "https://language.com"
- api_audience_tests = [None, "https://language2.com"]
- api_audience_expect = [host, "https://language2.com"]
- for t, e in zip(api_audience_tests, api_audience_expect):
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- gdch_mock = mock.MagicMock()
- type(gdch_mock).with_gdch_audience = mock.PropertyMock(
- return_value=gdch_mock
- )
- adc.return_value = (gdch_mock, None)
- transport_class(host=host, api_audience=t)
- gdch_mock.with_gdch_audience.assert_called_once_with(e)
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.InstancesGrpcTransport, grpc_helpers),
- (transports.InstancesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-def test_instances_transport_create_channel(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=["1", "2"],
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [transports.InstancesGrpcTransport, transports.InstancesGrpcAsyncIOTransport],
-)
-def test_instances_grpc_transport_client_cert_source_for_mtls(transport_class):
- cred = ga_credentials.AnonymousCredentials()
-
- # Check ssl_channel_credentials is used if provided.
- with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
- mock_ssl_channel_creds = mock.Mock()
- transport_class(
- host="squid.clam.whelk",
- credentials=cred,
- ssl_channel_credentials=mock_ssl_channel_creds,
- )
- mock_create_channel.assert_called_once_with(
- "squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_channel_creds,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
- # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls
- # is used.
- with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()):
- with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred:
- transport_class(
- credentials=cred,
- client_cert_source_for_mtls=client_cert_source_callback,
- )
- expected_cert, expected_key = client_cert_source_callback()
- mock_ssl_cred.assert_called_once_with(
- certificate_chain=expected_cert, private_key=expected_key
- )
-
-
-def test_instances_http_transport_client_cert_source_for_mtls():
- cred = ga_credentials.AnonymousCredentials()
- with mock.patch(
- "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"
- ) as mock_configure_mtls_channel:
- transports.InstancesRestTransport(
- credentials=cred, client_cert_source_for_mtls=client_cert_source_callback
- )
- mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback)
-
-
-def test_instances_rest_lro_client():
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.AbstractOperationsClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_instances_host_no_port(transport_name):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_instances_host_with_port(transport_name):
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com:8000"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:8000"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com:8000"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "rest",
- ],
-)
-def test_instances_client_transport_session_collision(transport_name):
- creds1 = ga_credentials.AnonymousCredentials()
- creds2 = ga_credentials.AnonymousCredentials()
- client1 = InstancesClient(
- credentials=creds1,
- transport=transport_name,
- )
- client2 = InstancesClient(
- credentials=creds2,
- transport=transport_name,
- )
- session1 = client1.transport.list_instances._session
- session2 = client2.transport.list_instances._session
- assert session1 != session2
- session1 = client1.transport.get_instance._session
- session2 = client2.transport.get_instance._session
- assert session1 != session2
- session1 = client1.transport.delete_instance._session
- session2 = client2.transport.delete_instance._session
- assert session1 != session2
- session1 = client1.transport.debug_instance._session
- session2 = client2.transport.debug_instance._session
- assert session1 != session2
-
-
-def test_instances_grpc_transport_channel():
- channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.InstancesGrpcTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-def test_instances_grpc_asyncio_transport_channel():
- channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.InstancesGrpcAsyncIOTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [transports.InstancesGrpcTransport, transports.InstancesGrpcAsyncIOTransport],
-)
-def test_instances_transport_channel_mtls_with_client_cert_source(transport_class):
- with mock.patch(
- "grpc.ssl_channel_credentials", autospec=True
- ) as grpc_ssl_channel_cred:
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_ssl_cred = mock.Mock()
- grpc_ssl_channel_cred.return_value = mock_ssl_cred
-
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
-
- cred = ga_credentials.AnonymousCredentials()
- with pytest.warns(DeprecationWarning):
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (cred, None)
- transport = transport_class(
- host="squid.clam.whelk",
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=client_cert_source_callback,
- )
- adc.assert_called_once()
-
- grpc_ssl_channel_cred.assert_called_once_with(
- certificate_chain=b"cert bytes", private_key=b"key bytes"
- )
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
- assert transport._ssl_channel_credentials == mock_ssl_cred
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [transports.InstancesGrpcTransport, transports.InstancesGrpcAsyncIOTransport],
-)
-def test_instances_transport_channel_mtls_with_adc(transport_class):
- mock_ssl_cred = mock.Mock()
- with mock.patch.multiple(
- "google.auth.transport.grpc.SslCredentials",
- __init__=mock.Mock(return_value=None),
- ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
- ):
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
- mock_cred = mock.Mock()
-
- with pytest.warns(DeprecationWarning):
- transport = transport_class(
- host="squid.clam.whelk",
- credentials=mock_cred,
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=None,
- )
-
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=mock_cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
-
-
-def test_instances_grpc_lro_client():
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.OperationsClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-def test_instances_grpc_lro_async_client():
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.OperationsAsyncClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-def test_instance_path():
- app = "squid"
- service = "clam"
- version = "whelk"
- instance = "octopus"
- expected = (
- "apps/{app}/services/{service}/versions/{version}/instances/{instance}".format(
- app=app,
- service=service,
- version=version,
- instance=instance,
- )
- )
- actual = InstancesClient.instance_path(app, service, version, instance)
- assert expected == actual
-
-
-def test_parse_instance_path():
- expected = {
- "app": "oyster",
- "service": "nudibranch",
- "version": "cuttlefish",
- "instance": "mussel",
- }
- path = InstancesClient.instance_path(**expected)
-
- # Check that the path construction is reversible.
- actual = InstancesClient.parse_instance_path(path)
- assert expected == actual
-
-
-def test_common_billing_account_path():
- billing_account = "winkle"
- expected = "billingAccounts/{billing_account}".format(
- billing_account=billing_account,
- )
- actual = InstancesClient.common_billing_account_path(billing_account)
- assert expected == actual
-
-
-def test_parse_common_billing_account_path():
- expected = {
- "billing_account": "nautilus",
- }
- path = InstancesClient.common_billing_account_path(**expected)
-
- # Check that the path construction is reversible.
- actual = InstancesClient.parse_common_billing_account_path(path)
- assert expected == actual
-
-
-def test_common_folder_path():
- folder = "scallop"
- expected = "folders/{folder}".format(
- folder=folder,
- )
- actual = InstancesClient.common_folder_path(folder)
- assert expected == actual
-
-
-def test_parse_common_folder_path():
- expected = {
- "folder": "abalone",
- }
- path = InstancesClient.common_folder_path(**expected)
-
- # Check that the path construction is reversible.
- actual = InstancesClient.parse_common_folder_path(path)
- assert expected == actual
-
-
-def test_common_organization_path():
- organization = "squid"
- expected = "organizations/{organization}".format(
- organization=organization,
- )
- actual = InstancesClient.common_organization_path(organization)
- assert expected == actual
-
-
-def test_parse_common_organization_path():
- expected = {
- "organization": "clam",
- }
- path = InstancesClient.common_organization_path(**expected)
-
- # Check that the path construction is reversible.
- actual = InstancesClient.parse_common_organization_path(path)
- assert expected == actual
-
-
-def test_common_project_path():
- project = "whelk"
- expected = "projects/{project}".format(
- project=project,
- )
- actual = InstancesClient.common_project_path(project)
- assert expected == actual
-
-
-def test_parse_common_project_path():
- expected = {
- "project": "octopus",
- }
- path = InstancesClient.common_project_path(**expected)
-
- # Check that the path construction is reversible.
- actual = InstancesClient.parse_common_project_path(path)
- assert expected == actual
-
-
-def test_common_location_path():
- project = "oyster"
- location = "nudibranch"
- expected = "projects/{project}/locations/{location}".format(
- project=project,
- location=location,
- )
- actual = InstancesClient.common_location_path(project, location)
- assert expected == actual
-
-
-def test_parse_common_location_path():
- expected = {
- "project": "cuttlefish",
- "location": "mussel",
- }
- path = InstancesClient.common_location_path(**expected)
-
- # Check that the path construction is reversible.
- actual = InstancesClient.parse_common_location_path(path)
- assert expected == actual
-
-
-def test_client_with_default_client_info():
- client_info = gapic_v1.client_info.ClientInfo()
-
- with mock.patch.object(
- transports.InstancesTransport, "_prep_wrapped_messages"
- ) as prep:
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
- with mock.patch.object(
- transports.InstancesTransport, "_prep_wrapped_messages"
- ) as prep:
- transport_class = InstancesClient.get_transport_class()
- transport = transport_class(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
-
-@pytest.mark.asyncio
-async def test_transport_close_async():
- client = InstancesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- with mock.patch.object(
- type(getattr(client.transport, "grpc_channel")), "close"
- ) as close:
- async with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_transport_close():
- transports = {
- "rest": "_session",
- "grpc": "_grpc_channel",
- }
-
- for transport, close_name in transports.items():
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- with mock.patch.object(
- type(getattr(client.transport, close_name)), "close"
- ) as close:
- with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_client_ctx():
- transports = [
- "rest",
- "grpc",
- ]
- for transport in transports:
- client = InstancesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- # Test client calls underlying transport.
- with mock.patch.object(type(client.transport), "close") as close:
- close.assert_not_called()
- with client:
- pass
- close.assert_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class",
- [
- (InstancesClient, transports.InstancesGrpcTransport),
- (InstancesAsyncClient, transports.InstancesGrpcAsyncIOTransport),
- ],
-)
-def test_api_key_credentials(client_class, transport_class):
- with mock.patch.object(
- google.auth._default, "get_api_key_credentials", create=True
- ) as get_api_key_credentials:
- mock_cred = mock.Mock()
- get_api_key_credentials.return_value = mock_cred
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options)
- patched.assert_called_once_with(
- credentials=mock_cred,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
diff --git a/tests/unit/gapic/appengine_admin_v1/test_services.py b/tests/unit/gapic/appengine_admin_v1/test_services.py
deleted file mode 100644
index 6b4b665..0000000
--- a/tests/unit/gapic/appengine_admin_v1/test_services.py
+++ /dev/null
@@ -1,2888 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import os
-
-# try/except added for compatibility with python < 3.8
-try:
- from unittest import mock
- from unittest.mock import AsyncMock # pragma: NO COVER
-except ImportError: # pragma: NO COVER
- import mock
-
-from collections.abc import Iterable
-import json
-import math
-
-from google.api_core import (
- future,
- gapic_v1,
- grpc_helpers,
- grpc_helpers_async,
- operation,
- operations_v1,
- path_template,
-)
-from google.api_core import client_options
-from google.api_core import exceptions as core_exceptions
-from google.api_core import operation_async # type: ignore
-import google.auth
-from google.auth import credentials as ga_credentials
-from google.auth.exceptions import MutualTLSChannelError
-from google.longrunning import operations_pb2 # type: ignore
-from google.oauth2 import service_account
-from google.protobuf import empty_pb2 # type: ignore
-from google.protobuf import field_mask_pb2 # type: ignore
-from google.protobuf import json_format
-import grpc
-from grpc.experimental import aio
-from proto.marshal.rules import wrappers
-from proto.marshal.rules.dates import DurationRule, TimestampRule
-import pytest
-from requests import PreparedRequest, Request, Response
-from requests.sessions import Session
-
-from google.cloud.appengine_admin_v1.services.services import (
- ServicesAsyncClient,
- ServicesClient,
- pagers,
- transports,
-)
-from google.cloud.appengine_admin_v1.types import appengine, network_settings
-from google.cloud.appengine_admin_v1.types import operation as ga_operation
-from google.cloud.appengine_admin_v1.types import service
-
-
-def client_cert_source_callback():
- return b"cert bytes", b"key bytes"
-
-
-# If default endpoint is localhost, then default mtls endpoint will be the same.
-# This method modifies the default endpoint so the client can produce a different
-# mtls endpoint for endpoint testing purposes.
-def modify_default_endpoint(client):
- return (
- "foo.googleapis.com"
- if ("localhost" in client.DEFAULT_ENDPOINT)
- else client.DEFAULT_ENDPOINT
- )
-
-
-def test__get_default_mtls_endpoint():
- api_endpoint = "example.googleapis.com"
- api_mtls_endpoint = "example.mtls.googleapis.com"
- sandbox_endpoint = "example.sandbox.googleapis.com"
- sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
- non_googleapi = "api.example.com"
-
- assert ServicesClient._get_default_mtls_endpoint(None) is None
- assert ServicesClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint
- assert (
- ServicesClient._get_default_mtls_endpoint(api_mtls_endpoint)
- == api_mtls_endpoint
- )
- assert (
- ServicesClient._get_default_mtls_endpoint(sandbox_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- ServicesClient._get_default_mtls_endpoint(sandbox_mtls_endpoint)
- == sandbox_mtls_endpoint
- )
- assert ServicesClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (ServicesClient, "grpc"),
- (ServicesAsyncClient, "grpc_asyncio"),
- (ServicesClient, "rest"),
- ],
-)
-def test_services_client_from_service_account_info(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_info"
- ) as factory:
- factory.return_value = creds
- info = {"valid": True}
- client = client_class.from_service_account_info(info, transport=transport_name)
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,transport_name",
- [
- (transports.ServicesGrpcTransport, "grpc"),
- (transports.ServicesGrpcAsyncIOTransport, "grpc_asyncio"),
- (transports.ServicesRestTransport, "rest"),
- ],
-)
-def test_services_client_service_account_always_use_jwt(
- transport_class, transport_name
-):
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=True)
- use_jwt.assert_called_once_with(True)
-
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=False)
- use_jwt.assert_not_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (ServicesClient, "grpc"),
- (ServicesAsyncClient, "grpc_asyncio"),
- (ServicesClient, "rest"),
- ],
-)
-def test_services_client_from_service_account_file(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_file"
- ) as factory:
- factory.return_value = creds
- client = client_class.from_service_account_file(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- client = client_class.from_service_account_json(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-def test_services_client_get_transport_class():
- transport = ServicesClient.get_transport_class()
- available_transports = [
- transports.ServicesGrpcTransport,
- transports.ServicesRestTransport,
- ]
- assert transport in available_transports
-
- transport = ServicesClient.get_transport_class("grpc")
- assert transport == transports.ServicesGrpcTransport
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (ServicesClient, transports.ServicesGrpcTransport, "grpc"),
- (ServicesAsyncClient, transports.ServicesGrpcAsyncIOTransport, "grpc_asyncio"),
- (ServicesClient, transports.ServicesRestTransport, "rest"),
- ],
-)
-@mock.patch.object(
- ServicesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ServicesClient)
-)
-@mock.patch.object(
- ServicesAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(ServicesAsyncClient),
-)
-def test_services_client_client_options(client_class, transport_class, transport_name):
- # Check that if channel is provided we won't create a new one.
- with mock.patch.object(ServicesClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
- client = client_class(transport=transport)
- gtc.assert_not_called()
-
- # Check that if channel is provided via str we will create a new one.
- with mock.patch.object(ServicesClient, "get_transport_class") as gtc:
- client = client_class(transport=transport_name)
- gtc.assert_called()
-
- # Check the case api_endpoint is provided.
- options = client_options.ClientOptions(api_endpoint="squid.clam.whelk")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name, client_options=options)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_MTLS_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
- # unsupported value.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
- with pytest.raises(MutualTLSChannelError):
- client = client_class(transport=transport_name)
-
- # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
- ):
- with pytest.raises(ValueError):
- client = client_class(transport=transport_name)
-
- # Check the case quota_project_id is provided
- options = client_options.ClientOptions(quota_project_id="octopus")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id="octopus",
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
- # Check the case api_endpoint is provided
- options = client_options.ClientOptions(
- api_audience="https://language.googleapis.com"
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience="https://language.googleapis.com",
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,use_client_cert_env",
- [
- (ServicesClient, transports.ServicesGrpcTransport, "grpc", "true"),
- (
- ServicesAsyncClient,
- transports.ServicesGrpcAsyncIOTransport,
- "grpc_asyncio",
- "true",
- ),
- (ServicesClient, transports.ServicesGrpcTransport, "grpc", "false"),
- (
- ServicesAsyncClient,
- transports.ServicesGrpcAsyncIOTransport,
- "grpc_asyncio",
- "false",
- ),
- (ServicesClient, transports.ServicesRestTransport, "rest", "true"),
- (ServicesClient, transports.ServicesRestTransport, "rest", "false"),
- ],
-)
-@mock.patch.object(
- ServicesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ServicesClient)
-)
-@mock.patch.object(
- ServicesAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(ServicesAsyncClient),
-)
-@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"})
-def test_services_client_mtls_env_auto(
- client_class, transport_class, transport_name, use_client_cert_env
-):
- # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default
- # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists.
-
- # Check the case client_cert_source is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- options = client_options.ClientOptions(
- client_cert_source=client_cert_source_callback
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
-
- if use_client_cert_env == "false":
- expected_client_cert_source = None
- expected_host = client.DEFAULT_ENDPOINT
- else:
- expected_client_cert_source = client_cert_source_callback
- expected_host = client.DEFAULT_MTLS_ENDPOINT
-
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case ADC client cert is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=client_cert_source_callback,
- ):
- if use_client_cert_env == "false":
- expected_host = client.DEFAULT_ENDPOINT
- expected_client_cert_source = None
- else:
- expected_host = client.DEFAULT_MTLS_ENDPOINT
- expected_client_cert_source = client_cert_source_callback
-
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case client_cert_source and ADC client cert are not provided.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize("client_class", [ServicesClient, ServicesAsyncClient])
-@mock.patch.object(
- ServicesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ServicesClient)
-)
-@mock.patch.object(
- ServicesAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(ServicesAsyncClient),
-)
-def test_services_client_get_mtls_endpoint_and_cert_source(client_class):
- mock_client_cert_source = mock.Mock()
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source == mock_client_cert_source
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
- mock_client_cert_source = mock.Mock()
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=mock_client_cert_source,
- ):
- (
- api_endpoint,
- cert_source,
- ) = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source == mock_client_cert_source
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (ServicesClient, transports.ServicesGrpcTransport, "grpc"),
- (ServicesAsyncClient, transports.ServicesGrpcAsyncIOTransport, "grpc_asyncio"),
- (ServicesClient, transports.ServicesRestTransport, "rest"),
- ],
-)
-def test_services_client_client_options_scopes(
- client_class, transport_class, transport_name
-):
- # Check the case scopes are provided.
- options = client_options.ClientOptions(
- scopes=["1", "2"],
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=["1", "2"],
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (ServicesClient, transports.ServicesGrpcTransport, "grpc", grpc_helpers),
- (
- ServicesAsyncClient,
- transports.ServicesGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- (ServicesClient, transports.ServicesRestTransport, "rest", None),
- ],
-)
-def test_services_client_client_options_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-def test_services_client_client_options_from_dict():
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.services.transports.ServicesGrpcTransport.__init__"
- ) as grpc_transport:
- grpc_transport.return_value = None
- client = ServicesClient(client_options={"api_endpoint": "squid.clam.whelk"})
- grpc_transport.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (ServicesClient, transports.ServicesGrpcTransport, "grpc", grpc_helpers),
- (
- ServicesAsyncClient,
- transports.ServicesGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- ],
-)
-def test_services_client_create_channel_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # test that the credentials from file are saved and used as the credentials.
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel"
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- file_creds = ga_credentials.AnonymousCredentials()
- load_creds.return_value = (file_creds, None)
- adc.return_value = (creds, None)
- client = client_class(client_options=options, transport=transport_name)
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=file_creds,
- credentials_file=None,
- quota_project_id=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=None,
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListServicesRequest,
- dict,
- ],
-)
-def test_list_services(request_type, transport: str = "grpc"):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_services), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = appengine.ListServicesResponse(
- next_page_token="next_page_token_value",
- )
- response = client.list_services(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListServicesRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListServicesPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-def test_list_services_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_services), "__call__") as call:
- client.list_services()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListServicesRequest()
-
-
-@pytest.mark.asyncio
-async def test_list_services_async(
- transport: str = "grpc_asyncio", request_type=appengine.ListServicesRequest
-):
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_services), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListServicesResponse(
- next_page_token="next_page_token_value",
- )
- )
- response = await client.list_services(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListServicesRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListServicesAsyncPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.asyncio
-async def test_list_services_async_from_dict():
- await test_list_services_async(request_type=dict)
-
-
-def test_list_services_field_headers():
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListServicesRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_services), "__call__") as call:
- call.return_value = appengine.ListServicesResponse()
- client.list_services(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_list_services_field_headers_async():
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListServicesRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_services), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListServicesResponse()
- )
- await client.list_services(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-def test_list_services_pager(transport_name: str = "grpc"):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_services), "__call__") as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- service.Service(),
- service.Service(),
- ],
- next_page_token="abc",
- ),
- appengine.ListServicesResponse(
- services=[],
- next_page_token="def",
- ),
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- service.Service(),
- ],
- ),
- RuntimeError,
- )
-
- metadata = ()
- metadata = tuple(metadata) + (
- gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)),
- )
- pager = client.list_services(request={})
-
- assert pager._metadata == metadata
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, service.Service) for i in results)
-
-
-def test_list_services_pages(transport_name: str = "grpc"):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_services), "__call__") as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- service.Service(),
- service.Service(),
- ],
- next_page_token="abc",
- ),
- appengine.ListServicesResponse(
- services=[],
- next_page_token="def",
- ),
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- service.Service(),
- ],
- ),
- RuntimeError,
- )
- pages = list(client.list_services(request={}).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.asyncio
-async def test_list_services_async_pager():
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_services), "__call__", new_callable=mock.AsyncMock
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- service.Service(),
- service.Service(),
- ],
- next_page_token="abc",
- ),
- appengine.ListServicesResponse(
- services=[],
- next_page_token="def",
- ),
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- service.Service(),
- ],
- ),
- RuntimeError,
- )
- async_pager = await client.list_services(
- request={},
- )
- assert async_pager.next_page_token == "abc"
- responses = []
- async for response in async_pager: # pragma: no branch
- responses.append(response)
-
- assert len(responses) == 6
- assert all(isinstance(i, service.Service) for i in responses)
-
-
-@pytest.mark.asyncio
-async def test_list_services_async_pages():
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_services), "__call__", new_callable=mock.AsyncMock
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- service.Service(),
- service.Service(),
- ],
- next_page_token="abc",
- ),
- appengine.ListServicesResponse(
- services=[],
- next_page_token="def",
- ),
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- service.Service(),
- ],
- ),
- RuntimeError,
- )
- pages = []
- # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
- # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
- async for page_ in ( # pragma: no branch
- await client.list_services(request={})
- ).pages:
- pages.append(page_)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetServiceRequest,
- dict,
- ],
-)
-def test_get_service(request_type, transport: str = "grpc"):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_service), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = service.Service(
- name="name_value",
- id="id_value",
- )
- response = client.get_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetServiceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, service.Service)
- assert response.name == "name_value"
- assert response.id == "id_value"
-
-
-def test_get_service_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_service), "__call__") as call:
- client.get_service()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetServiceRequest()
-
-
-@pytest.mark.asyncio
-async def test_get_service_async(
- transport: str = "grpc_asyncio", request_type=appengine.GetServiceRequest
-):
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_service), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- service.Service(
- name="name_value",
- id="id_value",
- )
- )
- response = await client.get_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetServiceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, service.Service)
- assert response.name == "name_value"
- assert response.id == "id_value"
-
-
-@pytest.mark.asyncio
-async def test_get_service_async_from_dict():
- await test_get_service_async(request_type=dict)
-
-
-def test_get_service_field_headers():
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetServiceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_service), "__call__") as call:
- call.return_value = service.Service()
- client.get_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_get_service_field_headers_async():
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetServiceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_service), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.Service())
- await client.get_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateServiceRequest,
- dict,
- ],
-)
-def test_update_service(request_type, transport: str = "grpc"):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.update_service), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.update_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateServiceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_update_service_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.update_service), "__call__") as call:
- client.update_service()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateServiceRequest()
-
-
-@pytest.mark.asyncio
-async def test_update_service_async(
- transport: str = "grpc_asyncio", request_type=appengine.UpdateServiceRequest
-):
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.update_service), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.update_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateServiceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_update_service_async_from_dict():
- await test_update_service_async(request_type=dict)
-
-
-def test_update_service_field_headers():
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateServiceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.update_service), "__call__") as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.update_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_update_service_field_headers_async():
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateServiceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.update_service), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.update_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteServiceRequest,
- dict,
- ],
-)
-def test_delete_service(request_type, transport: str = "grpc"):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_service), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.delete_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteServiceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_delete_service_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_service), "__call__") as call:
- client.delete_service()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteServiceRequest()
-
-
-@pytest.mark.asyncio
-async def test_delete_service_async(
- transport: str = "grpc_asyncio", request_type=appengine.DeleteServiceRequest
-):
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_service), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.delete_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteServiceRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_delete_service_async_from_dict():
- await test_delete_service_async(request_type=dict)
-
-
-def test_delete_service_field_headers():
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteServiceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_service), "__call__") as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.delete_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_delete_service_field_headers_async():
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteServiceRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_service), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.delete_service(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListServicesRequest,
- dict,
- ],
-)
-def test_list_services_rest(request_type):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = appengine.ListServicesResponse(
- next_page_token="next_page_token_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = appengine.ListServicesResponse.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.list_services(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListServicesPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_list_services_rest_interceptors(null_interceptor):
- transport = transports.ServicesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.ServicesRestInterceptor(),
- )
- client = ServicesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.ServicesRestInterceptor, "post_list_services"
- ) as post, mock.patch.object(
- transports.ServicesRestInterceptor, "pre_list_services"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.ListServicesRequest.pb(appengine.ListServicesRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = appengine.ListServicesResponse.to_json(
- appengine.ListServicesResponse()
- )
-
- request = appengine.ListServicesRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = appengine.ListServicesResponse()
-
- client.list_services(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_list_services_rest_bad_request(
- transport: str = "rest", request_type=appengine.ListServicesRequest
-):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.list_services(request)
-
-
-def test_list_services_rest_pager(transport: str = "rest"):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(Session, "request") as req:
- # TODO(kbandes): remove this mock unless there's a good reason for it.
- # with mock.patch.object(path_template, 'transcode') as transcode:
- # Set the response as a series of pages
- response = (
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- service.Service(),
- service.Service(),
- ],
- next_page_token="abc",
- ),
- appengine.ListServicesResponse(
- services=[],
- next_page_token="def",
- ),
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListServicesResponse(
- services=[
- service.Service(),
- service.Service(),
- ],
- ),
- )
- # Two responses for two calls
- response = response + response
-
- # Wrap the values into proper Response objs
- response = tuple(appengine.ListServicesResponse.to_json(x) for x in response)
- return_values = tuple(Response() for i in response)
- for return_val, response_val in zip(return_values, response):
- return_val._content = response_val.encode("UTF-8")
- return_val.status_code = 200
- req.side_effect = return_values
-
- sample_request = {"parent": "apps/sample1"}
-
- pager = client.list_services(request=sample_request)
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, service.Service) for i in results)
-
- pages = list(client.list_services(request=sample_request).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetServiceRequest,
- dict,
- ],
-)
-def test_get_service_rest(request_type):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = service.Service(
- name="name_value",
- id="id_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = service.Service.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.get_service(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, service.Service)
- assert response.name == "name_value"
- assert response.id == "id_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_get_service_rest_interceptors(null_interceptor):
- transport = transports.ServicesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.ServicesRestInterceptor(),
- )
- client = ServicesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.ServicesRestInterceptor, "post_get_service"
- ) as post, mock.patch.object(
- transports.ServicesRestInterceptor, "pre_get_service"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.GetServiceRequest.pb(appengine.GetServiceRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = service.Service.to_json(service.Service())
-
- request = appengine.GetServiceRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = service.Service()
-
- client.get_service(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_get_service_rest_bad_request(
- transport: str = "rest", request_type=appengine.GetServiceRequest
-):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.get_service(request)
-
-
-def test_get_service_rest_error():
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateServiceRequest,
- dict,
- ],
-)
-def test_update_service_rest(request_type):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2"}
- request_init["service"] = {
- "name": "name_value",
- "id": "id_value",
- "split": {"shard_by": 1, "allocations": {}},
- "labels": {},
- "network_settings": {"ingress_traffic_allowed": 1},
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.UpdateServiceRequest.meta.fields["service"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["service"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["service"][field])):
- del request_init["service"][field][i][subfield]
- else:
- del request_init["service"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.update_service(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_update_service_rest_interceptors(null_interceptor):
- transport = transports.ServicesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.ServicesRestInterceptor(),
- )
- client = ServicesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.ServicesRestInterceptor, "post_update_service"
- ) as post, mock.patch.object(
- transports.ServicesRestInterceptor, "pre_update_service"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.UpdateServiceRequest.pb(appengine.UpdateServiceRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.UpdateServiceRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.update_service(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_update_service_rest_bad_request(
- transport: str = "rest", request_type=appengine.UpdateServiceRequest
-):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.update_service(request)
-
-
-def test_update_service_rest_error():
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteServiceRequest,
- dict,
- ],
-)
-def test_delete_service_rest(request_type):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.delete_service(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_delete_service_rest_interceptors(null_interceptor):
- transport = transports.ServicesRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.ServicesRestInterceptor(),
- )
- client = ServicesClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.ServicesRestInterceptor, "post_delete_service"
- ) as post, mock.patch.object(
- transports.ServicesRestInterceptor, "pre_delete_service"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.DeleteServiceRequest.pb(appengine.DeleteServiceRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.DeleteServiceRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.delete_service(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_delete_service_rest_bad_request(
- transport: str = "rest", request_type=appengine.DeleteServiceRequest
-):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.delete_service(request)
-
-
-def test_delete_service_rest_error():
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-def test_credentials_transport_error():
- # It is an error to provide credentials and a transport instance.
- transport = transports.ServicesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # It is an error to provide a credentials file and a transport instance.
- transport = transports.ServicesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = ServicesClient(
- client_options={"credentials_file": "credentials.json"},
- transport=transport,
- )
-
- # It is an error to provide an api_key and a transport instance.
- transport = transports.ServicesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = ServicesClient(
- client_options=options,
- transport=transport,
- )
-
- # It is an error to provide an api_key and a credential.
- options = mock.Mock()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = ServicesClient(
- client_options=options, credentials=ga_credentials.AnonymousCredentials()
- )
-
- # It is an error to provide scopes and a transport instance.
- transport = transports.ServicesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = ServicesClient(
- client_options={"scopes": ["1", "2"]},
- transport=transport,
- )
-
-
-def test_transport_instance():
- # A client may be instantiated with a custom transport instance.
- transport = transports.ServicesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- client = ServicesClient(transport=transport)
- assert client.transport is transport
-
-
-def test_transport_get_channel():
- # A client may be instantiated with a custom transport instance.
- transport = transports.ServicesGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
- transport = transports.ServicesGrpcAsyncIOTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.ServicesGrpcTransport,
- transports.ServicesGrpcAsyncIOTransport,
- transports.ServicesRestTransport,
- ],
-)
-def test_transport_adc(transport_class):
- # Test default credentials are used if not provided.
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class()
- adc.assert_called_once()
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "rest",
- ],
-)
-def test_transport_kind(transport_name):
- transport = ServicesClient.get_transport_class(transport_name)(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert transport.kind == transport_name
-
-
-def test_transport_grpc_default():
- # A client should use the gRPC transport by default.
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert isinstance(
- client.transport,
- transports.ServicesGrpcTransport,
- )
-
-
-def test_services_base_transport_error():
- # Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(core_exceptions.DuplicateCredentialArgs):
- transport = transports.ServicesTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- credentials_file="credentials.json",
- )
-
-
-def test_services_base_transport():
- # Instantiate the base transport.
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.services.transports.ServicesTransport.__init__"
- ) as Transport:
- Transport.return_value = None
- transport = transports.ServicesTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Every method on the transport should just blindly
- # raise NotImplementedError.
- methods = (
- "list_services",
- "get_service",
- "update_service",
- "delete_service",
- )
- for method in methods:
- with pytest.raises(NotImplementedError):
- getattr(transport, method)(request=object())
-
- with pytest.raises(NotImplementedError):
- transport.close()
-
- # Additionally, the LRO client (a property) should
- # also raise NotImplementedError
- with pytest.raises(NotImplementedError):
- transport.operations_client
-
- # Catch all for all remaining methods and properties
- remainder = [
- "kind",
- ]
- for r in remainder:
- with pytest.raises(NotImplementedError):
- getattr(transport, r)()
-
-
-def test_services_base_transport_with_credentials_file():
- # Instantiate the base transport with a credentials file
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch(
- "google.cloud.appengine_admin_v1.services.services.transports.ServicesTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.ServicesTransport(
- credentials_file="credentials.json",
- quota_project_id="octopus",
- )
- load_creds.assert_called_once_with(
- "credentials.json",
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-def test_services_base_transport_with_adc():
- # Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
- "google.cloud.appengine_admin_v1.services.services.transports.ServicesTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.ServicesTransport()
- adc.assert_called_once()
-
-
-def test_services_auth_adc():
- # If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- ServicesClient()
- adc.assert_called_once_with(
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id=None,
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.ServicesGrpcTransport,
- transports.ServicesGrpcAsyncIOTransport,
- ],
-)
-def test_services_transport_auth_adc(transport_class):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
- adc.assert_called_once_with(
- scopes=["1", "2"],
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.ServicesGrpcTransport,
- transports.ServicesGrpcAsyncIOTransport,
- transports.ServicesRestTransport,
- ],
-)
-def test_services_transport_auth_gdch_credentials(transport_class):
- host = "https://language.com"
- api_audience_tests = [None, "https://language2.com"]
- api_audience_expect = [host, "https://language2.com"]
- for t, e in zip(api_audience_tests, api_audience_expect):
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- gdch_mock = mock.MagicMock()
- type(gdch_mock).with_gdch_audience = mock.PropertyMock(
- return_value=gdch_mock
- )
- adc.return_value = (gdch_mock, None)
- transport_class(host=host, api_audience=t)
- gdch_mock.with_gdch_audience.assert_called_once_with(e)
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.ServicesGrpcTransport, grpc_helpers),
- (transports.ServicesGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-def test_services_transport_create_channel(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=["1", "2"],
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [transports.ServicesGrpcTransport, transports.ServicesGrpcAsyncIOTransport],
-)
-def test_services_grpc_transport_client_cert_source_for_mtls(transport_class):
- cred = ga_credentials.AnonymousCredentials()
-
- # Check ssl_channel_credentials is used if provided.
- with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
- mock_ssl_channel_creds = mock.Mock()
- transport_class(
- host="squid.clam.whelk",
- credentials=cred,
- ssl_channel_credentials=mock_ssl_channel_creds,
- )
- mock_create_channel.assert_called_once_with(
- "squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_channel_creds,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
- # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls
- # is used.
- with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()):
- with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred:
- transport_class(
- credentials=cred,
- client_cert_source_for_mtls=client_cert_source_callback,
- )
- expected_cert, expected_key = client_cert_source_callback()
- mock_ssl_cred.assert_called_once_with(
- certificate_chain=expected_cert, private_key=expected_key
- )
-
-
-def test_services_http_transport_client_cert_source_for_mtls():
- cred = ga_credentials.AnonymousCredentials()
- with mock.patch(
- "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"
- ) as mock_configure_mtls_channel:
- transports.ServicesRestTransport(
- credentials=cred, client_cert_source_for_mtls=client_cert_source_callback
- )
- mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback)
-
-
-def test_services_rest_lro_client():
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.AbstractOperationsClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_services_host_no_port(transport_name):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_services_host_with_port(transport_name):
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com:8000"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:8000"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com:8000"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "rest",
- ],
-)
-def test_services_client_transport_session_collision(transport_name):
- creds1 = ga_credentials.AnonymousCredentials()
- creds2 = ga_credentials.AnonymousCredentials()
- client1 = ServicesClient(
- credentials=creds1,
- transport=transport_name,
- )
- client2 = ServicesClient(
- credentials=creds2,
- transport=transport_name,
- )
- session1 = client1.transport.list_services._session
- session2 = client2.transport.list_services._session
- assert session1 != session2
- session1 = client1.transport.get_service._session
- session2 = client2.transport.get_service._session
- assert session1 != session2
- session1 = client1.transport.update_service._session
- session2 = client2.transport.update_service._session
- assert session1 != session2
- session1 = client1.transport.delete_service._session
- session2 = client2.transport.delete_service._session
- assert session1 != session2
-
-
-def test_services_grpc_transport_channel():
- channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.ServicesGrpcTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-def test_services_grpc_asyncio_transport_channel():
- channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.ServicesGrpcAsyncIOTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [transports.ServicesGrpcTransport, transports.ServicesGrpcAsyncIOTransport],
-)
-def test_services_transport_channel_mtls_with_client_cert_source(transport_class):
- with mock.patch(
- "grpc.ssl_channel_credentials", autospec=True
- ) as grpc_ssl_channel_cred:
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_ssl_cred = mock.Mock()
- grpc_ssl_channel_cred.return_value = mock_ssl_cred
-
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
-
- cred = ga_credentials.AnonymousCredentials()
- with pytest.warns(DeprecationWarning):
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (cred, None)
- transport = transport_class(
- host="squid.clam.whelk",
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=client_cert_source_callback,
- )
- adc.assert_called_once()
-
- grpc_ssl_channel_cred.assert_called_once_with(
- certificate_chain=b"cert bytes", private_key=b"key bytes"
- )
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
- assert transport._ssl_channel_credentials == mock_ssl_cred
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [transports.ServicesGrpcTransport, transports.ServicesGrpcAsyncIOTransport],
-)
-def test_services_transport_channel_mtls_with_adc(transport_class):
- mock_ssl_cred = mock.Mock()
- with mock.patch.multiple(
- "google.auth.transport.grpc.SslCredentials",
- __init__=mock.Mock(return_value=None),
- ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
- ):
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
- mock_cred = mock.Mock()
-
- with pytest.warns(DeprecationWarning):
- transport = transport_class(
- host="squid.clam.whelk",
- credentials=mock_cred,
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=None,
- )
-
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=mock_cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
-
-
-def test_services_grpc_lro_client():
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.OperationsClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-def test_services_grpc_lro_async_client():
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.OperationsAsyncClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-def test_common_billing_account_path():
- billing_account = "squid"
- expected = "billingAccounts/{billing_account}".format(
- billing_account=billing_account,
- )
- actual = ServicesClient.common_billing_account_path(billing_account)
- assert expected == actual
-
-
-def test_parse_common_billing_account_path():
- expected = {
- "billing_account": "clam",
- }
- path = ServicesClient.common_billing_account_path(**expected)
-
- # Check that the path construction is reversible.
- actual = ServicesClient.parse_common_billing_account_path(path)
- assert expected == actual
-
-
-def test_common_folder_path():
- folder = "whelk"
- expected = "folders/{folder}".format(
- folder=folder,
- )
- actual = ServicesClient.common_folder_path(folder)
- assert expected == actual
-
-
-def test_parse_common_folder_path():
- expected = {
- "folder": "octopus",
- }
- path = ServicesClient.common_folder_path(**expected)
-
- # Check that the path construction is reversible.
- actual = ServicesClient.parse_common_folder_path(path)
- assert expected == actual
-
-
-def test_common_organization_path():
- organization = "oyster"
- expected = "organizations/{organization}".format(
- organization=organization,
- )
- actual = ServicesClient.common_organization_path(organization)
- assert expected == actual
-
-
-def test_parse_common_organization_path():
- expected = {
- "organization": "nudibranch",
- }
- path = ServicesClient.common_organization_path(**expected)
-
- # Check that the path construction is reversible.
- actual = ServicesClient.parse_common_organization_path(path)
- assert expected == actual
-
-
-def test_common_project_path():
- project = "cuttlefish"
- expected = "projects/{project}".format(
- project=project,
- )
- actual = ServicesClient.common_project_path(project)
- assert expected == actual
-
-
-def test_parse_common_project_path():
- expected = {
- "project": "mussel",
- }
- path = ServicesClient.common_project_path(**expected)
-
- # Check that the path construction is reversible.
- actual = ServicesClient.parse_common_project_path(path)
- assert expected == actual
-
-
-def test_common_location_path():
- project = "winkle"
- location = "nautilus"
- expected = "projects/{project}/locations/{location}".format(
- project=project,
- location=location,
- )
- actual = ServicesClient.common_location_path(project, location)
- assert expected == actual
-
-
-def test_parse_common_location_path():
- expected = {
- "project": "scallop",
- "location": "abalone",
- }
- path = ServicesClient.common_location_path(**expected)
-
- # Check that the path construction is reversible.
- actual = ServicesClient.parse_common_location_path(path)
- assert expected == actual
-
-
-def test_client_with_default_client_info():
- client_info = gapic_v1.client_info.ClientInfo()
-
- with mock.patch.object(
- transports.ServicesTransport, "_prep_wrapped_messages"
- ) as prep:
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
- with mock.patch.object(
- transports.ServicesTransport, "_prep_wrapped_messages"
- ) as prep:
- transport_class = ServicesClient.get_transport_class()
- transport = transport_class(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
-
-@pytest.mark.asyncio
-async def test_transport_close_async():
- client = ServicesAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- with mock.patch.object(
- type(getattr(client.transport, "grpc_channel")), "close"
- ) as close:
- async with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_transport_close():
- transports = {
- "rest": "_session",
- "grpc": "_grpc_channel",
- }
-
- for transport, close_name in transports.items():
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- with mock.patch.object(
- type(getattr(client.transport, close_name)), "close"
- ) as close:
- with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_client_ctx():
- transports = [
- "rest",
- "grpc",
- ]
- for transport in transports:
- client = ServicesClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- # Test client calls underlying transport.
- with mock.patch.object(type(client.transport), "close") as close:
- close.assert_not_called()
- with client:
- pass
- close.assert_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class",
- [
- (ServicesClient, transports.ServicesGrpcTransport),
- (ServicesAsyncClient, transports.ServicesGrpcAsyncIOTransport),
- ],
-)
-def test_api_key_credentials(client_class, transport_class):
- with mock.patch.object(
- google.auth._default, "get_api_key_credentials", create=True
- ) as get_api_key_credentials:
- mock_cred = mock.Mock()
- get_api_key_credentials.return_value = mock_cred
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options)
- patched.assert_called_once_with(
- credentials=mock_cred,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
diff --git a/tests/unit/gapic/appengine_admin_v1/test_versions.py b/tests/unit/gapic/appengine_admin_v1/test_versions.py
deleted file mode 100644
index 131e505..0000000
--- a/tests/unit/gapic/appengine_admin_v1/test_versions.py
+++ /dev/null
@@ -1,3652 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2023 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import os
-
-# try/except added for compatibility with python < 3.8
-try:
- from unittest import mock
- from unittest.mock import AsyncMock # pragma: NO COVER
-except ImportError: # pragma: NO COVER
- import mock
-
-from collections.abc import Iterable
-import json
-import math
-
-from google.api_core import (
- future,
- gapic_v1,
- grpc_helpers,
- grpc_helpers_async,
- operation,
- operations_v1,
- path_template,
-)
-from google.api_core import client_options
-from google.api_core import exceptions as core_exceptions
-from google.api_core import operation_async # type: ignore
-import google.auth
-from google.auth import credentials as ga_credentials
-from google.auth.exceptions import MutualTLSChannelError
-from google.longrunning import operations_pb2 # type: ignore
-from google.oauth2 import service_account
-from google.protobuf import duration_pb2 # type: ignore
-from google.protobuf import empty_pb2 # type: ignore
-from google.protobuf import field_mask_pb2 # type: ignore
-from google.protobuf import json_format
-from google.protobuf import timestamp_pb2 # type: ignore
-import grpc
-from grpc.experimental import aio
-from proto.marshal.rules import wrappers
-from proto.marshal.rules.dates import DurationRule, TimestampRule
-import pytest
-from requests import PreparedRequest, Request, Response
-from requests.sessions import Session
-
-from google.cloud.appengine_admin_v1.services.versions import (
- VersionsAsyncClient,
- VersionsClient,
- pagers,
- transports,
-)
-from google.cloud.appengine_admin_v1.types import app_yaml, appengine, deploy
-from google.cloud.appengine_admin_v1.types import operation as ga_operation
-from google.cloud.appengine_admin_v1.types import version
-
-
-def client_cert_source_callback():
- return b"cert bytes", b"key bytes"
-
-
-# If default endpoint is localhost, then default mtls endpoint will be the same.
-# This method modifies the default endpoint so the client can produce a different
-# mtls endpoint for endpoint testing purposes.
-def modify_default_endpoint(client):
- return (
- "foo.googleapis.com"
- if ("localhost" in client.DEFAULT_ENDPOINT)
- else client.DEFAULT_ENDPOINT
- )
-
-
-def test__get_default_mtls_endpoint():
- api_endpoint = "example.googleapis.com"
- api_mtls_endpoint = "example.mtls.googleapis.com"
- sandbox_endpoint = "example.sandbox.googleapis.com"
- sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
- non_googleapi = "api.example.com"
-
- assert VersionsClient._get_default_mtls_endpoint(None) is None
- assert VersionsClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint
- assert (
- VersionsClient._get_default_mtls_endpoint(api_mtls_endpoint)
- == api_mtls_endpoint
- )
- assert (
- VersionsClient._get_default_mtls_endpoint(sandbox_endpoint)
- == sandbox_mtls_endpoint
- )
- assert (
- VersionsClient._get_default_mtls_endpoint(sandbox_mtls_endpoint)
- == sandbox_mtls_endpoint
- )
- assert VersionsClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (VersionsClient, "grpc"),
- (VersionsAsyncClient, "grpc_asyncio"),
- (VersionsClient, "rest"),
- ],
-)
-def test_versions_client_from_service_account_info(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_info"
- ) as factory:
- factory.return_value = creds
- info = {"valid": True}
- client = client_class.from_service_account_info(info, transport=transport_name)
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_class,transport_name",
- [
- (transports.VersionsGrpcTransport, "grpc"),
- (transports.VersionsGrpcAsyncIOTransport, "grpc_asyncio"),
- (transports.VersionsRestTransport, "rest"),
- ],
-)
-def test_versions_client_service_account_always_use_jwt(
- transport_class, transport_name
-):
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=True)
- use_jwt.assert_called_once_with(True)
-
- with mock.patch.object(
- service_account.Credentials, "with_always_use_jwt_access", create=True
- ) as use_jwt:
- creds = service_account.Credentials(None, None, None)
- transport = transport_class(credentials=creds, always_use_jwt_access=False)
- use_jwt.assert_not_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_name",
- [
- (VersionsClient, "grpc"),
- (VersionsAsyncClient, "grpc_asyncio"),
- (VersionsClient, "rest"),
- ],
-)
-def test_versions_client_from_service_account_file(client_class, transport_name):
- creds = ga_credentials.AnonymousCredentials()
- with mock.patch.object(
- service_account.Credentials, "from_service_account_file"
- ) as factory:
- factory.return_value = creds
- client = client_class.from_service_account_file(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- client = client_class.from_service_account_json(
- "dummy/file/path.json", transport=transport_name
- )
- assert client.transport._credentials == creds
- assert isinstance(client, client_class)
-
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-def test_versions_client_get_transport_class():
- transport = VersionsClient.get_transport_class()
- available_transports = [
- transports.VersionsGrpcTransport,
- transports.VersionsRestTransport,
- ]
- assert transport in available_transports
-
- transport = VersionsClient.get_transport_class("grpc")
- assert transport == transports.VersionsGrpcTransport
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (VersionsClient, transports.VersionsGrpcTransport, "grpc"),
- (VersionsAsyncClient, transports.VersionsGrpcAsyncIOTransport, "grpc_asyncio"),
- (VersionsClient, transports.VersionsRestTransport, "rest"),
- ],
-)
-@mock.patch.object(
- VersionsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(VersionsClient)
-)
-@mock.patch.object(
- VersionsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(VersionsAsyncClient),
-)
-def test_versions_client_client_options(client_class, transport_class, transport_name):
- # Check that if channel is provided we won't create a new one.
- with mock.patch.object(VersionsClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
- client = client_class(transport=transport)
- gtc.assert_not_called()
-
- # Check that if channel is provided via str we will create a new one.
- with mock.patch.object(VersionsClient, "get_transport_class") as gtc:
- client = client_class(transport=transport_name)
- gtc.assert_called()
-
- # Check the case api_endpoint is provided.
- options = client_options.ClientOptions(api_endpoint="squid.clam.whelk")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name, client_options=options)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
- # "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_MTLS_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
- # unsupported value.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
- with pytest.raises(MutualTLSChannelError):
- client = client_class(transport=transport_name)
-
- # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
- ):
- with pytest.raises(ValueError):
- client = client_class(transport=transport_name)
-
- # Check the case quota_project_id is provided
- options = client_options.ClientOptions(quota_project_id="octopus")
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id="octopus",
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
- # Check the case api_endpoint is provided
- options = client_options.ClientOptions(
- api_audience="https://language.googleapis.com"
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience="https://language.googleapis.com",
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,use_client_cert_env",
- [
- (VersionsClient, transports.VersionsGrpcTransport, "grpc", "true"),
- (
- VersionsAsyncClient,
- transports.VersionsGrpcAsyncIOTransport,
- "grpc_asyncio",
- "true",
- ),
- (VersionsClient, transports.VersionsGrpcTransport, "grpc", "false"),
- (
- VersionsAsyncClient,
- transports.VersionsGrpcAsyncIOTransport,
- "grpc_asyncio",
- "false",
- ),
- (VersionsClient, transports.VersionsRestTransport, "rest", "true"),
- (VersionsClient, transports.VersionsRestTransport, "rest", "false"),
- ],
-)
-@mock.patch.object(
- VersionsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(VersionsClient)
-)
-@mock.patch.object(
- VersionsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(VersionsAsyncClient),
-)
-@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"})
-def test_versions_client_mtls_env_auto(
- client_class, transport_class, transport_name, use_client_cert_env
-):
- # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default
- # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists.
-
- # Check the case client_cert_source is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- options = client_options.ClientOptions(
- client_cert_source=client_cert_source_callback
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
-
- if use_client_cert_env == "false":
- expected_client_cert_source = None
- expected_host = client.DEFAULT_ENDPOINT
- else:
- expected_client_cert_source = client_cert_source_callback
- expected_host = client.DEFAULT_MTLS_ENDPOINT
-
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case ADC client cert is provided. Whether client cert is used depends on
- # GOOGLE_API_USE_CLIENT_CERTIFICATE value.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=client_cert_source_callback,
- ):
- if use_client_cert_env == "false":
- expected_host = client.DEFAULT_ENDPOINT
- expected_client_cert_source = None
- else:
- expected_host = client.DEFAULT_MTLS_ENDPOINT
- expected_client_cert_source = client_cert_source_callback
-
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=expected_host,
- scopes=None,
- client_cert_source_for_mtls=expected_client_cert_source,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # Check the case client_cert_source and ADC client cert are not provided.
- with mock.patch.dict(
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}
- ):
- with mock.patch.object(transport_class, "__init__") as patched:
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- patched.return_value = None
- client = client_class(transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize("client_class", [VersionsClient, VersionsAsyncClient])
-@mock.patch.object(
- VersionsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(VersionsClient)
-)
-@mock.patch.object(
- VersionsAsyncClient,
- "DEFAULT_ENDPOINT",
- modify_default_endpoint(VersionsAsyncClient),
-)
-def test_versions_client_get_mtls_endpoint_and_cert_source(client_class):
- mock_client_cert_source = mock.Mock()
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source == mock_client_cert_source
-
- # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
- mock_client_cert_source = mock.Mock()
- mock_api_endpoint = "foo"
- options = client_options.ClientOptions(
- client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint
- )
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
- options
- )
- assert api_endpoint == mock_api_endpoint
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always".
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=False,
- ):
- api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_ENDPOINT
- assert cert_source is None
-
- # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists.
- with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
- with mock.patch(
- "google.auth.transport.mtls.has_default_client_cert_source",
- return_value=True,
- ):
- with mock.patch(
- "google.auth.transport.mtls.default_client_cert_source",
- return_value=mock_client_cert_source,
- ):
- (
- api_endpoint,
- cert_source,
- ) = client_class.get_mtls_endpoint_and_cert_source()
- assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT
- assert cert_source == mock_client_cert_source
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name",
- [
- (VersionsClient, transports.VersionsGrpcTransport, "grpc"),
- (VersionsAsyncClient, transports.VersionsGrpcAsyncIOTransport, "grpc_asyncio"),
- (VersionsClient, transports.VersionsRestTransport, "rest"),
- ],
-)
-def test_versions_client_client_options_scopes(
- client_class, transport_class, transport_name
-):
- # Check the case scopes are provided.
- options = client_options.ClientOptions(
- scopes=["1", "2"],
- )
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=["1", "2"],
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (VersionsClient, transports.VersionsGrpcTransport, "grpc", grpc_helpers),
- (
- VersionsAsyncClient,
- transports.VersionsGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- (VersionsClient, transports.VersionsRestTransport, "rest", None),
- ],
-)
-def test_versions_client_client_options_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-def test_versions_client_client_options_from_dict():
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.versions.transports.VersionsGrpcTransport.__init__"
- ) as grpc_transport:
- grpc_transport.return_value = None
- client = VersionsClient(client_options={"api_endpoint": "squid.clam.whelk"})
- grpc_transport.assert_called_once_with(
- credentials=None,
- credentials_file=None,
- host="squid.clam.whelk",
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class,transport_name,grpc_helpers",
- [
- (VersionsClient, transports.VersionsGrpcTransport, "grpc", grpc_helpers),
- (
- VersionsAsyncClient,
- transports.VersionsGrpcAsyncIOTransport,
- "grpc_asyncio",
- grpc_helpers_async,
- ),
- ],
-)
-def test_versions_client_create_channel_credentials_file(
- client_class, transport_class, transport_name, grpc_helpers
-):
- # Check the case credentials file is provided.
- options = client_options.ClientOptions(credentials_file="credentials.json")
-
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options, transport=transport_name)
- patched.assert_called_once_with(
- credentials=None,
- credentials_file="credentials.json",
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )
-
- # test that the credentials from file are saved and used as the credentials.
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel"
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- file_creds = ga_credentials.AnonymousCredentials()
- load_creds.return_value = (file_creds, None)
- adc.return_value = (creds, None)
- client = client_class(client_options=options, transport=transport_name)
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=file_creds,
- credentials_file=None,
- quota_project_id=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=None,
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListVersionsRequest,
- dict,
- ],
-)
-def test_list_versions(request_type, transport: str = "grpc"):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_versions), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = appengine.ListVersionsResponse(
- next_page_token="next_page_token_value",
- )
- response = client.list_versions(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListVersionsRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListVersionsPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-def test_list_versions_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_versions), "__call__") as call:
- client.list_versions()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListVersionsRequest()
-
-
-@pytest.mark.asyncio
-async def test_list_versions_async(
- transport: str = "grpc_asyncio", request_type=appengine.ListVersionsRequest
-):
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_versions), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListVersionsResponse(
- next_page_token="next_page_token_value",
- )
- )
- response = await client.list_versions(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.ListVersionsRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListVersionsAsyncPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.asyncio
-async def test_list_versions_async_from_dict():
- await test_list_versions_async(request_type=dict)
-
-
-def test_list_versions_field_headers():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListVersionsRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_versions), "__call__") as call:
- call.return_value = appengine.ListVersionsResponse()
- client.list_versions(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_list_versions_field_headers_async():
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.ListVersionsRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_versions), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- appengine.ListVersionsResponse()
- )
- await client.list_versions(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-def test_list_versions_pager(transport_name: str = "grpc"):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_versions), "__call__") as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- version.Version(),
- version.Version(),
- ],
- next_page_token="abc",
- ),
- appengine.ListVersionsResponse(
- versions=[],
- next_page_token="def",
- ),
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- version.Version(),
- ],
- ),
- RuntimeError,
- )
-
- metadata = ()
- metadata = tuple(metadata) + (
- gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)),
- )
- pager = client.list_versions(request={})
-
- assert pager._metadata == metadata
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, version.Version) for i in results)
-
-
-def test_list_versions_pages(transport_name: str = "grpc"):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials,
- transport=transport_name,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.list_versions), "__call__") as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- version.Version(),
- version.Version(),
- ],
- next_page_token="abc",
- ),
- appengine.ListVersionsResponse(
- versions=[],
- next_page_token="def",
- ),
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- version.Version(),
- ],
- ),
- RuntimeError,
- )
- pages = list(client.list_versions(request={}).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.asyncio
-async def test_list_versions_async_pager():
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_versions), "__call__", new_callable=mock.AsyncMock
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- version.Version(),
- version.Version(),
- ],
- next_page_token="abc",
- ),
- appengine.ListVersionsResponse(
- versions=[],
- next_page_token="def",
- ),
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- version.Version(),
- ],
- ),
- RuntimeError,
- )
- async_pager = await client.list_versions(
- request={},
- )
- assert async_pager.next_page_token == "abc"
- responses = []
- async for response in async_pager: # pragma: no branch
- responses.append(response)
-
- assert len(responses) == 6
- assert all(isinstance(i, version.Version) for i in responses)
-
-
-@pytest.mark.asyncio
-async def test_list_versions_async_pages():
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials,
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(
- type(client.transport.list_versions), "__call__", new_callable=mock.AsyncMock
- ) as call:
- # Set the response to a series of pages.
- call.side_effect = (
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- version.Version(),
- version.Version(),
- ],
- next_page_token="abc",
- ),
- appengine.ListVersionsResponse(
- versions=[],
- next_page_token="def",
- ),
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- version.Version(),
- ],
- ),
- RuntimeError,
- )
- pages = []
- # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch`
- # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372
- async for page_ in ( # pragma: no branch
- await client.list_versions(request={})
- ).pages:
- pages.append(page_)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetVersionRequest,
- dict,
- ],
-)
-def test_get_version(request_type, transport: str = "grpc"):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_version), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = version.Version(
- name="name_value",
- id="id_value",
- inbound_services=[version.InboundServiceType.INBOUND_SERVICE_MAIL],
- instance_class="instance_class_value",
- zones=["zones_value"],
- runtime="runtime_value",
- runtime_channel="runtime_channel_value",
- threadsafe=True,
- vm=True,
- app_engine_apis=True,
- env="env_value",
- serving_status=version.ServingStatus.SERVING,
- created_by="created_by_value",
- disk_usage_bytes=1701,
- runtime_api_version="runtime_api_version_value",
- runtime_main_executable_path="runtime_main_executable_path_value",
- service_account="service_account_value",
- nobuild_files_regex="nobuild_files_regex_value",
- version_url="version_url_value",
- )
- response = client.get_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetVersionRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, version.Version)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.inbound_services == [
- version.InboundServiceType.INBOUND_SERVICE_MAIL
- ]
- assert response.instance_class == "instance_class_value"
- assert response.zones == ["zones_value"]
- assert response.runtime == "runtime_value"
- assert response.runtime_channel == "runtime_channel_value"
- assert response.threadsafe is True
- assert response.vm is True
- assert response.app_engine_apis is True
- assert response.env == "env_value"
- assert response.serving_status == version.ServingStatus.SERVING
- assert response.created_by == "created_by_value"
- assert response.disk_usage_bytes == 1701
- assert response.runtime_api_version == "runtime_api_version_value"
- assert response.runtime_main_executable_path == "runtime_main_executable_path_value"
- assert response.service_account == "service_account_value"
- assert response.nobuild_files_regex == "nobuild_files_regex_value"
- assert response.version_url == "version_url_value"
-
-
-def test_get_version_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_version), "__call__") as call:
- client.get_version()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetVersionRequest()
-
-
-@pytest.mark.asyncio
-async def test_get_version_async(
- transport: str = "grpc_asyncio", request_type=appengine.GetVersionRequest
-):
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_version), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- version.Version(
- name="name_value",
- id="id_value",
- inbound_services=[version.InboundServiceType.INBOUND_SERVICE_MAIL],
- instance_class="instance_class_value",
- zones=["zones_value"],
- runtime="runtime_value",
- runtime_channel="runtime_channel_value",
- threadsafe=True,
- vm=True,
- app_engine_apis=True,
- env="env_value",
- serving_status=version.ServingStatus.SERVING,
- created_by="created_by_value",
- disk_usage_bytes=1701,
- runtime_api_version="runtime_api_version_value",
- runtime_main_executable_path="runtime_main_executable_path_value",
- service_account="service_account_value",
- nobuild_files_regex="nobuild_files_regex_value",
- version_url="version_url_value",
- )
- )
- response = await client.get_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.GetVersionRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, version.Version)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.inbound_services == [
- version.InboundServiceType.INBOUND_SERVICE_MAIL
- ]
- assert response.instance_class == "instance_class_value"
- assert response.zones == ["zones_value"]
- assert response.runtime == "runtime_value"
- assert response.runtime_channel == "runtime_channel_value"
- assert response.threadsafe is True
- assert response.vm is True
- assert response.app_engine_apis is True
- assert response.env == "env_value"
- assert response.serving_status == version.ServingStatus.SERVING
- assert response.created_by == "created_by_value"
- assert response.disk_usage_bytes == 1701
- assert response.runtime_api_version == "runtime_api_version_value"
- assert response.runtime_main_executable_path == "runtime_main_executable_path_value"
- assert response.service_account == "service_account_value"
- assert response.nobuild_files_regex == "nobuild_files_regex_value"
- assert response.version_url == "version_url_value"
-
-
-@pytest.mark.asyncio
-async def test_get_version_async_from_dict():
- await test_get_version_async(request_type=dict)
-
-
-def test_get_version_field_headers():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetVersionRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_version), "__call__") as call:
- call.return_value = version.Version()
- client.get_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_get_version_field_headers_async():
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.GetVersionRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.get_version), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(version.Version())
- await client.get_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.CreateVersionRequest,
- dict,
- ],
-)
-def test_create_version(request_type, transport: str = "grpc"):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.create_version), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.create_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateVersionRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_create_version_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.create_version), "__call__") as call:
- client.create_version()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateVersionRequest()
-
-
-@pytest.mark.asyncio
-async def test_create_version_async(
- transport: str = "grpc_asyncio", request_type=appengine.CreateVersionRequest
-):
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.create_version), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.create_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.CreateVersionRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_create_version_async_from_dict():
- await test_create_version_async(request_type=dict)
-
-
-def test_create_version_field_headers():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.CreateVersionRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.create_version), "__call__") as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.create_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_create_version_field_headers_async():
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.CreateVersionRequest()
-
- request.parent = "parent_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.create_version), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.create_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "parent=parent_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateVersionRequest,
- dict,
- ],
-)
-def test_update_version(request_type, transport: str = "grpc"):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.update_version), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.update_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateVersionRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_update_version_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.update_version), "__call__") as call:
- client.update_version()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateVersionRequest()
-
-
-@pytest.mark.asyncio
-async def test_update_version_async(
- transport: str = "grpc_asyncio", request_type=appengine.UpdateVersionRequest
-):
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.update_version), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.update_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.UpdateVersionRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_update_version_async_from_dict():
- await test_update_version_async(request_type=dict)
-
-
-def test_update_version_field_headers():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateVersionRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.update_version), "__call__") as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.update_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_update_version_field_headers_async():
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.UpdateVersionRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.update_version), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.update_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteVersionRequest,
- dict,
- ],
-)
-def test_delete_version(request_type, transport: str = "grpc"):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_version), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = operations_pb2.Operation(name="operations/spam")
- response = client.delete_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteVersionRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-def test_delete_version_empty_call():
- # This test is a coverage failsafe to make sure that totally empty calls,
- # i.e. request == None and no flattened fields passed, work.
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_version), "__call__") as call:
- client.delete_version()
- call.assert_called()
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteVersionRequest()
-
-
-@pytest.mark.asyncio
-async def test_delete_version_async(
- transport: str = "grpc_asyncio", request_type=appengine.DeleteVersionRequest
-):
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Everything is optional in proto3 as far as the runtime is concerned,
- # and we are mocking out the actual API, so just send an empty request.
- request = request_type()
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_version), "__call__") as call:
- # Designate an appropriate return value for the call.
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/spam")
- )
- response = await client.delete_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == appengine.DeleteVersionRequest()
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, future.Future)
-
-
-@pytest.mark.asyncio
-async def test_delete_version_async_from_dict():
- await test_delete_version_async(request_type=dict)
-
-
-def test_delete_version_field_headers():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteVersionRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_version), "__call__") as call:
- call.return_value = operations_pb2.Operation(name="operations/op")
- client.delete_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls) == 1
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.asyncio
-async def test_delete_version_field_headers_async():
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Any value that is part of the HTTP/1.1 URI should be sent as
- # a field header. Set these to a non-empty value.
- request = appengine.DeleteVersionRequest()
-
- request.name = "name_value"
-
- # Mock the actual call within the gRPC stub, and fake the request.
- with mock.patch.object(type(client.transport.delete_version), "__call__") as call:
- call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
- operations_pb2.Operation(name="operations/op")
- )
- await client.delete_version(request)
-
- # Establish that the underlying gRPC stub method was called.
- assert len(call.mock_calls)
- _, args, _ = call.mock_calls[0]
- assert args[0] == request
-
- # Establish that the field header was sent.
- _, _, kw = call.mock_calls[0]
- assert (
- "x-goog-request-params",
- "name=name_value",
- ) in kw["metadata"]
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.ListVersionsRequest,
- dict,
- ],
-)
-def test_list_versions_rest(request_type):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1/services/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = appengine.ListVersionsResponse(
- next_page_token="next_page_token_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = appengine.ListVersionsResponse.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.list_versions(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, pagers.ListVersionsPager)
- assert response.next_page_token == "next_page_token_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_list_versions_rest_interceptors(null_interceptor):
- transport = transports.VersionsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.VersionsRestInterceptor(),
- )
- client = VersionsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.VersionsRestInterceptor, "post_list_versions"
- ) as post, mock.patch.object(
- transports.VersionsRestInterceptor, "pre_list_versions"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.ListVersionsRequest.pb(appengine.ListVersionsRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = appengine.ListVersionsResponse.to_json(
- appengine.ListVersionsResponse()
- )
-
- request = appengine.ListVersionsRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = appengine.ListVersionsResponse()
-
- client.list_versions(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_list_versions_rest_bad_request(
- transport: str = "rest", request_type=appengine.ListVersionsRequest
-):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1/services/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.list_versions(request)
-
-
-def test_list_versions_rest_pager(transport: str = "rest"):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(Session, "request") as req:
- # TODO(kbandes): remove this mock unless there's a good reason for it.
- # with mock.patch.object(path_template, 'transcode') as transcode:
- # Set the response as a series of pages
- response = (
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- version.Version(),
- version.Version(),
- ],
- next_page_token="abc",
- ),
- appengine.ListVersionsResponse(
- versions=[],
- next_page_token="def",
- ),
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- ],
- next_page_token="ghi",
- ),
- appengine.ListVersionsResponse(
- versions=[
- version.Version(),
- version.Version(),
- ],
- ),
- )
- # Two responses for two calls
- response = response + response
-
- # Wrap the values into proper Response objs
- response = tuple(appengine.ListVersionsResponse.to_json(x) for x in response)
- return_values = tuple(Response() for i in response)
- for return_val, response_val in zip(return_values, response):
- return_val._content = response_val.encode("UTF-8")
- return_val.status_code = 200
- req.side_effect = return_values
-
- sample_request = {"parent": "apps/sample1/services/sample2"}
-
- pager = client.list_versions(request=sample_request)
-
- results = list(pager)
- assert len(results) == 6
- assert all(isinstance(i, version.Version) for i in results)
-
- pages = list(client.list_versions(request=sample_request).pages)
- for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
- assert page_.raw_page.next_page_token == token
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.GetVersionRequest,
- dict,
- ],
-)
-def test_get_version_rest(request_type):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2/versions/sample3"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = version.Version(
- name="name_value",
- id="id_value",
- inbound_services=[version.InboundServiceType.INBOUND_SERVICE_MAIL],
- instance_class="instance_class_value",
- zones=["zones_value"],
- runtime="runtime_value",
- runtime_channel="runtime_channel_value",
- threadsafe=True,
- vm=True,
- app_engine_apis=True,
- env="env_value",
- serving_status=version.ServingStatus.SERVING,
- created_by="created_by_value",
- disk_usage_bytes=1701,
- runtime_api_version="runtime_api_version_value",
- runtime_main_executable_path="runtime_main_executable_path_value",
- service_account="service_account_value",
- nobuild_files_regex="nobuild_files_regex_value",
- version_url="version_url_value",
- )
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- # Convert return value to protobuf type
- return_value = version.Version.pb(return_value)
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.get_version(request)
-
- # Establish that the response is the type that we expect.
- assert isinstance(response, version.Version)
- assert response.name == "name_value"
- assert response.id == "id_value"
- assert response.inbound_services == [
- version.InboundServiceType.INBOUND_SERVICE_MAIL
- ]
- assert response.instance_class == "instance_class_value"
- assert response.zones == ["zones_value"]
- assert response.runtime == "runtime_value"
- assert response.runtime_channel == "runtime_channel_value"
- assert response.threadsafe is True
- assert response.vm is True
- assert response.app_engine_apis is True
- assert response.env == "env_value"
- assert response.serving_status == version.ServingStatus.SERVING
- assert response.created_by == "created_by_value"
- assert response.disk_usage_bytes == 1701
- assert response.runtime_api_version == "runtime_api_version_value"
- assert response.runtime_main_executable_path == "runtime_main_executable_path_value"
- assert response.service_account == "service_account_value"
- assert response.nobuild_files_regex == "nobuild_files_regex_value"
- assert response.version_url == "version_url_value"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_get_version_rest_interceptors(null_interceptor):
- transport = transports.VersionsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.VersionsRestInterceptor(),
- )
- client = VersionsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- transports.VersionsRestInterceptor, "post_get_version"
- ) as post, mock.patch.object(
- transports.VersionsRestInterceptor, "pre_get_version"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.GetVersionRequest.pb(appengine.GetVersionRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = version.Version.to_json(version.Version())
-
- request = appengine.GetVersionRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = version.Version()
-
- client.get_version(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_get_version_rest_bad_request(
- transport: str = "rest", request_type=appengine.GetVersionRequest
-):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2/versions/sample3"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.get_version(request)
-
-
-def test_get_version_rest_error():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.CreateVersionRequest,
- dict,
- ],
-)
-def test_create_version_rest(request_type):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1/services/sample2"}
- request_init["version"] = {
- "name": "name_value",
- "id": "id_value",
- "automatic_scaling": {
- "cool_down_period": {"seconds": 751, "nanos": 543},
- "cpu_utilization": {
- "aggregation_window_length": {},
- "target_utilization": 0.19540000000000002,
- },
- "max_concurrent_requests": 2499,
- "max_idle_instances": 1898,
- "max_total_instances": 2032,
- "max_pending_latency": {},
- "min_idle_instances": 1896,
- "min_total_instances": 2030,
- "min_pending_latency": {},
- "request_utilization": {
- "target_request_count_per_second": 3320,
- "target_concurrent_requests": 2820,
- },
- "disk_utilization": {
- "target_write_bytes_per_second": 3096,
- "target_write_ops_per_second": 2883,
- "target_read_bytes_per_second": 2953,
- "target_read_ops_per_second": 2740,
- },
- "network_utilization": {
- "target_sent_bytes_per_second": 2983,
- "target_sent_packets_per_second": 3179,
- "target_received_bytes_per_second": 3380,
- "target_received_packets_per_second": 3576,
- },
- "standard_scheduler_settings": {
- "target_cpu_utilization": 0.23770000000000002,
- "target_throughput_utilization": 0.3163,
- "min_instances": 1387,
- "max_instances": 1389,
- },
- },
- "basic_scaling": {"idle_timeout": {}, "max_instances": 1389},
- "manual_scaling": {"instances": 968},
- "inbound_services": [1],
- "instance_class": "instance_class_value",
- "network": {
- "forwarded_ports": ["forwarded_ports_value1", "forwarded_ports_value2"],
- "instance_tag": "instance_tag_value",
- "name": "name_value",
- "subnetwork_name": "subnetwork_name_value",
- "session_affinity": True,
- },
- "zones": ["zones_value1", "zones_value2"],
- "resources": {
- "cpu": 0.328,
- "disk_gb": 0.723,
- "memory_gb": 0.961,
- "volumes": [
- {
- "name": "name_value",
- "volume_type": "volume_type_value",
- "size_gb": 0.739,
- }
- ],
- "kms_key_reference": "kms_key_reference_value",
- },
- "runtime": "runtime_value",
- "runtime_channel": "runtime_channel_value",
- "threadsafe": True,
- "vm": True,
- "app_engine_apis": True,
- "beta_settings": {},
- "env": "env_value",
- "serving_status": 1,
- "created_by": "created_by_value",
- "create_time": {"seconds": 751, "nanos": 543},
- "disk_usage_bytes": 1701,
- "runtime_api_version": "runtime_api_version_value",
- "runtime_main_executable_path": "runtime_main_executable_path_value",
- "service_account": "service_account_value",
- "handlers": [
- {
- "url_regex": "url_regex_value",
- "static_files": {
- "path": "path_value",
- "upload_path_regex": "upload_path_regex_value",
- "http_headers": {},
- "mime_type": "mime_type_value",
- "expiration": {},
- "require_matching_file": True,
- "application_readable": True,
- },
- "script": {"script_path": "script_path_value"},
- "api_endpoint": {"script_path": "script_path_value"},
- "security_level": 1,
- "login": 1,
- "auth_fail_action": 1,
- "redirect_http_response_code": 1,
- }
- ],
- "error_handlers": [
- {
- "error_code": 1,
- "static_file": "static_file_value",
- "mime_type": "mime_type_value",
- }
- ],
- "libraries": [{"name": "name_value", "version": "version_value"}],
- "api_config": {
- "auth_fail_action": 1,
- "login": 1,
- "script": "script_value",
- "security_level": 1,
- "url": "url_value",
- },
- "env_variables": {},
- "build_env_variables": {},
- "default_expiration": {},
- "health_check": {
- "disable_health_check": True,
- "host": "host_value",
- "healthy_threshold": 1819,
- "unhealthy_threshold": 2046,
- "restart_threshold": 1841,
- "check_interval": {},
- "timeout": {},
- },
- "readiness_check": {
- "path": "path_value",
- "host": "host_value",
- "failure_threshold": 1812,
- "success_threshold": 1829,
- "check_interval": {},
- "timeout": {},
- "app_start_timeout": {},
- },
- "liveness_check": {
- "path": "path_value",
- "host": "host_value",
- "failure_threshold": 1812,
- "success_threshold": 1829,
- "check_interval": {},
- "timeout": {},
- "initial_delay": {},
- },
- "nobuild_files_regex": "nobuild_files_regex_value",
- "deployment": {
- "files": {},
- "container": {"image": "image_value"},
- "zip_": {"source_url": "source_url_value", "files_count": 1179},
- "cloud_build_options": {
- "app_yaml_path": "app_yaml_path_value",
- "cloud_build_timeout": {},
- },
- },
- "version_url": "version_url_value",
- "endpoints_api_service": {
- "name": "name_value",
- "config_id": "config_id_value",
- "rollout_strategy": 1,
- "disable_trace_sampling": True,
- },
- "entrypoint": {"shell": "shell_value"},
- "vpc_access_connector": {"name": "name_value", "egress_setting": 1},
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.CreateVersionRequest.meta.fields["version"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["version"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["version"][field])):
- del request_init["version"][field][i][subfield]
- else:
- del request_init["version"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.create_version(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_create_version_rest_interceptors(null_interceptor):
- transport = transports.VersionsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.VersionsRestInterceptor(),
- )
- client = VersionsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.VersionsRestInterceptor, "post_create_version"
- ) as post, mock.patch.object(
- transports.VersionsRestInterceptor, "pre_create_version"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.CreateVersionRequest.pb(appengine.CreateVersionRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.CreateVersionRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.create_version(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_create_version_rest_bad_request(
- transport: str = "rest", request_type=appengine.CreateVersionRequest
-):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"parent": "apps/sample1/services/sample2"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.create_version(request)
-
-
-def test_create_version_rest_error():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.UpdateVersionRequest,
- dict,
- ],
-)
-def test_update_version_rest(request_type):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2/versions/sample3"}
- request_init["version"] = {
- "name": "name_value",
- "id": "id_value",
- "automatic_scaling": {
- "cool_down_period": {"seconds": 751, "nanos": 543},
- "cpu_utilization": {
- "aggregation_window_length": {},
- "target_utilization": 0.19540000000000002,
- },
- "max_concurrent_requests": 2499,
- "max_idle_instances": 1898,
- "max_total_instances": 2032,
- "max_pending_latency": {},
- "min_idle_instances": 1896,
- "min_total_instances": 2030,
- "min_pending_latency": {},
- "request_utilization": {
- "target_request_count_per_second": 3320,
- "target_concurrent_requests": 2820,
- },
- "disk_utilization": {
- "target_write_bytes_per_second": 3096,
- "target_write_ops_per_second": 2883,
- "target_read_bytes_per_second": 2953,
- "target_read_ops_per_second": 2740,
- },
- "network_utilization": {
- "target_sent_bytes_per_second": 2983,
- "target_sent_packets_per_second": 3179,
- "target_received_bytes_per_second": 3380,
- "target_received_packets_per_second": 3576,
- },
- "standard_scheduler_settings": {
- "target_cpu_utilization": 0.23770000000000002,
- "target_throughput_utilization": 0.3163,
- "min_instances": 1387,
- "max_instances": 1389,
- },
- },
- "basic_scaling": {"idle_timeout": {}, "max_instances": 1389},
- "manual_scaling": {"instances": 968},
- "inbound_services": [1],
- "instance_class": "instance_class_value",
- "network": {
- "forwarded_ports": ["forwarded_ports_value1", "forwarded_ports_value2"],
- "instance_tag": "instance_tag_value",
- "name": "name_value",
- "subnetwork_name": "subnetwork_name_value",
- "session_affinity": True,
- },
- "zones": ["zones_value1", "zones_value2"],
- "resources": {
- "cpu": 0.328,
- "disk_gb": 0.723,
- "memory_gb": 0.961,
- "volumes": [
- {
- "name": "name_value",
- "volume_type": "volume_type_value",
- "size_gb": 0.739,
- }
- ],
- "kms_key_reference": "kms_key_reference_value",
- },
- "runtime": "runtime_value",
- "runtime_channel": "runtime_channel_value",
- "threadsafe": True,
- "vm": True,
- "app_engine_apis": True,
- "beta_settings": {},
- "env": "env_value",
- "serving_status": 1,
- "created_by": "created_by_value",
- "create_time": {"seconds": 751, "nanos": 543},
- "disk_usage_bytes": 1701,
- "runtime_api_version": "runtime_api_version_value",
- "runtime_main_executable_path": "runtime_main_executable_path_value",
- "service_account": "service_account_value",
- "handlers": [
- {
- "url_regex": "url_regex_value",
- "static_files": {
- "path": "path_value",
- "upload_path_regex": "upload_path_regex_value",
- "http_headers": {},
- "mime_type": "mime_type_value",
- "expiration": {},
- "require_matching_file": True,
- "application_readable": True,
- },
- "script": {"script_path": "script_path_value"},
- "api_endpoint": {"script_path": "script_path_value"},
- "security_level": 1,
- "login": 1,
- "auth_fail_action": 1,
- "redirect_http_response_code": 1,
- }
- ],
- "error_handlers": [
- {
- "error_code": 1,
- "static_file": "static_file_value",
- "mime_type": "mime_type_value",
- }
- ],
- "libraries": [{"name": "name_value", "version": "version_value"}],
- "api_config": {
- "auth_fail_action": 1,
- "login": 1,
- "script": "script_value",
- "security_level": 1,
- "url": "url_value",
- },
- "env_variables": {},
- "build_env_variables": {},
- "default_expiration": {},
- "health_check": {
- "disable_health_check": True,
- "host": "host_value",
- "healthy_threshold": 1819,
- "unhealthy_threshold": 2046,
- "restart_threshold": 1841,
- "check_interval": {},
- "timeout": {},
- },
- "readiness_check": {
- "path": "path_value",
- "host": "host_value",
- "failure_threshold": 1812,
- "success_threshold": 1829,
- "check_interval": {},
- "timeout": {},
- "app_start_timeout": {},
- },
- "liveness_check": {
- "path": "path_value",
- "host": "host_value",
- "failure_threshold": 1812,
- "success_threshold": 1829,
- "check_interval": {},
- "timeout": {},
- "initial_delay": {},
- },
- "nobuild_files_regex": "nobuild_files_regex_value",
- "deployment": {
- "files": {},
- "container": {"image": "image_value"},
- "zip_": {"source_url": "source_url_value", "files_count": 1179},
- "cloud_build_options": {
- "app_yaml_path": "app_yaml_path_value",
- "cloud_build_timeout": {},
- },
- },
- "version_url": "version_url_value",
- "endpoints_api_service": {
- "name": "name_value",
- "config_id": "config_id_value",
- "rollout_strategy": 1,
- "disable_trace_sampling": True,
- },
- "entrypoint": {"shell": "shell_value"},
- "vpc_access_connector": {"name": "name_value", "egress_setting": 1},
- }
- # The version of a generated dependency at test runtime may differ from the version used during generation.
- # Delete any fields which are not present in the current runtime dependency
- # See https://github.com/googleapis/gapic-generator-python/issues/1748
-
- # Determine if the message type is proto-plus or protobuf
- test_field = appengine.UpdateVersionRequest.meta.fields["version"]
-
- def get_message_fields(field):
- # Given a field which is a message (composite type), return a list with
- # all the fields of the message.
- # If the field is not a composite type, return an empty list.
- message_fields = []
-
- if hasattr(field, "message") and field.message:
- is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")
-
- if is_field_type_proto_plus_type:
- message_fields = field.message.meta.fields.values()
- # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
- else: # pragma: NO COVER
- message_fields = field.message.DESCRIPTOR.fields
- return message_fields
-
- runtime_nested_fields = [
- (field.name, nested_field.name)
- for field in get_message_fields(test_field)
- for nested_field in get_message_fields(field)
- ]
-
- subfields_not_in_runtime = []
-
- # For each item in the sample request, create a list of sub fields which are not present at runtime
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for field, value in request_init["version"].items(): # pragma: NO COVER
- result = None
- is_repeated = False
- # For repeated fields
- if isinstance(value, list) and len(value):
- is_repeated = True
- result = value[0]
- # For fields where the type is another message
- if isinstance(value, dict):
- result = value
-
- if result and hasattr(result, "keys"):
- for subfield in result.keys():
- if (field, subfield) not in runtime_nested_fields:
- subfields_not_in_runtime.append(
- {
- "field": field,
- "subfield": subfield,
- "is_repeated": is_repeated,
- }
- )
-
- # Remove fields from the sample request which are not present in the runtime version of the dependency
- # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
- for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
- field = subfield_to_delete.get("field")
- field_repeated = subfield_to_delete.get("is_repeated")
- subfield = subfield_to_delete.get("subfield")
- if subfield:
- if field_repeated:
- for i in range(0, len(request_init["version"][field])):
- del request_init["version"][field][i][subfield]
- else:
- del request_init["version"][field][subfield]
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.update_version(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_update_version_rest_interceptors(null_interceptor):
- transport = transports.VersionsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.VersionsRestInterceptor(),
- )
- client = VersionsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.VersionsRestInterceptor, "post_update_version"
- ) as post, mock.patch.object(
- transports.VersionsRestInterceptor, "pre_update_version"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.UpdateVersionRequest.pb(appengine.UpdateVersionRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.UpdateVersionRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.update_version(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_update_version_rest_bad_request(
- transport: str = "rest", request_type=appengine.UpdateVersionRequest
-):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2/versions/sample3"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.update_version(request)
-
-
-def test_update_version_rest_error():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-@pytest.mark.parametrize(
- "request_type",
- [
- appengine.DeleteVersionRequest,
- dict,
- ],
-)
-def test_delete_version_rest(request_type):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2/versions/sample3"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a response.
- with mock.patch.object(type(client.transport._session), "request") as req:
- # Designate an appropriate value for the returned response.
- return_value = operations_pb2.Operation(name="operations/spam")
-
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 200
- json_return_value = json_format.MessageToJson(return_value)
-
- response_value._content = json_return_value.encode("UTF-8")
- req.return_value = response_value
- response = client.delete_version(request)
-
- # Establish that the response is the type that we expect.
- assert response.operation.name == "operations/spam"
-
-
-@pytest.mark.parametrize("null_interceptor", [True, False])
-def test_delete_version_rest_interceptors(null_interceptor):
- transport = transports.VersionsRestTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- interceptor=None if null_interceptor else transports.VersionsRestInterceptor(),
- )
- client = VersionsClient(transport=transport)
- with mock.patch.object(
- type(client.transport._session), "request"
- ) as req, mock.patch.object(
- path_template, "transcode"
- ) as transcode, mock.patch.object(
- operation.Operation, "_set_result_from_operation"
- ), mock.patch.object(
- transports.VersionsRestInterceptor, "post_delete_version"
- ) as post, mock.patch.object(
- transports.VersionsRestInterceptor, "pre_delete_version"
- ) as pre:
- pre.assert_not_called()
- post.assert_not_called()
- pb_message = appengine.DeleteVersionRequest.pb(appengine.DeleteVersionRequest())
- transcode.return_value = {
- "method": "post",
- "uri": "my_uri",
- "body": pb_message,
- "query_params": pb_message,
- }
-
- req.return_value = Response()
- req.return_value.status_code = 200
- req.return_value.request = PreparedRequest()
- req.return_value._content = json_format.MessageToJson(
- operations_pb2.Operation()
- )
-
- request = appengine.DeleteVersionRequest()
- metadata = [
- ("key", "val"),
- ("cephalopod", "squid"),
- ]
- pre.return_value = request, metadata
- post.return_value = operations_pb2.Operation()
-
- client.delete_version(
- request,
- metadata=[
- ("key", "val"),
- ("cephalopod", "squid"),
- ],
- )
-
- pre.assert_called_once()
- post.assert_called_once()
-
-
-def test_delete_version_rest_bad_request(
- transport: str = "rest", request_type=appengine.DeleteVersionRequest
-):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # send a request that will satisfy transcoding
- request_init = {"name": "apps/sample1/services/sample2/versions/sample3"}
- request = request_type(**request_init)
-
- # Mock the http request call within the method and fake a BadRequest error.
- with mock.patch.object(Session, "request") as req, pytest.raises(
- core_exceptions.BadRequest
- ):
- # Wrap the value into a proper Response obj
- response_value = Response()
- response_value.status_code = 400
- response_value.request = Request()
- req.return_value = response_value
- client.delete_version(request)
-
-
-def test_delete_version_rest_error():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport="rest"
- )
-
-
-def test_credentials_transport_error():
- # It is an error to provide credentials and a transport instance.
- transport = transports.VersionsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport=transport,
- )
-
- # It is an error to provide a credentials file and a transport instance.
- transport = transports.VersionsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = VersionsClient(
- client_options={"credentials_file": "credentials.json"},
- transport=transport,
- )
-
- # It is an error to provide an api_key and a transport instance.
- transport = transports.VersionsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = VersionsClient(
- client_options=options,
- transport=transport,
- )
-
- # It is an error to provide an api_key and a credential.
- options = mock.Mock()
- options.api_key = "api_key"
- with pytest.raises(ValueError):
- client = VersionsClient(
- client_options=options, credentials=ga_credentials.AnonymousCredentials()
- )
-
- # It is an error to provide scopes and a transport instance.
- transport = transports.VersionsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- with pytest.raises(ValueError):
- client = VersionsClient(
- client_options={"scopes": ["1", "2"]},
- transport=transport,
- )
-
-
-def test_transport_instance():
- # A client may be instantiated with a custom transport instance.
- transport = transports.VersionsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- client = VersionsClient(transport=transport)
- assert client.transport is transport
-
-
-def test_transport_get_channel():
- # A client may be instantiated with a custom transport instance.
- transport = transports.VersionsGrpcTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
- transport = transports.VersionsGrpcAsyncIOTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- channel = transport.grpc_channel
- assert channel
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.VersionsGrpcTransport,
- transports.VersionsGrpcAsyncIOTransport,
- transports.VersionsRestTransport,
- ],
-)
-def test_transport_adc(transport_class):
- # Test default credentials are used if not provided.
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class()
- adc.assert_called_once()
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "rest",
- ],
-)
-def test_transport_kind(transport_name):
- transport = VersionsClient.get_transport_class(transport_name)(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert transport.kind == transport_name
-
-
-def test_transport_grpc_default():
- # A client should use the gRPC transport by default.
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- )
- assert isinstance(
- client.transport,
- transports.VersionsGrpcTransport,
- )
-
-
-def test_versions_base_transport_error():
- # Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(core_exceptions.DuplicateCredentialArgs):
- transport = transports.VersionsTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- credentials_file="credentials.json",
- )
-
-
-def test_versions_base_transport():
- # Instantiate the base transport.
- with mock.patch(
- "google.cloud.appengine_admin_v1.services.versions.transports.VersionsTransport.__init__"
- ) as Transport:
- Transport.return_value = None
- transport = transports.VersionsTransport(
- credentials=ga_credentials.AnonymousCredentials(),
- )
-
- # Every method on the transport should just blindly
- # raise NotImplementedError.
- methods = (
- "list_versions",
- "get_version",
- "create_version",
- "update_version",
- "delete_version",
- )
- for method in methods:
- with pytest.raises(NotImplementedError):
- getattr(transport, method)(request=object())
-
- with pytest.raises(NotImplementedError):
- transport.close()
-
- # Additionally, the LRO client (a property) should
- # also raise NotImplementedError
- with pytest.raises(NotImplementedError):
- transport.operations_client
-
- # Catch all for all remaining methods and properties
- remainder = [
- "kind",
- ]
- for r in remainder:
- with pytest.raises(NotImplementedError):
- getattr(transport, r)()
-
-
-def test_versions_base_transport_with_credentials_file():
- # Instantiate the base transport with a credentials file
- with mock.patch.object(
- google.auth, "load_credentials_from_file", autospec=True
- ) as load_creds, mock.patch(
- "google.cloud.appengine_admin_v1.services.versions.transports.VersionsTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.VersionsTransport(
- credentials_file="credentials.json",
- quota_project_id="octopus",
- )
- load_creds.assert_called_once_with(
- "credentials.json",
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-def test_versions_base_transport_with_adc():
- # Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
- "google.cloud.appengine_admin_v1.services.versions.transports.VersionsTransport._prep_wrapped_messages"
- ) as Transport:
- Transport.return_value = None
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport = transports.VersionsTransport()
- adc.assert_called_once()
-
-
-def test_versions_auth_adc():
- # If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- VersionsClient()
- adc.assert_called_once_with(
- scopes=None,
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id=None,
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.VersionsGrpcTransport,
- transports.VersionsGrpcAsyncIOTransport,
- ],
-)
-def test_versions_transport_auth_adc(transport_class):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- adc.return_value = (ga_credentials.AnonymousCredentials(), None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
- adc.assert_called_once_with(
- scopes=["1", "2"],
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- quota_project_id="octopus",
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [
- transports.VersionsGrpcTransport,
- transports.VersionsGrpcAsyncIOTransport,
- transports.VersionsRestTransport,
- ],
-)
-def test_versions_transport_auth_gdch_credentials(transport_class):
- host = "https://language.com"
- api_audience_tests = [None, "https://language2.com"]
- api_audience_expect = [host, "https://language2.com"]
- for t, e in zip(api_audience_tests, api_audience_expect):
- with mock.patch.object(google.auth, "default", autospec=True) as adc:
- gdch_mock = mock.MagicMock()
- type(gdch_mock).with_gdch_audience = mock.PropertyMock(
- return_value=gdch_mock
- )
- adc.return_value = (gdch_mock, None)
- transport_class(host=host, api_audience=t)
- gdch_mock.with_gdch_audience.assert_called_once_with(e)
-
-
-@pytest.mark.parametrize(
- "transport_class,grpc_helpers",
- [
- (transports.VersionsGrpcTransport, grpc_helpers),
- (transports.VersionsGrpcAsyncIOTransport, grpc_helpers_async),
- ],
-)
-def test_versions_transport_create_channel(transport_class, grpc_helpers):
- # If credentials and host are not provided, the transport class should use
- # ADC credentials.
- with mock.patch.object(
- google.auth, "default", autospec=True
- ) as adc, mock.patch.object(
- grpc_helpers, "create_channel", autospec=True
- ) as create_channel:
- creds = ga_credentials.AnonymousCredentials()
- adc.return_value = (creds, None)
- transport_class(quota_project_id="octopus", scopes=["1", "2"])
-
- create_channel.assert_called_with(
- "appengine.googleapis.com:443",
- credentials=creds,
- credentials_file=None,
- quota_project_id="octopus",
- default_scopes=(
- "https://www.googleapis.com/auth/appengine.admin",
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- ),
- scopes=["1", "2"],
- default_host="appengine.googleapis.com",
- ssl_credentials=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
-
-@pytest.mark.parametrize(
- "transport_class",
- [transports.VersionsGrpcTransport, transports.VersionsGrpcAsyncIOTransport],
-)
-def test_versions_grpc_transport_client_cert_source_for_mtls(transport_class):
- cred = ga_credentials.AnonymousCredentials()
-
- # Check ssl_channel_credentials is used if provided.
- with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
- mock_ssl_channel_creds = mock.Mock()
- transport_class(
- host="squid.clam.whelk",
- credentials=cred,
- ssl_channel_credentials=mock_ssl_channel_creds,
- )
- mock_create_channel.assert_called_once_with(
- "squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_channel_creds,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
-
- # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls
- # is used.
- with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()):
- with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred:
- transport_class(
- credentials=cred,
- client_cert_source_for_mtls=client_cert_source_callback,
- )
- expected_cert, expected_key = client_cert_source_callback()
- mock_ssl_cred.assert_called_once_with(
- certificate_chain=expected_cert, private_key=expected_key
- )
-
-
-def test_versions_http_transport_client_cert_source_for_mtls():
- cred = ga_credentials.AnonymousCredentials()
- with mock.patch(
- "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"
- ) as mock_configure_mtls_channel:
- transports.VersionsRestTransport(
- credentials=cred, client_cert_source_for_mtls=client_cert_source_callback
- )
- mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback)
-
-
-def test_versions_rest_lro_client():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="rest",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.AbstractOperationsClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_versions_host_no_port(transport_name):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:443"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "grpc",
- "grpc_asyncio",
- "rest",
- ],
-)
-def test_versions_host_with_port(transport_name):
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_options=client_options.ClientOptions(
- api_endpoint="appengine.googleapis.com:8000"
- ),
- transport=transport_name,
- )
- assert client.transport._host == (
- "appengine.googleapis.com:8000"
- if transport_name in ["grpc", "grpc_asyncio"]
- else "https://appengine.googleapis.com:8000"
- )
-
-
-@pytest.mark.parametrize(
- "transport_name",
- [
- "rest",
- ],
-)
-def test_versions_client_transport_session_collision(transport_name):
- creds1 = ga_credentials.AnonymousCredentials()
- creds2 = ga_credentials.AnonymousCredentials()
- client1 = VersionsClient(
- credentials=creds1,
- transport=transport_name,
- )
- client2 = VersionsClient(
- credentials=creds2,
- transport=transport_name,
- )
- session1 = client1.transport.list_versions._session
- session2 = client2.transport.list_versions._session
- assert session1 != session2
- session1 = client1.transport.get_version._session
- session2 = client2.transport.get_version._session
- assert session1 != session2
- session1 = client1.transport.create_version._session
- session2 = client2.transport.create_version._session
- assert session1 != session2
- session1 = client1.transport.update_version._session
- session2 = client2.transport.update_version._session
- assert session1 != session2
- session1 = client1.transport.delete_version._session
- session2 = client2.transport.delete_version._session
- assert session1 != session2
-
-
-def test_versions_grpc_transport_channel():
- channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.VersionsGrpcTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-def test_versions_grpc_asyncio_transport_channel():
- channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials())
-
- # Check that channel is used if provided.
- transport = transports.VersionsGrpcAsyncIOTransport(
- host="squid.clam.whelk",
- channel=channel,
- )
- assert transport.grpc_channel == channel
- assert transport._host == "squid.clam.whelk:443"
- assert transport._ssl_channel_credentials == None
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [transports.VersionsGrpcTransport, transports.VersionsGrpcAsyncIOTransport],
-)
-def test_versions_transport_channel_mtls_with_client_cert_source(transport_class):
- with mock.patch(
- "grpc.ssl_channel_credentials", autospec=True
- ) as grpc_ssl_channel_cred:
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_ssl_cred = mock.Mock()
- grpc_ssl_channel_cred.return_value = mock_ssl_cred
-
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
-
- cred = ga_credentials.AnonymousCredentials()
- with pytest.warns(DeprecationWarning):
- with mock.patch.object(google.auth, "default") as adc:
- adc.return_value = (cred, None)
- transport = transport_class(
- host="squid.clam.whelk",
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=client_cert_source_callback,
- )
- adc.assert_called_once()
-
- grpc_ssl_channel_cred.assert_called_once_with(
- certificate_chain=b"cert bytes", private_key=b"key bytes"
- )
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
- assert transport._ssl_channel_credentials == mock_ssl_cred
-
-
-# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
-# removed from grpc/grpc_asyncio transport constructor.
-@pytest.mark.parametrize(
- "transport_class",
- [transports.VersionsGrpcTransport, transports.VersionsGrpcAsyncIOTransport],
-)
-def test_versions_transport_channel_mtls_with_adc(transport_class):
- mock_ssl_cred = mock.Mock()
- with mock.patch.multiple(
- "google.auth.transport.grpc.SslCredentials",
- __init__=mock.Mock(return_value=None),
- ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
- ):
- with mock.patch.object(
- transport_class, "create_channel"
- ) as grpc_create_channel:
- mock_grpc_channel = mock.Mock()
- grpc_create_channel.return_value = mock_grpc_channel
- mock_cred = mock.Mock()
-
- with pytest.warns(DeprecationWarning):
- transport = transport_class(
- host="squid.clam.whelk",
- credentials=mock_cred,
- api_mtls_endpoint="mtls.squid.clam.whelk",
- client_cert_source=None,
- )
-
- grpc_create_channel.assert_called_once_with(
- "mtls.squid.clam.whelk:443",
- credentials=mock_cred,
- credentials_file=None,
- scopes=None,
- ssl_credentials=mock_ssl_cred,
- quota_project_id=None,
- options=[
- ("grpc.max_send_message_length", -1),
- ("grpc.max_receive_message_length", -1),
- ],
- )
- assert transport.grpc_channel == mock_grpc_channel
-
-
-def test_versions_grpc_lro_client():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.OperationsClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-def test_versions_grpc_lro_async_client():
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- transport = client.transport
-
- # Ensure that we have a api-core operations client.
- assert isinstance(
- transport.operations_client,
- operations_v1.OperationsAsyncClient,
- )
-
- # Ensure that subsequent calls to the property send the exact same object.
- assert transport.operations_client is transport.operations_client
-
-
-def test_common_billing_account_path():
- billing_account = "squid"
- expected = "billingAccounts/{billing_account}".format(
- billing_account=billing_account,
- )
- actual = VersionsClient.common_billing_account_path(billing_account)
- assert expected == actual
-
-
-def test_parse_common_billing_account_path():
- expected = {
- "billing_account": "clam",
- }
- path = VersionsClient.common_billing_account_path(**expected)
-
- # Check that the path construction is reversible.
- actual = VersionsClient.parse_common_billing_account_path(path)
- assert expected == actual
-
-
-def test_common_folder_path():
- folder = "whelk"
- expected = "folders/{folder}".format(
- folder=folder,
- )
- actual = VersionsClient.common_folder_path(folder)
- assert expected == actual
-
-
-def test_parse_common_folder_path():
- expected = {
- "folder": "octopus",
- }
- path = VersionsClient.common_folder_path(**expected)
-
- # Check that the path construction is reversible.
- actual = VersionsClient.parse_common_folder_path(path)
- assert expected == actual
-
-
-def test_common_organization_path():
- organization = "oyster"
- expected = "organizations/{organization}".format(
- organization=organization,
- )
- actual = VersionsClient.common_organization_path(organization)
- assert expected == actual
-
-
-def test_parse_common_organization_path():
- expected = {
- "organization": "nudibranch",
- }
- path = VersionsClient.common_organization_path(**expected)
-
- # Check that the path construction is reversible.
- actual = VersionsClient.parse_common_organization_path(path)
- assert expected == actual
-
-
-def test_common_project_path():
- project = "cuttlefish"
- expected = "projects/{project}".format(
- project=project,
- )
- actual = VersionsClient.common_project_path(project)
- assert expected == actual
-
-
-def test_parse_common_project_path():
- expected = {
- "project": "mussel",
- }
- path = VersionsClient.common_project_path(**expected)
-
- # Check that the path construction is reversible.
- actual = VersionsClient.parse_common_project_path(path)
- assert expected == actual
-
-
-def test_common_location_path():
- project = "winkle"
- location = "nautilus"
- expected = "projects/{project}/locations/{location}".format(
- project=project,
- location=location,
- )
- actual = VersionsClient.common_location_path(project, location)
- assert expected == actual
-
-
-def test_parse_common_location_path():
- expected = {
- "project": "scallop",
- "location": "abalone",
- }
- path = VersionsClient.common_location_path(**expected)
-
- # Check that the path construction is reversible.
- actual = VersionsClient.parse_common_location_path(path)
- assert expected == actual
-
-
-def test_client_with_default_client_info():
- client_info = gapic_v1.client_info.ClientInfo()
-
- with mock.patch.object(
- transports.VersionsTransport, "_prep_wrapped_messages"
- ) as prep:
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
- with mock.patch.object(
- transports.VersionsTransport, "_prep_wrapped_messages"
- ) as prep:
- transport_class = VersionsClient.get_transport_class()
- transport = transport_class(
- credentials=ga_credentials.AnonymousCredentials(),
- client_info=client_info,
- )
- prep.assert_called_once_with(client_info)
-
-
-@pytest.mark.asyncio
-async def test_transport_close_async():
- client = VersionsAsyncClient(
- credentials=ga_credentials.AnonymousCredentials(),
- transport="grpc_asyncio",
- )
- with mock.patch.object(
- type(getattr(client.transport, "grpc_channel")), "close"
- ) as close:
- async with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_transport_close():
- transports = {
- "rest": "_session",
- "grpc": "_grpc_channel",
- }
-
- for transport, close_name in transports.items():
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- with mock.patch.object(
- type(getattr(client.transport, close_name)), "close"
- ) as close:
- with client:
- close.assert_not_called()
- close.assert_called_once()
-
-
-def test_client_ctx():
- transports = [
- "rest",
- "grpc",
- ]
- for transport in transports:
- client = VersionsClient(
- credentials=ga_credentials.AnonymousCredentials(), transport=transport
- )
- # Test client calls underlying transport.
- with mock.patch.object(type(client.transport), "close") as close:
- close.assert_not_called()
- with client:
- pass
- close.assert_called()
-
-
-@pytest.mark.parametrize(
- "client_class,transport_class",
- [
- (VersionsClient, transports.VersionsGrpcTransport),
- (VersionsAsyncClient, transports.VersionsGrpcAsyncIOTransport),
- ],
-)
-def test_api_key_credentials(client_class, transport_class):
- with mock.patch.object(
- google.auth._default, "get_api_key_credentials", create=True
- ) as get_api_key_credentials:
- mock_cred = mock.Mock()
- get_api_key_credentials.return_value = mock_cred
- options = client_options.ClientOptions()
- options.api_key = "api_key"
- with mock.patch.object(transport_class, "__init__") as patched:
- patched.return_value = None
- client = client_class(client_options=options)
- patched.assert_called_once_with(
- credentials=mock_cred,
- credentials_file=None,
- host=client.DEFAULT_ENDPOINT,
- scopes=None,
- client_cert_source_for_mtls=None,
- quota_project_id=None,
- client_info=transports.base.DEFAULT_CLIENT_INFO,
- always_use_jwt_access=True,
- api_audience=None,
- )