Skip to content

Commit

Permalink
bump botocore dependency specification
Browse files Browse the repository at this point in the history
  • Loading branch information
jakob-keller committed Dec 16, 2024
1 parent a8da516 commit facd609
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 4 deletions.
5 changes: 5 additions & 0 deletions aiobotocore/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
parse_get_bucket_location as boto_parse_get_bucket_location,
)
from botocore.hooks import HierarchicalEmitter, logger
from botocore.signers import (
add_dsql_generate_db_auth_token_methods as boto_add_dsql_generate_db_auth_token_methods,
)
from botocore.signers import (
add_generate_db_auth_token as boto_add_generate_db_auth_token,
)
Expand All @@ -25,6 +28,7 @@
parse_get_bucket_location,
)
from .signers import (
add_dsql_generate_db_auth_token_methods,
add_generate_db_auth_token,
add_generate_presigned_post,
add_generate_presigned_url,
Expand All @@ -37,6 +41,7 @@
boto_add_generate_presigned_post: add_generate_presigned_post,
boto_add_generate_db_auth_token: add_generate_db_auth_token,
boto_parse_get_bucket_location: parse_get_bucket_location,
boto_add_dsql_generate_db_auth_token_methods: add_dsql_generate_db_auth_token_methods,
}


Expand Down
91 changes: 90 additions & 1 deletion aiobotocore/signers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import botocore
import botocore.auth
from botocore.exceptions import UnknownClientMethodError
from botocore.exceptions import ParamValidationError, UnknownClientMethodError
from botocore.signers import (
RequestSigner,
S3PostPresigner,
Expand Down Expand Up @@ -200,6 +200,15 @@ def add_generate_db_auth_token(class_attributes, **kwargs):
class_attributes['generate_db_auth_token'] = generate_db_auth_token


def add_dsql_generate_db_auth_token_methods(class_attributes, **kwargs):
class_attributes['generate_db_connect_auth_token'] = (

Check warning on line 204 in aiobotocore/signers.py

View check run for this annotation

Codecov / codecov/patch

aiobotocore/signers.py#L204

Added line #L204 was not covered by tests
dsql_generate_db_connect_auth_token
)
class_attributes['generate_db_connect_admin_auth_token'] = (

Check warning on line 207 in aiobotocore/signers.py

View check run for this annotation

Codecov / codecov/patch

aiobotocore/signers.py#L207

Added line #L207 was not covered by tests
dsql_generate_db_connect_admin_auth_token
)


async def generate_db_auth_token(
self, DBHostname, Port, DBUsername, Region=None
):
Expand Down Expand Up @@ -256,6 +265,86 @@ async def generate_db_auth_token(
return presigned_url[len(scheme) :]


async def _dsql_generate_db_auth_token(
self, Hostname, Action, Region=None, ExpiresIn=900
):
"""Generate a DSQL database token for an arbitrary action.
:type Hostname: str
:param Hostname: The DSQL endpoint host name.
:type Action: str
:param Action: Action to perform on the cluster (DbConnectAdmin or DbConnect).
:type Region: str
:param Region: The AWS region where the DSQL Cluster is hosted. If None, the client region will be used.
:type ExpiresIn: int
:param ExpiresIn: The token expiry duration in seconds (default is 900 seconds).
:return: A presigned url which can be used as an auth token.
"""
possible_actions = ("DbConnect", "DbConnectAdmin")

Check warning on line 282 in aiobotocore/signers.py

View check run for this annotation

Codecov / codecov/patch

aiobotocore/signers.py#L282

Added line #L282 was not covered by tests

if Action not in possible_actions:
raise ParamValidationError(

Check warning on line 285 in aiobotocore/signers.py

View check run for this annotation

Codecov / codecov/patch

aiobotocore/signers.py#L284-L285

Added lines #L284 - L285 were not covered by tests
report=f"Received {Action} for action but expected one of: {', '.join(possible_actions)}"
)

if Region is None:
Region = self.meta.region_name

Check warning on line 290 in aiobotocore/signers.py

View check run for this annotation

Codecov / codecov/patch

aiobotocore/signers.py#L289-L290

Added lines #L289 - L290 were not covered by tests

request_dict = {

Check warning on line 292 in aiobotocore/signers.py

View check run for this annotation

Codecov / codecov/patch

aiobotocore/signers.py#L292

Added line #L292 was not covered by tests
'url_path': '/',
'query_string': '',
'headers': {},
'body': {
'Action': Action,
},
'method': 'GET',
}
scheme = 'https://'
endpoint_url = f'{scheme}{Hostname}'
prepare_request_dict(request_dict, endpoint_url)
presigned_url = await self._request_signer.generate_presigned_url(

Check warning on line 304 in aiobotocore/signers.py

View check run for this annotation

Codecov / codecov/patch

aiobotocore/signers.py#L301-L304

Added lines #L301 - L304 were not covered by tests
operation_name=Action,
request_dict=request_dict,
region_name=Region,
expires_in=ExpiresIn,
signing_name='dsql',
)
return presigned_url[len(scheme) :]

Check warning on line 311 in aiobotocore/signers.py

View check run for this annotation

Codecov / codecov/patch

aiobotocore/signers.py#L311

Added line #L311 was not covered by tests


async def dsql_generate_db_connect_auth_token(
self, Hostname, Region=None, ExpiresIn=900
):
"""Generate a DSQL database token for the "DbConnect" action.
:type Hostname: str
:param Hostname: The DSQL endpoint host name.
:type Region: str
:param Region: The AWS region where the DSQL Cluster is hosted. If None, the client region will be used.
:type ExpiresIn: int
:param ExpiresIn: The token expiry duration in seconds (default is 900 seconds).
:return: A presigned url which can be used as an auth token.
"""
return await _dsql_generate_db_auth_token(

Check warning on line 326 in aiobotocore/signers.py

View check run for this annotation

Codecov / codecov/patch

aiobotocore/signers.py#L326

Added line #L326 was not covered by tests
self, Hostname, "DbConnect", Region, ExpiresIn
)


async def dsql_generate_db_connect_admin_auth_token(
self, Hostname, Region=None, ExpiresIn=900
):
"""Generate a DSQL database token for the "DbConnectAdmin" action.
:type Hostname: str
:param Hostname: The DSQL endpoint host name.
:type Region: str
:param Region: The AWS region where the DSQL Cluster is hosted. If None, the client region will be used.
:type ExpiresIn: int
:param ExpiresIn: The token expiry duration in seconds (default is 900 seconds).
:return: A presigned url which can be used as an auth token.
"""
return await _dsql_generate_db_auth_token(

Check warning on line 343 in aiobotocore/signers.py

View check run for this annotation

Codecov / codecov/patch

aiobotocore/signers.py#L343

Added line #L343 was not covered by tests
self, Hostname, "DbConnectAdmin", Region, ExpiresIn
)


class AioS3PostPresigner(S3PostPresigner):
async def generate_presigned_post(
self,
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ classifiers = [
dynamic = ["version", "readme"]

dependencies = [
"botocore >=1.35.67, <1.35.74", # NOTE: When updating, always keep `project.optional-dependencies` aligned
"botocore >=1.35.74, <1.35.82", # NOTE: When updating, always keep `project.optional-dependencies` aligned
"aiohttp >=3.9.2, <4.0.0",
"wrapt >=1.10.10, <2.0.0",
"aioitertools >=0.5.1, <1.0.0",
]

[project.optional-dependencies]
awscli = [
"awscli >=1.36.8, <1.36.15",
"awscli >=1.36.15, <1.36.23",
]
boto3 = [
"boto3 >=1.35.67, <1.35.74",
"boto3 >=1.35.74, <1.35.82",
]

[project.urls]
Expand Down
16 changes: 16 additions & 0 deletions tests/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@
from botocore.signers import (
RequestSigner,
S3PostPresigner,
_dsql_generate_db_auth_token,
add_dsql_generate_db_auth_token_methods,
add_generate_db_auth_token,
add_generate_presigned_post,
add_generate_presigned_url,
dsql_generate_db_connect_admin_auth_token,
dsql_generate_db_connect_auth_token,
generate_db_auth_token,
generate_presigned_post,
generate_presigned_url,
Expand Down Expand Up @@ -497,6 +501,18 @@
},
add_generate_db_auth_token: {'f61014e6fac4b5c7ee7ac2d2bec15fb16fa9fbe5'},
generate_db_auth_token: {'1f37e1e5982d8528841ce6b79f229b3e23a18959'},
add_dsql_generate_db_auth_token_methods: {
'95c68a1aac8ee549e11b5dc010b6bb03f9ea00ea',
},
_dsql_generate_db_auth_token: {
'53034b0475122209509db59fbd79a4ead70836cf',
},
dsql_generate_db_connect_auth_token: {
'29b5919b695113c55452f2325d0ff66dd719a647'
},
dsql_generate_db_connect_admin_auth_token: {
'd7e7a4899b8fd3a544dd1df95196517e2cfd5c84'
},
# tokens.py
create_token_resolver: {'b287f4879235a4292592a49b201d2b0bc2dbf401'},
DeferredRefreshableToken.__init__: {
Expand Down

0 comments on commit facd609

Please sign in to comment.