def __call__( self, request: compute.ListFirewallsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> compute.FirewallList: r"""Call the list method over HTTP. Args: request (~.compute.ListFirewallsRequest): The request object. A request message for Firewalls.List. 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, str]]): Strings which should be sent along with the request as metadata. Returns: ~.compute.FirewallList: Contains a list of firewalls. """ http_options = [ { "method": "get", "uri": "/compute/v1/projects/{project}/global/firewalls", }, ] request_kwargs = compute.ListFirewallsRequest.to_dict(request) transcoded_request = path_template.transcode( http_options, **request_kwargs) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params = json.loads( compute.ListFirewallsRequest.to_json( compute.ListFirewallsRequest( transcoded_request["query_params"]), including_default_value_fields=False, use_integers_for_enums=False, )) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( # Replace with proper schema configuration (http/https) logic "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), ) # 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 return compute.FirewallList.from_json(response.content, ignore_unknown_fields=True)
def __call__( self, request: compute.PatchFirewallRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> compute.Operation: r"""Call the patch method over HTTP. Args: request (~.compute.PatchFirewallRequest): The request object. A request message for Firewalls.Patch. 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, str]]): Strings which should be sent along with the request as metadata. Returns: ~.compute.Operation: Represents an Operation resource. Google Compute Engine has three Operation resources: \* `Global </compute/docs/reference/rest/v1/globalOperations>`__ \* `Regional </compute/docs/reference/rest/v1/regionOperations>`__ \* `Zonal </compute/docs/reference/rest/v1/zoneOperations>`__ You can use an operation resource to manage asynchronous API requests. For more information, read Handling API responses. Operations can be global, regional or zonal. - For global operations, use the ``globalOperations`` resource. - For regional operations, use the ``regionOperations`` resource. - For zonal operations, use the ``zonalOperations`` resource. For more information, read Global, Regional, and Zonal Resources. """ http_options = [ { "method": "patch", "uri": "/compute/v1/projects/{project}/global/firewalls/{firewall}", "body": "firewall_resource", }, ] request_kwargs = compute.PatchFirewallRequest.to_dict(request) transcoded_request = path_template.transcode( http_options, **request_kwargs) # Jsonify the request body body = compute.Firewall.to_json( compute.Firewall(transcoded_request["body"]), including_default_value_fields=False, use_integers_for_enums=False, ) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params = json.loads( compute.PatchFirewallRequest.to_json( compute.PatchFirewallRequest( transcoded_request["query_params"]), including_default_value_fields=False, use_integers_for_enums=False, )) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( # Replace with proper schema configuration (http/https) logic "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), data=body, ) # 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 return compute.Operation.from_json(response.content, ignore_unknown_fields=True)
def __call__( self, request: compute.GetPublicDelegatedPrefixeRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> compute.PublicDelegatedPrefix: r"""Call the get method over HTTP. Args: request (~.compute.GetPublicDelegatedPrefixeRequest): The request object. A request message for PublicDelegatedPrefixes.Get. 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, str]]): Strings which should be sent along with the request as metadata. Returns: ~.compute.PublicDelegatedPrefix: A PublicDelegatedPrefix resource represents an IP block within a PublicAdvertisedPrefix that is configured within a single cloud scope (global or region). IPs in the block can be allocated to resources within that scope. Public delegated prefixes may be further broken up into smaller IP blocks in the same scope as the parent block. """ http_options = [ { "method": "get", "uri": "/compute/v1/projects/{project}/regions/{region}/publicDelegatedPrefixes/{public_delegated_prefix}", }, ] request_kwargs = compute.GetPublicDelegatedPrefixeRequest.to_dict( request) transcoded_request = path_template.transcode( http_options, **request_kwargs) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params = json.loads( compute.GetPublicDelegatedPrefixeRequest.to_json( compute.GetPublicDelegatedPrefixeRequest( transcoded_request["query_params"]), including_default_value_fields=False, use_integers_for_enums=False, )) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( # Replace with proper schema configuration (http/https) logic "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), ) # 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 return compute.PublicDelegatedPrefix.from_json( response.content, ignore_unknown_fields=True)
def __call__( self, request: compute.SetIamPolicySnapshotRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> compute.Policy: r"""Call the set iam policy method over HTTP. Args: request (~.compute.SetIamPolicySnapshotRequest): The request object. A request message for Snapshots.SetIamPolicy. 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, str]]): Strings which should be sent along with the request as metadata. Returns: ~.compute.Policy: An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A ``Policy`` is a collection of ``bindings``. A ``binding`` binds one or more ``members`` to a single ``role``. Members can be user accounts, service accounts, Google groups, and domains (such as G Suite). A ``role`` is a named list of permissions; each ``role`` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a ``binding`` can also specify a ``condition``, which is a logical expression that allows access to a resource only if the expression evaluates to ``true``. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the `IAM documentation <https://cloud.google.com/iam/help/conditions/resource-policies>`__. **JSON example:** { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:[email protected]", "group:[email protected]", "domain:google.com", "serviceAccount:[email protected]" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:[email protected]" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 } **YAML example:** bindings: - members: - user:[email protected] - group:[email protected] - domain:google.com - serviceAccount:[email protected] role: roles/resourcemanager.organizationAdmin - members: - user:[email protected] role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3 For a description of IAM and its features, see the `IAM documentation <https://cloud.google.com/iam/docs/>`__. """ http_options = [ { "method": "post", "uri": "/compute/v1/projects/{project}/global/snapshots/{resource}/setIamPolicy", "body": "global_set_policy_request_resource", }, ] request_kwargs = compute.SetIamPolicySnapshotRequest.to_dict( request) transcoded_request = path_template.transcode( http_options, **request_kwargs) # Jsonify the request body body = compute.GlobalSetPolicyRequest.to_json( compute.GlobalSetPolicyRequest(transcoded_request["body"]), including_default_value_fields=False, use_integers_for_enums=False, ) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params = json.loads( compute.SetIamPolicySnapshotRequest.to_json( compute.SetIamPolicySnapshotRequest( transcoded_request["query_params"]), including_default_value_fields=False, use_integers_for_enums=False, )) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( # Replace with proper schema configuration (http/https) logic "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), data=body, ) # 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 return compute.Policy.from_json(response.content, ignore_unknown_fields=True)
def __call__( self, request: logging_metrics.UpdateLogMetricRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> logging_metrics.LogMetric: r"""Call the update log metric method over HTTP. Args: request (~.logging_metrics.UpdateLogMetricRequest): The request object. The parameters to UpdateLogMetric. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: ~.logging_metrics.LogMetric: Describes a logs-based metric. The value of the metric is the number of log entries that match a logs filter in a given time interval. Logs-based metrics can also be used to extract values from logs and create a distribution of the values. The distribution records the statistics of the extracted values along with an optional histogram of the values as specified by the bucket options. """ http_options: List[Dict[str, str]] = [ { 'method': 'put', 'uri': '/v2/{metric_name=projects/*/metrics/*}', 'body': 'metric', }, ] request, metadata = self._interceptor.pre_update_log_metric( request, metadata) request_kwargs = logging_metrics.UpdateLogMetricRequest.to_dict( request) transcoded_request = path_template.transcode( http_options, **request_kwargs) # Jsonify the request body body = logging_metrics.LogMetric.to_json( logging_metrics.LogMetric(transcoded_request['body']), including_default_value_fields=False, use_integers_for_enums=False) uri = transcoded_request['uri'] method = transcoded_request['method'] # Jsonify the query params query_params = json.loads( logging_metrics.UpdateLogMetricRequest.to_json( logging_metrics.UpdateLogMetricRequest( transcoded_request['query_params']), including_default_value_fields=False, use_integers_for_enums=False)) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers['Content-Type'] = 'application/json' response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), data=body, ) # 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 = logging_metrics.LogMetric.from_json( response.content, ignore_unknown_fields=True) resp = self._interceptor.post_update_log_metric(resp) return resp
def __call__( self, request: compute.GetPacketMirroringRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> compute.PacketMirroring: r"""Call the get method over HTTP. Args: request (~.compute.GetPacketMirroringRequest): The request object. A request message for PacketMirrorings.Get. 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, str]]): Strings which should be sent along with the request as metadata. Returns: ~.compute.PacketMirroring: Represents a Packet Mirroring resource. Packet Mirroring clones the traffic of specified instances in your Virtual Private Cloud (VPC) network and forwards it to a collector destination, such as an instance group of an internal TCP/UDP load balancer, for analysis or examination. For more information about setting up Packet Mirroring, see Using Packet Mirroring. """ http_options = [ { "method": "get", "uri": "/compute/v1/projects/{project}/regions/{region}/packetMirrorings/{packet_mirroring}", }, ] request_kwargs = compute.GetPacketMirroringRequest.to_dict(request) transcoded_request = path_template.transcode( http_options, **request_kwargs) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params = json.loads( compute.GetPacketMirroringRequest.to_json( compute.GetPacketMirroringRequest( transcoded_request["query_params"]), including_default_value_fields=False, use_integers_for_enums=False, )) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( # Replace with proper schema configuration (http/https) logic "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), ) # 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 return compute.PacketMirroring.from_json( response.content, ignore_unknown_fields=True)
def __call__( self, request: compute.GetAutoscalerRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> compute.Autoscaler: r"""Call the get method over HTTP. Args: request (~.compute.GetAutoscalerRequest): The request object. A request message for Autoscalers.Get. 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, str]]): Strings which should be sent along with the request as metadata. Returns: ~.compute.Autoscaler: Represents an Autoscaler resource. Google Compute Engine has two Autoscaler resources: \* `Zonal </compute/docs/reference/rest/v1/autoscalers>`__ \* `Regional </compute/docs/reference/rest/v1/regionAutoscalers>`__ Use autoscalers to automatically add or delete instances from a managed instance group according to your defined autoscaling policy. For more information, read Autoscaling Groups of Instances. For zonal managed instance groups resource, use the autoscaler resource. For regional managed instance groups, use the regionAutoscalers resource. """ http_options = [ { "method": "get", "uri": "/compute/v1/projects/{project}/zones/{zone}/autoscalers/{autoscaler}", }, ] request_kwargs = compute.GetAutoscalerRequest.to_dict(request) transcoded_request = path_template.transcode( http_options, **request_kwargs) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params = json.loads( compute.GetAutoscalerRequest.to_json( compute.GetAutoscalerRequest( transcoded_request["query_params"]), including_default_value_fields=False, use_integers_for_enums=False, )) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( # Replace with proper schema configuration (http/https) logic "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), ) # 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 return compute.Autoscaler.from_json(response.content, ignore_unknown_fields=True)
def __call__( self, request: logging_metrics.ListLogMetricsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> logging_metrics.ListLogMetricsResponse: r"""Call the list log metrics method over HTTP. Args: request (~.logging_metrics.ListLogMetricsRequest): The request object. The parameters to ListLogMetrics. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: ~.logging_metrics.ListLogMetricsResponse: Result returned from ListLogMetrics. """ http_options: List[Dict[str, str]] = [ { 'method': 'get', 'uri': '/v2/{parent=projects/*}/metrics', }, ] request, metadata = self._interceptor.pre_list_log_metrics( request, metadata) request_kwargs = logging_metrics.ListLogMetricsRequest.to_dict( request) transcoded_request = path_template.transcode( http_options, **request_kwargs) uri = transcoded_request['uri'] method = transcoded_request['method'] # Jsonify the query params query_params = json.loads( logging_metrics.ListLogMetricsRequest.to_json( logging_metrics.ListLogMetricsRequest( transcoded_request['query_params']), including_default_value_fields=False, use_integers_for_enums=False)) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers['Content-Type'] = 'application/json' response = getattr(self._session, method)( "{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), ) # 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 = logging_metrics.ListLogMetricsResponse.from_json( response.content, ignore_unknown_fields=True) resp = self._interceptor.post_list_log_metrics(resp) return resp
def _cancel_operation( self, request: operations_pb2.CancelOperationRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> empty_pb2.Empty: r"""Call the cancel operation method over HTTP. Args: request (~.operations_pb2.CancelOperationRequest): The request object. The request message for [Operations.CancelOperation][google.api_core.operations_v1.Operations.CancelOperation]. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. """ http_options = [ { "method": "post", "uri": "/v1/{name=operations/**}:cancel", "body": "*" }, ] if "google.longrunning.Operations.CancelOperation" in self._http_options: http_options = self._http_options[ "google.longrunning.Operations.CancelOperation"] request_kwargs = json_format.MessageToDict( request, preserving_proto_field_name=True, including_default_value_fields=True, ) transcoded_request = path_template.transcode(http_options, **request_kwargs) # Jsonify the request body body_request = operations_pb2.CancelOperationRequest() json_format.ParseDict(transcoded_request["body"], body_request) body = json_format.MessageToDict( body_request, including_default_value_fields=False, preserving_proto_field_name=False, use_integers_for_enums=False, ) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params_request = operations_pb2.CancelOperationRequest() json_format.ParseDict(transcoded_request["query_params"], query_params_request) query_params = json_format.MessageToDict( query_params_request, including_default_value_fields=False, preserving_proto_field_name=False, use_integers_for_enums=False, ) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), data=body, ) # 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 empty_pb2.Empty()
def __call__( self, request: compute.GetUrlMapRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> compute.UrlMap: r"""Call the get method over HTTP. Args: request (~.compute.GetUrlMapRequest): The request object. A request message for UrlMaps.Get. 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, str]]): Strings which should be sent along with the request as metadata. Returns: ~.compute.UrlMap: Represents a URL Map resource. Google Compute Engine has two URL Map resources: \* `Global </compute/docs/reference/rest/v1/urlMaps>`__ \* `Regional </compute/docs/reference/rest/v1/regionUrlMaps>`__ A URL map resource is a component of certain types of GCP load balancers and Traffic Director. \* urlMaps are used by external HTTP(S) load balancers and Traffic Director. \* regionUrlMaps are used by internal HTTP(S) load balancers. For a list of supported URL map features by load balancer type, see the Load balancing features: Routing and traffic management table. For a list of supported URL map features for Traffic Director, see the Traffic Director features: Routing and traffic management table. This resource defines mappings from host names and URL paths to either a backend service or a backend bucket. To use the global urlMaps resource, the backend service must have a loadBalancingScheme of either EXTERNAL or INTERNAL_SELF_MANAGED. To use the regionUrlMaps resource, the backend service must have a loadBalancingScheme of INTERNAL_MANAGED. For more information, read URL Map Concepts. """ http_options = [ { "method": "get", "uri": "/compute/v1/projects/{project}/global/urlMaps/{url_map}", }, ] request_kwargs = compute.GetUrlMapRequest.to_dict(request) transcoded_request = path_template.transcode(http_options, **request_kwargs) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params = json.loads( compute.GetUrlMapRequest.to_json( compute.GetUrlMapRequest(transcoded_request["query_params"]), including_default_value_fields=False, use_integers_for_enums=False, ) ) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( # Replace with proper schema configuration (http/https) logic "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), ) # 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 return compute.UrlMap.from_json( response.content, ignore_unknown_fields=True )
def __call__( self, request: compute.GetInstanceGroupRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> compute.InstanceGroup: r"""Call the get method over HTTP. Args: request (~.compute.GetInstanceGroupRequest): The request object. A request message for InstanceGroups.Get. 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, str]]): Strings which should be sent along with the request as metadata. Returns: ~.compute.InstanceGroup: Represents an Instance Group resource. Instance Groups can be used to configure a target for load balancing. Instance groups can either be managed or unmanaged. To create managed instance groups, use the instanceGroupManager or regionInstanceGroupManager resource instead. Use zonal unmanaged instance groups if you need to apply load balancing to groups of heterogeneous instances or if you need to manage the instances yourself. You cannot create regional unmanaged instance groups. For more information, read Instance groups. """ http_options = [ { "method": "get", "uri": "/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{instance_group}", }, ] request_kwargs = compute.GetInstanceGroupRequest.to_dict(request) transcoded_request = path_template.transcode( http_options, **request_kwargs) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params = json.loads( compute.GetInstanceGroupRequest.to_json( compute.GetInstanceGroupRequest( transcoded_request["query_params"]), including_default_value_fields=False, use_integers_for_enums=False, )) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( # Replace with proper schema configuration (http/https) logic "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), ) # 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 return compute.InstanceGroup.from_json(response.content, ignore_unknown_fields=True)
def __call__( self, request: compute.GetRegionCommitmentRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> compute.Commitment: r"""Call the get method over HTTP. Args: request (~.compute.GetRegionCommitmentRequest): The request object. A request message for RegionCommitments.Get. 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, str]]): Strings which should be sent along with the request as metadata. Returns: ~.compute.Commitment: Represents a regional Commitment resource. Creating a commitment resource means that you are purchasing a committed use contract with an explicit start and end time. You can create commitments based on vCPUs and memory usage and receive discounted rates. For full details, read Signing Up for Committed Use Discounts. """ http_options = [ { "method": "get", "uri": "/compute/v1/projects/{project}/regions/{region}/commitments/{commitment}", }, ] request_kwargs = compute.GetRegionCommitmentRequest.to_dict( request) transcoded_request = path_template.transcode( http_options, **request_kwargs) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params = json.loads( compute.GetRegionCommitmentRequest.to_json( compute.GetRegionCommitmentRequest( transcoded_request["query_params"]), including_default_value_fields=False, use_integers_for_enums=False, )) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( # Replace with proper schema configuration (http/https) logic "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), ) # 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 return compute.Commitment.from_json(response.content, ignore_unknown_fields=True)
def __call__( self, request: compute.GetRegionNetworkEndpointGroupRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> compute.NetworkEndpointGroup: r"""Call the get method over HTTP. Args: request (~.compute.GetRegionNetworkEndpointGroupRequest): The request object. A request message for RegionNetworkEndpointGroups.Get. 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, str]]): Strings which should be sent along with the request as metadata. Returns: ~.compute.NetworkEndpointGroup: Represents a collection of network endpoints. A network endpoint group (NEG) defines how a set of endpoints should be reached, whether they are reachable, and where they are located. For more information about using NEGs, see Setting up external HTTP(S) Load Balancing with internet NEGs, Setting up zonal NEGs, or Setting up external HTTP(S) Load Balancing with serverless NEGs. """ http_options = [ { "method": "get", "uri": "/compute/v1/projects/{project}/regions/{region}/networkEndpointGroups/{network_endpoint_group}", }, ] request_kwargs = compute.GetRegionNetworkEndpointGroupRequest.to_dict( request ) transcoded_request = path_template.transcode(http_options, **request_kwargs) uri = transcoded_request["uri"] method = transcoded_request["method"] # Jsonify the query params query_params = json.loads( compute.GetRegionNetworkEndpointGroupRequest.to_json( compute.GetRegionNetworkEndpointGroupRequest( transcoded_request["query_params"] ), including_default_value_fields=False, use_integers_for_enums=False, ) ) query_params.update(self._get_unset_required_fields(query_params)) # Send the request headers = dict(metadata) headers["Content-Type"] = "application/json" response = getattr(self._session, method)( # Replace with proper schema configuration (http/https) logic "https://{host}{uri}".format(host=self._host, uri=uri), timeout=timeout, headers=headers, params=rest_helpers.flatten_query_params(query_params), ) # 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 return compute.NetworkEndpointGroup.from_json( response.content, ignore_unknown_fields=True )