def __init__(self, method: Callable[..., asset_service.SearchAllResourcesResponse], request: asset_service.SearchAllResourcesRequest, response: asset_service.SearchAllResourcesResponse, *, metadata: Sequence[Tuple[str, str]] = ()): """Instantiate the pager. Args: method (Callable): The method that was originally called, and which instantiated this pager. request (:class:`~.asset_service.SearchAllResourcesRequest`): The initial request object. response (:class:`~.asset_service.SearchAllResourcesResponse`): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. """ self._method = method self._request = asset_service.SearchAllResourcesRequest(request) self._response = response self._metadata = metadata
async def search_all_resources( self, request: Union[asset_service.SearchAllResourcesRequest, dict] = None, *, scope: str = None, query: str = None, asset_types: Sequence[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.SearchAllResourcesAsyncPager: r"""Searches all the resources under a given accessible CRM scope (project/folder/organization). This RPC gives callers especially admins the ability to search all the resources under a scope, even if they don't have .get permission of all the resources. Callers should have cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be rejected. .. code-block:: python from google.cloud import asset_v1p1beta1 async def sample_search_all_resources(): # Create a client client = asset_v1p1beta1.AssetServiceAsyncClient() # Initialize request argument(s) request = asset_v1p1beta1.SearchAllResourcesRequest( scope="scope_value", ) # Make the request page_result = client.search_all_resources(request=request) # Handle the response async for response in page_result: print(response) Args: request (Union[google.cloud.asset_v1p1beta1.types.SearchAllResourcesRequest, dict]): The request object. Search all resources request. scope (:class:`str`): Required. The relative name of an asset. The search is limited to the resources within the ``scope``. The allowed value must be: - Organization number (such as "organizations/123") - Folder number(such as "folders/1234") - Project number (such as "projects/12345") - Project id (such as "projects/abc") This corresponds to the ``scope`` field on the ``request`` instance; if ``request`` is provided, this should not be set. query (:class:`str`): Optional. The query statement. This corresponds to the ``query`` field on the ``request`` instance; if ``request`` is provided, this should not be set. asset_types (:class:`Sequence[str]`): Optional. A list of asset types that this request searches for. If empty, it will search all the supported asset types. This corresponds to the ``asset_types`` 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, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.asset_v1p1beta1.services.asset_service.pagers.SearchAllResourcesAsyncPager: Search all resources response. 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([scope, query, asset_types]) if request is not None and has_flattened_params: raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") request = asset_service.SearchAllResourcesRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if scope is not None: request.scope = scope if query is not None: request.query = query if asset_types: request.asset_types.extend(asset_types) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = gapic_v1.method_async.wrap_method( self._client._transport.search_all_resources, default_retry=retries.Retry( initial=0.1, maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( core_exceptions.DeadlineExceeded, core_exceptions.ServiceUnavailable, ), deadline=15.0, ), default_timeout=15.0, client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata( (("scope", request.scope), )), ) # Send the request. response = await rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.SearchAllResourcesAsyncPager( method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response
def search_all_resources( self, request: asset_service.SearchAllResourcesRequest = None, *, scope: str = None, query: str = None, asset_types: Sequence[str] = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.SearchAllResourcesPager: r"""Searches all the resources under a given accessible CRM scope (project/folder/organization). This RPC gives callers especially admins the ability to search all the resources under a scope, even if they don't have .get permission of all the resources. Callers should have cloud.assets.SearchAllResources permission on the requested scope, otherwise it will be rejected. Args: request (google.cloud.asset_v1p1beta1.types.SearchAllResourcesRequest): The request object. Search all resources request. scope (str): Required. The relative name of an asset. The search is limited to the resources within the ``scope``. The allowed value must be: - Organization number (such as "organizations/123") - Folder number(such as "folders/1234") - Project number (such as "projects/12345") - Project id (such as "projects/abc") This corresponds to the ``scope`` field on the ``request`` instance; if ``request`` is provided, this should not be set. query (str): Optional. The query statement. This corresponds to the ``query`` field on the ``request`` instance; if ``request`` is provided, this should not be set. asset_types (Sequence[str]): Optional. A list of asset types that this request searches for. If empty, it will search all the supported asset types. This corresponds to the ``asset_types`` 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, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.asset_v1p1beta1.services.asset_service.pagers.SearchAllResourcesPager: Search all resources response. Iterating over this object will yield results and resolve additional pages automatically. """ # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([scope, query, asset_types]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." ) # Minor optimization to avoid making a copy if the user passes # in a asset_service.SearchAllResourcesRequest. # There's no risk of modifying the input as we've already verified # there are no flattened fields. if not isinstance(request, asset_service.SearchAllResourcesRequest): request = asset_service.SearchAllResourcesRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if scope is not None: request.scope = scope if query is not None: request.query = query if asset_types is not None: request.asset_types = asset_types # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.search_all_resources] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata((("scope", request.scope),)), ) # 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.SearchAllResourcesPager( method=rpc, request=request, response=response, metadata=metadata, ) # Done; return the response. return response