def __init__(self, algorithm, # type: AwsSigningAlgorithm credentials_provider, # type: AwsCredentialsProviderBase region, # type: str service, # type: str date=None, # type: Optional[datetime.datetime] should_sign_param=None, # type: Optional[Callable[[str], bool]] use_double_uri_encode=False, # type: bool should_normalize_uri_path=True, # type: bool body_signing_type=AwsBodySigningConfigType.BodySigningOn # type: AwsBodySigningConfigType ): # type: (...) -> None assert isinstance(algorithm, AwsSigningAlgorithm) assert isinstance(credentials_provider, AwsCredentialsProviderBase) assert isinstance_str(region) assert isinstance_str(service) assert isinstance(date, datetime.datetime) or date is None assert callable(should_sign_param) or should_sign_param is None assert isinstance(body_signing_type, AwsBodySigningConfigType) super(AwsSigningConfig, self).__init__() if date is None: date = datetime.datetime.now(_utc) try: timestamp = date.timestamp() except AttributeError: # Python 2 doesn't have datetime.timestamp() function. # If it did we could just call it from binding code instead of calculating it here. if date.tzinfo is None: timestamp = time.mktime(date.timetuple()) else: epoch = datetime.datetime(1970, 1, 1, tzinfo=_utc) timestamp = (date - epoch).total_seconds() self._priv_should_sign_cb = should_sign_param if should_sign_param is not None: def should_sign_param_wrapper(name): return should_sign_param(name=name) else: should_sign_param_wrapper = None self._binding = _awscrt.signing_config_new( algorithm, credentials_provider, region, service, date, timestamp, should_sign_param_wrapper, use_double_uri_encode, should_normalize_uri_path, body_signing_type)
def __init__( self, algorithm, signature_type, credentials_provider, region, service, date=None, should_sign_header=None, use_double_uri_encode=True, should_normalize_uri_path=True, signed_body_value=None, signed_body_header_type=AwsSignedBodyHeaderType.NONE, expiration_in_seconds=None, omit_session_token=False, ): assert isinstance(algorithm, AwsSigningAlgorithm) assert isinstance(signature_type, AwsSignatureType) assert isinstance(credentials_provider, AwsCredentialsProvider) assert isinstance(region, str) assert isinstance(service, str) assert callable(should_sign_header) or should_sign_header is None assert signed_body_value is None or (isinstance( signed_body_value, str) and len(signed_body_value) > 0) assert isinstance(signed_body_header_type, AwsSignedBodyHeaderType) assert expiration_in_seconds is None or expiration_in_seconds > 0 super().__init__() if date is None: date = datetime.datetime.now(datetime.timezone.utc) timestamp = date.timestamp() self._priv_should_sign_cb = should_sign_header if should_sign_header is not None: def should_sign_header_wrapper(name): return should_sign_header(name=name) else: should_sign_header_wrapper = None if expiration_in_seconds is None: # C layer uses 0 to indicate None expiration_in_seconds = 0 self._binding = _awscrt.signing_config_new( algorithm, signature_type, credentials_provider, region, service, date, timestamp, should_sign_header_wrapper, use_double_uri_encode, should_normalize_uri_path, signed_body_value, signed_body_header_type, expiration_in_seconds, omit_session_token)
def __init__( self, algorithm, signature_type, credentials_provider, region, service, date=None, should_sign_header=None, use_double_uri_encode=True, should_normalize_uri_path=True, signed_body_value_type=AwsSignedBodyValueType.PAYLOAD, signed_body_header_type=AwsSignedBodyHeaderType.NONE, expiration_in_seconds=None, omit_session_token=False, ): assert isinstance(algorithm, AwsSigningAlgorithm) assert isinstance(signature_type, AwsSignatureType) assert isinstance(credentials_provider, AwsCredentialsProviderBase) assert isinstance_str(region) assert isinstance_str(service) assert callable(should_sign_header) or should_sign_header is None assert isinstance(signed_body_value_type, AwsSignedBodyValueType) assert isinstance(signed_body_header_type, AwsSignedBodyHeaderType) assert expiration_in_seconds is None or expiration_in_seconds > 0 super(AwsSigningConfig, self).__init__() if date is None: date = datetime.datetime.now(_utc) try: timestamp = date.timestamp() except AttributeError: # Python 2 doesn't have datetime.timestamp() function. # If it did we could just call it from binding code instead of calculating it here. if date.tzinfo is None: timestamp = time.mktime(date.timetuple()) else: epoch = datetime.datetime(1970, 1, 1, tzinfo=_utc) timestamp = (date - epoch).total_seconds() self._priv_should_sign_cb = should_sign_header if should_sign_header is not None: def should_sign_header_wrapper(name): return should_sign_header(name=name) else: should_sign_header_wrapper = None if expiration_in_seconds is None: # C layer uses 0 to indicate None expiration_in_seconds = 0 self._binding = _awscrt.signing_config_new( algorithm, signature_type, credentials_provider, region, service, date, timestamp, should_sign_header_wrapper, use_double_uri_encode, should_normalize_uri_path, signed_body_value_type, signed_body_header_type, expiration_in_seconds, omit_session_token)