diff --git a/packages/google-cloud-compute/google/cloud/compute/__init__.py b/packages/google-cloud-compute/google/cloud/compute/__init__.py index 406a6ba53398..17634defb96d 100644 --- a/packages/google-cloud-compute/google/cloud/compute/__init__.py +++ b/packages/google-cloud-compute/google/cloud/compute/__init__.py @@ -294,6 +294,7 @@ AggregatedListNetworkAttachmentsRequest, AggregatedListNetworkEdgeSecurityServicesRequest, AggregatedListNetworkEndpointGroupsRequest, + AggregatedListNetworkFirewallPoliciesRequest, AggregatedListNodeGroupsRequest, AggregatedListNodeTemplatesRequest, AggregatedListNodeTypesRequest, @@ -560,6 +561,7 @@ FirewallList, FirewallLogConfig, FirewallPoliciesListAssociationsResponse, + FirewallPoliciesScopedList, FirewallPolicy, FirewallPolicyAssociation, FirewallPolicyList, @@ -1137,6 +1139,7 @@ NetworkEndpointGroupsListNetworkEndpoints, NetworkEndpointGroupsScopedList, NetworkEndpointWithHealthStatus, + NetworkFirewallPolicyAggregatedList, NetworkInterface, NetworkList, NetworkPeering, @@ -1919,6 +1922,7 @@ "AggregatedListNetworkAttachmentsRequest", "AggregatedListNetworkEdgeSecurityServicesRequest", "AggregatedListNetworkEndpointGroupsRequest", + "AggregatedListNetworkFirewallPoliciesRequest", "AggregatedListNodeGroupsRequest", "AggregatedListNodeTemplatesRequest", "AggregatedListNodeTypesRequest", @@ -2185,6 +2189,7 @@ "FirewallList", "FirewallLogConfig", "FirewallPoliciesListAssociationsResponse", + "FirewallPoliciesScopedList", "FirewallPolicy", "FirewallPolicyAssociation", "FirewallPolicyList", @@ -2762,6 +2767,7 @@ "NetworkEndpointGroupsListNetworkEndpoints", "NetworkEndpointGroupsScopedList", "NetworkEndpointWithHealthStatus", + "NetworkFirewallPolicyAggregatedList", "NetworkInterface", "NetworkList", "NetworkPeering", diff --git a/packages/google-cloud-compute/google/cloud/compute/gapic_version.py b/packages/google-cloud-compute/google/cloud/compute/gapic_version.py index c8313abd74cb..558c8aab67c5 100644 --- a/packages/google-cloud-compute/google/cloud/compute/gapic_version.py +++ b/packages/google-cloud-compute/google/cloud/compute/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.23.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/__init__.py b/packages/google-cloud-compute/google/cloud/compute_v1/__init__.py index de8581c432cf..cdd7b1d58cff 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/__init__.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/__init__.py @@ -176,6 +176,7 @@ AggregatedListNetworkAttachmentsRequest, AggregatedListNetworkEdgeSecurityServicesRequest, AggregatedListNetworkEndpointGroupsRequest, + AggregatedListNetworkFirewallPoliciesRequest, AggregatedListNodeGroupsRequest, AggregatedListNodeTemplatesRequest, AggregatedListNodeTypesRequest, @@ -442,6 +443,7 @@ FirewallList, FirewallLogConfig, FirewallPoliciesListAssociationsResponse, + FirewallPoliciesScopedList, FirewallPolicy, FirewallPolicyAssociation, FirewallPolicyList, @@ -1019,6 +1021,7 @@ NetworkEndpointGroupsListNetworkEndpoints, NetworkEndpointGroupsScopedList, NetworkEndpointWithHealthStatus, + NetworkFirewallPolicyAggregatedList, NetworkInterface, NetworkList, NetworkPeering, @@ -1705,6 +1708,7 @@ "AggregatedListNetworkAttachmentsRequest", "AggregatedListNetworkEdgeSecurityServicesRequest", "AggregatedListNetworkEndpointGroupsRequest", + "AggregatedListNetworkFirewallPoliciesRequest", "AggregatedListNodeGroupsRequest", "AggregatedListNodeTemplatesRequest", "AggregatedListNodeTypesRequest", @@ -1977,6 +1981,7 @@ "FirewallLogConfig", "FirewallPoliciesClient", "FirewallPoliciesListAssociationsResponse", + "FirewallPoliciesScopedList", "FirewallPolicy", "FirewallPolicyAssociation", "FirewallPolicyList", @@ -2584,6 +2589,7 @@ "NetworkEndpointGroupsScopedList", "NetworkEndpointWithHealthStatus", "NetworkFirewallPoliciesClient", + "NetworkFirewallPolicyAggregatedList", "NetworkInterface", "NetworkList", "NetworkPeering", diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/gapic_metadata.json b/packages/google-cloud-compute/google/cloud/compute_v1/gapic_metadata.json index 4cc069ff2947..dc47fbee26c3 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/gapic_metadata.json +++ b/packages/google-cloud-compute/google/cloud/compute_v1/gapic_metadata.json @@ -1972,6 +1972,11 @@ "add_rule" ] }, + "AggregatedList": { + "methods": [ + "aggregated_list" + ] + }, "CloneRules": { "methods": [ "clone_rules" diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/gapic_version.py b/packages/google-cloud-compute/google/cloud/compute_v1/gapic_version.py index c8313abd74cb..558c8aab67c5 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/gapic_version.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.23.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/client.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/client.py index 86042cde4d69..df2bdb1b42c1 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/client.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/client.py @@ -1255,6 +1255,131 @@ def error_code(self): # Done; return the response. return response + def aggregated_list( + self, + request: Optional[ + Union[compute.AggregatedListNetworkFirewallPoliciesRequest, dict] + ] = None, + *, + project: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.AggregatedListPager: + r"""Retrieves an aggregated list of network firewall policies, + listing network firewall policies from all applicable scopes + (global and regional) and grouping the results per scope. To + prevent failure, Google recommends that you set the + ``returnPartialSuccess`` parameter to ``true``. + + .. 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 compute_v1 + + def sample_aggregated_list(): + # Create a client + client = compute_v1.NetworkFirewallPoliciesClient() + + # Initialize request argument(s) + request = compute_v1.AggregatedListNetworkFirewallPoliciesRequest( + project="project_value", + ) + + # Make the request + page_result = client.aggregated_list(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.compute_v1.types.AggregatedListNetworkFirewallPoliciesRequest, dict]): + The request object. A request message for + NetworkFirewallPolicies.AggregatedList. + See the method description for details. + project (str): + Project ID for this request. + This corresponds to the ``project`` 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. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.compute_v1.services.network_firewall_policies.pagers.AggregatedListPager: + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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([project]) + 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." + ) + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance( + request, compute.AggregatedListNetworkFirewallPoliciesRequest + ): + request = compute.AggregatedListNetworkFirewallPoliciesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if project is not None: + request.project = project + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.aggregated_list] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("project", request.project),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.AggregatedListPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def clone_rules_unary( self, request: Optional[ diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/pagers.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/pagers.py index 5e1a7afcaeeb..b66397a23560 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/pagers.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/pagers.py @@ -41,6 +41,85 @@ from google.cloud.compute_v1.types import compute +class AggregatedListPager: + """A pager for iterating through ``aggregated_list`` requests. + + This class thinly wraps an initial + :class:`google.cloud.compute_v1.types.NetworkFirewallPolicyAggregatedList` object, and + provides an ``__iter__`` method to iterate through its + ``items`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``AggregatedList`` requests and continue to iterate + through the ``items`` field on the + corresponding responses. + + All the usual :class:`google.cloud.compute_v1.types.NetworkFirewallPolicyAggregatedList` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., compute.NetworkFirewallPolicyAggregatedList], + request: compute.AggregatedListNetworkFirewallPoliciesRequest, + response: compute.NetworkFirewallPolicyAggregatedList, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.compute_v1.types.AggregatedListNetworkFirewallPoliciesRequest): + The initial request object. + response (google.cloud.compute_v1.types.NetworkFirewallPolicyAggregatedList): + The initial response object. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = compute.AggregatedListNetworkFirewallPoliciesRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[compute.NetworkFirewallPolicyAggregatedList]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method( + self._request, + retry=self._retry, + timeout=self._timeout, + metadata=self._metadata, + ) + yield self._response + + def __iter__(self) -> Iterator[Tuple[str, compute.FirewallPoliciesScopedList]]: + for page in self.pages: + yield from page.items.items() + + def get(self, key: str) -> Optional[compute.FirewallPoliciesScopedList]: + return self._response.items.get(key) + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + class ListPager: """A pager for iterating through ``list`` requests. diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/base.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/base.py index 369cd9dbabe5..43db934d1ab0 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/base.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/base.py @@ -143,6 +143,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.aggregated_list: gapic_v1.method.wrap_method( + self.aggregated_list, + default_timeout=None, + client_info=client_info, + ), self.clone_rules: gapic_v1.method.wrap_method( self.clone_rules, default_timeout=None, @@ -242,6 +247,18 @@ def add_rule( ]: raise NotImplementedError() + @property + def aggregated_list( + self, + ) -> Callable[ + [compute.AggregatedListNetworkFirewallPoliciesRequest], + Union[ + compute.NetworkFirewallPolicyAggregatedList, + Awaitable[compute.NetworkFirewallPolicyAggregatedList], + ], + ]: + raise NotImplementedError() + @property def clone_rules( self, diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest.py index 3f1974d73269..0857cf64a012 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest.py @@ -84,6 +84,14 @@ def post_add_rule(self, response): logging.log(f"Received response: {response}") return response + def pre_aggregated_list(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_aggregated_list(self, response): + logging.log(f"Received response: {response}") + return response + def pre_clone_rules(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -250,6 +258,32 @@ def post_add_rule(self, response: compute.Operation) -> compute.Operation: """ return response + def pre_aggregated_list( + self, + request: compute.AggregatedListNetworkFirewallPoliciesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + compute.AggregatedListNetworkFirewallPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for aggregated_list + + Override in a subclass to manipulate the request or metadata + before they are sent to the NetworkFirewallPolicies server. + """ + return request, metadata + + def post_aggregated_list( + self, response: compute.NetworkFirewallPolicyAggregatedList + ) -> compute.NetworkFirewallPolicyAggregatedList: + """Post-rpc interceptor for aggregated_list + + Override in a subclass to manipulate the response + after it is returned by the NetworkFirewallPolicies server but before + it is returned to user code. + """ + return response + def pre_clone_rules( self, request: compute.CloneRulesNetworkFirewallPolicyRequest, @@ -1018,6 +1052,153 @@ def __call__( ) return resp + class _AggregatedList( + _BaseNetworkFirewallPoliciesRestTransport._BaseAggregatedList, + NetworkFirewallPoliciesRestStub, + ): + def __hash__(self): + return hash("NetworkFirewallPoliciesRestTransport.AggregatedList") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: compute.AggregatedListNetworkFirewallPoliciesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> compute.NetworkFirewallPolicyAggregatedList: + r"""Call the aggregated list method over HTTP. + + Args: + request (~.compute.AggregatedListNetworkFirewallPoliciesRequest): + The request object. A request message for + NetworkFirewallPolicies.AggregatedList. + See the method description for details. + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.compute.NetworkFirewallPolicyAggregatedList: + + """ + + http_options = ( + _BaseNetworkFirewallPoliciesRestTransport._BaseAggregatedList._get_http_options() + ) + + request, metadata = self._interceptor.pre_aggregated_list(request, metadata) + transcoded_request = _BaseNetworkFirewallPoliciesRestTransport._BaseAggregatedList._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseNetworkFirewallPoliciesRestTransport._BaseAggregatedList._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.compute_v1.NetworkFirewallPoliciesClient.AggregatedList", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "AggregatedList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + NetworkFirewallPoliciesRestTransport._AggregatedList._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = compute.NetworkFirewallPolicyAggregatedList() + pb_resp = compute.NetworkFirewallPolicyAggregatedList.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_aggregated_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + compute.NetworkFirewallPolicyAggregatedList.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.compute_v1.NetworkFirewallPoliciesClient.aggregated_list", + extra={ + "serviceName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "rpcName": "AggregatedList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + class _CloneRules( _BaseNetworkFirewallPoliciesRestTransport._BaseCloneRules, NetworkFirewallPoliciesRestStub, @@ -3251,6 +3432,17 @@ def add_rule( # In C++ this would require a dynamic_cast return self._AddRule(self._session, self._host, self._interceptor) # type: ignore + @property + def aggregated_list( + self, + ) -> Callable[ + [compute.AggregatedListNetworkFirewallPoliciesRequest], + compute.NetworkFirewallPolicyAggregatedList, + ]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._AggregatedList(self._session, self._host, self._interceptor) # type: ignore + @property def clone_rules( self, diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest_base.py b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest_base.py index 12b8707fa93e..6f191e61a07c 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest_base.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/services/network_firewall_policies/transports/rest_base.py @@ -199,6 +199,54 @@ def _get_query_params_json(transcoded_request): return query_params + class _BaseAggregatedList: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/compute/v1/projects/{project}/aggregated/firewallPolicies", + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = compute.AggregatedListNetworkFirewallPoliciesRequest.pb( + request + ) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=False, + ) + ) + query_params.update( + _BaseNetworkFirewallPoliciesRestTransport._BaseAggregatedList._get_unset_required_fields( + query_params + ) + ) + + return query_params + class _BaseCloneRules: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/types/__init__.py b/packages/google-cloud-compute/google/cloud/compute_v1/types/__init__.py index a8b9f8257d40..03d712bf890e 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/types/__init__.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/types/__init__.py @@ -66,6 +66,7 @@ AggregatedListNetworkAttachmentsRequest, AggregatedListNetworkEdgeSecurityServicesRequest, AggregatedListNetworkEndpointGroupsRequest, + AggregatedListNetworkFirewallPoliciesRequest, AggregatedListNodeGroupsRequest, AggregatedListNodeTemplatesRequest, AggregatedListNodeTypesRequest, @@ -332,6 +333,7 @@ FirewallList, FirewallLogConfig, FirewallPoliciesListAssociationsResponse, + FirewallPoliciesScopedList, FirewallPolicy, FirewallPolicyAssociation, FirewallPolicyList, @@ -909,6 +911,7 @@ NetworkEndpointGroupsListNetworkEndpoints, NetworkEndpointGroupsScopedList, NetworkEndpointWithHealthStatus, + NetworkFirewallPolicyAggregatedList, NetworkInterface, NetworkList, NetworkPeering, @@ -1592,6 +1595,7 @@ "AggregatedListNetworkAttachmentsRequest", "AggregatedListNetworkEdgeSecurityServicesRequest", "AggregatedListNetworkEndpointGroupsRequest", + "AggregatedListNetworkFirewallPoliciesRequest", "AggregatedListNodeGroupsRequest", "AggregatedListNodeTemplatesRequest", "AggregatedListNodeTypesRequest", @@ -1858,6 +1862,7 @@ "FirewallList", "FirewallLogConfig", "FirewallPoliciesListAssociationsResponse", + "FirewallPoliciesScopedList", "FirewallPolicy", "FirewallPolicyAssociation", "FirewallPolicyList", @@ -2435,6 +2440,7 @@ "NetworkEndpointGroupsListNetworkEndpoints", "NetworkEndpointGroupsScopedList", "NetworkEndpointWithHealthStatus", + "NetworkFirewallPolicyAggregatedList", "NetworkInterface", "NetworkList", "NetworkPeering", diff --git a/packages/google-cloud-compute/google/cloud/compute_v1/types/compute.py b/packages/google-cloud-compute/google/cloud/compute_v1/types/compute.py index 70daefa6ed54..38f7bc0a5fd6 100644 --- a/packages/google-cloud-compute/google/cloud/compute_v1/types/compute.py +++ b/packages/google-cloud-compute/google/cloud/compute_v1/types/compute.py @@ -76,6 +76,7 @@ "AggregatedListNetworkAttachmentsRequest", "AggregatedListNetworkEdgeSecurityServicesRequest", "AggregatedListNetworkEndpointGroupsRequest", + "AggregatedListNetworkFirewallPoliciesRequest", "AggregatedListNodeGroupsRequest", "AggregatedListNodeTemplatesRequest", "AggregatedListNodeTypesRequest", @@ -341,6 +342,7 @@ "FirewallList", "FirewallLogConfig", "FirewallPoliciesListAssociationsResponse", + "FirewallPoliciesScopedList", "FirewallPolicy", "FirewallPolicyAssociation", "FirewallPolicyList", @@ -918,6 +920,7 @@ "NetworkEndpointGroupsListNetworkEndpoints", "NetworkEndpointGroupsScopedList", "NetworkEndpointWithHealthStatus", + "NetworkFirewallPolicyAggregatedList", "NetworkInterface", "NetworkList", "NetworkPeering", @@ -2171,7 +2174,7 @@ class AccessConfig(proto.Message): This field is a member of `oneof`_ ``_public_ptr_domain_name``. security_policy (str): - [Output Only] The resource URL for the security policy + The resource URL for the security policy associated with this access config. This field is a member of `oneof`_ ``_security_policy``. @@ -7127,6 +7130,160 @@ class AggregatedListNetworkEndpointGroupsRequest(proto.Message): ) +class AggregatedListNetworkFirewallPoliciesRequest(proto.Message): + r"""A request message for NetworkFirewallPolicies.AggregatedList. + See the method description for details. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + filter (str): + A filter expression that filters resources listed in the + response. Most Compute resources support two types of filter + expressions: expressions that support regular expressions + and expressions that follow API improvement proposal + AIP-160. These two types of filter expressions cannot be + mixed in one request. If you want to use AIP-160, your + expression must specify the field name, an operator, and the + value that you want to use for filtering. The value must be + a string, a number, or a boolean. The operator must be + either ``=``, ``!=``, ``>``, ``<``, ``<=``, ``>=`` or ``:``. + For example, if you are filtering Compute Engine instances, + you can exclude instances named ``example-instance`` by + specifying ``name != example-instance``. The ``:*`` + comparison can be used to test whether a key has been + defined. For example, to find all objects with ``owner`` + label use: ``labels.owner:*`` You can also filter nested + fields. For example, you could specify + ``scheduling.automaticRestart = false`` to include instances + only if they are not scheduled for automatic restarts. You + can use filtering on nested fields to filter based on + resource labels. To filter on multiple expressions, provide + each separate expression within parentheses. For example: + ``(scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake")`` + By default, each expression is an ``AND`` expression. + However, you can include ``AND`` and ``OR`` expressions + explicitly. For example: + ``(cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true)`` + If you want to use a regular expression, use the ``eq`` + (equal) or ``ne`` (not equal) operator against a single + un-parenthesized expression with or without quotes or + against multiple parenthesized expressions. Examples: + ``fieldname eq unquoted literal`` + ``fieldname eq 'single quoted literal'`` + ``fieldname eq "double quoted literal"`` + ``(fieldname1 eq literal) (fieldname2 ne "literal")`` The + literal value is interpreted as a regular expression using + Google RE2 library syntax. The literal value must match the + entire field. For example, to filter for instances that do + not end with name "instance", you would use + ``name ne .*instance``. You cannot combine constraints on + multiple fields using regular expressions. + + This field is a member of `oneof`_ ``_filter``. + include_all_scopes (bool): + Indicates whether every visible scope for + each scope type (zone, region, global) should be + included in the response. For new resource types + added after this field, the flag has no effect + as new resource types will always include every + visible scope for each scope type in response. + For resource types which predate this field, if + this flag is omitted or false, only scopes of + the scope types where the resource type is + expected to be found will be included. + + This field is a member of `oneof`_ ``_include_all_scopes``. + max_results (int): + The maximum number of results per page that should be + returned. If the number of available results is larger than + ``maxResults``, Compute Engine returns a ``nextPageToken`` + that can be used to get the next page of results in + subsequent list requests. Acceptable values are ``0`` to + ``500``, inclusive. (Default: ``500``) + + This field is a member of `oneof`_ ``_max_results``. + order_by (str): + Sorts list results by a certain order. By default, results + are returned in alphanumerical order based on the resource + name. You can also sort results in descending order based on + the creation timestamp using + ``orderBy="creationTimestamp desc"``. This sorts results + based on the ``creationTimestamp`` field in reverse + chronological order (newest result first). Use this to sort + resources like operations so that the newest operation is + returned first. Currently, only sorting by ``name`` or + ``creationTimestamp desc`` is supported. + + This field is a member of `oneof`_ ``_order_by``. + page_token (str): + Specifies a page token to use. Set ``pageToken`` to the + ``nextPageToken`` returned by a previous list request to get + the next page of results. + + This field is a member of `oneof`_ ``_page_token``. + project (str): + Project ID for this request. + return_partial_success (bool): + Opt-in for partial success behavior which + provides partial results in case of failure. The + default value is false. For example, when + partial success behavior is enabled, + aggregatedList for a single zone scope either + returns all resources in the zone or no + resources, with an error code. + + This field is a member of `oneof`_ ``_return_partial_success``. + service_project_number (int): + The Shared VPC service project id or service + project number for which aggregated list request + is invoked for subnetworks list-usable api. + + This field is a member of `oneof`_ ``_service_project_number``. + """ + + filter: str = proto.Field( + proto.STRING, + number=336120696, + optional=True, + ) + include_all_scopes: bool = proto.Field( + proto.BOOL, + number=391327988, + optional=True, + ) + max_results: int = proto.Field( + proto.UINT32, + number=54715419, + optional=True, + ) + order_by: str = proto.Field( + proto.STRING, + number=160562920, + optional=True, + ) + page_token: str = proto.Field( + proto.STRING, + number=19994697, + optional=True, + ) + project: str = proto.Field( + proto.STRING, + number=227560217, + ) + return_partial_success: bool = proto.Field( + proto.BOOL, + number=517198390, + optional=True, + ) + service_project_number: int = proto.Field( + proto.INT64, + number=316757497, + optional=True, + ) + + class AggregatedListNodeGroupsRequest(proto.Message): r"""A request message for NodeGroups.AggregatedList. See the method description for details. @@ -12382,7 +12539,10 @@ class AttachedDiskInitializeParams(proto.Message): you created, specify the snapshot name in the following format: global/snapshots/my-backup If the source snapshot is deleted later, this field - will not be set. + will not be set. Note: You cannot create VMs in + bulk using a snapshot as the source. Use an + image instead when you create VMs using the bulk + insert method. This field is a member of `oneof`_ ``_source_snapshot``. source_snapshot_encryption_key (google.cloud.compute_v1.types.CustomerEncryptionKey): @@ -26805,17 +26965,16 @@ class ErrorInfo(proto.Message): This field is a member of `oneof`_ ``_domain``. metadatas (MutableMapping[str, str]): - Additional structured details about this - error. Keys must match /a-z+/ but should ideally - be lowerCamelCase. Also they must be limited to - 64 characters in length. When identifying the - current value of an exceeded limit, the units - should be contained in the key, not the value. - For example, rather than {"instanceLimit": - "100/request"}, should be returned as, - {"instanceLimitPerRequest": "100"}, if the - client exceeds the number of instances that can - be created in a single (batch) request. + Additional structured details about this error. Keys must + match a regular expression of ``a-z+`` but should ideally be + lowerCamelCase. Also, they must be limited to 64 characters + in length. When identifying the current value of an exceeded + limit, the units should be contained in the key, not the + value. For example, rather than + ``{"instanceLimit": "100/request"}``, should be returned as, + ``{"instanceLimitPerRequest": "100"}``, if the client + exceeds the number of instances that can be created in a + single (batch) request. reason (str): The reason of the error. This is a constant value that identifies the proximate cause of the error. Error reasons @@ -27996,6 +28155,35 @@ class FirewallPoliciesListAssociationsResponse(proto.Message): ) +class FirewallPoliciesScopedList(proto.Message): + r""" + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + firewall_policies (MutableSequence[google.cloud.compute_v1.types.FirewallPolicy]): + A list of firewall policies contained in this + scope. + warning (google.cloud.compute_v1.types.Warning): + Informational warning which replaces the list + of firewall policies when the list is empty. + + This field is a member of `oneof`_ ``_warning``. + """ + + firewall_policies: MutableSequence["FirewallPolicy"] = proto.RepeatedField( + proto.MESSAGE, + number=392512943, + message="FirewallPolicy", + ) + warning: "Warning" = proto.Field( + proto.MESSAGE, + number=50704284, + optional=True, + message="Warning", + ) + + class FirewallPolicy(proto.Message): r"""Represents a Firewall Policy resource. @@ -42984,13 +43172,13 @@ class InstanceGroup(proto.Message): This field is a member of `oneof`_ ``_name``. named_ports (MutableSequence[google.cloud.compute_v1.types.NamedPort]): - Assigns a name to a port number. For example: {name: "http", - port: 80} This allows the system to reference ports by the - assigned name instead of a port number. Named ports can also - contain multiple ports. For example: [{name: "app1", port: - 8080}, {name: "app1", port: 8081}, {name: "app2", port: - 8082}] Named ports apply to all instances in this instance - group. + Optional. Assigns a name to a port number. For example: + {name: "http", port: 80} This allows the system to reference + ports by the assigned name instead of a port number. Named + ports can also contain multiple ports. For example: [{name: + "app1", port: 8080}, {name: "app1", port: 8081}, {name: + "app2", port: 8082}] Named ports apply to all instances in + this instance group. network (str): [Output Only] The URL of the network to which all instances in the instance group belong. If your instance has multiple @@ -48529,15 +48717,16 @@ class InterconnectAttachment(proto.Message): Mbit/s - BPS_200M: 200 Mbit/s - BPS_300M: 300 Mbit/s - BPS_400M: 400 Mbit/s - BPS_500M: 500 Mbit/s - BPS_1G: 1 Gbit/s - BPS_2G: 2 Gbit/s - BPS_5G: 5 Gbit/s - BPS_10G: 10 - Gbit/s - BPS_20G: 20 Gbit/s - BPS_50G: 50 Gbit/s Check the - Bandwidth enum for the list of possible values. + Gbit/s - BPS_20G: 20 Gbit/s - BPS_50G: 50 Gbit/s - BPS_100G: + 100 Gbit/s Check the Bandwidth enum for the list of possible + values. This field is a member of `oneof`_ ``_bandwidth``. candidate_ipv6_subnets (MutableSequence[str]): This field is not available. candidate_subnets (MutableSequence[str]): - Up to 16 candidate prefixes that can be used - to restrict the allocation of + Input only. Up to 16 candidate prefixes that + can be used to restrict the allocation of cloudRouterIpAddress and customerRouterIpAddress for this attachment. All prefixes must be within link-local address space (169.254.0.0/16) and @@ -48599,10 +48788,10 @@ class InterconnectAttachment(proto.Message): This field is a member of `oneof`_ ``_description``. edge_availability_domain (str): - Desired availability domain for the attachment. Only - available for type PARTNER, at creation time, and can take - one of the following values: - AVAILABILITY_DOMAIN_ANY - - AVAILABILITY_DOMAIN_1 - AVAILABILITY_DOMAIN_2 For improved + Input only. Desired availability domain for the attachment. + Only available for type PARTNER, at creation time, and can + take one of the following values: - AVAILABILITY_DOMAIN_ANY + - AVAILABILITY_DOMAIN_1 - AVAILABILITY_DOMAIN_2 For improved reliability, customers should configure a pair of attachments, one per availability domain. The selected availability domain will be provided to the Partner via the @@ -48816,9 +49005,9 @@ class InterconnectAttachment(proto.Message): This field is a member of `oneof`_ ``_state``. subnet_length (int): - Length of the IPv4 subnet mask. Allowed - values: - 29 (default) - 30 The default value is - 29, except for Cross-Cloud Interconnect + Input only. Length of the IPv4 subnet mask. + Allowed values: - 29 (default) - 30 The default + value is 29, except for Cross-Cloud Interconnect connections that use an InterconnectRemoteLocation with a constraints.subnetLengthRange.min equal to 30. @@ -48859,12 +49048,14 @@ class Bandwidth(proto.Enum): - BPS_200M: 200 Mbit/s - BPS_300M: 300 Mbit/s - BPS_400M: 400 Mbit/s - BPS_500M: 500 Mbit/s - BPS_1G: 1 Gbit/s - BPS_2G: 2 Gbit/s - BPS_5G: 5 Gbit/s - BPS_10G: 10 Gbit/s - BPS_20G: 20 Gbit/s - - BPS_50G: 50 Gbit/s + BPS_50G: 50 Gbit/s - BPS_100G: 100 Gbit/s Values: UNDEFINED_BANDWIDTH (0): A value indicating that the enum field is not set. + BPS_100G (49547952): + 100 Gbit/s BPS_100M (49547958): 100 Mbit/s BPS_10G (278693006): @@ -48891,6 +49082,7 @@ class Bandwidth(proto.Enum): 5 Gbit/s """ UNDEFINED_BANDWIDTH = 0 + BPS_100G = 49547952 BPS_100M = 49547958 BPS_10G = 278693006 BPS_1G = 355358448 @@ -48905,15 +49097,15 @@ class Bandwidth(proto.Enum): BPS_5G = 355358572 class EdgeAvailabilityDomain(proto.Enum): - r"""Desired availability domain for the attachment. Only available for - type PARTNER, at creation time, and can take one of the following - values: - AVAILABILITY_DOMAIN_ANY - AVAILABILITY_DOMAIN_1 - - AVAILABILITY_DOMAIN_2 For improved reliability, customers should - configure a pair of attachments, one per availability domain. The - selected availability domain will be provided to the Partner via the - pairing key, so that the provisioned circuit will lie in the - specified domain. If not specified, the value will default to - AVAILABILITY_DOMAIN_ANY. + r"""Input only. Desired availability domain for the attachment. Only + available for type PARTNER, at creation time, and can take one of + the following values: - AVAILABILITY_DOMAIN_ANY - + AVAILABILITY_DOMAIN_1 - AVAILABILITY_DOMAIN_2 For improved + reliability, customers should configure a pair of attachments, one + per availability domain. The selected availability domain will be + provided to the Partner via the pairing key, so that the provisioned + circuit will lie in the specified domain. If not specified, the + value will default to AVAILABILITY_DOMAIN_ANY. Values: UNDEFINED_EDGE_AVAILABILITY_DOMAIN (0): @@ -69947,12 +70139,12 @@ class NetworkEndpoint(proto.Message): Attributes: annotations (MutableMapping[str, str]): - Metadata defined as annotations on the - network endpoint. + Optional metadata defined as annotations on + the network endpoint. client_destination_port (int): Represents the port number to which PSC consumer sends - packets. Only valid for network endpoint groups created with - GCE_VM_IP_PORTMAP endpoint type. + packets. Optional. Only valid for network endpoint groups + created with GCE_VM_IP_PORTMAP endpoint type. This field is a member of `oneof`_ ``_client_destination_port``. fqdn (str): @@ -69964,7 +70156,8 @@ class NetworkEndpoint(proto.Message): This field is a member of `oneof`_ ``_fqdn``. instance (str): The name or a URL of VM instance of this network endpoint. - This field is required for network endpoints of type + Optional, the field presence depends on the network endpoint + type. The field is required for network endpoints of type GCE_VM_IP and GCE_VM_IP_PORT. The instance must be in the same zone of network endpoint group (for zonal NEGs) or in the zone within the region of the NEG (for regional NEGs). @@ -70051,24 +70244,24 @@ class NetworkEndpointGroup(proto.Message): Attributes: annotations (MutableMapping[str, str]): - Metadata defined as annotations on the - network endpoint group. + Optional. Metadata defined as annotations on + the network endpoint group. app_engine (google.cloud.compute_v1.types.NetworkEndpointGroupAppEngine): - Only valid when networkEndpointType is - SERVERLESS. Only one of cloudRun, appEngine or - cloudFunction may be set. + Optional. Only valid when networkEndpointType + is SERVERLESS. Only one of cloudRun, appEngine + or cloudFunction may be set. This field is a member of `oneof`_ ``_app_engine``. cloud_function (google.cloud.compute_v1.types.NetworkEndpointGroupCloudFunction): - Only valid when networkEndpointType is - SERVERLESS. Only one of cloudRun, appEngine or - cloudFunction may be set. + Optional. Only valid when networkEndpointType + is SERVERLESS. Only one of cloudRun, appEngine + or cloudFunction may be set. This field is a member of `oneof`_ ``_cloud_function``. cloud_run (google.cloud.compute_v1.types.NetworkEndpointGroupCloudRun): - Only valid when networkEndpointType is - SERVERLESS. Only one of cloudRun, appEngine or - cloudFunction may be set. + Optional. Only valid when networkEndpointType + is SERVERLESS. Only one of cloudRun, appEngine + or cloudFunction may be set. This field is a member of `oneof`_ ``_cloud_run``. creation_timestamp (str): @@ -70077,9 +70270,9 @@ class NetworkEndpointGroup(proto.Message): This field is a member of `oneof`_ ``_creation_timestamp``. default_port (int): The default port used if the port number is not specified in - the network endpoint. If the network endpoint type is either - GCE_VM_IP, SERVERLESS or PRIVATE_SERVICE_CONNECT, this field - must not be specified. + the network endpoint. Optional. If the network endpoint type + is either GCE_VM_IP, SERVERLESS or PRIVATE_SERVICE_CONNECT, + this field must not be specified. This field is a member of `oneof`_ ``_default_port``. description (str): @@ -70125,13 +70318,16 @@ class NetworkEndpointGroup(proto.Message): This field is a member of `oneof`_ ``_network_endpoint_type``. psc_data (google.cloud.compute_v1.types.NetworkEndpointGroupPscData): + Optional. Only valid when networkEndpointType is + PRIVATE_SERVICE_CONNECT. This field is a member of `oneof`_ ``_psc_data``. psc_target_service (str): - The target service url used to set up private - service connection to a Google API or a PSC - Producer Service Attachment. An example value - is: asia-northeast3-cloudkms.googleapis.com + The target service url used to set up private service + connection to a Google API or a PSC Producer Service + Attachment. An example value is: + asia-northeast3-cloudkms.googleapis.com. Optional. Only + valid when networkEndpointType is PRIVATE_SERVICE_CONNECT. This field is a member of `oneof`_ ``_psc_target_service``. region (str): @@ -70906,9 +71102,11 @@ class NetworkEndpointWithHealthStatus(proto.Message): Attributes: healths (MutableSequence[google.cloud.compute_v1.types.HealthStatusForNetworkEndpoint]): - [Output only] The health status of network endpoint; + [Output only] The health status of network endpoint. + Optional. Displayed only if the network endpoint has + centralized health checking configured. network_endpoint (google.cloud.compute_v1.types.NetworkEndpoint): - [Output only] The network endpoint; + [Output only] The network endpoint. This field is a member of `oneof`_ ``_network_endpoint``. """ @@ -70926,6 +71124,89 @@ class NetworkEndpointWithHealthStatus(proto.Message): ) +class NetworkFirewallPolicyAggregatedList(proto.Message): + r""" + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + id (str): + [Output Only] Unique identifier for the resource; defined by + the server. + + This field is a member of `oneof`_ ``_id``. + items (MutableMapping[str, google.cloud.compute_v1.types.FirewallPoliciesScopedList]): + A list of FirewallPoliciesScopedList + resources. + kind (str): + [Output Only] Type of resource. Always + compute#networkFirewallPoliciesAggregatedList for lists of + network firewall policies. + + This field is a member of `oneof`_ ``_kind``. + next_page_token (str): + [Output Only] This token allows you to get the next page of + results for list requests. If the number of results is + larger than maxResults, use the nextPageToken as a value for + the query parameter pageToken in the next list request. + Subsequent list requests will have their own nextPageToken + to continue paging through the results. + + This field is a member of `oneof`_ ``_next_page_token``. + self_link (str): + [Output Only] Server-defined URL for this resource. + + This field is a member of `oneof`_ ``_self_link``. + unreachables (MutableSequence[str]): + [Output Only] Unreachable resources. + warning (google.cloud.compute_v1.types.Warning): + [Output Only] Informational warning message. + + This field is a member of `oneof`_ ``_warning``. + """ + + @property + def raw_page(self): + return self + + id: str = proto.Field( + proto.STRING, + number=3355, + optional=True, + ) + items: MutableMapping[str, "FirewallPoliciesScopedList"] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=100526016, + message="FirewallPoliciesScopedList", + ) + kind: str = proto.Field( + proto.STRING, + number=3292052, + optional=True, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=79797525, + optional=True, + ) + self_link: str = proto.Field( + proto.STRING, + number=456214797, + optional=True, + ) + unreachables: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=243372063, + ) + warning: "Warning" = proto.Field( + proto.MESSAGE, + number=50704284, + optional=True, + message="Warning", + ) + + class NetworkInterface(proto.Message): r"""A network interface resource attached to an instance. @@ -72466,6 +72747,17 @@ class NetworkRoutingConfig(proto.Message): the list of possible values. This field is a member of `oneof`_ ``_bgp_inter_region_cost``. + effective_bgp_always_compare_med (bool): + [Output Only] Effective value of the bgp_always_compare_med + field. + + This field is a member of `oneof`_ ``_effective_bgp_always_compare_med``. + effective_bgp_inter_region_cost (str): + [Output Only] Effective value of the bgp_inter_region_cost + field. Check the EffectiveBgpInterRegionCost enum for the + list of possible values. + + This field is a member of `oneof`_ ``_effective_bgp_inter_region_cost``. routing_mode (str): The network-wide routing mode to use. If set to REGIONAL, this network's Cloud Routers will @@ -72500,7 +72792,9 @@ class BgpBestPathSelectionMode(proto.Enum): class BgpInterRegionCost(proto.Enum): r"""Allows to define a preferred approach for handling inter-region cost in the selection process when using the STANDARD BGP best path - selection algorithm. Can be DEFAULT or ADD_COST_TO_MED. + selection algorithm. Can be DEFAULT or ADD_COST_TO_MED. Additional + supported values which may be not listed in the enum directly due to + technical reasons: ADD_COST_TO_MED DEFAULT Values: UNDEFINED_BGP_INTER_REGION_COST (0): @@ -72515,6 +72809,18 @@ class BgpInterRegionCost(proto.Enum): ADD_COST_TO_MED = 490583004 DEFAULT = 115302945 + class EffectiveBgpInterRegionCost(proto.Enum): + r"""[Output Only] Effective value of the bgp_inter_region_cost field. + Additional supported values which may be not listed in the enum + directly due to technical reasons: ADD_COST_TO_MED DEFAULT + + Values: + UNDEFINED_EFFECTIVE_BGP_INTER_REGION_COST (0): + A value indicating that the enum field is not + set. + """ + UNDEFINED_EFFECTIVE_BGP_INTER_REGION_COST = 0 + class RoutingMode(proto.Enum): r"""The network-wide routing mode to use. If set to REGIONAL, this network's Cloud Routers will only advertise routes with @@ -72550,6 +72856,16 @@ class RoutingMode(proto.Enum): number=462142689, optional=True, ) + effective_bgp_always_compare_med: bool = proto.Field( + proto.BOOL, + number=214661838, + optional=True, + ) + effective_bgp_inter_region_cost: str = proto.Field( + proto.STRING, + number=185098313, + optional=True, + ) routing_mode: str = proto.Field( proto.STRING, number=475143548, @@ -105129,12 +105445,14 @@ class TargetHttpsProxy(proto.Message): SSL Certificate resource or Certificate Manager Certificate resource. Mixing Classic Certificates and Certificate Manager Certificates is not allowed. Certificate Manager - Certificates must include the certificatemanager API. - Certificate Manager Certificates are not supported by Global - external Application Load Balancer or Classic Application - Load Balancer, use certificate_map instead. Currently, you - may specify up to 15 Classic SSL Certificates. Certificate - Manager Certificates accepted formats are: - + Certificates must include the certificatemanager API + namespace. Using Certificate Manager Certificates in this + field is not supported by Global external Application Load + Balancer or Classic Application Load Balancer, use + certificate_map instead. Currently, you may specify up to 15 + Classic SSL Certificates or up to 100 Certificate Manager + Certificates. Certificate Manager Certificates accepted + formats are: - //certificatemanager.googleapis.com/projects/{project}/locations/{ location}/certificates/{resourceName}. - https://certificatemanager.googleapis.com/v1alpha1/projects/{project diff --git a/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_firewall_policies_aggregated_list_sync.py b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_firewall_policies_aggregated_list_sync.py new file mode 100644 index 000000000000..3d4c70a1bd00 --- /dev/null +++ b/packages/google-cloud-compute/samples/generated_samples/compute_v1_generated_network_firewall_policies_aggregated_list_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2024 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 AggregatedList +# 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-compute + + +# [START compute_v1_generated_NetworkFirewallPolicies_AggregatedList_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 compute_v1 + + +def sample_aggregated_list(): + # Create a client + client = compute_v1.NetworkFirewallPoliciesClient() + + # Initialize request argument(s) + request = compute_v1.AggregatedListNetworkFirewallPoliciesRequest( + project="project_value", + ) + + # Make the request + page_result = client.aggregated_list(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END compute_v1_generated_NetworkFirewallPolicies_AggregatedList_sync] diff --git a/packages/google-cloud-compute/samples/generated_samples/snippet_metadata_google.cloud.compute.v1.json b/packages/google-cloud-compute/samples/generated_samples/snippet_metadata_google.cloud.compute.v1.json index f749c3d6ced8..b6dba6ed06c0 100644 --- a/packages/google-cloud-compute/samples/generated_samples/snippet_metadata_google.cloud.compute.v1.json +++ b/packages/google-cloud-compute/samples/generated_samples/snippet_metadata_google.cloud.compute.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-compute", - "version": "1.23.0" + "version": "0.1.0" }, "snippets": [ { @@ -28119,6 +28119,86 @@ ], "title": "compute_v1_generated_network_firewall_policies_add_rule_sync.py" }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.compute_v1.NetworkFirewallPoliciesClient", + "shortName": "NetworkFirewallPoliciesClient" + }, + "fullName": "google.cloud.compute_v1.NetworkFirewallPoliciesClient.aggregated_list", + "method": { + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies.AggregatedList", + "service": { + "fullName": "google.cloud.compute.v1.NetworkFirewallPolicies", + "shortName": "NetworkFirewallPolicies" + }, + "shortName": "AggregatedList" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.compute_v1.types.AggregatedListNetworkFirewallPoliciesRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.compute_v1.services.network_firewall_policies.pagers.AggregatedListPager", + "shortName": "aggregated_list" + }, + "description": "Sample for AggregatedList", + "file": "compute_v1_generated_network_firewall_policies_aggregated_list_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "compute_v1_generated_NetworkFirewallPolicies_AggregatedList_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "compute_v1_generated_network_firewall_policies_aggregated_list_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_firewall_policies.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_firewall_policies.py index 6938b9add120..e8d9eb6bbdad 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_firewall_policies.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_network_firewall_policies.py @@ -1816,6 +1816,284 @@ def test_add_rule_unary_rest_flattened_error(transport: str = "rest"): ) +def test_aggregated_list_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = NetworkFirewallPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.aggregated_list in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.aggregated_list] = mock_rpc + + request = {} + client.aggregated_list(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.aggregated_list(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_aggregated_list_rest_required_fields( + request_type=compute.AggregatedListNetworkFirewallPoliciesRequest, +): + transport_class = transports.NetworkFirewallPoliciesRestTransport + + request_init = {} + request_init["project"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).aggregated_list._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["project"] = "project_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).aggregated_list._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "include_all_scopes", + "max_results", + "order_by", + "page_token", + "return_partial_success", + "service_project_number", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "project" in jsonified_request + assert jsonified_request["project"] == "project_value" + + client = NetworkFirewallPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = compute.NetworkFirewallPolicyAggregatedList() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.NetworkFirewallPolicyAggregatedList.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.aggregated_list(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_aggregated_list_rest_unset_required_fields(): + transport = transports.NetworkFirewallPoliciesRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.aggregated_list._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "includeAllScopes", + "maxResults", + "orderBy", + "pageToken", + "returnPartialSuccess", + "serviceProjectNumber", + ) + ) + & set(("project",)) + ) + + +def test_aggregated_list_rest_flattened(): + client = NetworkFirewallPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.NetworkFirewallPolicyAggregatedList() + + # get arguments that satisfy an http rule for this method + sample_request = {"project": "sample1"} + + # get truthy value for each flattened field + mock_args = dict( + project="project_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = compute.NetworkFirewallPolicyAggregatedList.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.aggregated_list(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/compute/v1/projects/{project}/aggregated/firewallPolicies" + % client.transport._host, + args[1], + ) + + +def test_aggregated_list_rest_flattened_error(transport: str = "rest"): + client = NetworkFirewallPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.aggregated_list( + compute.AggregatedListNetworkFirewallPoliciesRequest(), + project="project_value", + ) + + +def test_aggregated_list_rest_pager(transport: str = "rest"): + client = NetworkFirewallPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + compute.NetworkFirewallPolicyAggregatedList( + items={ + "a": compute.FirewallPoliciesScopedList(), + "b": compute.FirewallPoliciesScopedList(), + "c": compute.FirewallPoliciesScopedList(), + }, + next_page_token="abc", + ), + compute.NetworkFirewallPolicyAggregatedList( + items={}, + next_page_token="def", + ), + compute.NetworkFirewallPolicyAggregatedList( + items={ + "g": compute.FirewallPoliciesScopedList(), + }, + next_page_token="ghi", + ), + compute.NetworkFirewallPolicyAggregatedList( + items={ + "h": compute.FirewallPoliciesScopedList(), + "i": compute.FirewallPoliciesScopedList(), + }, + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + compute.NetworkFirewallPolicyAggregatedList.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"project": "sample1"} + + pager = client.aggregated_list(request=sample_request) + + assert isinstance(pager.get("a"), compute.FirewallPoliciesScopedList) + assert pager.get("h") is None + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, tuple) for i in results) + for result in results: + assert isinstance(result, tuple) + assert tuple(type(t) for t in result) == ( + str, + compute.FirewallPoliciesScopedList, + ) + + assert pager.get("a") is None + assert isinstance(pager.get("h"), compute.FirewallPoliciesScopedList) + + pages = list(client.aggregated_list(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + def test_clone_rules_rest_use_cached_wrapped_rpc(): # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, # instead of constructing them on each call @@ -6800,6 +7078,138 @@ def test_add_rule_rest_interceptors(null_interceptor): post.assert_called_once() +def test_aggregated_list_rest_bad_request( + request_type=compute.AggregatedListNetworkFirewallPoliciesRequest, +): + client = NetworkFirewallPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"project": "sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.aggregated_list(request) + + +@pytest.mark.parametrize( + "request_type", + [ + compute.AggregatedListNetworkFirewallPoliciesRequest, + dict, + ], +) +def test_aggregated_list_rest_call_success(request_type): + client = NetworkFirewallPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"project": "sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = compute.NetworkFirewallPolicyAggregatedList( + id="id_value", + kind="kind_value", + next_page_token="next_page_token_value", + self_link="self_link_value", + unreachables=["unreachables_value"], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = compute.NetworkFirewallPolicyAggregatedList.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.aggregated_list(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.AggregatedListPager) + assert response.id == "id_value" + assert response.kind == "kind_value" + assert response.next_page_token == "next_page_token_value" + assert response.self_link == "self_link_value" + assert response.unreachables == ["unreachables_value"] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_aggregated_list_rest_interceptors(null_interceptor): + transport = transports.NetworkFirewallPoliciesRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.NetworkFirewallPoliciesRestInterceptor(), + ) + client = NetworkFirewallPoliciesClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.NetworkFirewallPoliciesRestInterceptor, "post_aggregated_list" + ) as post, mock.patch.object( + transports.NetworkFirewallPoliciesRestInterceptor, "pre_aggregated_list" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = compute.AggregatedListNetworkFirewallPoliciesRequest.pb( + compute.AggregatedListNetworkFirewallPoliciesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = compute.NetworkFirewallPolicyAggregatedList.to_json( + compute.NetworkFirewallPolicyAggregatedList() + ) + req.return_value.content = return_value + + request = compute.AggregatedListNetworkFirewallPoliciesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = compute.NetworkFirewallPolicyAggregatedList() + + client.aggregated_list( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + def test_clone_rules_rest_bad_request( request_type=compute.CloneRulesNetworkFirewallPolicyRequest, ): @@ -9555,6 +9965,26 @@ def test_add_rule_unary_empty_call_rest(): assert args[0] == request_msg +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_aggregated_list_empty_call_rest(): + client = NetworkFirewallPoliciesClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.aggregated_list), "__call__") as call: + client.aggregated_list(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = compute.AggregatedListNetworkFirewallPoliciesRequest() + + assert args[0] == request_msg + + # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. def test_clone_rules_unary_empty_call_rest(): @@ -9863,6 +10293,7 @@ def test_network_firewall_policies_base_transport(): methods = ( "add_association", "add_rule", + "aggregated_list", "clone_rules", "delete", "get", @@ -10020,6 +10451,9 @@ def test_network_firewall_policies_client_transport_session_collision(transport_ session1 = client1.transport.add_rule._session session2 = client2.transport.add_rule._session assert session1 != session2 + session1 = client1.transport.aggregated_list._session + session2 = client2.transport.aggregated_list._session + assert session1 != session2 session1 = client1.transport.clone_rules._session session2 = client2.transport.clone_rules._session assert session1 != session2 diff --git a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_networks.py b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_networks.py index 18c91606938f..2169edfd6c21 100644 --- a/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_networks.py +++ b/packages/google-cloud-compute/tests/unit/gapic/compute_v1/test_networks.py @@ -5451,6 +5451,8 @@ def test_insert_rest_call_success(request_type): "bgp_always_compare_med": True, "bgp_best_path_selection_mode": "bgp_best_path_selection_mode_value", "bgp_inter_region_cost": "bgp_inter_region_cost_value", + "effective_bgp_always_compare_med": True, + "effective_bgp_inter_region_cost": "effective_bgp_inter_region_cost_value", "routing_mode": "routing_mode_value", }, "self_link": "self_link_value", @@ -5967,6 +5969,8 @@ def test_patch_rest_call_success(request_type): "bgp_always_compare_med": True, "bgp_best_path_selection_mode": "bgp_best_path_selection_mode_value", "bgp_inter_region_cost": "bgp_inter_region_cost_value", + "effective_bgp_always_compare_med": True, + "effective_bgp_inter_region_cost": "effective_bgp_inter_region_cost_value", "routing_mode": "routing_mode_value", }, "self_link": "self_link_value",