Skip to content

Examples#

Index > OpsWorks > Examples

Auto-generated documentation for OpsWorks type annotations stubs module types-aiobotocore-opsworks.

Client#

Implicit type annotations#

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

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

Client method usage example#

# OpsWorksClient usage example

from aioboto3.session import Session


session = Session()

async with session.client("opsworks") as client:  # (1)
    result = await client.assign_instance()  # (2)
  1. client: OpsWorksClient
  2. result: EmptyResponseMetadataTypeDef

Paginator usage example#

# DescribeEcsClustersPaginator usage example

from aioboto3.session import Session


session = Session()

async with session.client("opsworks") as client:  # (1)
    paginator = client.get_paginator("describe_ecs_clusters")  # (2)
    async for item in paginator.paginate(...):
        print(item)  # (3)
  1. client: OpsWorksClient
  2. paginator: DescribeEcsClustersPaginator
  3. item: DescribeEcsClustersResultTypeDef

Waiter usage example#

# AppExistsWaiter usage example

from aioboto3.session import Session


session = Session()

async with session.client("opsworks") as client:  # (1)
    waiter = client.get_waiter("app_exists")  # (2)
    await waiter.wait(...)
  1. client: OpsWorksClient
  2. waiter: AppExistsWaiter

Explicit type annotations#

With types-aioboto3-lite[opsworks] or a standalone types_aiobotocore_opsworks package, you have to explicitly specify client: OpsWorksClient 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.

Client method usage example#

# OpsWorksClient usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_opsworks.client import OpsWorksClient
from types_aiobotocore_opsworks.type_defs import EmptyResponseMetadataTypeDef
from types_aiobotocore_opsworks.type_defs import AssignInstanceRequestTypeDef


session = Session()

client: OpsWorksClient
async with session.client("opsworks") as client:  # (1)
    kwargs: AssignInstanceRequestTypeDef = {...}  # (2)
    result: EmptyResponseMetadataTypeDef = await client.assign_instance(**kwargs)  # (3)
  1. client: OpsWorksClient
  2. kwargs: AssignInstanceRequestTypeDef
  3. result: EmptyResponseMetadataTypeDef

Paginator usage example#

# DescribeEcsClustersPaginator usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_opsworks.client import OpsWorksClient
from types_aiobotocore_opsworks.paginator import DescribeEcsClustersPaginator
from types_aiobotocore_opsworks.type_defs import DescribeEcsClustersResultTypeDef


session = Session()

client: OpsWorksClient
async with session.client("opsworks") as client:  # (1)
    paginator: DescribeEcsClustersPaginator = client.get_paginator("describe_ecs_clusters")  # (2)
    async for item in paginator.paginate(...):
        item: DescribeEcsClustersResultTypeDef
        print(item)  # (3)
  1. client: OpsWorksClient
  2. paginator: DescribeEcsClustersPaginator
  3. item: DescribeEcsClustersResultTypeDef

Waiter usage example#

# AppExistsWaiter usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_opsworks.client import OpsWorksClient
from types_aiobotocore_opsworks.waiter import AppExistsWaiter


session = Session()

async with session.client("opsworks") as client:  # (1)
    waiter = client.get_waiter("app_exists")  # (2)
    await waiter.wait(...)
  1. client: OpsWorksClient
  2. waiter: AppExistsWaiter

Service Resource#

Implicit type annotations#

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

ServiceResource method usage example#

# OpsWorksServiceResource usage example

from aioboto3.session import Session


session = Session()

async with session.resource("opsworks") as resource:  # (1)
    result = await resource.create_stack(...)  # (2)
  1. resource: OpsWorksServiceResource
  2. result: Stack

Collection usage example#

# ServiceResourceStacksCollection usage example

from aioboto3.session import Session


session = Session()

async with session.resource("opsworks") as resource:  # (1)
    collection = resource.stacks  # (2)
    async for item in collection:
        print(item)  # (3)
  1. resource: OpsWorksServiceResource
  2. collection: ServiceResourceStacksCollection
  3. item: Stack

Explicit type annotations#

With types-aioboto3-lite[opsworks] or a standalone types_aiobotocore_opsworks package, you have to explicitly specify resource: OpsWorksServiceResource 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.

ServiceResource method usage example#

# OpsWorksServiceResource usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_opsworks.service_resource import OpsWorksServiceResource
from types_aiobotocore_opsworks.service_resource import Stack
from types_aiobotocore_opsworks.type_defs import CreateStackRequestServiceResourceCreateStackTypeDef


session = Session()

resource: OpsWorksServiceResource
async with session.resource("opsworks") as resource:  # (1)
    kwargs: CreateStackRequestServiceResourceCreateStackTypeDef = {...}  # (2)
    result: Stack = await resource.create_stack(...) # (3)
  1. resource: OpsWorksServiceResource
  2. kwargs: CreateStackRequestServiceResourceCreateStackTypeDef
  3. result: Stack

Collection usage example#

# ServiceResourceStacksCollection usage example with type annotations

from aioboto3.session import Session

from types_aiobotocore_opsworks.service_resource import OpsWorksServiceResource
from types_aiobotocore_opsworks.service_resource import ServiceResourceStacksCollection
from types_aiobotocore_opsworks.service_resource import Stack


session = Session()

resource: OpsWorksServiceResource
async with session.resource("opsworks") as resource:  # (1)
    collection: ServiceResourceStacksCollection = resource.stacks  # (2)
    async for item in collection:
        item: Stack
        print(item)  # (3)
  1. resource: OpsWorksServiceResource
  2. collection: OpsWorksServiceResource
  3. item: Stack