def test_search_all_resources(self):
        # Setup Expected Response
        next_page_token = ""
        results_element = {}
        results = [results_element]
        expected_response = {
            "next_page_token": next_page_token,
            "results": results
        }
        expected_response = asset_service_pb2.SearchAllResourcesResponse(
            **expected_response)

        # Mock the API response
        channel = ChannelStub(responses=[expected_response])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = asset_v1p1beta1.AssetServiceClient()

        # Setup Request
        scope = "scope109264468"

        paged_list_response = client.search_all_resources(scope)
        resources = list(paged_list_response)
        assert len(resources) == 1

        assert expected_response.results[0] == resources[0]

        assert len(channel.requests) == 1
        expected_request = asset_service_pb2.SearchAllResourcesRequest(
            scope=scope)
        actual_request = channel.requests[0][1]
        assert expected_request == actual_request
    def test_search_all_resources_exception(self):
        channel = ChannelStub(responses=[CustomException()])
        patch = mock.patch("google.api_core.grpc_helpers.create_channel")
        with patch as create_channel:
            create_channel.return_value = channel
            client = asset_v1p1beta1.AssetServiceClient()

        # Setup request
        scope = "scope109264468"

        paged_list_response = client.search_all_resources(scope)
        with pytest.raises(CustomException):
            list(paged_list_response)
def sample_search_all_iam_policies():
    # Create a client
    client = asset_v1p1beta1.AssetServiceClient()

    # Initialize request argument(s)
    request = asset_v1p1beta1.SearchAllIamPoliciesRequest(
        scope="scope_value", )

    # Make the request
    page_result = client.search_all_iam_policies(request=request)

    # Handle the response
    for response in page_result:
        print(response)