Skip to content

Examples#

Index > Glacier > Examples

Auto-generated documentation for Glacier type annotations stubs module mypy-boto3-glacier.

Client#

Implicit type annotations#

Can be used with boto3-stubs[glacier] package installed.

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

Client method usage example#

# GlacierClient usage example

from boto3.session import Session


session = Session()

client = session.client("glacier")  # (1)
result = client.abort_multipart_upload()  # (2)
  1. client: GlacierClient
  2. result: EmptyResponseMetadataTypeDef

Paginator usage example#

# ListJobsPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("glacier")  # (1)

paginator = client.get_paginator("list_jobs")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: GlacierClient
  2. paginator: ListJobsPaginator
  3. item: ListJobsOutputTypeDef

Waiter usage example#

# VaultExistsWaiter usage example

from boto3.session import Session


session = Session()
client = session.client("glacier")  # (1)

waiter = client.get_waiter("vault_exists")  # (2)
waiter.wait(...)
  1. client: GlacierClient
  2. waiter: VaultExistsWaiter

Explicit type annotations#

With boto3-stubs-lite[glacier] or a standalone mypy_boto3_glacier package, you have to explicitly specify client: GlacierClient 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#

# GlacierClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_glacier.client import GlacierClient
from mypy_boto3_glacier.type_defs import EmptyResponseMetadataTypeDef
from mypy_boto3_glacier.type_defs import AbortMultipartUploadInputTypeDef


session = Session()

client: GlacierClient = session.client("glacier")

kwargs: AbortMultipartUploadInputTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.abort_multipart_upload(**kwargs)

Paginator usage example#

# ListJobsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_glacier.client import GlacierClient
from mypy_boto3_glacier.paginator import ListJobsPaginator
from mypy_boto3_glacier.type_defs import ListJobsOutputTypeDef


session = Session()
client: GlacierClient = session.client("glacier")

paginator: ListJobsPaginator = client.get_paginator("list_jobs")
for item in paginator.paginate(...):
    item: ListJobsOutputTypeDef
    print(item)

Waiter usage example#

# VaultExistsWaiter usage example with type annotations

from boto3.session import Session

from mypy_boto3_glacier.client import GlacierClient
from mypy_boto3_glacier.waiter import VaultExistsWaiter

session = Session()
client: GlacierClient = session.client("glacier")

waiter: VaultExistsWaiter = client.get_waiter("vault_exists")
waiter.wait(...)

Service Resource#

Implicit type annotations#

Can be used with boto3-stubs[glacier] package installed.

ServiceResource method usage example#

# GlacierServiceResource usage example

from boto3.session import Session


session = Session()

resource = session.resource("glacier")  # (1)
result = resource.create_vault(...)  # (2)
  1. resource: GlacierServiceResource
  2. result: Vault

Collection usage example#

# ServiceResourceVaultsCollection usage example

from boto3.session import Session


session = Session()
resource = session.resource("glacier")  # (1)

collection = resource.vaults  # (2)
for item in collection:
    print(item)  # (3)
  1. resource: GlacierServiceResource
  2. collection: ServiceResourceVaultsCollection
  3. item: Vault

Explicit type annotations#

With boto3-stubs-lite[glacier] or a standalone mypy_boto3_glacier package, you have to explicitly specify resource: GlacierServiceResource 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#

# GlacierServiceResource usage example with type annotations

from boto3.session import Session

from mypy_boto3_glacier.service_resource import GlacierServiceResource
from mypy_boto3_glacier.service_resource import Vault
from mypy_boto3_glacier.type_defs import CreateVaultInputServiceResourceCreateVaultTypeDef


session = Session()

resource: GlacierServiceResource = session.resource("glacier")
kwargs: CreateVaultInputServiceResourceCreateVaultTypeDef = {...}  # (2)
result: Vault = resource.create_vault(**kwargs)
  1. resource: GlacierServiceResource
  2. kwargs: CreateVaultInputServiceResourceCreateVaultTypeDef
  3. result: Vault

Collection usage example#

# ServiceResourceVaultsCollection usage example with type annotations

from boto3.session import Session

from mypy_boto3_glacier.service_resource import GlacierServiceResource
from mypy_boto3_glacier.service_resource import ServiceResourceVaultsCollection
from mypy_boto3_glacier.service_resource import Vault


session = Session()

resource: GlacierServiceResource = session.resource("glacier")  # (1)

collection: ServiceResourceVaultsCollection = resource.vaults  # (2)
for item in collection:
    item: Vault
    print(item)  # (3)
  1. resource: GlacierServiceResource
  2. collection: GlacierServiceResource
  3. item: Vault