carlogtt_python_library.utils.aws_sig_v4_requests module

This module …

class carlogtt_python_library.utils.aws_sig_v4_requests.AwsSigV4Protocol(*values)[source]

Bases: Enum

Enum representing supported protocol types for the session.

RPCv0 = 1
RPCv1 = 2
class carlogtt_python_library.utils.aws_sig_v4_requests.AwsSigV4RequestMethod(*values)[source]

Bases: Enum

Enum class for the different types of requests that can be made to the PipelinesAPI.

Each enum value represents a specific type of request, such as GET, POST, PUT, or DELETE.

DELETE = 'DELETE'
GET = 'GET'
POST = 'POST'
PUT = 'PUT'
class carlogtt_python_library.utils.aws_sig_v4_requests.AwsSigV4Session(region_name: str, service_name: str, boto_session: Session, protocol: AwsSigV4Protocol)[source]

Bases: Session

Custom session that signs all outgoing HTTP requests using AWS Signature Version 4.

Parameters:
  • region_name – AWS region where the service is hosted (e.g., ‘us-west-2’).

  • service_name – Name of the AWS service (e.g., ‘execute-api’).

  • boto_session – Boto3 session that includes credentials.

  • protocol – AwsSigV4Protocol version for the request headers.

Raises:

AwsSigV4SessionError – If credentials are missing or HTTP response fails.

prepare_request(request: Request)[source]

Prepares and signs a request with AWS Signature Version 4.

Parameters:

request – The request object to be prepared and signed.

Returns:

The prepared request with SigV4 headers.

Raises:

AwsSigV4SessionError – If the specified protocol is not supported.

request(*args, **kwargs) Response[source]

Sends a signed HTTP request and checks for successful response status.

Parameters:
  • args – Positional arguments passed to requests.Session.request().

  • kwargs – Keyword arguments to configure the request.

Returns:

The HTTP response object.

Raises:

AwsSigV4SessionError – If the HTTP status code indicates failure.