Skip to content

CloudWatchLogsClient#

Index > CloudWatchLogs > CloudWatchLogsClient

Auto-generated documentation for CloudWatchLogs type annotations stubs module mypy-boto3-logs.

CloudWatchLogsClient#

Type annotations and code completion for boto3.client("logs"). boto3 documentation

# CloudWatchLogsClient usage example

from boto3.session import Session
from mypy_boto3_logs.client import CloudWatchLogsClient

def get_logs_client() -> CloudWatchLogsClient:
    return Session().client("logs")

Exceptions#

boto3 client exceptions are generated in runtime. This class provides code completion for boto3.client("logs").exceptions structure.

# Exceptions.exceptions usage example

client = boto3.client("logs")

try:
    do_something(client)
except (
    client.exceptions.AccessDeniedException,
    client.exceptions.ClientError,
    client.exceptions.ConflictException,
    client.exceptions.DataAlreadyAcceptedException,
    client.exceptions.InvalidOperationException,
    client.exceptions.InvalidParameterException,
    client.exceptions.InvalidSequenceTokenException,
    client.exceptions.LimitExceededException,
    client.exceptions.MalformedQueryException,
    client.exceptions.OperationAbortedException,
    client.exceptions.ResourceAlreadyExistsException,
    client.exceptions.ResourceNotFoundException,
    client.exceptions.ServiceQuotaExceededException,
    client.exceptions.ServiceUnavailableException,
    client.exceptions.SessionStreamingException,
    client.exceptions.SessionTimeoutException,
    client.exceptions.ThrottlingException,
    client.exceptions.TooManyTagsException,
    client.exceptions.UnrecognizedClientException,
    client.exceptions.ValidationException,
) as e:
    print(e)
# Exceptions.exceptions type checking example

from mypy_boto3_logs.client import Exceptions

def handle_error(exc: Exceptions.AccessDeniedException) -> None:
    ...

Methods#

associate_kms_key#

Associates the specified KMS key with either one log group in the account, or with all stored CloudWatch Logs query insights results in the account.

Type annotations and code completion for boto3.client("logs").associate_kms_key method. boto3 documentation

# associate_kms_key method definition

def associate_kms_key(
    self,
    *,
    kmsKeyId: str,
    logGroupName: str = ...,
    resourceIdentifier: str = ...,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# associate_kms_key method usage example with argument unpacking

kwargs: AssociateKmsKeyRequestRequestTypeDef = {  # (1)
    "kmsKeyId": ...,
}

parent.associate_kms_key(**kwargs)
  1. See AssociateKmsKeyRequestRequestTypeDef

can_paginate#

Check if an operation can be paginated.

Type annotations and code completion for boto3.client("logs").can_paginate method. boto3 documentation

# can_paginate method definition

def can_paginate(
    self,
    operation_name: str,
) -> bool:
    ...

cancel_export_task#

Cancels the specified export task.

Type annotations and code completion for boto3.client("logs").cancel_export_task method. boto3 documentation

# cancel_export_task method definition

def cancel_export_task(
    self,
    *,
    taskId: str,
) -> EmptyResponseMetadataTypeDef:  # (1)
    ...
  1. See EmptyResponseMetadataTypeDef
# cancel_export_task method usage example with argument unpacking

kwargs: CancelExportTaskRequestRequestTypeDef = {  # (1)
    "taskId": ...,
}

parent.cancel_export_task(**kwargs)
  1. See CancelExportTaskRequestRequestTypeDef

close#

Closes underlying endpoint connections.

Type annotations and code completion for boto3.client("logs").close method.