Skip to content

Examples#

Index > GuardDuty > Examples

Auto-generated documentation for GuardDuty type annotations stubs module types-aiobotocore-guardduty.

Client#

Implicit type annotations#

Can be used with types-aioboto3[guardduty] package installed.

Write your GuardDuty code as usual, type checking and code completion should work out of the box.

# GuardDutyClient usage example

from aioboto3.session import Session


session = Session()

async with session.client("guardduty") as client:  # (1)
    result = await client.create_detector()  # (2)
  1. client: GuardDutyClient
  2. result: CreateDetectorResponseTypeDef
# DescribeMalwareScansPaginator usage example

from aioboto3.session import Session


session = Session()

async with session.client("guardduty") as client:  # (1)
    paginator = client.get_paginator("describe_malware_scans")  # (2)
    async for item in paginator.paginate(...):
        print(item)  # (3)
  1. client: GuardDutyClient
  2. paginator: DescribeMalwareScansPaginator
  3. item: DescribeMalwareScansResponseTypeDef

Explicit type annotations#

With types-aioboto3-lite[guardduty] or a standalone types_aiobotocore_guardduty package, you have to explicitly specify client: GuardDutyClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# GuardDutyClient usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_guardduty.client import GuardDutyClient
from types_aiobotocore_guardduty.type_defs import CreateDetectorResponseTypeDef
from types_aiobotocore_guardduty.type_defs import CreateDetectorRequestRequestTypeDef


session = Session()

client: GuardDutyClient
async with session.client("guardduty") as client:  # (1)
    kwargs: CreateDetectorRequestRequestTypeDef = {...}  # (2)
    result: CreateDetectorResponseTypeDef = await client.create_detector(**kwargs)  # (3)
  1. client: GuardDutyClient
  2. kwargs: CreateDetectorRequestRequestTypeDef
  3. result: CreateDetectorResponseTypeDef
# DescribeMalwareScansPaginator usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_guardduty.client import GuardDutyClient
from types_aiobotocore_guardduty.paginator import DescribeMalwareScansPaginator
from types_aiobotocore_guardduty.type_defs import DescribeMalwareScansResponseTypeDef


session = Session()

client: GuardDutyClient
async with session.client("guardduty") as client:  # (1)
    paginator: DescribeMalwareScansPaginator = client.get_paginator("describe_malware_scans")  # (2)
    async for item in paginator.paginate(...):
        item: DescribeMalwareScansResponseTypeDef
        print(item)  # (3)
  1. client: GuardDutyClient
  2. paginator: DescribeMalwareScansPaginator
  3. item: DescribeMalwareScansResponseTypeDef