diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/async_client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/async_client.py index c3f55deaebb6..5bf8dd9b585b 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/async_client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/async_client.py @@ -204,6 +204,7 @@ async def get_application( self, request: Union[appengine.GetApplicationRequest, dict] = None, *, + name: str = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -232,6 +233,13 @@ async def sample_get_application(): request (Union[google.cloud.appengine_admin_v1.types.GetApplicationRequest, dict]): The request object. Request message for `Applications.GetApplication`. + name (:class:`str`): + Name of the Application resource to get. Example: + ``apps/myapp``. + + 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. @@ -246,8 +254,22 @@ async def sample_get_application(): """ # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + request = appengine.GetApplicationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = gapic_v1.method_async.wrap_method( @@ -378,6 +400,8 @@ async def update_application( controlling user access to the application. - ``default_cookie_expiration`` - Cookie expiration policy for the application. + - ``iap`` - Identity-Aware Proxy properties for the + application. .. code-block:: python diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/client.py index a7639dd2bfe7..59b9cd811805 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/client.py @@ -410,6 +410,7 @@ def get_application( self, request: Union[appengine.GetApplicationRequest, dict] = None, *, + name: str = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -438,6 +439,13 @@ def sample_get_application(): request (Union[google.cloud.appengine_admin_v1.types.GetApplicationRequest, dict]): The request object. Request message for `Applications.GetApplication`. + name (str): + Name of the Application resource to get. Example: + ``apps/myapp``. + + 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. @@ -452,12 +460,25 @@ def sample_get_application(): """ # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + # Minor optimization to avoid making a copy if the user passes # in a appengine.GetApplicationRequest. # There's no risk of modifying the input as we've already verified # there are no flattened fields. if not isinstance(request, appengine.GetApplicationRequest): request = appengine.GetApplicationRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -586,6 +607,8 @@ def update_application( controlling user access to the application. - ``default_cookie_expiration`` - Cookie expiration policy for the application. + - ``iap`` - Identity-Aware Proxy properties for the + application. .. code-block:: python diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc.py index cc65019afe17..53f5dbeff95b 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc.py @@ -320,6 +320,8 @@ def update_application( controlling user access to the application. - ``default_cookie_expiration`` - Cookie expiration policy for the application. + - ``iap`` - Identity-Aware Proxy properties for the + application. Returns: Callable[[~.UpdateApplicationRequest], diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc_asyncio.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc_asyncio.py index f93b2baa5de1..a4315b9cd1e2 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc_asyncio.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc_asyncio.py @@ -331,6 +331,8 @@ def update_application( controlling user access to the application. - ``default_cookie_expiration`` - Cookie expiration policy for the application. + - ``iap`` - Identity-Aware Proxy properties for the + application. Returns: Callable[[~.UpdateApplicationRequest], diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/appengine.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/appengine.py index be1229654c30..f4427c28d1f3 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/appengine.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/appengine.py @@ -142,8 +142,8 @@ class UpdateApplicationRequest(proto.Message): An Application containing the updated resource. update_mask (google.protobuf.field_mask_pb2.FieldMask): - Standard field mask for the set of fields to - be updated. + Required. Standard field mask for the set of + fields to be updated. """ name = proto.Field( @@ -258,8 +258,8 @@ class UpdateServiceRequest(proto.Message): service. Only fields set in the field mask will be updated. update_mask (google.protobuf.field_mask_pb2.FieldMask): - Standard field mask for the set of fields to - be updated. + Required. Standard field mask for the set of + fields to be updated. migrate_traffic (bool): Set to ``true`` to gradually shift traffic to one or more versions that you specify. By default, traffic is shifted @@ -1101,8 +1101,8 @@ class UpdateDomainMappingRequest(proto.Message): resource. Only fields set in the field mask will be updated. update_mask (google.protobuf.field_mask_pb2.FieldMask): - Standard field mask for the set of fields to - be updated. + Required. Standard field mask for the set of + fields to be updated. """ name = proto.Field( diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/application.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/application.py index 263562dc7aa4..f7687e517bb8 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/application.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/application.py @@ -83,6 +83,11 @@ class Application(proto.Message): by this application to store content. @OutputOnly + service_account (str): + The service account associated with the + application. This is the app-level default + identity. If no identity provided during create + version, Admin API will fallback to this one. iap (google.cloud.appengine_admin_v1.types.Application.IdentityAwareProxy): gcr_domain (str): @@ -226,6 +231,10 @@ class FeatureSettings(proto.Message): proto.STRING, number=12, ) + service_account = proto.Field( + proto.STRING, + number=13, + ) iap = proto.Field( proto.MESSAGE, number=14, diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/service.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/service.py index 77e26086b0ca..c42ffeca730a 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/service.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/service.py @@ -54,6 +54,24 @@ class Service(proto.Message): Mapping that defines fractional HTTP traffic diversion to different versions within the service. + labels (Mapping[str, str]): + A set of labels to apply to this service. + Labels are key/value pairs that describe the + service and all resources that belong to it + (e.g., versions). The labels can be used to + search and group resources, and are propagated + to the usage and billing reports, enabling + fine-grain analysis of costs. An example of + using labels is to tag resources belonging to + different environments (e.g., "env=prod", + "env=qa"). +

Label keys and values can be no longer than + 63 characters and can only contain lowercase + letters, numeric characters, underscores, + dashes, and international characters. Label keys + must start with a lowercase letter or an + international character. Each service can have + at most 32 labels. network_settings (google.cloud.appengine_admin_v1.types.NetworkSettings): Ingress settings for this service. Will apply to all versions. @@ -72,6 +90,11 @@ class Service(proto.Message): number=3, message="TrafficSplit", ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) network_settings = proto.Field( proto.MESSAGE, number=6, diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/version.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/version.py index 7ea30287ac0e..0bd545809232 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/version.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/types/version.py @@ -148,6 +148,9 @@ class Version(proto.Message): vm (bool): Whether to deploy this version in a container on a virtual machine. + app_engine_apis (bool): + Allows App Engine second generation runtimes + to access the legacy bundled services. beta_settings (Mapping[str, str]): Metadata settings that are supplied to this version to enable beta runtime features. @@ -330,6 +333,10 @@ class Version(proto.Message): proto.BOOL, number=12, ) + app_engine_apis = proto.Field( + proto.BOOL, + number=128, + ) beta_settings = proto.MapField( proto.STRING, proto.STRING, @@ -964,12 +971,30 @@ class VpcAccessConnector(proto.Message): Full Serverless VPC Access Connector name e.g. /projects/my-project/locations/us-central1/connectors/c1. + egress_setting (google.cloud.appengine_admin_v1.types.VpcAccessConnector.EgressSetting): + The egress setting for the connector, + controlling what traffic is diverted through it. """ + class EgressSetting(proto.Enum): + r"""Available egress settings. + + This controls what traffic is diverted through the VPC Access + Connector resource. By default PRIVATE_IP_RANGES will be used. + """ + EGRESS_SETTING_UNSPECIFIED = 0 + ALL_TRAFFIC = 1 + PRIVATE_IP_RANGES = 2 + name = proto.Field( proto.STRING, number=1, ) + egress_setting = proto.Field( + proto.ENUM, + number=2, + enum=EgressSetting, + ) class Entrypoint(proto.Message): diff --git a/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_appengine admin_v1.json b/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_appengine admin_v1.json index 7d498a2625de..a3212d28fea3 100644 --- a/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_appengine admin_v1.json +++ b/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_appengine admin_v1.json @@ -185,6 +185,10 @@ "name": "request", "type": "google.cloud.appengine_admin_v1.types.GetApplicationRequest" }, + { + "name": "name", + "type": "str" + }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -261,6 +265,10 @@ "name": "request", "type": "google.cloud.appengine_admin_v1.types.GetApplicationRequest" }, + { + "name": "name", + "type": "str" + }, { "name": "retry", "type": "google.api_core.retry.Retry" diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py index f3ccc2a93a81..205bbeb38a4c 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py @@ -675,6 +675,7 @@ def test_get_application(request_type, transport: str = "grpc"): serving_status=application.Application.ServingStatus.SERVING, default_hostname="default_hostname_value", default_bucket="default_bucket_value", + service_account="service_account_value", gcr_domain="gcr_domain_value", database_type=application.Application.DatabaseType.CLOUD_DATASTORE, ) @@ -695,6 +696,7 @@ def test_get_application(request_type, transport: str = "grpc"): assert response.serving_status == application.Application.ServingStatus.SERVING assert response.default_hostname == "default_hostname_value" assert response.default_bucket == "default_bucket_value" + assert response.service_account == "service_account_value" assert response.gcr_domain == "gcr_domain_value" assert ( response.database_type == application.Application.DatabaseType.CLOUD_DATASTORE @@ -743,6 +745,7 @@ async def test_get_application_async( serving_status=application.Application.ServingStatus.SERVING, default_hostname="default_hostname_value", default_bucket="default_bucket_value", + service_account="service_account_value", gcr_domain="gcr_domain_value", database_type=application.Application.DatabaseType.CLOUD_DATASTORE, ) @@ -764,6 +767,7 @@ async def test_get_application_async( assert response.serving_status == application.Application.ServingStatus.SERVING assert response.default_hostname == "default_hostname_value" assert response.default_bucket == "default_bucket_value" + assert response.service_account == "service_account_value" assert response.gcr_domain == "gcr_domain_value" assert ( response.database_type == application.Application.DatabaseType.CLOUD_DATASTORE @@ -836,6 +840,88 @@ async def test_get_application_field_headers_async(): ) in kw["metadata"] +def test_get_application_flattened(): + client = ApplicationsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_application), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = application.Application() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_application( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_application_flattened_error(): + client = ApplicationsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_application( + appengine.GetApplicationRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_application_flattened_async(): + client = ApplicationsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_application), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = application.Application() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + application.Application() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_application( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_application_flattened_error_async(): + client = ApplicationsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_application( + appengine.GetApplicationRequest(), + name="name_value", + ) + + @pytest.mark.parametrize( "request_type", [ diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py index ba0ef0362cd2..9bf3cd12cb22 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py @@ -994,6 +994,7 @@ def test_get_version(request_type, transport: str = "grpc"): runtime_channel="runtime_channel_value", threadsafe=True, vm=True, + app_engine_apis=True, env="env_value", serving_status=version.ServingStatus.SERVING, created_by="created_by_value", @@ -1027,6 +1028,7 @@ def test_get_version(request_type, transport: str = "grpc"): assert response.runtime_channel == "runtime_channel_value" assert response.threadsafe is True assert response.vm is True + assert response.app_engine_apis is True assert response.env == "env_value" assert response.serving_status == version.ServingStatus.SERVING assert response.created_by == "created_by_value" @@ -1081,6 +1083,7 @@ async def test_get_version_async( runtime_channel="runtime_channel_value", threadsafe=True, vm=True, + app_engine_apis=True, env="env_value", serving_status=version.ServingStatus.SERVING, created_by="created_by_value", @@ -1112,6 +1115,7 @@ async def test_get_version_async( assert response.runtime_channel == "runtime_channel_value" assert response.threadsafe is True assert response.vm is True + assert response.app_engine_apis is True assert response.env == "env_value" assert response.serving_status == version.ServingStatus.SERVING assert response.created_by == "created_by_value"