diff --git a/google/cloud/container/__init__.py b/google/cloud/container/__init__.py index 477cb459..e7390061 100644 --- a/google/cloud/container/__init__.py +++ b/google/cloud/container/__init__.py @@ -31,11 +31,15 @@ AdvancedMachineFeatures, AuthenticatorGroupsConfig, Autopilot, + AutopilotCompatibilityIssue, AutoprovisioningNodePoolDefaults, AutoUpgradeOptions, + BestEffortProvisioning, BinaryAuthorization, BlueGreenSettings, CancelOperationRequest, + CheckAutopilotCompatibilityRequest, + CheckAutopilotCompatibilityResponse, ClientCertificateConfig, CloudRunConfig, Cluster, @@ -81,6 +85,7 @@ IPAllocationPolicy, IPv6AccessType, Jwk, + K8sBetaAPIConfig, KubernetesDashboard, LegacyAbac, LinuxNodeConfig, @@ -185,11 +190,15 @@ "AdvancedMachineFeatures", "AuthenticatorGroupsConfig", "Autopilot", + "AutopilotCompatibilityIssue", "AutoprovisioningNodePoolDefaults", "AutoUpgradeOptions", + "BestEffortProvisioning", "BinaryAuthorization", "BlueGreenSettings", "CancelOperationRequest", + "CheckAutopilotCompatibilityRequest", + "CheckAutopilotCompatibilityResponse", "ClientCertificateConfig", "CloudRunConfig", "Cluster", @@ -233,6 +242,7 @@ "IntraNodeVisibilityConfig", "IPAllocationPolicy", "Jwk", + "K8sBetaAPIConfig", "KubernetesDashboard", "LegacyAbac", "LinuxNodeConfig", diff --git a/google/cloud/container_v1/__init__.py b/google/cloud/container_v1/__init__.py index c7cd3767..af3051b9 100644 --- a/google/cloud/container_v1/__init__.py +++ b/google/cloud/container_v1/__init__.py @@ -26,11 +26,15 @@ AdvancedMachineFeatures, AuthenticatorGroupsConfig, Autopilot, + AutopilotCompatibilityIssue, AutoprovisioningNodePoolDefaults, AutoUpgradeOptions, + BestEffortProvisioning, BinaryAuthorization, BlueGreenSettings, CancelOperationRequest, + CheckAutopilotCompatibilityRequest, + CheckAutopilotCompatibilityResponse, ClientCertificateConfig, CloudRunConfig, Cluster, @@ -76,6 +80,7 @@ IPAllocationPolicy, IPv6AccessType, Jwk, + K8sBetaAPIConfig, KubernetesDashboard, LegacyAbac, LinuxNodeConfig, @@ -180,10 +185,14 @@ "AuthenticatorGroupsConfig", "AutoUpgradeOptions", "Autopilot", + "AutopilotCompatibilityIssue", "AutoprovisioningNodePoolDefaults", + "BestEffortProvisioning", "BinaryAuthorization", "BlueGreenSettings", "CancelOperationRequest", + "CheckAutopilotCompatibilityRequest", + "CheckAutopilotCompatibilityResponse", "ClientCertificateConfig", "CloudRunConfig", "Cluster", @@ -230,6 +239,7 @@ "IdentityServiceConfig", "IntraNodeVisibilityConfig", "Jwk", + "K8sBetaAPIConfig", "KubernetesDashboard", "LegacyAbac", "LinuxNodeConfig", diff --git a/google/cloud/container_v1/gapic_metadata.json b/google/cloud/container_v1/gapic_metadata.json index 5ef3b3dd..85cb487b 100644 --- a/google/cloud/container_v1/gapic_metadata.json +++ b/google/cloud/container_v1/gapic_metadata.json @@ -15,6 +15,11 @@ "cancel_operation" ] }, + "CheckAutopilotCompatibility": { + "methods": [ + "check_autopilot_compatibility" + ] + }, "CompleteIPRotation": { "methods": [ "complete_ip_rotation" @@ -185,6 +190,11 @@ "cancel_operation" ] }, + "CheckAutopilotCompatibility": { + "methods": [ + "check_autopilot_compatibility" + ] + }, "CompleteIPRotation": { "methods": [ "complete_ip_rotation" diff --git a/google/cloud/container_v1/services/cluster_manager/async_client.py b/google/cloud/container_v1/services/cluster_manager/async_client.py index 33f4568a..dc642563 100644 --- a/google/cloud/container_v1/services/cluster_manager/async_client.py +++ b/google/cloud/container_v1/services/cluster_manager/async_client.py @@ -4614,6 +4614,89 @@ async def sample_list_usable_subnetworks(): # Done; return the response. return response + async def check_autopilot_compatibility( + self, + request: Optional[ + Union[cluster_service.CheckAutopilotCompatibilityRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> cluster_service.CheckAutopilotCompatibilityResponse: + r"""Checks the cluster compatibility with Autopilot mode, + and returns a list of compatibility issues. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import container_v1 + + async def sample_check_autopilot_compatibility(): + # Create a client + client = container_v1.ClusterManagerAsyncClient() + + # Initialize request argument(s) + request = container_v1.CheckAutopilotCompatibilityRequest( + ) + + # Make the request + response = await client.check_autopilot_compatibility(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.container_v1.types.CheckAutopilotCompatibilityRequest, dict]]): + The request object. CheckAutopilotCompatibilityRequest + requests getting the blockers for the + given operation in the cluster. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.container_v1.types.CheckAutopilotCompatibilityResponse: + CheckAutopilotCompatibilityResponse + has a list of compatibility issues. + + """ + # Create or coerce a protobuf request object. + request = cluster_service.CheckAutopilotCompatibilityRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.check_autopilot_compatibility, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/container_v1/services/cluster_manager/client.py b/google/cloud/container_v1/services/cluster_manager/client.py index 87dc6aa0..210ba4f5 100644 --- a/google/cloud/container_v1/services/cluster_manager/client.py +++ b/google/cloud/container_v1/services/cluster_manager/client.py @@ -4761,6 +4761,92 @@ def sample_list_usable_subnetworks(): # Done; return the response. return response + def check_autopilot_compatibility( + self, + request: Optional[ + Union[cluster_service.CheckAutopilotCompatibilityRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> cluster_service.CheckAutopilotCompatibilityResponse: + r"""Checks the cluster compatibility with Autopilot mode, + and returns a list of compatibility issues. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import container_v1 + + def sample_check_autopilot_compatibility(): + # Create a client + client = container_v1.ClusterManagerClient() + + # Initialize request argument(s) + request = container_v1.CheckAutopilotCompatibilityRequest( + ) + + # Make the request + response = client.check_autopilot_compatibility(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.container_v1.types.CheckAutopilotCompatibilityRequest, dict]): + The request object. CheckAutopilotCompatibilityRequest + requests getting the blockers for the + given operation in the cluster. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.container_v1.types.CheckAutopilotCompatibilityResponse: + CheckAutopilotCompatibilityResponse + has a list of compatibility issues. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a cluster_service.CheckAutopilotCompatibilityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, cluster_service.CheckAutopilotCompatibilityRequest): + request = cluster_service.CheckAutopilotCompatibilityRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.check_autopilot_compatibility + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def __enter__(self) -> "ClusterManagerClient": return self diff --git a/google/cloud/container_v1/services/cluster_manager/transports/base.py b/google/cloud/container_v1/services/cluster_manager/transports/base.py index 2c4a4aee..7659285d 100644 --- a/google/cloud/container_v1/services/cluster_manager/transports/base.py +++ b/google/cloud/container_v1/services/cluster_manager/transports/base.py @@ -378,6 +378,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.check_autopilot_compatibility: gapic_v1.method.wrap_method( + self.check_autopilot_compatibility, + default_timeout=None, + client_info=client_info, + ), } def close(self): @@ -701,6 +706,18 @@ def list_usable_subnetworks( ]: raise NotImplementedError() + @property + def check_autopilot_compatibility( + self, + ) -> Callable[ + [cluster_service.CheckAutopilotCompatibilityRequest], + Union[ + cluster_service.CheckAutopilotCompatibilityResponse, + Awaitable[cluster_service.CheckAutopilotCompatibilityResponse], + ], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/google/cloud/container_v1/services/cluster_manager/transports/grpc.py b/google/cloud/container_v1/services/cluster_manager/transports/grpc.py index 3dcdd5a9..83f2f029 100644 --- a/google/cloud/container_v1/services/cluster_manager/transports/grpc.py +++ b/google/cloud/container_v1/services/cluster_manager/transports/grpc.py @@ -1156,6 +1156,38 @@ def list_usable_subnetworks( ) return self._stubs["list_usable_subnetworks"] + @property + def check_autopilot_compatibility( + self, + ) -> Callable[ + [cluster_service.CheckAutopilotCompatibilityRequest], + cluster_service.CheckAutopilotCompatibilityResponse, + ]: + r"""Return a callable for the check autopilot compatibility method over gRPC. + + Checks the cluster compatibility with Autopilot mode, + and returns a list of compatibility issues. + + Returns: + Callable[[~.CheckAutopilotCompatibilityRequest], + ~.CheckAutopilotCompatibilityResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "check_autopilot_compatibility" not in self._stubs: + self._stubs[ + "check_autopilot_compatibility" + ] = self.grpc_channel.unary_unary( + "/google.container.v1.ClusterManager/CheckAutopilotCompatibility", + request_serializer=cluster_service.CheckAutopilotCompatibilityRequest.serialize, + response_deserializer=cluster_service.CheckAutopilotCompatibilityResponse.deserialize, + ) + return self._stubs["check_autopilot_compatibility"] + def close(self): self.grpc_channel.close() diff --git a/google/cloud/container_v1/services/cluster_manager/transports/grpc_asyncio.py b/google/cloud/container_v1/services/cluster_manager/transports/grpc_asyncio.py index b308b28d..59326ab5 100644 --- a/google/cloud/container_v1/services/cluster_manager/transports/grpc_asyncio.py +++ b/google/cloud/container_v1/services/cluster_manager/transports/grpc_asyncio.py @@ -1208,6 +1208,38 @@ def list_usable_subnetworks( ) return self._stubs["list_usable_subnetworks"] + @property + def check_autopilot_compatibility( + self, + ) -> Callable[ + [cluster_service.CheckAutopilotCompatibilityRequest], + Awaitable[cluster_service.CheckAutopilotCompatibilityResponse], + ]: + r"""Return a callable for the check autopilot compatibility method over gRPC. + + Checks the cluster compatibility with Autopilot mode, + and returns a list of compatibility issues. + + Returns: + Callable[[~.CheckAutopilotCompatibilityRequest], + Awaitable[~.CheckAutopilotCompatibilityResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "check_autopilot_compatibility" not in self._stubs: + self._stubs[ + "check_autopilot_compatibility" + ] = self.grpc_channel.unary_unary( + "/google.container.v1.ClusterManager/CheckAutopilotCompatibility", + request_serializer=cluster_service.CheckAutopilotCompatibilityRequest.serialize, + response_deserializer=cluster_service.CheckAutopilotCompatibilityResponse.deserialize, + ) + return self._stubs["check_autopilot_compatibility"] + def close(self): return self.grpc_channel.close() diff --git a/google/cloud/container_v1/types/__init__.py b/google/cloud/container_v1/types/__init__.py index bc9131a0..1b0016b1 100644 --- a/google/cloud/container_v1/types/__init__.py +++ b/google/cloud/container_v1/types/__init__.py @@ -20,11 +20,15 @@ AdvancedMachineFeatures, AuthenticatorGroupsConfig, Autopilot, + AutopilotCompatibilityIssue, AutoprovisioningNodePoolDefaults, AutoUpgradeOptions, + BestEffortProvisioning, BinaryAuthorization, BlueGreenSettings, CancelOperationRequest, + CheckAutopilotCompatibilityRequest, + CheckAutopilotCompatibilityResponse, ClientCertificateConfig, CloudRunConfig, Cluster, @@ -70,6 +74,7 @@ IPAllocationPolicy, IPv6AccessType, Jwk, + K8sBetaAPIConfig, KubernetesDashboard, LegacyAbac, LinuxNodeConfig, @@ -172,11 +177,15 @@ "AdvancedMachineFeatures", "AuthenticatorGroupsConfig", "Autopilot", + "AutopilotCompatibilityIssue", "AutoprovisioningNodePoolDefaults", "AutoUpgradeOptions", + "BestEffortProvisioning", "BinaryAuthorization", "BlueGreenSettings", "CancelOperationRequest", + "CheckAutopilotCompatibilityRequest", + "CheckAutopilotCompatibilityResponse", "ClientCertificateConfig", "CloudRunConfig", "Cluster", @@ -220,6 +229,7 @@ "IntraNodeVisibilityConfig", "IPAllocationPolicy", "Jwk", + "K8sBetaAPIConfig", "KubernetesDashboard", "LegacyAbac", "LinuxNodeConfig", diff --git a/google/cloud/container_v1/types/cluster_service.py b/google/cloud/container_v1/types/cluster_service.py index 52d7de75..dbfc2b32 100644 --- a/google/cloud/container_v1/types/cluster_service.py +++ b/google/cloud/container_v1/types/cluster_service.py @@ -72,6 +72,7 @@ "PodCIDROverprovisionConfig", "IPAllocationPolicy", "Cluster", + "K8sBetaAPIConfig", "NodePoolAutoConfig", "NodePoolDefaults", "NodeConfigDefaults", @@ -106,6 +107,7 @@ "BlueGreenSettings", "NodePool", "NodeManagement", + "BestEffortProvisioning", "AutoUpgradeOptions", "MaintenancePolicy", "MaintenanceWindow", @@ -140,6 +142,9 @@ "GetJSONWebKeysRequest", "Jwk", "GetJSONWebKeysResponse", + "CheckAutopilotCompatibilityRequest", + "AutopilotCompatibilityIssue", + "CheckAutopilotCompatibilityResponse", "ReleaseChannel", "CostManagementConfig", "IntraNodeVisibilityConfig", @@ -2500,6 +2505,8 @@ class Cluster(proto.Message): up-to-date value before proceeding. fleet (google.cloud.container_v1.types.Fleet): Fleet information for the cluster. + enable_k8s_beta_apis (google.cloud.container_v1.types.K8sBetaAPIConfig): + Beta APIs Config """ class Status(proto.Enum): @@ -2831,6 +2838,25 @@ class Status(proto.Enum): number=140, message="Fleet", ) + enable_k8s_beta_apis: "K8sBetaAPIConfig" = proto.Field( + proto.MESSAGE, + number=143, + message="K8sBetaAPIConfig", + ) + + +class K8sBetaAPIConfig(proto.Message): + r"""K8sBetaAPIConfig , configuration for beta APIs + + Attributes: + enabled_apis (MutableSequence[str]): + Enabled k8s beta APIs. + """ + + enabled_apis: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=1, + ) class NodePoolAutoConfig(proto.Message): @@ -3088,6 +3114,16 @@ class ClusterUpdate(proto.Message): cluster. The pod ranges specified here must have been specified earlier in the 'additional_pod_ranges_config' argument. + enable_k8s_beta_apis (google.cloud.container_v1.types.K8sBetaAPIConfig): + Kubernetes open source beta apis enabled on + the cluster. Only beta apis + desired_enable_fqdn_network_policy (bool): + Enable/Disable FQDN Network Policy for the + cluster. + + This field is a member of `oneof`_ ``_desired_enable_fqdn_network_policy``. + desired_k8s_beta_apis (google.cloud.container_v1.types.K8sBetaAPIConfig): + Desired Beta APIs to be enabled for cluster. """ desired_node_version: str = proto.Field( @@ -3299,6 +3335,21 @@ class ClusterUpdate(proto.Message): number=121, message="AdditionalPodRangesConfig", ) + enable_k8s_beta_apis: "K8sBetaAPIConfig" = proto.Field( + proto.MESSAGE, + number=122, + message="K8sBetaAPIConfig", + ) + desired_enable_fqdn_network_policy: bool = proto.Field( + proto.BOOL, + number=126, + optional=True, + ) + desired_k8s_beta_apis: "K8sBetaAPIConfig" = proto.Field( + proto.MESSAGE, + number=131, + message="K8sBetaAPIConfig", + ) class AdditionalPodRangesConfig(proto.Message): @@ -5204,6 +5255,8 @@ class NodePool(proto.Message): on the value of node pool fields, and may be sent on update requests to ensure the client has an up-to-date value before proceeding. + best_effort_provisioning (google.cloud.container_v1.types.BestEffortProvisioning): + Enable best effort provisioning for nodes """ class Status(proto.Enum): @@ -5549,6 +5602,11 @@ class Type(proto.Enum): proto.STRING, number=110, ) + best_effort_provisioning: "BestEffortProvisioning" = proto.Field( + proto.MESSAGE, + number=113, + message="BestEffortProvisioning", + ) class NodeManagement(proto.Message): @@ -5589,6 +5647,34 @@ class NodeManagement(proto.Message): ) +class BestEffortProvisioning(proto.Message): + r"""Best effort provisioning. + + Attributes: + enabled (bool): + When this is enabled, cluster/node pool + creations will ignore non-fatal errors like + stockout to best provision as many nodes as + possible right now and eventually bring up all + target number of nodes + min_provision_nodes (int): + Minimum number of nodes to be provisioned to + be considered as succeeded, and the rest of + nodes will be provisioned gradually and + eventually when stockout issue has been + resolved. + """ + + enabled: bool = proto.Field( + proto.BOOL, + number=1, + ) + min_provision_nodes: int = proto.Field( + proto.INT32, + number=2, + ) + + class AutoUpgradeOptions(proto.Message): r"""AutoUpgradeOptions defines the set of options for the user to control how the Auto Upgrades will proceed. @@ -6845,6 +6931,9 @@ class NetworkConfig(proto.Message): r"""NetworkConfig reports the relative names of network & subnetwork. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: network (str): Output only. The relative name of the Google Compute Engine @@ -6888,6 +6977,11 @@ class NetworkConfig(proto.Message): gateway_api_config (google.cloud.container_v1.types.GatewayAPIConfig): GatewayAPIConfig contains the desired config of Gateway API on this cluster. + enable_fqdn_network_policy (bool): + Whether FQDN Network Policy is enabled on + this cluster. + + This field is a member of `oneof`_ ``_enable_fqdn_network_policy``. """ network: str = proto.Field( @@ -6936,6 +7030,11 @@ class NetworkConfig(proto.Message): number=16, message="GatewayAPIConfig", ) + enable_fqdn_network_policy: bool = proto.Field( + proto.BOOL, + number=19, + optional=True, + ) class GatewayAPIConfig(proto.Message): @@ -7159,6 +7258,119 @@ class GetJSONWebKeysResponse(proto.Message): ) +class CheckAutopilotCompatibilityRequest(proto.Message): + r"""CheckAutopilotCompatibilityRequest requests getting the + blockers for the given operation in the cluster. + + Attributes: + name (str): + The name (project, location, cluster) of the cluster to + retrieve. Specified in the format + ``projects/*/locations/*/clusters/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class AutopilotCompatibilityIssue(proto.Message): + r"""AutopilotCompatibilityIssue contains information about a + specific compatibility issue with Autopilot mode. + + Attributes: + last_observation (google.protobuf.timestamp_pb2.Timestamp): + The last time when this issue was observed. + constraint_type (str): + The constraint type of the issue. + incompatibility_type (google.cloud.container_v1.types.AutopilotCompatibilityIssue.IssueType): + The incompatibility type of this issue. + subjects (MutableSequence[str]): + The name of the resources which are subject + to this issue. + documentation_url (str): + A URL to a public documnetation, which + addresses resolving this issue. + description (str): + The description of the issue. + """ + + class IssueType(proto.Enum): + r"""The type of the reported issue. + + Values: + UNSPECIFIED (0): + Default value, should not be used. + INCOMPATIBILITY (1): + Indicates that the issue is a known + incompatibility between the cluster and + Autopilot mode. + ADDITIONAL_CONFIG_REQUIRED (2): + Indicates the issue is an incompatibility if + customers take no further action to resolve. + PASSED_WITH_OPTIONAL_CONFIG (3): + Indicates the issue is not an + incompatibility, but depending on the workloads + business logic, there is a potential that they + won't work on Autopilot. + """ + UNSPECIFIED = 0 + INCOMPATIBILITY = 1 + ADDITIONAL_CONFIG_REQUIRED = 2 + PASSED_WITH_OPTIONAL_CONFIG = 3 + + last_observation: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + constraint_type: str = proto.Field( + proto.STRING, + number=2, + ) + incompatibility_type: IssueType = proto.Field( + proto.ENUM, + number=3, + enum=IssueType, + ) + subjects: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=4, + ) + documentation_url: str = proto.Field( + proto.STRING, + number=5, + ) + description: str = proto.Field( + proto.STRING, + number=6, + ) + + +class CheckAutopilotCompatibilityResponse(proto.Message): + r"""CheckAutopilotCompatibilityResponse has a list of + compatibility issues. + + Attributes: + issues (MutableSequence[google.cloud.container_v1.types.AutopilotCompatibilityIssue]): + The list of issues for the given operation. + summary (str): + The summary of the autopilot compatibility + response. + """ + + issues: MutableSequence["AutopilotCompatibilityIssue"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="AutopilotCompatibilityIssue", + ) + summary: str = proto.Field( + proto.STRING, + number=2, + ) + + class ReleaseChannel(proto.Message): r"""ReleaseChannel indicates which release channel a cluster is subscribed to. Release channels are arranged in order of risk. diff --git a/google/cloud/container_v1beta1/__init__.py b/google/cloud/container_v1beta1/__init__.py index b1804d1b..72bc8cbf 100644 --- a/google/cloud/container_v1beta1/__init__.py +++ b/google/cloud/container_v1beta1/__init__.py @@ -26,11 +26,15 @@ AdvancedMachineFeatures, AuthenticatorGroupsConfig, Autopilot, + AutopilotCompatibilityIssue, AutoprovisioningNodePoolDefaults, AutoUpgradeOptions, + BestEffortProvisioning, BinaryAuthorization, BlueGreenSettings, CancelOperationRequest, + CheckAutopilotCompatibilityRequest, + CheckAutopilotCompatibilityResponse, ClientCertificateConfig, CloudRunConfig, Cluster, @@ -79,6 +83,7 @@ IPAllocationPolicy, IstioConfig, Jwk, + K8sBetaAPIConfig, KalmConfig, KubernetesDashboard, LegacyAbac, @@ -195,10 +200,14 @@ "AuthenticatorGroupsConfig", "AutoUpgradeOptions", "Autopilot", + "AutopilotCompatibilityIssue", "AutoprovisioningNodePoolDefaults", + "BestEffortProvisioning", "BinaryAuthorization", "BlueGreenSettings", "CancelOperationRequest", + "CheckAutopilotCompatibilityRequest", + "CheckAutopilotCompatibilityResponse", "ClientCertificateConfig", "CloudRunConfig", "Cluster", @@ -248,6 +257,7 @@ "IntraNodeVisibilityConfig", "IstioConfig", "Jwk", + "K8sBetaAPIConfig", "KalmConfig", "KubernetesDashboard", "LegacyAbac", diff --git a/google/cloud/container_v1beta1/gapic_metadata.json b/google/cloud/container_v1beta1/gapic_metadata.json index 4e429961..b925b821 100644 --- a/google/cloud/container_v1beta1/gapic_metadata.json +++ b/google/cloud/container_v1beta1/gapic_metadata.json @@ -15,6 +15,11 @@ "cancel_operation" ] }, + "CheckAutopilotCompatibility": { + "methods": [ + "check_autopilot_compatibility" + ] + }, "CompleteIPRotation": { "methods": [ "complete_ip_rotation" @@ -190,6 +195,11 @@ "cancel_operation" ] }, + "CheckAutopilotCompatibility": { + "methods": [ + "check_autopilot_compatibility" + ] + }, "CompleteIPRotation": { "methods": [ "complete_ip_rotation" diff --git a/google/cloud/container_v1beta1/services/cluster_manager/async_client.py b/google/cloud/container_v1beta1/services/cluster_manager/async_client.py index 9dbec8e6..54d77f71 100644 --- a/google/cloud/container_v1beta1/services/cluster_manager/async_client.py +++ b/google/cloud/container_v1beta1/services/cluster_manager/async_client.py @@ -4687,6 +4687,89 @@ async def sample_list_usable_subnetworks(): # Done; return the response. return response + async def check_autopilot_compatibility( + self, + request: Optional[ + Union[cluster_service.CheckAutopilotCompatibilityRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> cluster_service.CheckAutopilotCompatibilityResponse: + r"""Checks the cluster compatibility with Autopilot mode, + and returns a list of compatibility issues. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import container_v1beta1 + + async def sample_check_autopilot_compatibility(): + # Create a client + client = container_v1beta1.ClusterManagerAsyncClient() + + # Initialize request argument(s) + request = container_v1beta1.CheckAutopilotCompatibilityRequest( + ) + + # Make the request + response = await client.check_autopilot_compatibility(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.container_v1beta1.types.CheckAutopilotCompatibilityRequest, dict]]): + The request object. CheckAutopilotCompatibilityRequest + requests getting the blockers for the + given operation in the cluster. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.container_v1beta1.types.CheckAutopilotCompatibilityResponse: + CheckAutopilotCompatibilityResponse + has a list of compatibility issues. + + """ + # Create or coerce a protobuf request object. + request = cluster_service.CheckAutopilotCompatibilityRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.check_autopilot_compatibility, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def list_locations( self, request: Optional[Union[cluster_service.ListLocationsRequest, dict]] = None, diff --git a/google/cloud/container_v1beta1/services/cluster_manager/client.py b/google/cloud/container_v1beta1/services/cluster_manager/client.py index 487d52fd..14d00ae5 100644 --- a/google/cloud/container_v1beta1/services/cluster_manager/client.py +++ b/google/cloud/container_v1beta1/services/cluster_manager/client.py @@ -4820,6 +4820,92 @@ def sample_list_usable_subnetworks(): # Done; return the response. return response + def check_autopilot_compatibility( + self, + request: Optional[ + Union[cluster_service.CheckAutopilotCompatibilityRequest, dict] + ] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> cluster_service.CheckAutopilotCompatibilityResponse: + r"""Checks the cluster compatibility with Autopilot mode, + and returns a list of compatibility issues. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud import container_v1beta1 + + def sample_check_autopilot_compatibility(): + # Create a client + client = container_v1beta1.ClusterManagerClient() + + # Initialize request argument(s) + request = container_v1beta1.CheckAutopilotCompatibilityRequest( + ) + + # Make the request + response = client.check_autopilot_compatibility(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.container_v1beta1.types.CheckAutopilotCompatibilityRequest, dict]): + The request object. CheckAutopilotCompatibilityRequest + requests getting the blockers for the + given operation in the cluster. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.container_v1beta1.types.CheckAutopilotCompatibilityResponse: + CheckAutopilotCompatibilityResponse + has a list of compatibility issues. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a cluster_service.CheckAutopilotCompatibilityRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, cluster_service.CheckAutopilotCompatibilityRequest): + request = cluster_service.CheckAutopilotCompatibilityRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.check_autopilot_compatibility + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def list_locations( self, request: Optional[Union[cluster_service.ListLocationsRequest, dict]] = None, diff --git a/google/cloud/container_v1beta1/services/cluster_manager/transports/base.py b/google/cloud/container_v1beta1/services/cluster_manager/transports/base.py index f705f455..075e0def 100644 --- a/google/cloud/container_v1beta1/services/cluster_manager/transports/base.py +++ b/google/cloud/container_v1beta1/services/cluster_manager/transports/base.py @@ -388,6 +388,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=20.0, client_info=client_info, ), + self.check_autopilot_compatibility: gapic_v1.method.wrap_method( + self.check_autopilot_compatibility, + default_timeout=None, + client_info=client_info, + ), self.list_locations: gapic_v1.method.wrap_method( self.list_locations, default_retry=retries.Retry( @@ -726,6 +731,18 @@ def list_usable_subnetworks( ]: raise NotImplementedError() + @property + def check_autopilot_compatibility( + self, + ) -> Callable[ + [cluster_service.CheckAutopilotCompatibilityRequest], + Union[ + cluster_service.CheckAutopilotCompatibilityResponse, + Awaitable[cluster_service.CheckAutopilotCompatibilityResponse], + ], + ]: + raise NotImplementedError() + @property def list_locations( self, diff --git a/google/cloud/container_v1beta1/services/cluster_manager/transports/grpc.py b/google/cloud/container_v1beta1/services/cluster_manager/transports/grpc.py index 992ef6af..78d54c20 100644 --- a/google/cloud/container_v1beta1/services/cluster_manager/transports/grpc.py +++ b/google/cloud/container_v1beta1/services/cluster_manager/transports/grpc.py @@ -1156,6 +1156,38 @@ def list_usable_subnetworks( ) return self._stubs["list_usable_subnetworks"] + @property + def check_autopilot_compatibility( + self, + ) -> Callable[ + [cluster_service.CheckAutopilotCompatibilityRequest], + cluster_service.CheckAutopilotCompatibilityResponse, + ]: + r"""Return a callable for the check autopilot compatibility method over gRPC. + + Checks the cluster compatibility with Autopilot mode, + and returns a list of compatibility issues. + + Returns: + Callable[[~.CheckAutopilotCompatibilityRequest], + ~.CheckAutopilotCompatibilityResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "check_autopilot_compatibility" not in self._stubs: + self._stubs[ + "check_autopilot_compatibility" + ] = self.grpc_channel.unary_unary( + "/google.container.v1beta1.ClusterManager/CheckAutopilotCompatibility", + request_serializer=cluster_service.CheckAutopilotCompatibilityRequest.serialize, + response_deserializer=cluster_service.CheckAutopilotCompatibilityResponse.deserialize, + ) + return self._stubs["check_autopilot_compatibility"] + @property def list_locations( self, diff --git a/google/cloud/container_v1beta1/services/cluster_manager/transports/grpc_asyncio.py b/google/cloud/container_v1beta1/services/cluster_manager/transports/grpc_asyncio.py index 7613064d..13d4a748 100644 --- a/google/cloud/container_v1beta1/services/cluster_manager/transports/grpc_asyncio.py +++ b/google/cloud/container_v1beta1/services/cluster_manager/transports/grpc_asyncio.py @@ -1208,6 +1208,38 @@ def list_usable_subnetworks( ) return self._stubs["list_usable_subnetworks"] + @property + def check_autopilot_compatibility( + self, + ) -> Callable[ + [cluster_service.CheckAutopilotCompatibilityRequest], + Awaitable[cluster_service.CheckAutopilotCompatibilityResponse], + ]: + r"""Return a callable for the check autopilot compatibility method over gRPC. + + Checks the cluster compatibility with Autopilot mode, + and returns a list of compatibility issues. + + Returns: + Callable[[~.CheckAutopilotCompatibilityRequest], + Awaitable[~.CheckAutopilotCompatibilityResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "check_autopilot_compatibility" not in self._stubs: + self._stubs[ + "check_autopilot_compatibility" + ] = self.grpc_channel.unary_unary( + "/google.container.v1beta1.ClusterManager/CheckAutopilotCompatibility", + request_serializer=cluster_service.CheckAutopilotCompatibilityRequest.serialize, + response_deserializer=cluster_service.CheckAutopilotCompatibilityResponse.deserialize, + ) + return self._stubs["check_autopilot_compatibility"] + @property def list_locations( self, diff --git a/google/cloud/container_v1beta1/types/__init__.py b/google/cloud/container_v1beta1/types/__init__.py index 5c999336..71a85c79 100644 --- a/google/cloud/container_v1beta1/types/__init__.py +++ b/google/cloud/container_v1beta1/types/__init__.py @@ -20,11 +20,15 @@ AdvancedMachineFeatures, AuthenticatorGroupsConfig, Autopilot, + AutopilotCompatibilityIssue, AutoprovisioningNodePoolDefaults, AutoUpgradeOptions, + BestEffortProvisioning, BinaryAuthorization, BlueGreenSettings, CancelOperationRequest, + CheckAutopilotCompatibilityRequest, + CheckAutopilotCompatibilityResponse, ClientCertificateConfig, CloudRunConfig, Cluster, @@ -73,6 +77,7 @@ IPAllocationPolicy, IstioConfig, Jwk, + K8sBetaAPIConfig, KalmConfig, KubernetesDashboard, LegacyAbac, @@ -187,11 +192,15 @@ "AdvancedMachineFeatures", "AuthenticatorGroupsConfig", "Autopilot", + "AutopilotCompatibilityIssue", "AutoprovisioningNodePoolDefaults", "AutoUpgradeOptions", + "BestEffortProvisioning", "BinaryAuthorization", "BlueGreenSettings", "CancelOperationRequest", + "CheckAutopilotCompatibilityRequest", + "CheckAutopilotCompatibilityResponse", "ClientCertificateConfig", "CloudRunConfig", "Cluster", @@ -239,6 +248,7 @@ "IPAllocationPolicy", "IstioConfig", "Jwk", + "K8sBetaAPIConfig", "KalmConfig", "KubernetesDashboard", "LegacyAbac", diff --git a/google/cloud/container_v1beta1/types/cluster_service.py b/google/cloud/container_v1beta1/types/cluster_service.py index 76610a83..8c2cb0c4 100644 --- a/google/cloud/container_v1beta1/types/cluster_service.py +++ b/google/cloud/container_v1beta1/types/cluster_service.py @@ -80,6 +80,7 @@ "AuthenticatorGroupsConfig", "ClusterTelemetry", "Cluster", + "K8sBetaAPIConfig", "WorkloadConfig", "ProtectConfig", "NodePoolDefaults", @@ -109,6 +110,7 @@ "ListOperationsResponse", "GetServerConfigRequest", "ServerConfig", + "BestEffortProvisioning", "WindowsVersions", "CreateNodePoolRequest", "DeleteNodePoolRequest", @@ -174,6 +176,9 @@ "GetJSONWebKeysRequest", "Jwk", "GetJSONWebKeysResponse", + "CheckAutopilotCompatibilityRequest", + "AutopilotCompatibilityIssue", + "CheckAutopilotCompatibilityResponse", "ReleaseChannel", "CostManagementConfig", "TpuConfig", @@ -2595,6 +2600,9 @@ class Cluster(proto.Message): master/node upgrades are disabled. Alpha enabled clusters are automatically deleted thirty days after creation. + enable_k8s_beta_apis (google.cloud.container_v1beta1.types.K8sBetaAPIConfig): + Kubernetes open source beta apis enabled on + the cluster. Only beta apis. resource_labels (MutableMapping[str, str]): The resource labels for the cluster to use to annotate any related Google Compute Engine @@ -2917,6 +2925,11 @@ class Status(proto.Enum): proto.BOOL, number=14, ) + enable_k8s_beta_apis: "K8sBetaAPIConfig" = proto.Field( + proto.MESSAGE, + number=143, + message="K8sBetaAPIConfig", + ) resource_labels: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, @@ -3195,6 +3208,21 @@ class Status(proto.Enum): ) +class K8sBetaAPIConfig(proto.Message): + r"""Kubernetes open source beta apis enabled on the cluster. + + Attributes: + enabled_apis (MutableSequence[str]): + api name, e.g. + storage.k8s.io/v1beta1/csistoragecapacities. + """ + + enabled_apis: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=1, + ) + + class WorkloadConfig(proto.Message): r"""WorkloadConfig defines the flags to enable or disable the workload configurations for the cluster. @@ -3576,6 +3604,16 @@ class ClusterUpdate(proto.Message): cluster. The pod ranges specified here must have been specified earlier in the 'additional_pod_ranges_config' argument. + enable_k8s_beta_apis (google.cloud.container_v1beta1.types.K8sBetaAPIConfig): + Kubernetes open source beta apis enabled on + the cluster. Only beta apis + desired_enable_fqdn_network_policy (bool): + Enable/Disable FQDN Network Policy for the + cluster. + + This field is a member of `oneof`_ ``_desired_enable_fqdn_network_policy``. + desired_k8s_beta_apis (google.cloud.container_v1beta1.types.K8sBetaAPIConfig): + Beta APIs enabled for cluster. """ desired_node_version: str = proto.Field( @@ -3823,6 +3861,21 @@ class ClusterUpdate(proto.Message): number=121, message="AdditionalPodRangesConfig", ) + enable_k8s_beta_apis: "K8sBetaAPIConfig" = proto.Field( + proto.MESSAGE, + number=122, + message="K8sBetaAPIConfig", + ) + desired_enable_fqdn_network_policy: bool = proto.Field( + proto.BOOL, + number=126, + optional=True, + ) + desired_k8s_beta_apis: "K8sBetaAPIConfig" = proto.Field( + proto.MESSAGE, + number=131, + message="K8sBetaAPIConfig", + ) class AdditionalPodRangesConfig(proto.Message): @@ -5411,6 +5464,34 @@ class AvailableVersion(proto.Message): ) +class BestEffortProvisioning(proto.Message): + r"""Best effort provisioning. + + Attributes: + enabled (bool): + When this is enabled, cluster/node pool + creations will ignore non-fatal errors like + stockout to best provision as many nodes as + possible right now and eventually bring up all + target number of nodes + min_provision_nodes (int): + Minimum number of nodes to be provisioned to + be considered as succeeded, and the rest of + nodes will be provisioned gradually and + eventually when stockout issue has been + resolved. + """ + + enabled: bool = proto.Field( + proto.BOOL, + number=1, + ) + min_provision_nodes: int = proto.Field( + proto.INT32, + number=2, + ) + + class WindowsVersions(proto.Message): r"""Windows server versions. @@ -5829,6 +5910,8 @@ class NodePool(proto.Message): on the value of node pool fields, and may be sent on update requests to ensure the client has an up-to-date value before proceeding. + best_effort_provisioning (google.cloud.container_v1beta1.types.BestEffortProvisioning): + Enable best effort provisioning for nodes """ class Status(proto.Enum): @@ -6150,6 +6233,11 @@ class Type(proto.Enum): proto.STRING, number=110, ) + best_effort_provisioning: "BestEffortProvisioning" = proto.Field( + proto.MESSAGE, + number=113, + message="BestEffortProvisioning", + ) class NodeManagement(proto.Message): @@ -7615,6 +7703,9 @@ class NetworkConfig(proto.Message): r"""NetworkConfig reports the relative names of network & subnetwork. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: network (str): Output only. The relative name of the Google Compute Engine @@ -7658,6 +7749,11 @@ class NetworkConfig(proto.Message): gateway_api_config (google.cloud.container_v1beta1.types.GatewayAPIConfig): GatewayAPIConfig contains the desired config of Gateway API on this cluster. + enable_fqdn_network_policy (bool): + Whether FQDN Network Policy is enabled on + this cluster. + + This field is a member of `oneof`_ ``_enable_fqdn_network_policy``. """ network: str = proto.Field( @@ -7706,6 +7802,11 @@ class NetworkConfig(proto.Message): number=16, message="GatewayAPIConfig", ) + enable_fqdn_network_policy: bool = proto.Field( + proto.BOOL, + number=19, + optional=True, + ) class GatewayAPIConfig(proto.Message): @@ -8509,6 +8610,119 @@ class GetJSONWebKeysResponse(proto.Message): ) +class CheckAutopilotCompatibilityRequest(proto.Message): + r"""CheckAutopilotCompatibilityRequest requests getting the + blockers for the given operation in the cluster. + + Attributes: + name (str): + The name (project, location, cluster) of the cluster to + retrieve. Specified in the format + ``projects/*/locations/*/clusters/*``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class AutopilotCompatibilityIssue(proto.Message): + r"""AutopilotCompatibilityIssue contains information about a + specific compatibility issue with Autopilot mode. + + Attributes: + last_observation (google.protobuf.timestamp_pb2.Timestamp): + The last time when this issue was observed. + constraint_type (str): + The constraint type of the issue. + incompatibility_type (google.cloud.container_v1beta1.types.AutopilotCompatibilityIssue.IssueType): + The incompatibility type of this issue. + subjects (MutableSequence[str]): + The name of the resources which are subject + to this issue. + documentation_url (str): + A URL to a public documnetation, which + addresses resolving this issue. + description (str): + The description of the issue. + """ + + class IssueType(proto.Enum): + r"""The type of the reported issue. + + Values: + UNSPECIFIED (0): + Default value, should not be used. + INCOMPATIBILITY (1): + Indicates that the issue is a known + incompatibility between the cluster and + Autopilot mode. + ADDITIONAL_CONFIG_REQUIRED (2): + Indicates the issue is an incompatibility if + customers take no further action to resolve. + PASSED_WITH_OPTIONAL_CONFIG (3): + Indicates the issue is not an + incompatibility, but depending on the workloads + business logic, there is a potential that they + won't work on Autopilot. + """ + UNSPECIFIED = 0 + INCOMPATIBILITY = 1 + ADDITIONAL_CONFIG_REQUIRED = 2 + PASSED_WITH_OPTIONAL_CONFIG = 3 + + last_observation: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + constraint_type: str = proto.Field( + proto.STRING, + number=2, + ) + incompatibility_type: IssueType = proto.Field( + proto.ENUM, + number=3, + enum=IssueType, + ) + subjects: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=4, + ) + documentation_url: str = proto.Field( + proto.STRING, + number=5, + ) + description: str = proto.Field( + proto.STRING, + number=6, + ) + + +class CheckAutopilotCompatibilityResponse(proto.Message): + r"""CheckAutopilotCompatibilityResponse has a list of + compatibility issues. + + Attributes: + issues (MutableSequence[google.cloud.container_v1beta1.types.AutopilotCompatibilityIssue]): + The list of issues for the given operation. + summary (str): + The summary of the autopilot compatibility + response. + """ + + issues: MutableSequence["AutopilotCompatibilityIssue"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="AutopilotCompatibilityIssue", + ) + summary: str = proto.Field( + proto.STRING, + number=2, + ) + + class ReleaseChannel(proto.Message): r"""ReleaseChannel indicates which release channel a cluster is subscribed to. Release channels are arranged in order of risk. diff --git a/samples/generated_samples/container_v1_generated_cluster_manager_check_autopilot_compatibility_async.py b/samples/generated_samples/container_v1_generated_cluster_manager_check_autopilot_compatibility_async.py new file mode 100644 index 00000000..d459f738 --- /dev/null +++ b/samples/generated_samples/container_v1_generated_cluster_manager_check_autopilot_compatibility_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CheckAutopilotCompatibility +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-container + + +# [START container_v1_generated_ClusterManager_CheckAutopilotCompatibility_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import container_v1 + + +async def sample_check_autopilot_compatibility(): + # Create a client + client = container_v1.ClusterManagerAsyncClient() + + # Initialize request argument(s) + request = container_v1.CheckAutopilotCompatibilityRequest( + ) + + # Make the request + response = await client.check_autopilot_compatibility(request=request) + + # Handle the response + print(response) + +# [END container_v1_generated_ClusterManager_CheckAutopilotCompatibility_async] diff --git a/samples/generated_samples/container_v1_generated_cluster_manager_check_autopilot_compatibility_sync.py b/samples/generated_samples/container_v1_generated_cluster_manager_check_autopilot_compatibility_sync.py new file mode 100644 index 00000000..db544a70 --- /dev/null +++ b/samples/generated_samples/container_v1_generated_cluster_manager_check_autopilot_compatibility_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CheckAutopilotCompatibility +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-container + + +# [START container_v1_generated_ClusterManager_CheckAutopilotCompatibility_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import container_v1 + + +def sample_check_autopilot_compatibility(): + # Create a client + client = container_v1.ClusterManagerClient() + + # Initialize request argument(s) + request = container_v1.CheckAutopilotCompatibilityRequest( + ) + + # Make the request + response = client.check_autopilot_compatibility(request=request) + + # Handle the response + print(response) + +# [END container_v1_generated_ClusterManager_CheckAutopilotCompatibility_sync] diff --git a/samples/generated_samples/container_v1beta1_generated_cluster_manager_check_autopilot_compatibility_async.py b/samples/generated_samples/container_v1beta1_generated_cluster_manager_check_autopilot_compatibility_async.py new file mode 100644 index 00000000..30da40c5 --- /dev/null +++ b/samples/generated_samples/container_v1beta1_generated_cluster_manager_check_autopilot_compatibility_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CheckAutopilotCompatibility +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-container + + +# [START container_v1beta1_generated_ClusterManager_CheckAutopilotCompatibility_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import container_v1beta1 + + +async def sample_check_autopilot_compatibility(): + # Create a client + client = container_v1beta1.ClusterManagerAsyncClient() + + # Initialize request argument(s) + request = container_v1beta1.CheckAutopilotCompatibilityRequest( + ) + + # Make the request + response = await client.check_autopilot_compatibility(request=request) + + # Handle the response + print(response) + +# [END container_v1beta1_generated_ClusterManager_CheckAutopilotCompatibility_async] diff --git a/samples/generated_samples/container_v1beta1_generated_cluster_manager_check_autopilot_compatibility_sync.py b/samples/generated_samples/container_v1beta1_generated_cluster_manager_check_autopilot_compatibility_sync.py new file mode 100644 index 00000000..89d43c28 --- /dev/null +++ b/samples/generated_samples/container_v1beta1_generated_cluster_manager_check_autopilot_compatibility_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CheckAutopilotCompatibility +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-container + + +# [START container_v1beta1_generated_ClusterManager_CheckAutopilotCompatibility_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud import container_v1beta1 + + +def sample_check_autopilot_compatibility(): + # Create a client + client = container_v1beta1.ClusterManagerClient() + + # Initialize request argument(s) + request = container_v1beta1.CheckAutopilotCompatibilityRequest( + ) + + # Make the request + response = client.check_autopilot_compatibility(request=request) + + # Handle the response + print(response) + +# [END container_v1beta1_generated_ClusterManager_CheckAutopilotCompatibility_sync] diff --git a/samples/generated_samples/snippet_metadata_google.container.v1.json b/samples/generated_samples/snippet_metadata_google.container.v1.json index 35acfe2c..477de1ee 100644 --- a/samples/generated_samples/snippet_metadata_google.container.v1.json +++ b/samples/generated_samples/snippet_metadata_google.container.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-container", - "version": "2.22.0" + "version": "0.1.0" }, "snippets": [ { @@ -190,6 +190,159 @@ ], "title": "container_v1_generated_cluster_manager_cancel_operation_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.container_v1.ClusterManagerAsyncClient", + "shortName": "ClusterManagerAsyncClient" + }, + "fullName": "google.cloud.container_v1.ClusterManagerAsyncClient.check_autopilot_compatibility", + "method": { + "fullName": "google.container.v1.ClusterManager.CheckAutopilotCompatibility", + "service": { + "fullName": "google.container.v1.ClusterManager", + "shortName": "ClusterManager" + }, + "shortName": "CheckAutopilotCompatibility" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.container_v1.types.CheckAutopilotCompatibilityRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.container_v1.types.CheckAutopilotCompatibilityResponse", + "shortName": "check_autopilot_compatibility" + }, + "description": "Sample for CheckAutopilotCompatibility", + "file": "container_v1_generated_cluster_manager_check_autopilot_compatibility_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "container_v1_generated_ClusterManager_CheckAutopilotCompatibility_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "container_v1_generated_cluster_manager_check_autopilot_compatibility_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.container_v1.ClusterManagerClient", + "shortName": "ClusterManagerClient" + }, + "fullName": "google.cloud.container_v1.ClusterManagerClient.check_autopilot_compatibility", + "method": { + "fullName": "google.container.v1.ClusterManager.CheckAutopilotCompatibility", + "service": { + "fullName": "google.container.v1.ClusterManager", + "shortName": "ClusterManager" + }, + "shortName": "CheckAutopilotCompatibility" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.container_v1.types.CheckAutopilotCompatibilityRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.container_v1.types.CheckAutopilotCompatibilityResponse", + "shortName": "check_autopilot_compatibility" + }, + "description": "Sample for CheckAutopilotCompatibility", + "file": "container_v1_generated_cluster_manager_check_autopilot_compatibility_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "container_v1_generated_ClusterManager_CheckAutopilotCompatibility_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "container_v1_generated_cluster_manager_check_autopilot_compatibility_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/samples/generated_samples/snippet_metadata_google.container.v1beta1.json b/samples/generated_samples/snippet_metadata_google.container.v1beta1.json index d94eac8d..afdb562b 100644 --- a/samples/generated_samples/snippet_metadata_google.container.v1beta1.json +++ b/samples/generated_samples/snippet_metadata_google.container.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-container", - "version": "2.22.0" + "version": "0.1.0" }, "snippets": [ { @@ -182,6 +182,159 @@ ], "title": "container_v1beta1_generated_cluster_manager_cancel_operation_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.container_v1beta1.ClusterManagerAsyncClient", + "shortName": "ClusterManagerAsyncClient" + }, + "fullName": "google.cloud.container_v1beta1.ClusterManagerAsyncClient.check_autopilot_compatibility", + "method": { + "fullName": "google.container.v1beta1.ClusterManager.CheckAutopilotCompatibility", + "service": { + "fullName": "google.container.v1beta1.ClusterManager", + "shortName": "ClusterManager" + }, + "shortName": "CheckAutopilotCompatibility" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.container_v1beta1.types.CheckAutopilotCompatibilityRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.container_v1beta1.types.CheckAutopilotCompatibilityResponse", + "shortName": "check_autopilot_compatibility" + }, + "description": "Sample for CheckAutopilotCompatibility", + "file": "container_v1beta1_generated_cluster_manager_check_autopilot_compatibility_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "container_v1beta1_generated_ClusterManager_CheckAutopilotCompatibility_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "container_v1beta1_generated_cluster_manager_check_autopilot_compatibility_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.container_v1beta1.ClusterManagerClient", + "shortName": "ClusterManagerClient" + }, + "fullName": "google.cloud.container_v1beta1.ClusterManagerClient.check_autopilot_compatibility", + "method": { + "fullName": "google.container.v1beta1.ClusterManager.CheckAutopilotCompatibility", + "service": { + "fullName": "google.container.v1beta1.ClusterManager", + "shortName": "ClusterManager" + }, + "shortName": "CheckAutopilotCompatibility" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.container_v1beta1.types.CheckAutopilotCompatibilityRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.container_v1beta1.types.CheckAutopilotCompatibilityResponse", + "shortName": "check_autopilot_compatibility" + }, + "description": "Sample for CheckAutopilotCompatibility", + "file": "container_v1beta1_generated_cluster_manager_check_autopilot_compatibility_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "container_v1beta1_generated_ClusterManager_CheckAutopilotCompatibility_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "container_v1beta1_generated_cluster_manager_check_autopilot_compatibility_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/scripts/fixup_container_v1_keywords.py b/scripts/fixup_container_v1_keywords.py index 80b16377..2d51f43f 100644 --- a/scripts/fixup_container_v1_keywords.py +++ b/scripts/fixup_container_v1_keywords.py @@ -40,6 +40,7 @@ class containerCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'cancel_operation': ('project_id', 'zone', 'operation_id', 'name', ), + 'check_autopilot_compatibility': ('name', ), 'complete_ip_rotation': ('project_id', 'zone', 'cluster_id', 'name', ), 'complete_node_pool_upgrade': ('name', ), 'create_cluster': ('cluster', 'project_id', 'zone', 'parent', ), diff --git a/scripts/fixup_container_v1beta1_keywords.py b/scripts/fixup_container_v1beta1_keywords.py index 4284707b..17b1b0aa 100644 --- a/scripts/fixup_container_v1beta1_keywords.py +++ b/scripts/fixup_container_v1beta1_keywords.py @@ -40,6 +40,7 @@ class containerCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'cancel_operation': ('project_id', 'zone', 'operation_id', 'name', ), + 'check_autopilot_compatibility': ('name', ), 'complete_ip_rotation': ('project_id', 'zone', 'cluster_id', 'name', ), 'complete_node_pool_upgrade': ('name', ), 'create_cluster': ('project_id', 'zone', 'cluster', 'parent', ), diff --git a/tests/unit/gapic/container_v1/test_cluster_manager.py b/tests/unit/gapic/container_v1/test_cluster_manager.py index fce41dee..ab4d44fe 100644 --- a/tests/unit/gapic/container_v1/test_cluster_manager.py +++ b/tests/unit/gapic/container_v1/test_cluster_manager.py @@ -9931,6 +9931,167 @@ async def test_list_usable_subnetworks_async_pages(): assert page_.raw_page.next_page_token == token +@pytest.mark.parametrize( + "request_type", + [ + cluster_service.CheckAutopilotCompatibilityRequest, + dict, + ], +) +def test_check_autopilot_compatibility(request_type, transport: str = "grpc"): + client = ClusterManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_autopilot_compatibility), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = cluster_service.CheckAutopilotCompatibilityResponse( + summary="summary_value", + ) + response = client.check_autopilot_compatibility(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == cluster_service.CheckAutopilotCompatibilityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, cluster_service.CheckAutopilotCompatibilityResponse) + assert response.summary == "summary_value" + + +def test_check_autopilot_compatibility_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 = ClusterManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_autopilot_compatibility), "__call__" + ) as call: + client.check_autopilot_compatibility() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == cluster_service.CheckAutopilotCompatibilityRequest() + + +@pytest.mark.asyncio +async def test_check_autopilot_compatibility_async( + transport: str = "grpc_asyncio", + request_type=cluster_service.CheckAutopilotCompatibilityRequest, +): + client = ClusterManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_autopilot_compatibility), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cluster_service.CheckAutopilotCompatibilityResponse( + summary="summary_value", + ) + ) + response = await client.check_autopilot_compatibility(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == cluster_service.CheckAutopilotCompatibilityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, cluster_service.CheckAutopilotCompatibilityResponse) + assert response.summary == "summary_value" + + +@pytest.mark.asyncio +async def test_check_autopilot_compatibility_async_from_dict(): + await test_check_autopilot_compatibility_async(request_type=dict) + + +def test_check_autopilot_compatibility_field_headers(): + client = ClusterManagerClient( + 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 = cluster_service.CheckAutopilotCompatibilityRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_autopilot_compatibility), "__call__" + ) as call: + call.return_value = cluster_service.CheckAutopilotCompatibilityResponse() + client.check_autopilot_compatibility(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_check_autopilot_compatibility_field_headers_async(): + client = ClusterManagerAsyncClient( + 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 = cluster_service.CheckAutopilotCompatibilityRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_autopilot_compatibility), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cluster_service.CheckAutopilotCompatibilityResponse() + ) + await client.check_autopilot_compatibility(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ClusterManagerGrpcTransport( @@ -10101,6 +10262,7 @@ def test_cluster_manager_base_transport(): "set_network_policy", "set_maintenance_policy", "list_usable_subnetworks", + "check_autopilot_compatibility", ) for method in methods: with pytest.raises(NotImplementedError): diff --git a/tests/unit/gapic/container_v1beta1/test_cluster_manager.py b/tests/unit/gapic/container_v1beta1/test_cluster_manager.py index c299d152..014f8e8f 100644 --- a/tests/unit/gapic/container_v1beta1/test_cluster_manager.py +++ b/tests/unit/gapic/container_v1beta1/test_cluster_manager.py @@ -10043,6 +10043,167 @@ async def test_list_usable_subnetworks_async_pages(): assert page_.raw_page.next_page_token == token +@pytest.mark.parametrize( + "request_type", + [ + cluster_service.CheckAutopilotCompatibilityRequest, + dict, + ], +) +def test_check_autopilot_compatibility(request_type, transport: str = "grpc"): + client = ClusterManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_autopilot_compatibility), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = cluster_service.CheckAutopilotCompatibilityResponse( + summary="summary_value", + ) + response = client.check_autopilot_compatibility(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == cluster_service.CheckAutopilotCompatibilityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, cluster_service.CheckAutopilotCompatibilityResponse) + assert response.summary == "summary_value" + + +def test_check_autopilot_compatibility_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 = ClusterManagerClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_autopilot_compatibility), "__call__" + ) as call: + client.check_autopilot_compatibility() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == cluster_service.CheckAutopilotCompatibilityRequest() + + +@pytest.mark.asyncio +async def test_check_autopilot_compatibility_async( + transport: str = "grpc_asyncio", + request_type=cluster_service.CheckAutopilotCompatibilityRequest, +): + client = ClusterManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_autopilot_compatibility), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cluster_service.CheckAutopilotCompatibilityResponse( + summary="summary_value", + ) + ) + response = await client.check_autopilot_compatibility(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == cluster_service.CheckAutopilotCompatibilityRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, cluster_service.CheckAutopilotCompatibilityResponse) + assert response.summary == "summary_value" + + +@pytest.mark.asyncio +async def test_check_autopilot_compatibility_async_from_dict(): + await test_check_autopilot_compatibility_async(request_type=dict) + + +def test_check_autopilot_compatibility_field_headers(): + client = ClusterManagerClient( + 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 = cluster_service.CheckAutopilotCompatibilityRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_autopilot_compatibility), "__call__" + ) as call: + call.return_value = cluster_service.CheckAutopilotCompatibilityResponse() + client.check_autopilot_compatibility(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_check_autopilot_compatibility_field_headers_async(): + client = ClusterManagerAsyncClient( + 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 = cluster_service.CheckAutopilotCompatibilityRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_autopilot_compatibility), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cluster_service.CheckAutopilotCompatibilityResponse() + ) + await client.check_autopilot_compatibility(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + @pytest.mark.parametrize( "request_type", [ @@ -10446,6 +10607,7 @@ def test_cluster_manager_base_transport(): "set_network_policy", "set_maintenance_policy", "list_usable_subnetworks", + "check_autopilot_compatibility", "list_locations", ) for method in methods: