diff --git a/packages/google-cloud-os-config/docs/osconfig_v1/os_config_service.rst b/packages/google-cloud-os-config/docs/osconfig_v1/os_config_service.rst index cb2be750ce40..e082a4b65651 100644 --- a/packages/google-cloud-os-config/docs/osconfig_v1/os_config_service.rst +++ b/packages/google-cloud-os-config/docs/osconfig_v1/os_config_service.rst @@ -5,7 +5,6 @@ OsConfigService :members: :inherited-members: - .. automodule:: google.cloud.osconfig_v1.services.os_config_service.pagers :members: :inherited-members: diff --git a/packages/google-cloud-os-config/google/cloud/osconfig/__init__.py b/packages/google-cloud-os-config/google/cloud/osconfig/__init__.py index 2708c1d6b1b8..39c2c0dc302d 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig/__init__.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,12 +14,13 @@ # limitations under the License. # -from google.cloud.osconfig_v1.services.os_config_service.async_client import ( - OsConfigServiceAsyncClient, -) from google.cloud.osconfig_v1.services.os_config_service.client import ( OsConfigServiceClient, ) +from google.cloud.osconfig_v1.services.os_config_service.async_client import ( + OsConfigServiceAsyncClient, +) + from google.cloud.osconfig_v1.types.inventory import Inventory from google.cloud.osconfig_v1.types.osconfig_common import FixedOrPercent from google.cloud.osconfig_v1.types.patch_deployments import ( @@ -65,39 +65,39 @@ from google.cloud.osconfig_v1.types.patch_jobs import ZypperSettings __all__ = ( - "AptSettings", - "CancelPatchJobRequest", + "OsConfigServiceClient", + "OsConfigServiceAsyncClient", + "Inventory", + "FixedOrPercent", "CreatePatchDeploymentRequest", "DeletePatchDeploymentRequest", + "GetPatchDeploymentRequest", + "ListPatchDeploymentsRequest", + "ListPatchDeploymentsResponse", + "MonthlySchedule", + "OneTimeSchedule", + "PatchDeployment", + "RecurringSchedule", + "WeekDayOfMonth", + "WeeklySchedule", + "AptSettings", + "CancelPatchJobRequest", "ExecStep", "ExecStepConfig", "ExecutePatchJobRequest", - "FixedOrPercent", "GcsObject", - "GetPatchDeploymentRequest", "GetPatchJobRequest", "GooSettings", "Instance", - "Inventory", - "ListPatchDeploymentsRequest", - "ListPatchDeploymentsResponse", "ListPatchJobInstanceDetailsRequest", "ListPatchJobInstanceDetailsResponse", "ListPatchJobsRequest", "ListPatchJobsResponse", - "MonthlySchedule", - "OneTimeSchedule", - "OsConfigServiceAsyncClient", - "OsConfigServiceClient", "PatchConfig", - "PatchDeployment", "PatchInstanceFilter", "PatchJob", "PatchJobInstanceDetails", "PatchRollout", - "RecurringSchedule", - "WeekDayOfMonth", - "WeeklySchedule", "WindowsUpdateSettings", "YumSettings", "ZypperSettings", diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/__init__.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/__init__.py index 3153077a8052..b67c795a4f18 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/__init__.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +15,8 @@ # from .services.os_config_service import OsConfigServiceClient +from .services.os_config_service import OsConfigServiceAsyncClient + from .types.inventory import Inventory from .types.osconfig_common import FixedOrPercent from .types.patch_deployments import CreatePatchDeploymentRequest @@ -51,8 +52,8 @@ from .types.patch_jobs import YumSettings from .types.patch_jobs import ZypperSettings - __all__ = ( + "OsConfigServiceAsyncClient", "AptSettings", "CancelPatchJobRequest", "CreatePatchDeploymentRequest", @@ -75,6 +76,7 @@ "ListPatchJobsResponse", "MonthlySchedule", "OneTimeSchedule", + "OsConfigServiceClient", "PatchConfig", "PatchDeployment", "PatchInstanceFilter", @@ -87,5 +89,4 @@ "WindowsUpdateSettings", "YumSettings", "ZypperSettings", - "OsConfigServiceClient", ) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/gapic_metadata.json b/packages/google-cloud-os-config/google/cloud/osconfig_v1/gapic_metadata.json new file mode 100644 index 000000000000..8f824ed89cbc --- /dev/null +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/gapic_metadata.json @@ -0,0 +1,113 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.osconfig_v1", + "protoPackage": "google.cloud.osconfig.v1", + "schema": "1.0", + "services": { + "OsConfigService": { + "clients": { + "grpc": { + "libraryClient": "OsConfigServiceClient", + "rpcs": { + "CancelPatchJob": { + "methods": [ + "cancel_patch_job" + ] + }, + "CreatePatchDeployment": { + "methods": [ + "create_patch_deployment" + ] + }, + "DeletePatchDeployment": { + "methods": [ + "delete_patch_deployment" + ] + }, + "ExecutePatchJob": { + "methods": [ + "execute_patch_job" + ] + }, + "GetPatchDeployment": { + "methods": [ + "get_patch_deployment" + ] + }, + "GetPatchJob": { + "methods": [ + "get_patch_job" + ] + }, + "ListPatchDeployments": { + "methods": [ + "list_patch_deployments" + ] + }, + "ListPatchJobInstanceDetails": { + "methods": [ + "list_patch_job_instance_details" + ] + }, + "ListPatchJobs": { + "methods": [ + "list_patch_jobs" + ] + } + } + }, + "grpc-async": { + "libraryClient": "OsConfigServiceAsyncClient", + "rpcs": { + "CancelPatchJob": { + "methods": [ + "cancel_patch_job" + ] + }, + "CreatePatchDeployment": { + "methods": [ + "create_patch_deployment" + ] + }, + "DeletePatchDeployment": { + "methods": [ + "delete_patch_deployment" + ] + }, + "ExecutePatchJob": { + "methods": [ + "execute_patch_job" + ] + }, + "GetPatchDeployment": { + "methods": [ + "get_patch_deployment" + ] + }, + "GetPatchJob": { + "methods": [ + "get_patch_job" + ] + }, + "ListPatchDeployments": { + "methods": [ + "list_patch_deployments" + ] + }, + "ListPatchJobInstanceDetails": { + "methods": [ + "list_patch_job_instance_details" + ] + }, + "ListPatchJobs": { + "methods": [ + "list_patch_jobs" + ] + } + } + } + } + } + } +} diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/__init__.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/__init__.py index 42ffdf2bc43d..4de65971c238 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/__init__.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/__init__.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/__init__.py index 0d1727b0c9cc..3610b9bc5af8 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/__init__.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import OsConfigServiceClient from .async_client import OsConfigServiceAsyncClient diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/async_client.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/async_client.py index c38b7068eef4..91c5bad2c439 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/async_client.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,18 +20,17 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.osconfig_v1.services.os_config_service import pagers from google.cloud.osconfig_v1.types import patch_deployments from google.cloud.osconfig_v1.types import patch_jobs -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import OsConfigServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import OsConfigServiceGrpcAsyncIOTransport from .client import OsConfigServiceClient @@ -59,31 +56,26 @@ class OsConfigServiceAsyncClient: ) patch_job_path = staticmethod(OsConfigServiceClient.patch_job_path) parse_patch_job_path = staticmethod(OsConfigServiceClient.parse_patch_job_path) - common_billing_account_path = staticmethod( OsConfigServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( OsConfigServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(OsConfigServiceClient.common_folder_path) parse_common_folder_path = staticmethod( OsConfigServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( OsConfigServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( OsConfigServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(OsConfigServiceClient.common_project_path) parse_common_project_path = staticmethod( OsConfigServiceClient.parse_common_project_path ) - common_location_path = staticmethod(OsConfigServiceClient.common_location_path) parse_common_location_path = staticmethod( OsConfigServiceClient.parse_common_location_path @@ -91,7 +83,8 @@ class OsConfigServiceAsyncClient: @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -106,7 +99,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -123,7 +116,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> OsConfigServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: OsConfigServiceTransport: The transport used by the client instance. @@ -137,12 +130,12 @@ def transport(self) -> OsConfigServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, OsConfigServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the os config service client. + """Instantiates the os config service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -174,7 +167,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = OsConfigServiceClient( credentials=credentials, transport=transport, @@ -197,7 +189,6 @@ async def execute_patch_job( request (:class:`google.cloud.osconfig_v1.types.ExecutePatchJobRequest`): The request object. A request message to initiate patching across Compute Engine instances. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -219,7 +210,6 @@ async def execute_patch_job( """ # Create or coerce a protobuf request object. - request = patch_jobs.ExecutePatchJobRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -266,7 +256,6 @@ async def get_patch_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -301,7 +290,6 @@ async def get_patch_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -339,7 +327,6 @@ async def cancel_patch_job( Args: request (:class:`google.cloud.osconfig_v1.types.CancelPatchJobRequest`): The request object. Message for canceling a patch job. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -361,7 +348,6 @@ async def cancel_patch_job( """ # Create or coerce a protobuf request object. - request = patch_jobs.CancelPatchJobRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -404,7 +390,6 @@ async def list_patch_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -434,7 +419,6 @@ async def list_patch_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -486,7 +470,6 @@ async def list_patch_job_instance_details( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -516,7 +499,6 @@ async def list_patch_job_instance_details( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -592,7 +574,6 @@ async def create_patch_deployment( This corresponds to the ``patch_deployment_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -623,7 +604,6 @@ async def create_patch_deployment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if patch_deployment is not None: @@ -673,7 +653,6 @@ async def get_patch_deployment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -704,7 +683,6 @@ async def get_patch_deployment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -750,7 +728,6 @@ async def list_patch_deployments( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -780,7 +757,6 @@ async def list_patch_deployments( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -832,7 +808,6 @@ async def delete_patch_deployment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -853,7 +828,6 @@ async def delete_patch_deployment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/client.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/client.py index 8e6ea722695e..a24e6914d7f8 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/client.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -35,9 +33,8 @@ from google.cloud.osconfig_v1.services.os_config_service import pagers from google.cloud.osconfig_v1.types import patch_deployments from google.cloud.osconfig_v1.types import patch_jobs -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import OsConfigServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import OsConfigServiceGrpcTransport from .transports.grpc_asyncio import OsConfigServiceGrpcAsyncIOTransport @@ -58,7 +55,7 @@ class OsConfigServiceClientMeta(type): _transport_registry["grpc_asyncio"] = OsConfigServiceGrpcAsyncIOTransport def get_transport_class(cls, label: str = None,) -> Type[OsConfigServiceTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -85,7 +82,8 @@ class OsConfigServiceClient(metaclass=OsConfigServiceClientMeta): @staticmethod def _get_default_mtls_endpoint(api_endpoint): - """Convert api endpoint to mTLS endpoint. + """Converts api endpoint to mTLS endpoint. + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. Args: @@ -119,7 +117,8 @@ def _get_default_mtls_endpoint(api_endpoint): @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -136,7 +135,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -155,23 +154,24 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> OsConfigServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - OsConfigServiceTransport: The transport used by the client instance. + OsConfigServiceTransport: The transport used by the client + instance. """ return self._transport @staticmethod def instance_path(project: str, zone: str, instance: str,) -> str: - """Return a fully-qualified instance string.""" + """Returns a fully-qualified instance string.""" return "projects/{project}/zones/{zone}/instances/{instance}".format( project=project, zone=zone, instance=instance, ) @staticmethod def parse_instance_path(path: str) -> Dict[str, str]: - """Parse a instance path into its component segments.""" + """Parses a instance path into its component segments.""" m = re.match( r"^projects/(?P.+?)/zones/(?P.+?)/instances/(?P.+?)$", path, @@ -180,14 +180,14 @@ def parse_instance_path(path: str) -> Dict[str, str]: @staticmethod def patch_deployment_path(project: str, patch_deployment: str,) -> str: - """Return a fully-qualified patch_deployment string.""" + """Returns a fully-qualified patch_deployment string.""" return "projects/{project}/patchDeployments/{patch_deployment}".format( project=project, patch_deployment=patch_deployment, ) @staticmethod def parse_patch_deployment_path(path: str) -> Dict[str, str]: - """Parse a patch_deployment path into its component segments.""" + """Parses a patch_deployment path into its component segments.""" m = re.match( r"^projects/(?P.+?)/patchDeployments/(?P.+?)$", path, @@ -196,20 +196,20 @@ def parse_patch_deployment_path(path: str) -> Dict[str, str]: @staticmethod def patch_job_path(project: str, patch_job: str,) -> str: - """Return a fully-qualified patch_job string.""" + """Returns a fully-qualified patch_job string.""" return "projects/{project}/patchJobs/{patch_job}".format( project=project, patch_job=patch_job, ) @staticmethod def parse_patch_job_path(path: str) -> Dict[str, str]: - """Parse a patch_job path into its component segments.""" + """Parses a patch_job path into its component segments.""" m = re.match(r"^projects/(?P.+?)/patchJobs/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod def common_billing_account_path(billing_account: str,) -> str: - """Return a fully-qualified billing_account string.""" + """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -222,7 +222,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: @staticmethod def common_folder_path(folder: str,) -> str: - """Return a fully-qualified folder string.""" + """Returns a fully-qualified folder string.""" return "folders/{folder}".format(folder=folder,) @staticmethod @@ -233,7 +233,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: @staticmethod def common_organization_path(organization: str,) -> str: - """Return a fully-qualified organization string.""" + """Returns a fully-qualified organization string.""" return "organizations/{organization}".format(organization=organization,) @staticmethod @@ -244,7 +244,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: @staticmethod def common_project_path(project: str,) -> str: - """Return a fully-qualified project string.""" + """Returns a fully-qualified project string.""" return "projects/{project}".format(project=project,) @staticmethod @@ -255,7 +255,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]: @staticmethod def common_location_path(project: str, location: str,) -> str: - """Return a fully-qualified location string.""" + """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -269,12 +269,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, OsConfigServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the os config service client. + """Instantiates the os config service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -329,9 +329,10 @@ def __init__( client_cert_source_func = client_options.client_cert_source else: is_mtls = mtls.has_default_client_cert_source() - client_cert_source_func = ( - mtls.default_client_cert_source() if is_mtls else None - ) + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -343,12 +344,14 @@ def __init__( elif use_mtls_env == "always": api_endpoint = self.DEFAULT_MTLS_ENDPOINT elif use_mtls_env == "auto": - api_endpoint = ( - self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT - ) + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT else: raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always" + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" ) # Save or instantiate the transport. @@ -363,8 +366,8 @@ def __init__( ) if client_options.scopes: raise ValueError( - "When providing a transport instance, " - "provide its scopes directly." + "When providing a transport instance, provide its scopes " + "directly." ) self._transport = transport else: @@ -394,7 +397,6 @@ def execute_patch_job( request (google.cloud.osconfig_v1.types.ExecutePatchJobRequest): The request object. A request message to initiate patching across Compute Engine instances. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -416,7 +418,6 @@ def execute_patch_job( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a patch_jobs.ExecutePatchJobRequest. # There's no risk of modifying the input as we've already verified @@ -464,7 +465,6 @@ def get_patch_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -501,10 +501,8 @@ def get_patch_job( # there are no flattened fields. if not isinstance(request, patch_jobs.GetPatchJobRequest): request = patch_jobs.GetPatchJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -538,7 +536,6 @@ def cancel_patch_job( Args: request (google.cloud.osconfig_v1.types.CancelPatchJobRequest): The request object. Message for canceling a patch job. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -560,7 +557,6 @@ def cancel_patch_job( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a patch_jobs.CancelPatchJobRequest. # There's no risk of modifying the input as we've already verified @@ -604,7 +600,6 @@ def list_patch_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -636,10 +631,8 @@ def list_patch_jobs( # there are no flattened fields. if not isinstance(request, patch_jobs.ListPatchJobsRequest): request = patch_jobs.ListPatchJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -687,7 +680,6 @@ def list_patch_job_instance_details( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -719,10 +711,8 @@ def list_patch_job_instance_details( # there are no flattened fields. if not isinstance(request, patch_jobs.ListPatchJobInstanceDetailsRequest): request = patch_jobs.ListPatchJobInstanceDetailsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -796,7 +786,6 @@ def create_patch_deployment( This corresponds to the ``patch_deployment_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -829,10 +818,8 @@ def create_patch_deployment( # there are no flattened fields. if not isinstance(request, patch_deployments.CreatePatchDeploymentRequest): request = patch_deployments.CreatePatchDeploymentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if patch_deployment is not None: @@ -878,7 +865,6 @@ def get_patch_deployment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -911,10 +897,8 @@ def get_patch_deployment( # there are no flattened fields. if not isinstance(request, patch_deployments.GetPatchDeploymentRequest): request = patch_deployments.GetPatchDeploymentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -956,7 +940,6 @@ def list_patch_deployments( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -988,10 +971,8 @@ def list_patch_deployments( # there are no flattened fields. if not isinstance(request, patch_deployments.ListPatchDeploymentsRequest): request = patch_deployments.ListPatchDeploymentsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1039,7 +1020,6 @@ def delete_patch_deployment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1062,10 +1042,8 @@ def delete_patch_deployment( # there are no flattened fields. if not isinstance(request, patch_deployments.DeletePatchDeploymentRequest): request = patch_deployments.DeletePatchDeploymentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/pagers.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/pagers.py index 9a577125c29f..643682e73afb 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/pagers.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, @@ -118,7 +116,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -248,7 +246,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -380,7 +378,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/__init__.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/__init__.py index c4974e12a438..81f5e75901d2 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/__init__.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/base.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/base.py index 165135e9c5ff..eb879d811658 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/base.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,21 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.osconfig_v1.types import patch_deployments from google.cloud.osconfig_v1.types import patch_jobs -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -37,27 +36,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class OsConfigServiceTransport(abc.ABC): """Abstract transport class for OsConfigService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "osconfig.googleapis.com" + def __init__( self, *, - host: str = "osconfig.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -66,7 +79,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -80,29 +93,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -148,38 +208,38 @@ def _prep_wrapped_messages(self, client_info): @property def execute_patch_job( self, - ) -> typing.Callable[ + ) -> Callable[ [patch_jobs.ExecutePatchJobRequest], - typing.Union[patch_jobs.PatchJob, typing.Awaitable[patch_jobs.PatchJob]], + Union[patch_jobs.PatchJob, Awaitable[patch_jobs.PatchJob]], ]: raise NotImplementedError() @property def get_patch_job( self, - ) -> typing.Callable[ + ) -> Callable[ [patch_jobs.GetPatchJobRequest], - typing.Union[patch_jobs.PatchJob, typing.Awaitable[patch_jobs.PatchJob]], + Union[patch_jobs.PatchJob, Awaitable[patch_jobs.PatchJob]], ]: raise NotImplementedError() @property def cancel_patch_job( self, - ) -> typing.Callable[ + ) -> Callable[ [patch_jobs.CancelPatchJobRequest], - typing.Union[patch_jobs.PatchJob, typing.Awaitable[patch_jobs.PatchJob]], + Union[patch_jobs.PatchJob, Awaitable[patch_jobs.PatchJob]], ]: raise NotImplementedError() @property def list_patch_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [patch_jobs.ListPatchJobsRequest], - typing.Union[ + Union[ patch_jobs.ListPatchJobsResponse, - typing.Awaitable[patch_jobs.ListPatchJobsResponse], + Awaitable[patch_jobs.ListPatchJobsResponse], ], ]: raise NotImplementedError() @@ -187,11 +247,11 @@ def list_patch_jobs( @property def list_patch_job_instance_details( self, - ) -> typing.Callable[ + ) -> Callable[ [patch_jobs.ListPatchJobInstanceDetailsRequest], - typing.Union[ + Union[ patch_jobs.ListPatchJobInstanceDetailsResponse, - typing.Awaitable[patch_jobs.ListPatchJobInstanceDetailsResponse], + Awaitable[patch_jobs.ListPatchJobInstanceDetailsResponse], ], ]: raise NotImplementedError() @@ -199,11 +259,11 @@ def list_patch_job_instance_details( @property def create_patch_deployment( self, - ) -> typing.Callable[ + ) -> Callable[ [patch_deployments.CreatePatchDeploymentRequest], - typing.Union[ + Union[ patch_deployments.PatchDeployment, - typing.Awaitable[patch_deployments.PatchDeployment], + Awaitable[patch_deployments.PatchDeployment], ], ]: raise NotImplementedError() @@ -211,11 +271,11 @@ def create_patch_deployment( @property def get_patch_deployment( self, - ) -> typing.Callable[ + ) -> Callable[ [patch_deployments.GetPatchDeploymentRequest], - typing.Union[ + Union[ patch_deployments.PatchDeployment, - typing.Awaitable[patch_deployments.PatchDeployment], + Awaitable[patch_deployments.PatchDeployment], ], ]: raise NotImplementedError() @@ -223,11 +283,11 @@ def get_patch_deployment( @property def list_patch_deployments( self, - ) -> typing.Callable[ + ) -> Callable[ [patch_deployments.ListPatchDeploymentsRequest], - typing.Union[ + Union[ patch_deployments.ListPatchDeploymentsResponse, - typing.Awaitable[patch_deployments.ListPatchDeploymentsResponse], + Awaitable[patch_deployments.ListPatchDeploymentsResponse], ], ]: raise NotImplementedError() @@ -235,9 +295,9 @@ def list_patch_deployments( @property def delete_patch_deployment( self, - ) -> typing.Callable[ + ) -> Callable[ [patch_deployments.DeletePatchDeploymentRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py index 1302a1592091..139eb8b6388c 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.osconfig_v1.types import patch_deployments from google.cloud.osconfig_v1.types import patch_jobs -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.protobuf import empty_pb2 # type: ignore from .base import OsConfigServiceTransport, DEFAULT_CLIENT_INFO @@ -55,7 +52,7 @@ def __init__( self, *, host: str = "osconfig.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -69,7 +66,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -179,7 +177,7 @@ def __init__( def create_channel( cls, host: str = "osconfig.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -210,13 +208,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -455,7 +455,7 @@ def list_patch_deployments( @property def delete_patch_deployment( self, - ) -> Callable[[patch_deployments.DeletePatchDeploymentRequest], empty.Empty]: + ) -> Callable[[patch_deployments.DeletePatchDeploymentRequest], empty_pb2.Empty]: r"""Return a callable for the delete patch deployment method over gRPC. Delete an OS Config patch deployment. @@ -474,7 +474,7 @@ def delete_patch_deployment( self._stubs["delete_patch_deployment"] = self.grpc_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/DeletePatchDeployment", request_serializer=patch_deployments.DeletePatchDeploymentRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_patch_deployment"] diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py index f579fb1f5986..6c1e0f4e891a 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.osconfig_v1.types import patch_deployments from google.cloud.osconfig_v1.types import patch_jobs -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.protobuf import empty_pb2 # type: ignore from .base import OsConfigServiceTransport, DEFAULT_CLIENT_INFO from .grpc import OsConfigServiceGrpcTransport @@ -58,7 +55,7 @@ class OsConfigServiceGrpcAsyncIOTransport(OsConfigServiceTransport): def create_channel( cls, host: str = "osconfig.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -85,13 +82,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -99,7 +98,7 @@ def __init__( self, *, host: str = "osconfig.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -113,7 +112,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -171,7 +171,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -463,7 +462,7 @@ def list_patch_deployments( def delete_patch_deployment( self, ) -> Callable[ - [patch_deployments.DeletePatchDeploymentRequest], Awaitable[empty.Empty] + [patch_deployments.DeletePatchDeploymentRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the delete patch deployment method over gRPC. @@ -483,7 +482,7 @@ def delete_patch_deployment( self._stubs["delete_patch_deployment"] = self.grpc_channel.unary_unary( "/google.cloud.osconfig.v1.OsConfigService/DeletePatchDeployment", request_serializer=patch_deployments.DeletePatchDeploymentRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_patch_deployment"] diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/__init__.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/__init__.py index 7020841251e9..34ff16d5ddfa 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/__init__.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .inventory import Inventory from .osconfig_common import FixedOrPercent from .patch_deployments import ( diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/inventory.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/inventory.py index 68d1a75d6eaa..d78bb461f12c 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/inventory.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/inventory.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -28,7 +25,6 @@ class Inventory(proto.Message): r"""The inventory details of a VM. - Attributes: os_info (google.cloud.osconfig_v1.types.Inventory.OsInfo): Base level operating system information for @@ -43,7 +39,6 @@ class Inventory(proto.Message): class OsInfo(proto.Message): r"""Operating system information for the VM. - Attributes: hostname (str): The VM hostname. @@ -68,25 +63,17 @@ class OsInfo(proto.Message): running on the VM. """ - hostname = proto.Field(proto.STRING, number=9) - - long_name = proto.Field(proto.STRING, number=2) - - short_name = proto.Field(proto.STRING, number=3) - - version = proto.Field(proto.STRING, number=4) - - architecture = proto.Field(proto.STRING, number=5) - - kernel_version = proto.Field(proto.STRING, number=6) - - kernel_release = proto.Field(proto.STRING, number=7) - - osconfig_agent_version = proto.Field(proto.STRING, number=8) + hostname = proto.Field(proto.STRING, number=9,) + long_name = proto.Field(proto.STRING, number=2,) + short_name = proto.Field(proto.STRING, number=3,) + version = proto.Field(proto.STRING, number=4,) + architecture = proto.Field(proto.STRING, number=5,) + kernel_version = proto.Field(proto.STRING, number=6,) + kernel_release = proto.Field(proto.STRING, number=7,) + osconfig_agent_version = proto.Field(proto.STRING, number=8,) class Item(proto.Message): r"""A single piece of inventory on a VM. - Attributes: id (str): Identifier for this item, unique across items @@ -118,25 +105,23 @@ class Type(proto.Enum): INSTALLED_PACKAGE = 1 AVAILABLE_PACKAGE = 2 - id = proto.Field(proto.STRING, number=1) - + id = proto.Field(proto.STRING, number=1,) origin_type = proto.Field( proto.ENUM, number=2, enum="Inventory.Item.OriginType", ) - - create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp.Timestamp,) - + create_time = proto.Field( + proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp, + ) type_ = proto.Field(proto.ENUM, number=5, enum="Inventory.Item.Type",) - installed_package = proto.Field( proto.MESSAGE, number=6, oneof="details", message="Inventory.SoftwarePackage", ) - available_package = proto.Field( proto.MESSAGE, number=7, @@ -146,7 +131,6 @@ class Type(proto.Enum): class SoftwarePackage(proto.Message): r"""Software package information of the operating system. - Attributes: yum_package (google.cloud.osconfig_v1.types.Inventory.VersionedPackage): Yum package info. For details about the yum package manager, @@ -188,46 +172,39 @@ class SoftwarePackage(proto.Message): oneof="details", message="Inventory.VersionedPackage", ) - apt_package = proto.Field( proto.MESSAGE, number=2, oneof="details", message="Inventory.VersionedPackage", ) - zypper_package = proto.Field( proto.MESSAGE, number=3, oneof="details", message="Inventory.VersionedPackage", ) - googet_package = proto.Field( proto.MESSAGE, number=4, oneof="details", message="Inventory.VersionedPackage", ) - zypper_patch = proto.Field( proto.MESSAGE, number=5, oneof="details", message="Inventory.ZypperPatch", ) - wua_package = proto.Field( proto.MESSAGE, number=6, oneof="details", message="Inventory.WindowsUpdatePackage", ) - qfe_package = proto.Field( proto.MESSAGE, number=7, oneof="details", message="Inventory.WindowsQuickFixEngineeringPackage", ) - cos_package = proto.Field( proto.MESSAGE, number=8, @@ -250,11 +227,9 @@ class VersionedPackage(proto.Message): The version of the package. """ - package_name = proto.Field(proto.STRING, number=4) - - architecture = proto.Field(proto.STRING, number=2) - - version = proto.Field(proto.STRING, number=3) + package_name = proto.Field(proto.STRING, number=4,) + architecture = proto.Field(proto.STRING, number=2,) + version = proto.Field(proto.STRING, number=3,) class WindowsUpdatePackage(proto.Message): r"""Details related to a Windows Update package. Field data and names @@ -294,7 +269,6 @@ class WindowsUpdatePackage(proto.Message): class WindowsUpdateCategory(proto.Message): r"""Categories specified by the Windows Update. - Attributes: id (str): The identifier of the windows update @@ -303,37 +277,27 @@ class WindowsUpdateCategory(proto.Message): The name of the windows update category. """ - id = proto.Field(proto.STRING, number=1) - - name = proto.Field(proto.STRING, number=2) - - title = proto.Field(proto.STRING, number=1) - - description = proto.Field(proto.STRING, number=2) + id = proto.Field(proto.STRING, number=1,) + name = proto.Field(proto.STRING, number=2,) + title = proto.Field(proto.STRING, number=1,) + description = proto.Field(proto.STRING, number=2,) categories = proto.RepeatedField( proto.MESSAGE, number=3, message="Inventory.WindowsUpdatePackage.WindowsUpdateCategory", ) - - kb_article_ids = proto.RepeatedField(proto.STRING, number=4) - - support_url = proto.Field(proto.STRING, number=11) - - more_info_urls = proto.RepeatedField(proto.STRING, number=5) - - update_id = proto.Field(proto.STRING, number=6) - - revision_number = proto.Field(proto.INT32, number=7) - + kb_article_ids = proto.RepeatedField(proto.STRING, number=4,) + support_url = proto.Field(proto.STRING, number=11,) + more_info_urls = proto.RepeatedField(proto.STRING, number=5,) + update_id = proto.Field(proto.STRING, number=6,) + revision_number = proto.Field(proto.INT32, number=7,) last_deployment_change_time = proto.Field( - proto.MESSAGE, number=10, message=timestamp.Timestamp, + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, ) class ZypperPatch(proto.Message): r"""Details related to a Zypper Patch. - Attributes: patch_name (str): The name of the patch. @@ -346,13 +310,10 @@ class ZypperPatch(proto.Message): patch. """ - patch_name = proto.Field(proto.STRING, number=5) - - category = proto.Field(proto.STRING, number=2) - - severity = proto.Field(proto.STRING, number=3) - - summary = proto.Field(proto.STRING, number=4) + patch_name = proto.Field(proto.STRING, number=5,) + category = proto.Field(proto.STRING, number=2,) + severity = proto.Field(proto.STRING, number=3,) + summary = proto.Field(proto.STRING, number=4,) class WindowsQuickFixEngineeringPackage(proto.Message): r"""Information related to a Quick Fix Engineering package. @@ -375,18 +336,14 @@ class WindowsQuickFixEngineeringPackage(proto.Message): installed_on field. """ - caption = proto.Field(proto.STRING, number=1) - - description = proto.Field(proto.STRING, number=2) - - hot_fix_id = proto.Field(proto.STRING, number=3) - + caption = proto.Field(proto.STRING, number=1,) + description = proto.Field(proto.STRING, number=2,) + hot_fix_id = proto.Field(proto.STRING, number=3,) install_time = proto.Field( - proto.MESSAGE, number=5, message=timestamp.Timestamp, + proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp, ) os_info = proto.Field(proto.MESSAGE, number=1, message=OsInfo,) - items = proto.MapField(proto.STRING, proto.MESSAGE, number=2, message=Item,) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/osconfig_common.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/osconfig_common.py index d96012632070..2bf62d6963bd 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/osconfig_common.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/osconfig_common.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -36,9 +34,8 @@ class FixedOrPercent(proto.Message): reference value. """ - fixed = proto.Field(proto.INT32, number=1, oneof="mode") - - percent = proto.Field(proto.INT32, number=2, oneof="mode") + fixed = proto.Field(proto.INT32, number=1, oneof="mode",) + percent = proto.Field(proto.INT32, number=2, oneof="mode",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/osconfig_service.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/osconfig_service.py index af4e143c505f..5a02c6a217ab 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/osconfig_service.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/osconfig_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/patch_deployments.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/patch_deployments.py index 4c36884e5929..d24680477355 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/patch_deployments.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/patch_deployments.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.osconfig_v1.types import patch_jobs -from google.protobuf import duration_pb2 as gp_duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.type import datetime_pb2 as datetime # type: ignore -from google.type import dayofweek_pb2 as dayofweek # type: ignore -from google.type import timeofday_pb2 as timeofday # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import datetime_pb2 # type: ignore +from google.type import dayofweek_pb2 # type: ignore +from google.type import timeofday_pb2 # type: ignore __protobuf__ = proto.module( @@ -93,34 +90,24 @@ class PatchDeployment(proto.Message): Optional. Rollout strategy of the patch job. """ - name = proto.Field(proto.STRING, number=1) - - description = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + description = proto.Field(proto.STRING, number=2,) instance_filter = proto.Field( proto.MESSAGE, number=3, message=patch_jobs.PatchInstanceFilter, ) - patch_config = proto.Field(proto.MESSAGE, number=4, message=patch_jobs.PatchConfig,) - - duration = proto.Field(proto.MESSAGE, number=5, message=gp_duration.Duration,) - + duration = proto.Field(proto.MESSAGE, number=5, message=duration_pb2.Duration,) one_time_schedule = proto.Field( proto.MESSAGE, number=6, oneof="schedule", message="OneTimeSchedule", ) - recurring_schedule = proto.Field( proto.MESSAGE, number=7, oneof="schedule", message="RecurringSchedule", ) - - create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp.Timestamp,) - + create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) last_execute_time = proto.Field( - proto.MESSAGE, number=10, message=timestamp.Timestamp, + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, ) - rollout = proto.Field(proto.MESSAGE, number=11, message=patch_jobs.PatchRollout,) @@ -134,12 +121,13 @@ class OneTimeSchedule(proto.Message): time. """ - execute_time = proto.Field(proto.MESSAGE, number=1, message=timestamp.Timestamp,) + execute_time = proto.Field( + proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + ) class RecurringSchedule(proto.Message): r"""Sets the time for recurring patch deployments. - Attributes: time_zone (google.type.datetime_pb2.TimeZone): Required. Defines the time zone that ``time_of_day`` is @@ -176,42 +164,33 @@ class Frequency(proto.Enum): WEEKLY = 1 MONTHLY = 2 - time_zone = proto.Field(proto.MESSAGE, number=1, message=datetime.TimeZone,) - - start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - time_of_day = proto.Field(proto.MESSAGE, number=4, message=timeofday.TimeOfDay,) - + time_zone = proto.Field(proto.MESSAGE, number=1, message=datetime_pb2.TimeZone,) + start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + time_of_day = proto.Field(proto.MESSAGE, number=4, message=timeofday_pb2.TimeOfDay,) frequency = proto.Field(proto.ENUM, number=5, enum=Frequency,) - weekly = proto.Field( proto.MESSAGE, number=6, oneof="schedule_config", message="WeeklySchedule", ) - monthly = proto.Field( proto.MESSAGE, number=7, oneof="schedule_config", message="MonthlySchedule", ) - last_execute_time = proto.Field( - proto.MESSAGE, number=9, message=timestamp.Timestamp, + proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp, ) - next_execute_time = proto.Field( - proto.MESSAGE, number=10, message=timestamp.Timestamp, + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, ) class WeeklySchedule(proto.Message): r"""Represents a weekly schedule. - Attributes: day_of_week (google.type.dayofweek_pb2.DayOfWeek): Required. Day of the week. """ - day_of_week = proto.Field(proto.ENUM, number=1, enum=dayofweek.DayOfWeek,) + day_of_week = proto.Field(proto.ENUM, number=1, enum=dayofweek_pb2.DayOfWeek,) class MonthlySchedule(proto.Message): @@ -234,8 +213,7 @@ class MonthlySchedule(proto.Message): week_day_of_month = proto.Field( proto.MESSAGE, number=1, oneof="day_of_month", message="WeekDayOfMonth", ) - - month_day = proto.Field(proto.INT32, number=2, oneof="day_of_month") + month_day = proto.Field(proto.INT32, number=2, oneof="day_of_month",) class WeekDayOfMonth(proto.Message): @@ -251,14 +229,12 @@ class WeekDayOfMonth(proto.Message): Required. A day of the week. """ - week_ordinal = proto.Field(proto.INT32, number=1) - - day_of_week = proto.Field(proto.ENUM, number=2, enum=dayofweek.DayOfWeek,) + week_ordinal = proto.Field(proto.INT32, number=1,) + day_of_week = proto.Field(proto.ENUM, number=2, enum=dayofweek_pb2.DayOfWeek,) class CreatePatchDeploymentRequest(proto.Message): r"""A request message for creating a patch deployment. - Attributes: parent (str): Required. The project to apply this patch deployment to in @@ -277,28 +253,24 @@ class CreatePatchDeploymentRequest(proto.Message): Required. The patch deployment to create. """ - parent = proto.Field(proto.STRING, number=1) - - patch_deployment_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + patch_deployment_id = proto.Field(proto.STRING, number=2,) patch_deployment = proto.Field(proto.MESSAGE, number=3, message="PatchDeployment",) class GetPatchDeploymentRequest(proto.Message): r"""A request message for retrieving a patch deployment. - Attributes: name (str): Required. The resource name of the patch deployment in the form ``projects/*/patchDeployments/*``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListPatchDeploymentsRequest(proto.Message): r"""A request message for listing patch deployments. - Attributes: parent (str): Required. The resource name of the parent in the form @@ -313,16 +285,13 @@ class ListPatchDeploymentsRequest(proto.Message): from. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListPatchDeploymentsResponse(proto.Message): r"""A response message for listing patch deployments. - Attributes: patch_deployments (Sequence[google.cloud.osconfig_v1.types.PatchDeployment]): The list of patch deployments. @@ -338,20 +307,18 @@ def raw_page(self): patch_deployments = proto.RepeatedField( proto.MESSAGE, number=1, message="PatchDeployment", ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeletePatchDeploymentRequest(proto.Message): r"""A request message for deleting a patch deployment. - Attributes: name (str): Required. The resource name of the patch deployment in the form ``projects/*/patchDeployments/*``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/patch_jobs.py b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/patch_jobs.py index 0b84a2490298..9f633765b89b 100644 --- a/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/patch_jobs.py +++ b/packages/google-cloud-os-config/google/cloud/osconfig_v1/types/patch_jobs.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.osconfig_v1.types import osconfig_common -from google.protobuf import duration_pb2 as gp_duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -83,35 +80,27 @@ class ExecutePatchJobRequest(proto.Message): Rollout strategy of the patch job. """ - parent = proto.Field(proto.STRING, number=1) - - description = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + description = proto.Field(proto.STRING, number=2,) instance_filter = proto.Field( proto.MESSAGE, number=7, message="PatchInstanceFilter", ) - patch_config = proto.Field(proto.MESSAGE, number=4, message="PatchConfig",) - - duration = proto.Field(proto.MESSAGE, number=5, message=gp_duration.Duration,) - - dry_run = proto.Field(proto.BOOL, number=6) - - display_name = proto.Field(proto.STRING, number=8) - + duration = proto.Field(proto.MESSAGE, number=5, message=duration_pb2.Duration,) + dry_run = proto.Field(proto.BOOL, number=6,) + display_name = proto.Field(proto.STRING, number=8,) rollout = proto.Field(proto.MESSAGE, number=9, message="PatchRollout",) class GetPatchJobRequest(proto.Message): r"""Request to get an active or completed patch job. - Attributes: name (str): Required. Name of the patch in the form ``projects/*/patchJobs/*`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListPatchJobInstanceDetailsRequest(proto.Message): @@ -135,13 +124,10 @@ class ListPatchJobInstanceDetailsRequest(proto.Message): zone, name, state, or ``failure_reason``. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) class ListPatchJobInstanceDetailsResponse(proto.Message): @@ -163,8 +149,7 @@ def raw_page(self): patch_job_instance_details = proto.RepeatedField( proto.MESSAGE, number=1, message="PatchJobInstanceDetails", ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class PatchJobInstanceDetails(proto.Message): @@ -190,20 +175,15 @@ class PatchJobInstanceDetails(proto.Message): attempts to apply the patch. """ - name = proto.Field(proto.STRING, number=1) - - instance_system_id = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + instance_system_id = proto.Field(proto.STRING, number=2,) state = proto.Field(proto.ENUM, number=3, enum="Instance.PatchState",) - - failure_reason = proto.Field(proto.STRING, number=4) - - attempt_count = proto.Field(proto.INT64, number=5) + failure_reason = proto.Field(proto.STRING, number=4,) + attempt_count = proto.Field(proto.INT64, number=5,) class ListPatchJobsRequest(proto.Message): r"""A request message for listing patch jobs. - Attributes: parent (str): Required. In the form of ``projects/*`` @@ -220,18 +200,14 @@ class ListPatchJobsRequest(proto.Message): filtering is only available on the patch_deployment field. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) class ListPatchJobsResponse(proto.Message): r"""A response message for listing patch jobs. - Attributes: patch_jobs (Sequence[google.cloud.osconfig_v1.types.PatchJob]): The list of patch jobs. @@ -245,8 +221,7 @@ def raw_page(self): return self patch_jobs = proto.RepeatedField(proto.MESSAGE, number=1, message="PatchJob",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class PatchJob(proto.Message): @@ -364,68 +339,40 @@ class InstanceDetailsSummary(proto.Message): communicate with the service. """ - pending_instance_count = proto.Field(proto.INT64, number=1) - - inactive_instance_count = proto.Field(proto.INT64, number=2) - - notified_instance_count = proto.Field(proto.INT64, number=3) - - started_instance_count = proto.Field(proto.INT64, number=4) - - downloading_patches_instance_count = proto.Field(proto.INT64, number=5) - - applying_patches_instance_count = proto.Field(proto.INT64, number=6) - - rebooting_instance_count = proto.Field(proto.INT64, number=7) - - succeeded_instance_count = proto.Field(proto.INT64, number=8) - - succeeded_reboot_required_instance_count = proto.Field(proto.INT64, number=9) - - failed_instance_count = proto.Field(proto.INT64, number=10) - - acked_instance_count = proto.Field(proto.INT64, number=11) - - timed_out_instance_count = proto.Field(proto.INT64, number=12) - - pre_patch_step_instance_count = proto.Field(proto.INT64, number=13) - - post_patch_step_instance_count = proto.Field(proto.INT64, number=14) - - no_agent_detected_instance_count = proto.Field(proto.INT64, number=15) - - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=14) - - description = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - + pending_instance_count = proto.Field(proto.INT64, number=1,) + inactive_instance_count = proto.Field(proto.INT64, number=2,) + notified_instance_count = proto.Field(proto.INT64, number=3,) + started_instance_count = proto.Field(proto.INT64, number=4,) + downloading_patches_instance_count = proto.Field(proto.INT64, number=5,) + applying_patches_instance_count = proto.Field(proto.INT64, number=6,) + rebooting_instance_count = proto.Field(proto.INT64, number=7,) + succeeded_instance_count = proto.Field(proto.INT64, number=8,) + succeeded_reboot_required_instance_count = proto.Field(proto.INT64, number=9,) + failed_instance_count = proto.Field(proto.INT64, number=10,) + acked_instance_count = proto.Field(proto.INT64, number=11,) + timed_out_instance_count = proto.Field(proto.INT64, number=12,) + pre_patch_step_instance_count = proto.Field(proto.INT64, number=13,) + post_patch_step_instance_count = proto.Field(proto.INT64, number=14,) + no_agent_detected_instance_count = proto.Field(proto.INT64, number=15,) + + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=14,) + description = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) state = proto.Field(proto.ENUM, number=5, enum=State,) - instance_filter = proto.Field( proto.MESSAGE, number=13, message="PatchInstanceFilter", ) - patch_config = proto.Field(proto.MESSAGE, number=7, message="PatchConfig",) - - duration = proto.Field(proto.MESSAGE, number=8, message=gp_duration.Duration,) - + duration = proto.Field(proto.MESSAGE, number=8, message=duration_pb2.Duration,) instance_details_summary = proto.Field( proto.MESSAGE, number=9, message=InstanceDetailsSummary, ) - - dry_run = proto.Field(proto.BOOL, number=10) - - error_message = proto.Field(proto.STRING, number=11) - - percent_complete = proto.Field(proto.DOUBLE, number=12) - - patch_deployment = proto.Field(proto.STRING, number=15) - + dry_run = proto.Field(proto.BOOL, number=10,) + error_message = proto.Field(proto.STRING, number=11,) + percent_complete = proto.Field(proto.DOUBLE, number=12,) + patch_deployment = proto.Field(proto.STRING, number=15,) rollout = proto.Field(proto.MESSAGE, number=16, message="PatchRollout",) @@ -465,26 +412,19 @@ class RebootConfig(proto.Enum): NEVER = 3 reboot_config = proto.Field(proto.ENUM, number=1, enum=RebootConfig,) - apt = proto.Field(proto.MESSAGE, number=3, message="AptSettings",) - yum = proto.Field(proto.MESSAGE, number=4, message="YumSettings",) - goo = proto.Field(proto.MESSAGE, number=5, message="GooSettings",) - zypper = proto.Field(proto.MESSAGE, number=6, message="ZypperSettings",) - windows_update = proto.Field( proto.MESSAGE, number=7, message="WindowsUpdateSettings", ) - pre_step = proto.Field(proto.MESSAGE, number=8, message="ExecStep",) - post_step = proto.Field(proto.MESSAGE, number=9, message="ExecStep",) class Instance(proto.Message): - r"""Namespace for instance state enums.""" + r"""Namespace for instance state enums. """ class PatchState(proto.Enum): r"""Patch state of an instance.""" @@ -508,14 +448,13 @@ class PatchState(proto.Enum): class CancelPatchJobRequest(proto.Message): r"""Message for canceling a patch job. - Attributes: name (str): Required. Name of the patch in the form ``projects/*/patchJobs/*`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class AptSettings(proto.Message): @@ -546,10 +485,8 @@ class Type(proto.Enum): UPGRADE = 2 type_ = proto.Field(proto.ENUM, number=1, enum=Type,) - - excludes = proto.RepeatedField(proto.STRING, number=2) - - exclusive_packages = proto.RepeatedField(proto.STRING, number=3) + excludes = proto.RepeatedField(proto.STRING, number=2,) + exclusive_packages = proto.RepeatedField(proto.STRING, number=3,) class YumSettings(proto.Message): @@ -576,17 +513,14 @@ class YumSettings(proto.Message): fields. """ - security = proto.Field(proto.BOOL, number=1) - - minimal = proto.Field(proto.BOOL, number=2) - - excludes = proto.RepeatedField(proto.STRING, number=3) - - exclusive_packages = proto.RepeatedField(proto.STRING, number=4) + security = proto.Field(proto.BOOL, number=1,) + minimal = proto.Field(proto.BOOL, number=2,) + excludes = proto.RepeatedField(proto.STRING, number=3,) + exclusive_packages = proto.RepeatedField(proto.STRING, number=4,) class GooSettings(proto.Message): - r"""Googet patching is performed by running ``googet update``.""" + r"""Googet patching is performed by running ``googet update``. """ class ZypperSettings(proto.Message): @@ -615,22 +549,16 @@ class ZypperSettings(proto.Message): with any other patch configuration fields. """ - with_optional = proto.Field(proto.BOOL, number=1) - - with_update = proto.Field(proto.BOOL, number=2) - - categories = proto.RepeatedField(proto.STRING, number=3) - - severities = proto.RepeatedField(proto.STRING, number=4) - - excludes = proto.RepeatedField(proto.STRING, number=5) - - exclusive_patches = proto.RepeatedField(proto.STRING, number=6) + with_optional = proto.Field(proto.BOOL, number=1,) + with_update = proto.Field(proto.BOOL, number=2,) + categories = proto.RepeatedField(proto.STRING, number=3,) + severities = proto.RepeatedField(proto.STRING, number=4,) + excludes = proto.RepeatedField(proto.STRING, number=5,) + exclusive_patches = proto.RepeatedField(proto.STRING, number=6,) class WindowsUpdateSettings(proto.Message): r"""Windows patching is performed using the Windows Update Agent. - Attributes: classifications (Sequence[google.cloud.osconfig_v1.types.WindowsUpdateSettings.Classification]): Only apply updates of these windows update @@ -661,15 +589,12 @@ class Classification(proto.Enum): UPDATE = 9 classifications = proto.RepeatedField(proto.ENUM, number=1, enum=Classification,) - - excludes = proto.RepeatedField(proto.STRING, number=2) - - exclusive_patches = proto.RepeatedField(proto.STRING, number=3) + excludes = proto.RepeatedField(proto.STRING, number=2,) + exclusive_patches = proto.RepeatedField(proto.STRING, number=3,) class ExecStep(proto.Message): r"""A step that runs an executable for a PatchJob. - Attributes: linux_exec_step_config (google.cloud.osconfig_v1.types.ExecStepConfig): The ExecStepConfig for all Linux VMs targeted @@ -682,7 +607,6 @@ class ExecStep(proto.Message): linux_exec_step_config = proto.Field( proto.MESSAGE, number=1, message="ExecStepConfig", ) - windows_exec_step_config = proto.Field( proto.MESSAGE, number=2, message="ExecStepConfig", ) @@ -690,7 +614,6 @@ class ExecStep(proto.Message): class ExecStepConfig(proto.Message): r"""Common configurations for an ExecStep. - Attributes: local_path (str): An absolute path to the executable on the VM. @@ -714,20 +637,16 @@ class Interpreter(proto.Enum): SHELL = 1 POWERSHELL = 2 - local_path = proto.Field(proto.STRING, number=1, oneof="executable") - + local_path = proto.Field(proto.STRING, number=1, oneof="executable",) gcs_object = proto.Field( proto.MESSAGE, number=2, oneof="executable", message="GcsObject", ) - - allowed_success_codes = proto.RepeatedField(proto.INT32, number=3) - + allowed_success_codes = proto.RepeatedField(proto.INT32, number=3,) interpreter = proto.Field(proto.ENUM, number=4, enum=Interpreter,) class GcsObject(proto.Message): r"""Cloud Storage object representation. - Attributes: bucket (str): Required. Bucket of the Cloud Storage object. @@ -740,11 +659,9 @@ class GcsObject(proto.Message): change. """ - bucket = proto.Field(proto.STRING, number=1) - - object_ = proto.Field(proto.STRING, number=2) - - generation_number = proto.Field(proto.INT64, number=3) + bucket = proto.Field(proto.STRING, number=1,) + object_ = proto.Field(proto.STRING, number=2,) + generation_number = proto.Field(proto.INT64, number=3,) class PatchInstanceFilter(proto.Message): @@ -796,17 +713,13 @@ class GroupLabel(proto.Message): filter. """ - labels = proto.MapField(proto.STRING, proto.STRING, number=1) - - all_ = proto.Field(proto.BOOL, number=1) + labels = proto.MapField(proto.STRING, proto.STRING, number=1,) + all_ = proto.Field(proto.BOOL, number=1,) group_labels = proto.RepeatedField(proto.MESSAGE, number=2, message=GroupLabel,) - - zones = proto.RepeatedField(proto.STRING, number=3) - - instances = proto.RepeatedField(proto.STRING, number=4) - - instance_name_prefixes = proto.RepeatedField(proto.STRING, number=5) + zones = proto.RepeatedField(proto.STRING, number=3,) + instances = proto.RepeatedField(proto.STRING, number=4,) + instance_name_prefixes = proto.RepeatedField(proto.STRING, number=5,) class PatchRollout(proto.Message): @@ -855,7 +768,6 @@ class Mode(proto.Enum): CONCURRENT_ZONES = 2 mode = proto.Field(proto.ENUM, number=1, enum=Mode,) - disruption_budget = proto.Field( proto.MESSAGE, number=2, message=osconfig_common.FixedOrPercent, ) diff --git a/packages/google-cloud-os-config/scripts/fixup_osconfig_v1_keywords.py b/packages/google-cloud-os-config/scripts/fixup_osconfig_v1_keywords.py index 9f7025cdf188..b5accfbe2244 100644 --- a/packages/google-cloud-os-config/scripts/fixup_osconfig_v1_keywords.py +++ b/packages/google-cloud-os-config/scripts/fixup_osconfig_v1_keywords.py @@ -1,6 +1,5 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import argparse import os import libcst as cst @@ -41,16 +39,15 @@ def partition( class osconfigCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'cancel_patch_job': ('name', ), - 'create_patch_deployment': ('parent', 'patch_deployment_id', 'patch_deployment', ), - 'delete_patch_deployment': ('name', ), - 'execute_patch_job': ('parent', 'instance_filter', 'description', 'patch_config', 'duration', 'dry_run', 'display_name', 'rollout', ), - 'get_patch_deployment': ('name', ), - 'get_patch_job': ('name', ), - 'list_patch_deployments': ('parent', 'page_size', 'page_token', ), - 'list_patch_job_instance_details': ('parent', 'page_size', 'page_token', 'filter', ), - 'list_patch_jobs': ('parent', 'page_size', 'page_token', 'filter', ), - + 'cancel_patch_job': ('name', ), + 'create_patch_deployment': ('parent', 'patch_deployment_id', 'patch_deployment', ), + 'delete_patch_deployment': ('name', ), + 'execute_patch_job': ('parent', 'instance_filter', 'description', 'patch_config', 'duration', 'dry_run', 'display_name', 'rollout', ), + 'get_patch_deployment': ('name', ), + 'get_patch_job': ('name', ), + 'list_patch_deployments': ('parent', 'page_size', 'page_token', ), + 'list_patch_job_instance_details': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_patch_jobs': ('parent', 'page_size', 'page_token', 'filter', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -81,7 +78,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), - cst.Element(value=arg.value) +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 diff --git a/packages/google-cloud-os-config/tests/__init__.py b/packages/google-cloud-os-config/tests/__init__.py new file mode 100644 index 000000000000..4de65971c238 --- /dev/null +++ b/packages/google-cloud-os-config/tests/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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/packages/google-cloud-os-config/tests/unit/__init__.py b/packages/google-cloud-os-config/tests/unit/__init__.py new file mode 100644 index 000000000000..4de65971c238 --- /dev/null +++ b/packages/google-cloud-os-config/tests/unit/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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/packages/google-cloud-os-config/tests/unit/gapic/__init__.py b/packages/google-cloud-os-config/tests/unit/gapic/__init__.py new file mode 100644 index 000000000000..4de65971c238 --- /dev/null +++ b/packages/google-cloud-os-config/tests/unit/gapic/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/__init__.py b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/__init__.py index 42ffdf2bc43d..4de65971c238 100644 --- a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/__init__.py +++ b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py index 9bac4685718c..d66b1105797f 100644 --- a/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py +++ b/packages/google-cloud-os-config/tests/unit/gapic/osconfig_v1/test_os_config_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,13 +23,13 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.osconfig_v1.services.os_config_service import ( OsConfigServiceAsyncClient, @@ -38,15 +37,45 @@ from google.cloud.osconfig_v1.services.os_config_service import OsConfigServiceClient from google.cloud.osconfig_v1.services.os_config_service import pagers from google.cloud.osconfig_v1.services.os_config_service import transports +from google.cloud.osconfig_v1.services.os_config_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.osconfig_v1.services.os_config_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.osconfig_v1.types import osconfig_common from google.cloud.osconfig_v1.types import patch_deployments from google.cloud.osconfig_v1.types import patch_jobs from google.oauth2 import service_account -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.type import datetime_pb2 as datetime # type: ignore -from google.type import dayofweek_pb2 as dayofweek # type: ignore -from google.type import timeofday_pb2 as timeofday # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import datetime_pb2 # type: ignore +from google.type import dayofweek_pb2 # type: ignore +from google.type import timeofday_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -97,7 +126,7 @@ def test__get_default_mtls_endpoint(): "client_class", [OsConfigServiceClient, OsConfigServiceAsyncClient,] ) def test_os_config_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -114,7 +143,7 @@ def test_os_config_service_client_from_service_account_info(client_class): "client_class", [OsConfigServiceClient, OsConfigServiceAsyncClient,] ) def test_os_config_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -167,7 +196,7 @@ def test_os_config_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(OsConfigServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -465,7 +494,7 @@ def test_execute_patch_job( transport: str = "grpc", request_type=patch_jobs.ExecutePatchJobRequest ): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -487,33 +516,22 @@ def test_execute_patch_job( percent_complete=0.1705, patch_deployment="patch_deployment_value", ) - response = client.execute_patch_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.ExecutePatchJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, patch_jobs.PatchJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.state == patch_jobs.PatchJob.State.STARTED - assert response.dry_run is True - assert response.error_message == "error_message_value" - assert math.isclose(response.percent_complete, 0.1705, rel_tol=1e-6) - assert response.patch_deployment == "patch_deployment_value" @@ -525,7 +543,7 @@ def test_execute_patch_job_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 = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -535,7 +553,6 @@ def test_execute_patch_job_empty_call(): client.execute_patch_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.ExecutePatchJobRequest() @@ -544,7 +561,7 @@ async def test_execute_patch_job_async( transport: str = "grpc_asyncio", request_type=patch_jobs.ExecutePatchJobRequest ): client = OsConfigServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -568,32 +585,22 @@ async def test_execute_patch_job_async( patch_deployment="patch_deployment_value", ) ) - response = await client.execute_patch_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.ExecutePatchJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, patch_jobs.PatchJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.state == patch_jobs.PatchJob.State.STARTED - assert response.dry_run is True - assert response.error_message == "error_message_value" - assert math.isclose(response.percent_complete, 0.1705, rel_tol=1e-6) - assert response.patch_deployment == "patch_deployment_value" @@ -603,11 +610,12 @@ async def test_execute_patch_job_async_from_dict(): def test_execute_patch_job_field_headers(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(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 = patch_jobs.ExecutePatchJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -615,7 +623,6 @@ def test_execute_patch_job_field_headers(): type(client.transport.execute_patch_job), "__call__" ) as call: call.return_value = patch_jobs.PatchJob() - client.execute_patch_job(request) # Establish that the underlying gRPC stub method was called. @@ -630,11 +637,14 @@ def test_execute_patch_job_field_headers(): @pytest.mark.asyncio async def test_execute_patch_job_field_headers_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + 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 = patch_jobs.ExecutePatchJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -642,7 +652,6 @@ async def test_execute_patch_job_field_headers_async(): type(client.transport.execute_patch_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(patch_jobs.PatchJob()) - await client.execute_patch_job(request) # Establish that the underlying gRPC stub method was called. @@ -659,7 +668,7 @@ def test_get_patch_job( transport: str = "grpc", request_type=patch_jobs.GetPatchJobRequest ): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -679,33 +688,22 @@ def test_get_patch_job( percent_complete=0.1705, patch_deployment="patch_deployment_value", ) - response = client.get_patch_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.GetPatchJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, patch_jobs.PatchJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.state == patch_jobs.PatchJob.State.STARTED - assert response.dry_run is True - assert response.error_message == "error_message_value" - assert math.isclose(response.percent_complete, 0.1705, rel_tol=1e-6) - assert response.patch_deployment == "patch_deployment_value" @@ -717,7 +715,7 @@ def test_get_patch_job_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 = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -725,7 +723,6 @@ def test_get_patch_job_empty_call(): client.get_patch_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.GetPatchJobRequest() @@ -734,7 +731,7 @@ async def test_get_patch_job_async( transport: str = "grpc_asyncio", request_type=patch_jobs.GetPatchJobRequest ): client = OsConfigServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -756,32 +753,22 @@ async def test_get_patch_job_async( patch_deployment="patch_deployment_value", ) ) - response = await client.get_patch_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.GetPatchJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, patch_jobs.PatchJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.state == patch_jobs.PatchJob.State.STARTED - assert response.dry_run is True - assert response.error_message == "error_message_value" - assert math.isclose(response.percent_complete, 0.1705, rel_tol=1e-6) - assert response.patch_deployment == "patch_deployment_value" @@ -791,17 +778,17 @@ async def test_get_patch_job_async_from_dict(): def test_get_patch_job_field_headers(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(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 = patch_jobs.GetPatchJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_patch_job), "__call__") as call: call.return_value = patch_jobs.PatchJob() - client.get_patch_job(request) # Establish that the underlying gRPC stub method was called. @@ -816,17 +803,19 @@ def test_get_patch_job_field_headers(): @pytest.mark.asyncio async def test_get_patch_job_field_headers_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + 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 = patch_jobs.GetPatchJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_patch_job), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(patch_jobs.PatchJob()) - await client.get_patch_job(request) # Establish that the underlying gRPC stub method was called. @@ -840,13 +829,12 @@ async def test_get_patch_job_field_headers_async(): def test_get_patch_job_flattened(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_patch_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = patch_jobs.PatchJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_patch_job(name="name_value",) @@ -855,12 +843,11 @@ def test_get_patch_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_patch_job_flattened_error(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -872,7 +859,9 @@ def test_get_patch_job_flattened_error(): @pytest.mark.asyncio async def test_get_patch_job_flattened_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_patch_job), "__call__") as call: @@ -888,13 +877,14 @@ async def test_get_patch_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_patch_job_flattened_error_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -908,7 +898,7 @@ def test_cancel_patch_job( transport: str = "grpc", request_type=patch_jobs.CancelPatchJobRequest ): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -928,33 +918,22 @@ def test_cancel_patch_job( percent_complete=0.1705, patch_deployment="patch_deployment_value", ) - response = client.cancel_patch_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.CancelPatchJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, patch_jobs.PatchJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.state == patch_jobs.PatchJob.State.STARTED - assert response.dry_run is True - assert response.error_message == "error_message_value" - assert math.isclose(response.percent_complete, 0.1705, rel_tol=1e-6) - assert response.patch_deployment == "patch_deployment_value" @@ -966,7 +945,7 @@ def test_cancel_patch_job_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 = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -974,7 +953,6 @@ def test_cancel_patch_job_empty_call(): client.cancel_patch_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.CancelPatchJobRequest() @@ -983,7 +961,7 @@ async def test_cancel_patch_job_async( transport: str = "grpc_asyncio", request_type=patch_jobs.CancelPatchJobRequest ): client = OsConfigServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1005,32 +983,22 @@ async def test_cancel_patch_job_async( patch_deployment="patch_deployment_value", ) ) - response = await client.cancel_patch_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.CancelPatchJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, patch_jobs.PatchJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.state == patch_jobs.PatchJob.State.STARTED - assert response.dry_run is True - assert response.error_message == "error_message_value" - assert math.isclose(response.percent_complete, 0.1705, rel_tol=1e-6) - assert response.patch_deployment == "patch_deployment_value" @@ -1040,17 +1008,17 @@ async def test_cancel_patch_job_async_from_dict(): def test_cancel_patch_job_field_headers(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(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 = patch_jobs.CancelPatchJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.cancel_patch_job), "__call__") as call: call.return_value = patch_jobs.PatchJob() - client.cancel_patch_job(request) # Establish that the underlying gRPC stub method was called. @@ -1065,17 +1033,19 @@ def test_cancel_patch_job_field_headers(): @pytest.mark.asyncio async def test_cancel_patch_job_field_headers_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + 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 = patch_jobs.CancelPatchJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.cancel_patch_job), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(patch_jobs.PatchJob()) - await client.cancel_patch_job(request) # Establish that the underlying gRPC stub method was called. @@ -1092,7 +1062,7 @@ def test_list_patch_jobs( transport: str = "grpc", request_type=patch_jobs.ListPatchJobsRequest ): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1105,19 +1075,15 @@ def test_list_patch_jobs( call.return_value = patch_jobs.ListPatchJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_patch_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.ListPatchJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPatchJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -1129,7 +1095,7 @@ def test_list_patch_jobs_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 = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1137,7 +1103,6 @@ def test_list_patch_jobs_empty_call(): client.list_patch_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.ListPatchJobsRequest() @@ -1146,7 +1111,7 @@ async def test_list_patch_jobs_async( transport: str = "grpc_asyncio", request_type=patch_jobs.ListPatchJobsRequest ): client = OsConfigServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1159,18 +1124,15 @@ async def test_list_patch_jobs_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( patch_jobs.ListPatchJobsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_patch_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.ListPatchJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListPatchJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1180,17 +1142,17 @@ async def test_list_patch_jobs_async_from_dict(): def test_list_patch_jobs_field_headers(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(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 = patch_jobs.ListPatchJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_patch_jobs), "__call__") as call: call.return_value = patch_jobs.ListPatchJobsResponse() - client.list_patch_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -1205,11 +1167,14 @@ def test_list_patch_jobs_field_headers(): @pytest.mark.asyncio async def test_list_patch_jobs_field_headers_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + 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 = patch_jobs.ListPatchJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1217,7 +1182,6 @@ async def test_list_patch_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( patch_jobs.ListPatchJobsResponse() ) - await client.list_patch_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -1231,13 +1195,12 @@ async def test_list_patch_jobs_field_headers_async(): def test_list_patch_jobs_flattened(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_patch_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = patch_jobs.ListPatchJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_patch_jobs(parent="parent_value",) @@ -1246,12 +1209,11 @@ def test_list_patch_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_patch_jobs_flattened_error(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1263,7 +1225,9 @@ def test_list_patch_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_patch_jobs_flattened_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_patch_jobs), "__call__") as call: @@ -1281,13 +1245,14 @@ async def test_list_patch_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_patch_jobs_flattened_error_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1298,7 +1263,7 @@ async def test_list_patch_jobs_flattened_error_async(): def test_list_patch_jobs_pager(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_patch_jobs), "__call__") as call: @@ -1336,7 +1301,7 @@ def test_list_patch_jobs_pager(): def test_list_patch_jobs_pages(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_patch_jobs), "__call__") as call: @@ -1366,7 +1331,9 @@ def test_list_patch_jobs_pages(): @pytest.mark.asyncio async def test_list_patch_jobs_async_pager(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1403,7 +1370,9 @@ async def test_list_patch_jobs_async_pager(): @pytest.mark.asyncio async def test_list_patch_jobs_async_pages(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1439,7 +1408,7 @@ def test_list_patch_job_instance_details( transport: str = "grpc", request_type=patch_jobs.ListPatchJobInstanceDetailsRequest ): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1454,19 +1423,15 @@ def test_list_patch_job_instance_details( call.return_value = patch_jobs.ListPatchJobInstanceDetailsResponse( next_page_token="next_page_token_value", ) - response = client.list_patch_job_instance_details(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.ListPatchJobInstanceDetailsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPatchJobInstanceDetailsPager) - assert response.next_page_token == "next_page_token_value" @@ -1478,7 +1443,7 @@ def test_list_patch_job_instance_details_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 = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1488,7 +1453,6 @@ def test_list_patch_job_instance_details_empty_call(): client.list_patch_job_instance_details() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.ListPatchJobInstanceDetailsRequest() @@ -1498,7 +1462,7 @@ async def test_list_patch_job_instance_details_async( request_type=patch_jobs.ListPatchJobInstanceDetailsRequest, ): client = OsConfigServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1515,18 +1479,15 @@ async def test_list_patch_job_instance_details_async( next_page_token="next_page_token_value", ) ) - response = await client.list_patch_job_instance_details(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == patch_jobs.ListPatchJobInstanceDetailsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListPatchJobInstanceDetailsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1536,11 +1497,12 @@ async def test_list_patch_job_instance_details_async_from_dict(): def test_list_patch_job_instance_details_field_headers(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(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 = patch_jobs.ListPatchJobInstanceDetailsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1548,7 +1510,6 @@ def test_list_patch_job_instance_details_field_headers(): type(client.transport.list_patch_job_instance_details), "__call__" ) as call: call.return_value = patch_jobs.ListPatchJobInstanceDetailsResponse() - client.list_patch_job_instance_details(request) # Establish that the underlying gRPC stub method was called. @@ -1563,11 +1524,14 @@ def test_list_patch_job_instance_details_field_headers(): @pytest.mark.asyncio async def test_list_patch_job_instance_details_field_headers_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + 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 = patch_jobs.ListPatchJobInstanceDetailsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1577,7 +1541,6 @@ async def test_list_patch_job_instance_details_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( patch_jobs.ListPatchJobInstanceDetailsResponse() ) - await client.list_patch_job_instance_details(request) # Establish that the underlying gRPC stub method was called. @@ -1591,7 +1554,7 @@ async def test_list_patch_job_instance_details_field_headers_async(): def test_list_patch_job_instance_details_flattened(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1599,7 +1562,6 @@ def test_list_patch_job_instance_details_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = patch_jobs.ListPatchJobInstanceDetailsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_patch_job_instance_details(parent="parent_value",) @@ -1608,12 +1570,11 @@ def test_list_patch_job_instance_details_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_patch_job_instance_details_flattened_error(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1625,7 +1586,9 @@ def test_list_patch_job_instance_details_flattened_error(): @pytest.mark.asyncio async def test_list_patch_job_instance_details_flattened_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1645,13 +1608,14 @@ async def test_list_patch_job_instance_details_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_patch_job_instance_details_flattened_error_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1662,7 +1626,7 @@ async def test_list_patch_job_instance_details_flattened_error_async(): def test_list_patch_job_instance_details_pager(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1708,7 +1672,7 @@ def test_list_patch_job_instance_details_pager(): def test_list_patch_job_instance_details_pages(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1746,7 +1710,9 @@ def test_list_patch_job_instance_details_pages(): @pytest.mark.asyncio async def test_list_patch_job_instance_details_async_pager(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1791,7 +1757,9 @@ async def test_list_patch_job_instance_details_async_pager(): @pytest.mark.asyncio async def test_list_patch_job_instance_details_async_pages(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1837,7 +1805,7 @@ def test_create_patch_deployment( transport: str = "grpc", request_type=patch_deployments.CreatePatchDeploymentRequest ): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1853,24 +1821,19 @@ def test_create_patch_deployment( name="name_value", description="description_value", one_time_schedule=patch_deployments.OneTimeSchedule( - execute_time=timestamp.Timestamp(seconds=751) + execute_time=timestamp_pb2.Timestamp(seconds=751) ), ) - response = client.create_patch_deployment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.CreatePatchDeploymentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, patch_deployments.PatchDeployment) - assert response.name == "name_value" - assert response.description == "description_value" @@ -1882,7 +1845,7 @@ def test_create_patch_deployment_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 = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1892,7 +1855,6 @@ def test_create_patch_deployment_empty_call(): client.create_patch_deployment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.CreatePatchDeploymentRequest() @@ -1902,7 +1864,7 @@ async def test_create_patch_deployment_async( request_type=patch_deployments.CreatePatchDeploymentRequest, ): client = OsConfigServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1919,20 +1881,16 @@ async def test_create_patch_deployment_async( name="name_value", description="description_value", ) ) - response = await client.create_patch_deployment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.CreatePatchDeploymentRequest() # Establish that the response is the type that we expect. assert isinstance(response, patch_deployments.PatchDeployment) - assert response.name == "name_value" - assert response.description == "description_value" @@ -1942,11 +1900,12 @@ async def test_create_patch_deployment_async_from_dict(): def test_create_patch_deployment_field_headers(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(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 = patch_deployments.CreatePatchDeploymentRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1954,7 +1913,6 @@ def test_create_patch_deployment_field_headers(): type(client.transport.create_patch_deployment), "__call__" ) as call: call.return_value = patch_deployments.PatchDeployment() - client.create_patch_deployment(request) # Establish that the underlying gRPC stub method was called. @@ -1969,11 +1927,14 @@ def test_create_patch_deployment_field_headers(): @pytest.mark.asyncio async def test_create_patch_deployment_field_headers_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + 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 = patch_deployments.CreatePatchDeploymentRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1983,7 +1944,6 @@ async def test_create_patch_deployment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( patch_deployments.PatchDeployment() ) - await client.create_patch_deployment(request) # Establish that the underlying gRPC stub method was called. @@ -1997,7 +1957,7 @@ async def test_create_patch_deployment_field_headers_async(): def test_create_patch_deployment_flattened(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2005,7 +1965,6 @@ def test_create_patch_deployment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = patch_deployments.PatchDeployment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_patch_deployment( @@ -2018,18 +1977,15 @@ def test_create_patch_deployment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].patch_deployment == patch_deployments.PatchDeployment( name="name_value" ) - assert args[0].patch_deployment_id == "patch_deployment_id_value" def test_create_patch_deployment_flattened_error(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2044,7 +2000,9 @@ def test_create_patch_deployment_flattened_error(): @pytest.mark.asyncio async def test_create_patch_deployment_flattened_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2068,19 +2026,18 @@ async def test_create_patch_deployment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].patch_deployment == patch_deployments.PatchDeployment( name="name_value" ) - assert args[0].patch_deployment_id == "patch_deployment_id_value" @pytest.mark.asyncio async def test_create_patch_deployment_flattened_error_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2097,7 +2054,7 @@ def test_get_patch_deployment( transport: str = "grpc", request_type=patch_deployments.GetPatchDeploymentRequest ): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2113,24 +2070,19 @@ def test_get_patch_deployment( name="name_value", description="description_value", one_time_schedule=patch_deployments.OneTimeSchedule( - execute_time=timestamp.Timestamp(seconds=751) + execute_time=timestamp_pb2.Timestamp(seconds=751) ), ) - response = client.get_patch_deployment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.GetPatchDeploymentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, patch_deployments.PatchDeployment) - assert response.name == "name_value" - assert response.description == "description_value" @@ -2142,7 +2094,7 @@ def test_get_patch_deployment_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 = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2152,7 +2104,6 @@ def test_get_patch_deployment_empty_call(): client.get_patch_deployment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.GetPatchDeploymentRequest() @@ -2162,7 +2113,7 @@ async def test_get_patch_deployment_async( request_type=patch_deployments.GetPatchDeploymentRequest, ): client = OsConfigServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2179,20 +2130,16 @@ async def test_get_patch_deployment_async( name="name_value", description="description_value", ) ) - response = await client.get_patch_deployment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.GetPatchDeploymentRequest() # Establish that the response is the type that we expect. assert isinstance(response, patch_deployments.PatchDeployment) - assert response.name == "name_value" - assert response.description == "description_value" @@ -2202,11 +2149,12 @@ async def test_get_patch_deployment_async_from_dict(): def test_get_patch_deployment_field_headers(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(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 = patch_deployments.GetPatchDeploymentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2214,7 +2162,6 @@ def test_get_patch_deployment_field_headers(): type(client.transport.get_patch_deployment), "__call__" ) as call: call.return_value = patch_deployments.PatchDeployment() - client.get_patch_deployment(request) # Establish that the underlying gRPC stub method was called. @@ -2229,11 +2176,14 @@ def test_get_patch_deployment_field_headers(): @pytest.mark.asyncio async def test_get_patch_deployment_field_headers_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + 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 = patch_deployments.GetPatchDeploymentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2243,7 +2193,6 @@ async def test_get_patch_deployment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( patch_deployments.PatchDeployment() ) - await client.get_patch_deployment(request) # Establish that the underlying gRPC stub method was called. @@ -2257,7 +2206,7 @@ async def test_get_patch_deployment_field_headers_async(): def test_get_patch_deployment_flattened(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2265,7 +2214,6 @@ def test_get_patch_deployment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = patch_deployments.PatchDeployment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_patch_deployment(name="name_value",) @@ -2274,12 +2222,11 @@ def test_get_patch_deployment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_patch_deployment_flattened_error(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2291,7 +2238,9 @@ def test_get_patch_deployment_flattened_error(): @pytest.mark.asyncio async def test_get_patch_deployment_flattened_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2311,13 +2260,14 @@ async def test_get_patch_deployment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_patch_deployment_flattened_error_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2331,7 +2281,7 @@ def test_list_patch_deployments( transport: str = "grpc", request_type=patch_deployments.ListPatchDeploymentsRequest ): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2346,19 +2296,15 @@ def test_list_patch_deployments( call.return_value = patch_deployments.ListPatchDeploymentsResponse( next_page_token="next_page_token_value", ) - response = client.list_patch_deployments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.ListPatchDeploymentsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPatchDeploymentsPager) - assert response.next_page_token == "next_page_token_value" @@ -2370,7 +2316,7 @@ def test_list_patch_deployments_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 = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2380,7 +2326,6 @@ def test_list_patch_deployments_empty_call(): client.list_patch_deployments() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.ListPatchDeploymentsRequest() @@ -2390,7 +2335,7 @@ async def test_list_patch_deployments_async( request_type=patch_deployments.ListPatchDeploymentsRequest, ): client = OsConfigServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2407,18 +2352,15 @@ async def test_list_patch_deployments_async( next_page_token="next_page_token_value", ) ) - response = await client.list_patch_deployments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.ListPatchDeploymentsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListPatchDeploymentsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2428,11 +2370,12 @@ async def test_list_patch_deployments_async_from_dict(): def test_list_patch_deployments_field_headers(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(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 = patch_deployments.ListPatchDeploymentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2440,7 +2383,6 @@ def test_list_patch_deployments_field_headers(): type(client.transport.list_patch_deployments), "__call__" ) as call: call.return_value = patch_deployments.ListPatchDeploymentsResponse() - client.list_patch_deployments(request) # Establish that the underlying gRPC stub method was called. @@ -2455,11 +2397,14 @@ def test_list_patch_deployments_field_headers(): @pytest.mark.asyncio async def test_list_patch_deployments_field_headers_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + 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 = patch_deployments.ListPatchDeploymentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2469,7 +2414,6 @@ async def test_list_patch_deployments_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( patch_deployments.ListPatchDeploymentsResponse() ) - await client.list_patch_deployments(request) # Establish that the underlying gRPC stub method was called. @@ -2483,7 +2427,7 @@ async def test_list_patch_deployments_field_headers_async(): def test_list_patch_deployments_flattened(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2491,7 +2435,6 @@ def test_list_patch_deployments_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = patch_deployments.ListPatchDeploymentsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_patch_deployments(parent="parent_value",) @@ -2500,12 +2443,11 @@ def test_list_patch_deployments_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_patch_deployments_flattened_error(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2517,7 +2459,9 @@ def test_list_patch_deployments_flattened_error(): @pytest.mark.asyncio async def test_list_patch_deployments_flattened_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2537,13 +2481,14 @@ async def test_list_patch_deployments_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_patch_deployments_flattened_error_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2554,7 +2499,7 @@ async def test_list_patch_deployments_flattened_error_async(): def test_list_patch_deployments_pager(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2600,7 +2545,7 @@ def test_list_patch_deployments_pager(): def test_list_patch_deployments_pages(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2638,7 +2583,9 @@ def test_list_patch_deployments_pages(): @pytest.mark.asyncio async def test_list_patch_deployments_async_pager(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2683,7 +2630,9 @@ async def test_list_patch_deployments_async_pager(): @pytest.mark.asyncio async def test_list_patch_deployments_async_pages(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2727,7 +2676,7 @@ def test_delete_patch_deployment( transport: str = "grpc", request_type=patch_deployments.DeletePatchDeploymentRequest ): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2740,13 +2689,11 @@ def test_delete_patch_deployment( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_patch_deployment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.DeletePatchDeploymentRequest() # Establish that the response is the type that we expect. @@ -2761,7 +2708,7 @@ def test_delete_patch_deployment_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 = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2771,7 +2718,6 @@ def test_delete_patch_deployment_empty_call(): client.delete_patch_deployment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.DeletePatchDeploymentRequest() @@ -2781,7 +2727,7 @@ async def test_delete_patch_deployment_async( request_type=patch_deployments.DeletePatchDeploymentRequest, ): client = OsConfigServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2794,13 +2740,11 @@ async def test_delete_patch_deployment_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_patch_deployment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == patch_deployments.DeletePatchDeploymentRequest() # Establish that the response is the type that we expect. @@ -2813,11 +2757,12 @@ async def test_delete_patch_deployment_async_from_dict(): def test_delete_patch_deployment_field_headers(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(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 = patch_deployments.DeletePatchDeploymentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2825,7 +2770,6 @@ def test_delete_patch_deployment_field_headers(): type(client.transport.delete_patch_deployment), "__call__" ) as call: call.return_value = None - client.delete_patch_deployment(request) # Establish that the underlying gRPC stub method was called. @@ -2840,11 +2784,14 @@ def test_delete_patch_deployment_field_headers(): @pytest.mark.asyncio async def test_delete_patch_deployment_field_headers_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + 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 = patch_deployments.DeletePatchDeploymentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2852,7 +2799,6 @@ async def test_delete_patch_deployment_field_headers_async(): type(client.transport.delete_patch_deployment), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_patch_deployment(request) # Establish that the underlying gRPC stub method was called. @@ -2866,7 +2812,7 @@ async def test_delete_patch_deployment_field_headers_async(): def test_delete_patch_deployment_flattened(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2874,7 +2820,6 @@ def test_delete_patch_deployment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_patch_deployment(name="name_value",) @@ -2883,12 +2828,11 @@ def test_delete_patch_deployment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_patch_deployment_flattened_error(): - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2900,7 +2844,9 @@ def test_delete_patch_deployment_flattened_error(): @pytest.mark.asyncio async def test_delete_patch_deployment_flattened_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2918,13 +2864,14 @@ async def test_delete_patch_deployment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_patch_deployment_flattened_error_async(): - client = OsConfigServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2937,16 +2884,16 @@ async def test_delete_patch_deployment_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.OsConfigServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.OsConfigServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = OsConfigServiceClient( @@ -2956,7 +2903,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.OsConfigServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = OsConfigServiceClient( @@ -2967,7 +2914,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.OsConfigServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = OsConfigServiceClient(transport=transport) assert client.transport is transport @@ -2976,13 +2923,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.OsConfigServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.OsConfigServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -2997,23 +2944,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = OsConfigServiceClient(credentials=credentials.AnonymousCredentials(),) + client = OsConfigServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.OsConfigServiceGrpcTransport,) def test_os_config_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.OsConfigServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3025,7 +2972,7 @@ def test_os_config_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.OsConfigServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3046,15 +2993,37 @@ def test_os_config_service_base_transport(): getattr(transport, method)(request=object()) +@requires_google_auth_gte_1_25_0 def test_os_config_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.osconfig_v1.services.os_config_service.transports.OsConfigServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.OsConfigServiceTransport( + 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/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_os_config_service_base_transport_with_credentials_file_old_google_auth(): + # 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.osconfig_v1.services.os_config_service.transports.OsConfigServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.OsConfigServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3067,19 +3036,33 @@ def test_os_config_service_base_transport_with_credentials_file(): def test_os_config_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.osconfig_v1.services.os_config_service.transports.OsConfigServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.OsConfigServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_os_config_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + OsConfigServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_os_config_service_auth_adc_old_google_auth(): + # 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) OsConfigServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3087,20 +3070,156 @@ def test_os_config_service_auth_adc(): ) -def test_os_config_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.OsConfigServiceGrpcTransport, + transports.OsConfigServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_os_config_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.OsConfigServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + 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/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.OsConfigServiceGrpcTransport, + transports.OsConfigServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_os_config_service_transport_auth_adc_old_google_auth(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") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.OsConfigServiceGrpcTransport, grpc_helpers), + (transports.OsConfigServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_os_config_service_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( + "osconfig.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="osconfig.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.OsConfigServiceGrpcTransport, grpc_helpers), + (transports.OsConfigServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_os_config_service_transport_create_channel_old_api_core( + 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") + + create_channel.assert_called_with( + "osconfig.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.OsConfigServiceGrpcTransport, grpc_helpers), + (transports.OsConfigServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_os_config_service_transport_create_channel_user_scopes( + 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( + "osconfig.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -3109,7 +3228,7 @@ def test_os_config_service_transport_auth_adc(): ], ) def test_os_config_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -3148,7 +3267,7 @@ def test_os_config_service_grpc_transport_client_cert_source_for_mtls(transport_ def test_os_config_service_host_no_port(): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="osconfig.googleapis.com" ), @@ -3158,7 +3277,7 @@ def test_os_config_service_host_no_port(): def test_os_config_service_host_with_port(): client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="osconfig.googleapis.com:8000" ), @@ -3214,9 +3333,9 @@ def test_os_config_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -3294,7 +3413,6 @@ def test_instance_path(): project = "squid" zone = "clam" instance = "whelk" - expected = "projects/{project}/zones/{zone}/instances/{instance}".format( project=project, zone=zone, instance=instance, ) @@ -3318,7 +3436,6 @@ def test_parse_instance_path(): def test_patch_deployment_path(): project = "cuttlefish" patch_deployment = "mussel" - expected = "projects/{project}/patchDeployments/{patch_deployment}".format( project=project, patch_deployment=patch_deployment, ) @@ -3341,7 +3458,6 @@ def test_parse_patch_deployment_path(): def test_patch_job_path(): project = "scallop" patch_job = "abalone" - expected = "projects/{project}/patchJobs/{patch_job}".format( project=project, patch_job=patch_job, ) @@ -3363,7 +3479,6 @@ def test_parse_patch_job_path(): def test_common_billing_account_path(): billing_account = "whelk" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3384,7 +3499,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) actual = OsConfigServiceClient.common_folder_path(folder) assert expected == actual @@ -3403,7 +3517,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) actual = OsConfigServiceClient.common_organization_path(organization) assert expected == actual @@ -3422,7 +3535,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) actual = OsConfigServiceClient.common_project_path(project) assert expected == actual @@ -3442,7 +3554,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "scallop" location = "abalone" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -3469,7 +3580,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.OsConfigServiceTransport, "_prep_wrapped_messages" ) as prep: client = OsConfigServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3478,6 +3589,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = OsConfigServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info)