def test_get_exclusion(self): # Setup Expected Response name_2 = 'name2-1052831874' description = 'description-1724546052' filter_ = 'filter-1274492040' disabled = True expected_response = { 'name': name_2, 'description': description, 'filter': filter_, 'disabled': disabled } expected_response = logging_config_pb2.LogExclusion( **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 = logging_v2.ConfigServiceV2Client() # Setup Request name = client.exclusion_path('[PROJECT]', '[EXCLUSION]') response = client.get_exclusion(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.GetExclusionRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_cmek_settings(self): # Setup Expected Response name = "name3373707" kms_key_name = "kmsKeyName2094986649" service_account_id = "serviceAccountId-111486921" expected_response = { "name": name, "kms_key_name": kms_key_name, "service_account_id": service_account_id, } expected_response = logging_config_pb2.CmekSettings( **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 = logging_v2.ConfigServiceV2Client() response = client.update_cmek_settings() assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.UpdateCmekSettingsRequest() actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_list_sinks(self): # Setup Expected Response next_page_token = '' sinks_element = {} sinks = [sinks_element] expected_response = { 'next_page_token': next_page_token, 'sinks': sinks } expected_response = logging_config_pb2.ListSinksResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup Request parent = client.project_path('[PROJECT]') paged_list_response = client.list_sinks(parent) resources = list(paged_list_response) assert len(resources) == 1 assert expected_response.sinks[0] == resources[0] assert len(channel.requests) == 1 expected_request = logging_config_pb2.ListSinksRequest(parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_exclusion(self): # Setup Expected Response name_2 = 'name2-1052831874' description = 'description-1724546052' filter_ = 'filter-1274492040' disabled = True expected_response = { 'name': name_2, 'description': description, 'filter': filter_, 'disabled': disabled } expected_response = logging_config_pb2.LogExclusion( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup Request name = client.exclusion_path('[PROJECT]', '[EXCLUSION]') exclusion = {} update_mask = {} response = client.update_exclusion(name, exclusion, update_mask) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.UpdateExclusionRequest( name=name, exclusion=exclusion, update_mask=update_mask) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_sink(self): # Setup Expected Response name = "name3373707" destination = "destination-1429847026" filter_ = "filter-1274492040" writer_identity = "writerIdentity775638794" include_children = True expected_response = { "name": name, "destination": destination, "filter": filter_, "writer_identity": writer_identity, "include_children": include_children, } expected_response = logging_config_pb2.LogSink(**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 = logging_v2.ConfigServiceV2Client() # Setup Request sink_name = client.sink_path("[PROJECT]", "[SINK]") sink = {} response = client.update_sink(sink_name, sink) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.UpdateSinkRequest( sink_name=sink_name, sink=sink) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_exclusion(self): # Setup Expected Response name = 'name3373707' description = 'description-1724546052' filter_ = 'filter-1274492040' disabled = True expected_response = { 'name': name, 'description': description, 'filter': filter_, 'disabled': disabled } expected_response = logging_config_pb2.LogExclusion( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup Request parent = client.project_path('[PROJECT]') exclusion = {} response = client.create_exclusion(parent, exclusion) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.CreateExclusionRequest( parent=parent, exclusion=exclusion) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_exclusion(self): # Setup Expected Response name = "name3373707" description = "description-1724546052" filter_ = "filter-1274492040" disabled = True expected_response = { "name": name, "description": description, "filter": filter_, "disabled": disabled, } expected_response = logging_config_pb2.LogExclusion( **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 = logging_v2.ConfigServiceV2Client() # Setup Request parent = client.project_path("[PROJECT]") exclusion = {} response = client.create_exclusion(parent, exclusion) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.CreateExclusionRequest( parent=parent, exclusion=exclusion) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_exclusion(self): # Setup Expected Response name_2 = "name2-1052831874" description = "description-1724546052" filter_ = "filter-1274492040" disabled = True expected_response = { "name": name_2, "description": description, "filter": filter_, "disabled": disabled, } expected_response = logging_config_pb2.LogExclusion( **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 = logging_v2.ConfigServiceV2Client() # Setup Request name = client.exclusion_path("[PROJECT]", "[EXCLUSION]") exclusion = {} update_mask = {} response = client.update_exclusion(name, exclusion, update_mask) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.UpdateExclusionRequest( name=name, exclusion=exclusion, update_mask=update_mask) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_sink(self): # Setup Expected Response name = 'name3373707' destination = 'destination-1429847026' filter_ = 'filter-1274492040' writer_identity = 'writerIdentity775638794' include_children = True expected_response = { 'name': name, 'destination': destination, 'filter': filter_, 'writer_identity': writer_identity, 'include_children': include_children } expected_response = logging_config_pb2.LogSink(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup Request parent = client.project_path('[PROJECT]') sink = {} response = client.create_sink(parent, sink) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.CreateSinkRequest(parent=parent, sink=sink) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_list_sinks(self): # Setup Expected Response next_page_token = "" sinks_element = {} sinks = [sinks_element] expected_response = { "next_page_token": next_page_token, "sinks": sinks } expected_response = logging_config_pb2.ListSinksResponse( **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 = logging_v2.ConfigServiceV2Client() # Setup Request parent = client.project_path("[PROJECT]") paged_list_response = client.list_sinks(parent) resources = list(paged_list_response) assert len(resources) == 1 assert expected_response.sinks[0] == resources[0] assert len(channel.requests) == 1 expected_request = logging_config_pb2.ListSinksRequest(parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_sink(self): # Setup Expected Response name = 'name3373707' destination = 'destination-1429847026' filter_ = 'filter-1274492040' writer_identity = 'writerIdentity775638794' include_children = True expected_response = { 'name': name, 'destination': destination, 'filter': filter_, 'writer_identity': writer_identity, 'include_children': include_children } expected_response = logging_config_pb2.LogSink(**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 = logging_v2.ConfigServiceV2Client() # Setup Request sink_name = client.sink_path('[PROJECT]', '[SINK]') sink = {} response = client.update_sink(sink_name, sink) assert expected_response == response assert len(channel.requests) == 1 expected_request = logging_config_pb2.UpdateSinkRequest( sink_name=sink_name, sink=sink) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_list_exclusions(self): # Setup Expected Response next_page_token = '' exclusions_element = {} exclusions = [exclusions_element] expected_response = { 'next_page_token': next_page_token, 'exclusions': exclusions } expected_response = logging_config_pb2.ListExclusionsResponse( **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 = logging_v2.ConfigServiceV2Client() # Setup Request parent = client.project_path('[PROJECT]') paged_list_response = client.list_exclusions(parent) resources = list(paged_list_response) assert len(resources) == 1 assert expected_response.exclusions[0] == resources[0] assert len(channel.requests) == 1 expected_request = logging_config_pb2.ListExclusionsRequest( parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request
def sample_undelete_bucket(): # Create a client client = logging_v2.ConfigServiceV2Client() # Initialize request argument(s) request = logging_v2.UndeleteBucketRequest(name="name_value", ) # Make the request client.undelete_bucket(request=request)
def sample_delete_exclusion(): # Create a client client = logging_v2.ConfigServiceV2Client() # Initialize request argument(s) request = logging_v2.DeleteExclusionRequest(name="name_value", ) # Make the request client.delete_exclusion(request=request)
def sample_delete_sink(): # Create a client client = logging_v2.ConfigServiceV2Client() # Initialize request argument(s) request = logging_v2.DeleteSinkRequest(sink_name="sink_name_value", ) # Make the request client.delete_sink(request=request)
def test_update_cmek_settings_exception(self): # Mock the API response 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 = logging_v2.ConfigServiceV2Client() with pytest.raises(CustomException): client.update_cmek_settings()
def test_list_sinks_exception(self): channel = ChannelStub(responses=[CustomException()]) client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup request parent = client.project_path('[PROJECT]') paged_list_response = client.list_sinks(parent) with pytest.raises(CustomException): list(paged_list_response)
def test_delete_sink_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup request sink_name = client.sink_path('[PROJECT]', '[SINK]') with pytest.raises(CustomException): client.delete_sink(sink_name)
def test_delete_exclusion_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup request name = client.exclusion_path('[PROJECT]', '[EXCLUSION]') with pytest.raises(CustomException): client.delete_exclusion(name)
def sample_undelete_bucket(): """Snippet for undelete_bucket""" # Create a client client = logging_v2.ConfigServiceV2Client() # Initialize request argument(s) request = logging_v2.UndeleteBucketRequest() # Make the request response = client.undelete_bucket(request=request)
def sample_delete_exclusion(): """Snippet for delete_exclusion""" # Create a client client = logging_v2.ConfigServiceV2Client() # Initialize request argument(s) request = logging_v2.DeleteExclusionRequest() # Make the request response = client.delete_exclusion(request=request)
def test_create_exclusion_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup request parent = client.project_path('[PROJECT]') exclusion = {} with pytest.raises(CustomException): client.create_exclusion(parent, exclusion)
def sample_update_bucket(): # Create a client client = logging_v2.ConfigServiceV2Client() # Initialize request argument(s) request = logging_v2.UpdateBucketRequest(name="name_value", ) # Make the request response = client.update_bucket(request=request) # Handle the response print(response)
def sample_get_settings(): # Create a client client = logging_v2.ConfigServiceV2Client() # Initialize request argument(s) request = logging_v2.GetSettingsRequest(name="name_value", ) # Make the request response = client.get_settings(request=request) # Handle the response print(response)
def test_list_sinks_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 = logging_v2.ConfigServiceV2Client() # Setup request parent = client.project_path("[PROJECT]") paged_list_response = client.list_sinks(parent) with pytest.raises(CustomException): list(paged_list_response)
def sample_list_buckets(): # Create a client client = logging_v2.ConfigServiceV2Client() # Initialize request argument(s) request = logging_v2.ListBucketsRequest(parent="parent_value", ) # Make the request page_result = client.list_buckets(request=request) # Handle the response for response in page_result: print(response)
def test_delete_exclusion_exception(self): # Mock the API response 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 = logging_v2.ConfigServiceV2Client() # Setup request name = client.exclusion_path("[PROJECT]", "[EXCLUSION]") with pytest.raises(CustomException): client.delete_exclusion(name)
def sample_list_buckets(): """Snippet for list_buckets""" # Create a client client = logging_v2.ConfigServiceV2Client() # Initialize request argument(s) request = logging_v2.ListBucketsRequest() # Make the request page_result = client.list_buckets(request=request) for response in page_result: print("{}".format(response))
def test_delete_exclusion(self): channel = ChannelStub() client = logging_v2.ConfigServiceV2Client(channel=channel) # Setup Request name = client.exclusion_path('[PROJECT]', '[EXCLUSION]') client.delete_exclusion(name) assert len(channel.requests) == 1 expected_request = logging_config_pb2.DeleteExclusionRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_sink_exception(self): # Mock the API response 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 = logging_v2.ConfigServiceV2Client() # Setup request sink_name = client.sink_path("[PROJECT]", "[SINK]") with pytest.raises(CustomException): client.get_sink(sink_name)