code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def _is_within_directory(directory: Union[str, os.PathLike], target: Union[str, os.PathLike]) -> bool:
"""Checks if target is located under directory"""
abs_directory = os.path.abspath(directory)
abs_target = os.path.abspath(target)
prefix = os.path.commonprefix([abs_directory, abs_target])
return... | Checks if target is located under directory | _is_within_directory | python | aws/aws-sam-cli | samcli/lib/utils/tar.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/tar.py | Apache-2.0 |
def extract_tarfile(
tarfile_path: Union[str, os.PathLike] = "",
file_obj: Optional[IO[bytes]] = None,
unpack_dir: Union[str, os.PathLike] = "",
) -> None:
"""
Extracts a tarfile using the provided parameters. If file_obj is specified,
it is used instead of the file_obj opened for tarfile_path.
... |
Extracts a tarfile using the provided parameters. If file_obj is specified,
it is used instead of the file_obj opened for tarfile_path.
Parameters
----------
tarfile_path Union[str, os.PathLike]
Key representing a full path to the file or directory and the Value representing the path withi... | extract_tarfile | python | aws/aws-sam-cli | samcli/lib/utils/tar.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/tar.py | Apache-2.0 |
def to_timestamp(some_time):
"""
Converts the given datetime value to Unix timestamp
Parameters
----------
some_time : datetime.datetime
Value to be converted to unix epoch. This must be without any timezone identifier
Returns
-------
int
Unix timestamp of the given tim... |
Converts the given datetime value to Unix timestamp
Parameters
----------
some_time : datetime.datetime
Value to be converted to unix epoch. This must be without any timezone identifier
Returns
-------
int
Unix timestamp of the given time
| to_timestamp | python | aws/aws-sam-cli | samcli/lib/utils/time.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/time.py | Apache-2.0 |
def to_utc(some_time):
"""
Convert the given date to UTC, if the date contains a timezone.
Parameters
----------
some_time : datetime.datetime
datetime object to convert to UTC
Returns
-------
datetime.datetime
Converted datetime object
"""
# Convert timezone a... |
Convert the given date to UTC, if the date contains a timezone.
Parameters
----------
some_time : datetime.datetime
datetime object to convert to UTC
Returns
-------
datetime.datetime
Converted datetime object
| to_utc | python | aws/aws-sam-cli | samcli/lib/utils/time.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/time.py | Apache-2.0 |
def parse_date(date_string):
"""
Parse the given string as datetime object. This parser supports in almost any string formats.
For relative times, like `10min ago`, this parser computes the actual time relative to current UTC time. This
allows time to always be in UTC if an explicit time zone is not pr... |
Parse the given string as datetime object. This parser supports in almost any string formats.
For relative times, like `10min ago`, this parser computes the actual time relative to current UTC time. This
allows time to always be in UTC if an explicit time zone is not provided.
Parameters
--------... | parse_date | python | aws/aws-sam-cli | samcli/lib/utils/time.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/time.py | Apache-2.0 |
def check_newer_version(func):
"""
This function returns a wrapped function definition, which checks if there are newer version of SAM CLI available
Parameters
----------
func: function reference
Actual function (command) which will be executed
Returns
-------
function referenc... |
This function returns a wrapped function definition, which checks if there are newer version of SAM CLI available
Parameters
----------
func: function reference
Actual function (command) which will be executed
Returns
-------
function reference:
A wrapped function referenc... | check_newer_version | python | aws/aws-sam-cli | samcli/lib/utils/version_checker.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/version_checker.py | Apache-2.0 |
def _inform_newer_version(force_check=False) -> None:
"""
Compares installed SAM CLI version with the up to date version from PyPi,
and print information if up to date version is different then what is installed now
It will store last version check time into GlobalConfig, so that it won't be running al... |
Compares installed SAM CLI version with the up to date version from PyPi,
and print information if up to date version is different then what is installed now
It will store last version check time into GlobalConfig, so that it won't be running all the time
Currently, it will be checking weekly
Par... | _inform_newer_version | python | aws/aws-sam-cli | samcli/lib/utils/version_checker.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/version_checker.py | Apache-2.0 |
def fetch_and_compare_versions() -> None:
"""
Compare current up to date version with the installed one, and inform if a newer version available
"""
response = get(AWS_SAM_CLI_PYPI_ENDPOINT, timeout=PYPI_CALL_TIMEOUT_IN_SECONDS)
result = response.json()
latest_version = result.get("info", {}).ge... |
Compare current up to date version with the installed one, and inform if a newer version available
| fetch_and_compare_versions | python | aws/aws-sam-cli | samcli/lib/utils/version_checker.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/version_checker.py | Apache-2.0 |
def is_version_check_overdue(last_version_check) -> bool:
"""
Check if last version check have been made longer then a week ago
Parameters
----------
last_version_check: epoch time
last_version_check epoch time read from GlobalConfig
Returns
-------
bool:
True if last_v... |
Check if last version check have been made longer then a week ago
Parameters
----------
last_version_check: epoch time
last_version_check epoch time read from GlobalConfig
Returns
-------
bool:
True if last_version_check is None or older then a week, False otherwise
| is_version_check_overdue | python | aws/aws-sam-cli | samcli/lib/utils/version_checker.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/utils/version_checker.py | Apache-2.0 |
def _get_deployment_preferences_status(function):
"""
Takes a AWS::Serverless::Function resource and checks if resource have a deployment preferences applied
to it. If DeploymentPreference found then it returns its status if it is enabled or not.
"""
deployment_preference = function.get("Properties"... |
Takes a AWS::Serverless::Function resource and checks if resource have a deployment preferences applied
to it. If DeploymentPreference found then it returns its status if it is enabled or not.
| _get_deployment_preferences_status | python | aws/aws-sam-cli | samcli/lib/warnings/sam_cli_warning.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/warnings/sam_cli_warning.py | Apache-2.0 |
def check_template_for_warning(self, warning_name, template_dict):
"""
Checks provided template against the warning based on warning_name.
Parameters
----------
warning_name: Name of warning which needs to be checked.
template_dict: template dict
Returns
... |
Checks provided template against the warning based on warning_name.
Parameters
----------
warning_name: Name of warning which needs to be checked.
template_dict: template dict
Returns
-------
warning_message if warning detected. None if no warning found.... | check_template_for_warning | python | aws/aws-sam-cli | samcli/lib/warnings/sam_cli_warning.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/warnings/sam_cli_warning.py | Apache-2.0 |
def check(self, template_dict):
"""
Checking if template dictionary have CodeDeployWarning or not.
"""
functions = [
resource
for (_, resource) in template_dict.get("Resources", {}).items()
if resource.get("Type", "") == "AWS::Serverless::Function"
... |
Checking if template dictionary have CodeDeployWarning or not.
| check | python | aws/aws-sam-cli | samcli/lib/warnings/sam_cli_warning.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/warnings/sam_cli_warning.py | Apache-2.0 |
def check(self, template_dict):
"""
Checking if template dictionary have Function with Condition and DeploymentPreferences which
will trigger this warning.
"""
functions = [
resource
for (_, resource) in template_dict.get("Resources", {}).items()
... |
Checking if template dictionary have Function with Condition and DeploymentPreferences which
will trigger this warning.
| check | python | aws/aws-sam-cli | samcli/lib/warnings/sam_cli_warning.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/lib/warnings/sam_cli_warning.py | Apache-2.0 |
def construct_v1_event(
flask_request, port, binary_types, stage_name=None, stage_variables=None, operation_name=None, api_type=Route.API
) -> Dict[str, Any]:
"""
Helper method that constructs the Event to be passed to Lambda.
Used for Http apis with payload v1 and Rest apis because the payloads are alm... |
Helper method that constructs the Event to be passed to Lambda.
Used for Http apis with payload v1 and Rest apis because the payloads are almost identical
:param request flask_request: Flask Request
:param port: the port number
:param binary_types: list of binary types
:param stage_name: Optio... | construct_v1_event | python | aws/aws-sam-cli | samcli/local/apigw/event_constructor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/event_constructor.py | Apache-2.0 |
def construct_v2_event_http(
flask_request,
port,
binary_types,
stage_name=None,
stage_variables=None,
route_key=None,
request_time_epoch=int(time()),
request_time=datetime.utcnow().strftime("%d/%b/%Y:%H:%M:%S +0000"),
) -> Dict[str, Any]:
"""
Helper method that constructs the Ev... |
Helper method that constructs the Event 2.0 to be passed to Lambda
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
:param request flask_request: Flask Request
:param port: the port number
:param binary_types: list of binary types
:param s... | construct_v2_event_http | python | aws/aws-sam-cli | samcli/local/apigw/event_constructor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/event_constructor.py | Apache-2.0 |
def _query_string_params(flask_request):
"""
Constructs an APIGW equivalent query string dictionary
Parameters
----------
flask_request request
Request from Flask
Returns dict (str: str), dict (str: list of str)
-------
Empty dict if no query params where in the request oth... |
Constructs an APIGW equivalent query string dictionary
Parameters
----------
flask_request request
Request from Flask
Returns dict (str: str), dict (str: list of str)
-------
Empty dict if no query params where in the request otherwise returns a dictionary of key to value
... | _query_string_params | python | aws/aws-sam-cli | samcli/local/apigw/event_constructor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/event_constructor.py | Apache-2.0 |
def _query_string_params_v_2_0(flask_request):
"""
Constructs an APIGW equivalent query string dictionary using the 2.0 format
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#2.0
Parameters
----------
flask_request request
Request f... |
Constructs an APIGW equivalent query string dictionary using the 2.0 format
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#2.0
Parameters
----------
flask_request request
Request from Flask
Returns dict (str: str)
-------
... | _query_string_params_v_2_0 | python | aws/aws-sam-cli | samcli/local/apigw/event_constructor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/event_constructor.py | Apache-2.0 |
def _event_headers(flask_request, port):
"""
Constructs an APIGW equivalent headers dictionary
Parameters
----------
flask_request request
Request from Flask
int port
Forwarded Port
cors_headers dict
Dict of the Cors properties
Returns dict (str: str), dict (str... |
Constructs an APIGW equivalent headers dictionary
Parameters
----------
flask_request request
Request from Flask
int port
Forwarded Port
cors_headers dict
Dict of the Cors properties
Returns dict (str: str), dict (str: list of str)
-------
Returns a dic... | _event_headers | python | aws/aws-sam-cli | samcli/local/apigw/event_constructor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/event_constructor.py | Apache-2.0 |
def _event_http_cookies(flask_request):
"""
All cookie headers in the request are combined with commas.
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
Parameters
----------
flask_request request
Request from Flask
Returns lis... |
All cookie headers in the request are combined with commas.
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
Parameters
----------
flask_request request
Request from Flask
Returns list
-------
Returns a list of cookies... | _event_http_cookies | python | aws/aws-sam-cli | samcli/local/apigw/event_constructor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/event_constructor.py | Apache-2.0 |
def _event_http_headers(flask_request, port):
"""
Duplicate headers are combined with commas.
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
Parameters
----------
flask_request request
Request from Flask
Returns list
----... |
Duplicate headers are combined with commas.
https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
Parameters
----------
flask_request request
Request from Flask
Returns list
-------
Returns a list of cookies
| _event_http_headers | python | aws/aws-sam-cli | samcli/local/apigw/event_constructor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/event_constructor.py | Apache-2.0 |
def __init__(
self,
api: Api,
lambda_runner: LocalLambdaRunner,
static_dir: Optional[str] = None,
port: Optional[int] = None,
host: Optional[str] = None,
stderr: Optional[StreamWriter] = None,
ssl_context: Optional[Tuple[str, str]] = None,
):
"... |
Creates an ApiGatewayService
Parameters
----------
api : Api
an Api object that contains the list of routes and properties
lambda_runner : samcli.commands.local.lib.local_lambda.LocalLambdaRunner
The Lambda runner class capable of invoking the function
... | __init__ | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def create(self):
"""
Creates a Flask Application that can be started.
"""
# Setting sam local start-api to respond using HTTP/1.1 instead of the default HTTP/1.0
WSGIRequestHandler.protocol_version = "HTTP/1.1"
self._app = Flask(
__name__,
static... |
Creates a Flask Application that can be started.
| create | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _add_catch_all_path(self, methods: List[str], path: str, route: Route):
"""
Add the catch all route to the _app and the dictionary of routes.
:param list(str) methods: List of HTTP Methods
:param str path: Path off the base url
:param Route route: contains the default route ... |
Add the catch all route to the _app and the dictionary of routes.
:param list(str) methods: List of HTTP Methods
:param str path: Path off the base url
:param Route route: contains the default route configurations
| _add_catch_all_path | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _generate_route_keys(self, methods, path):
"""
Generates the key to the _dict_of_routes based on the list of methods
and path supplied
Parameters
----------
methods : List[str]
List of HTTP Methods
path : str
Path off the base url
... |
Generates the key to the _dict_of_routes based on the list of methods
and path supplied
Parameters
----------
methods : List[str]
List of HTTP Methods
path : str
Path off the base url
Yields
------
route_key : str
... | _generate_route_keys | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _construct_error_handling(self):
"""
Updates the Flask app with Error Handlers for different Error Codes
"""
# Both path and method not present
self._app.register_error_handler(404, ServiceErrorResponses.route_not_found)
# Path is present, but method not allowed
... |
Updates the Flask app with Error Handlers for different Error Codes
| _construct_error_handling | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _create_method_arn(self, flask_request: Request, event_type: str) -> str:
"""
Creates a method ARN with fake AWS values
Parameters
----------
flask_request: Request
Flask request object to get method and path
event_type: str
Type of event (API... |
Creates a method ARN with fake AWS values
Parameters
----------
flask_request: Request
Flask request object to get method and path
event_type: str
Type of event (API or HTTP)
Returns
-------
str
A built method ARN wit... | _create_method_arn | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _generate_lambda_token_authorizer_event(
self, flask_request: Request, route: Route, lambda_authorizer: LambdaAuthorizer
) -> dict:
"""
Creates a Lambda authorizer token event
Parameters
----------
flask_request: Request
Flask request object to get me... |
Creates a Lambda authorizer token event
Parameters
----------
flask_request: Request
Flask request object to get method and path
route: Route
Route object representing the endpoint to be invoked later
lambda_authorizer: LambdaAuthorizer
... | _generate_lambda_token_authorizer_event | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _generate_lambda_request_authorizer_event_http(
self, lambda_authorizer_payload: str, identity_values: list, method_arn: str
) -> dict:
"""
Helper method to generate part of the event required for different payload versions
for API Gateway V2
Parameters
---------... |
Helper method to generate part of the event required for different payload versions
for API Gateway V2
Parameters
----------
lambda_authorizer_payload: str
The payload version of the Lambda authorizer
identity_values: list
A list of string identi... | _generate_lambda_request_authorizer_event_http | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _generate_lambda_request_authorizer_event(
self, flask_request: Request, route: Route, lambda_authorizer: LambdaAuthorizer
) -> dict:
"""
Creates a Lambda authorizer request event
Parameters
----------
flask_request: Request
Flask request object to ge... |
Creates a Lambda authorizer request event
Parameters
----------
flask_request: Request
Flask request object to get method and path
route: Route
Route object representing the endpoint to be invoked later
lambda_authorizer: LambdaAuthorizer
... | _generate_lambda_request_authorizer_event | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _generate_lambda_authorizer_event(
self, flask_request: Request, route: Route, lambda_authorizer: LambdaAuthorizer
) -> dict:
"""
Generate a Lambda authorizer event
Parameters
----------
flask_request: Request
Flask request object to get method and en... |
Generate a Lambda authorizer event
Parameters
----------
flask_request: Request
Flask request object to get method and endpoint
route: Route
Route object representing the endpoint to be invoked later
lambda_authorizer: LambdaAuthorizer
... | _generate_lambda_authorizer_event | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _generate_lambda_event(self, flask_request: Request, route: Route, method: str, endpoint: str) -> dict:
"""
Helper function to generate the correct Lambda event
Parameters
----------
flask_request: Request
The global Flask Request object
route: Route
... |
Helper function to generate the correct Lambda event
Parameters
----------
flask_request: Request
The global Flask Request object
route: Route
The Route that was called
method: str
The method of the request (eg. GET, POST) from the Fl... | _generate_lambda_event | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _build_v1_context(self, route: Route) -> Dict[str, Any]:
"""
Helper function to a 1.0 request context
Parameters
----------
route: Route
The Route object that was invoked
Returns
-------
dict
JSON object containing context var... |
Helper function to a 1.0 request context
Parameters
----------
route: Route
The Route object that was invoked
Returns
-------
dict
JSON object containing context variables
| _build_v1_context | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _build_v2_context(self, route: Route) -> Dict[str, Any]:
"""
Helper function to a 2.0 request context
Parameters
----------
route: Route
The Route object that was invoked
Returns
-------
dict
JSON object containing context var... |
Helper function to a 2.0 request context
Parameters
----------
route: Route
The Route object that was invoked
Returns
-------
dict
JSON object containing context variables
| _build_v2_context | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _valid_identity_sources(self, request: Request, route: Route) -> bool:
"""
Validates if the route contains all the valid identity sources defined in the route's Lambda Authorizer
Parameters
----------
request: Request
Flask request object containing incoming requ... |
Validates if the route contains all the valid identity sources defined in the route's Lambda Authorizer
Parameters
----------
request: Request
Flask request object containing incoming request variables
route: Route
the Route object that contains the Lamb... | _valid_identity_sources | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _invoke_lambda_function(self, lambda_function_name: str, event: dict) -> Union[str, bytes]:
"""
Helper method to invoke a function and setup stdout+stderr
Parameters
----------
lambda_function_name: str
The name of the Lambda function to invoke
event: dic... |
Helper method to invoke a function and setup stdout+stderr
Parameters
----------
lambda_function_name: str
The name of the Lambda function to invoke
event: dict
The event object to pass into the Lambda function
Returns
-------
Un... | _invoke_lambda_function | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _request_handler(self, **kwargs):
"""
We handle all requests to the host:port. The general flow of handling a request is as follows
* Fetch request from the Flask Global state. This is where Flask places the request and is per thread so
multiple requests are still handled correctl... |
We handle all requests to the host:port. The general flow of handling a request is as follows
* Fetch request from the Flask Global state. This is where Flask places the request and is per thread so
multiple requests are still handled correctly
* Find the Lambda function to invoke by... | _request_handler | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _invoke_parse_lambda_authorizer(
self, lambda_authorizer: LambdaAuthorizer, auth_lambda_event: dict, route_lambda_event: dict, route: Route
) -> None:
"""
Helper method to invoke and parse the output of a Lambda authorizer
Parameters
----------
lambda_authorizer:... |
Helper method to invoke and parse the output of a Lambda authorizer
Parameters
----------
lambda_authorizer: LambdaAuthorizer
The route's Lambda authorizer
auth_lambda_event: dict
The event to pass to the Lambda authorizer
route_lambda_event: dic... | _invoke_parse_lambda_authorizer | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _get_current_route(self, flask_request):
"""
Get the route (Route) based on the current request
:param request flask_request: Flask Request
:return: Route matching the endpoint and method of the request
"""
method, endpoint = self.get_request_methods_endpoints(flask_... |
Get the route (Route) based on the current request
:param request flask_request: Flask Request
:return: Route matching the endpoint and method of the request
| _get_current_route | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def get_request_methods_endpoints(flask_request):
"""
Separated out for testing requests in request handler
:param request flask_request: Flask Request
:return: the request's endpoint and method
"""
endpoint = flask_request.endpoint
method = flask_request.method
... |
Separated out for testing requests in request handler
:param request flask_request: Flask Request
:return: the request's endpoint and method
| get_request_methods_endpoints | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _parse_v1_payload_format_lambda_output(lambda_output: str, binary_types, flask_request, event_type):
"""
Parses the output from the Lambda Container
:param str lambda_output: Output from Lambda Invoke
:param binary_types: list of binary types
:param flask_request: flash requ... |
Parses the output from the Lambda Container
:param str lambda_output: Output from Lambda Invoke
:param binary_types: list of binary types
:param flask_request: flash request object
:param event_type: determines the route event type
:return: Tuple(int, dict, str, bool)
... | _parse_v1_payload_format_lambda_output | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _parse_v2_payload_format_lambda_output(lambda_output: str, binary_types, flask_request):
"""
Parses the output from the Lambda Container. V2 Payload Format means that the event_type is only HTTP
:param str lambda_output: Output from Lambda Invoke
:param binary_types: list of binary ... |
Parses the output from the Lambda Container. V2 Payload Format means that the event_type is only HTTP
:param str lambda_output: Output from Lambda Invoke
:param binary_types: list of binary types
:param flask_request: flash request object
:return: Tuple(int, dict, str, bool)
... | _parse_v2_payload_format_lambda_output | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _should_base64_decode_body(binary_types, flask_request, lamba_response_headers, is_base_64_encoded):
"""
Whether or not the body should be decoded from Base64 to Binary
Parameters
----------
binary_types list(basestring)
Corresponds to self.binary_types (aka. wha... |
Whether or not the body should be decoded from Base64 to Binary
Parameters
----------
binary_types list(basestring)
Corresponds to self.binary_types (aka. what is parsed from SAM Template
flask_request flask.request
Flask request
lamba_response_h... | _should_base64_decode_body | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def _merge_response_headers(headers, multi_headers):
"""
Merge multiValueHeaders headers with headers
* If you specify values for both headers and multiValueHeaders, API Gateway merges them into a single list.
* If the same key-value pair is specified in both, the value will only appear... |
Merge multiValueHeaders headers with headers
* If you specify values for both headers and multiValueHeaders, API Gateway merges them into a single list.
* If the same key-value pair is specified in both, the value will only appear once.
Parameters
----------
headers di... | _merge_response_headers | python | aws/aws-sam-cli | samcli/local/apigw/local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/local_apigw_service.py | Apache-2.0 |
def convert_path_to_flask(path):
"""
Converts a Path from an Api Gateway defined path to one that is accepted by Flask
Examples:
'/id/{id}' => '/id/<id>'
'/{proxy+}' => '/<path:proxy>'
:param str path: Path to convert to Flask defined path
:return str: Path rep... |
Converts a Path from an Api Gateway defined path to one that is accepted by Flask
Examples:
'/id/{id}' => '/id/<id>'
'/{proxy+}' => '/<path:proxy>'
:param str path: Path to convert to Flask defined path
:return str: Path representing a Flask path
| convert_path_to_flask | python | aws/aws-sam-cli | samcli/local/apigw/path_converter.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/path_converter.py | Apache-2.0 |
def convert_path_to_api_gateway(path):
"""
Converts a Path from a Flask defined path to one that is accepted by Api Gateway
Examples:
'/id/<id>' => '/id/{id}'
'/<path:proxy>' => '/{proxy+}'
:param str path: Path to convert to Api Gateway defined path
:return st... |
Converts a Path from a Flask defined path to one that is accepted by Api Gateway
Examples:
'/id/<id>' => '/id/{id}'
'/<path:proxy>' => '/{proxy+}'
:param str path: Path to convert to Api Gateway defined path
:return str: Path representing an Api Gateway path
| convert_path_to_api_gateway | python | aws/aws-sam-cli | samcli/local/apigw/path_converter.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/path_converter.py | Apache-2.0 |
def __init__(
self,
function_name: Optional[str],
path: str,
methods: List[str],
event_type: str = API,
payload_format_version: Optional[str] = None,
is_default_route: bool = False,
operation_name=None,
stack_path: str = "",
authorizer_name... |
Creates an ApiGatewayRoute
:param list(str) methods: http method
:param function_name: Name of the Lambda function this API is connected to
:param str path: Path off the base url
:param str event_type: Type of the event. "Api" or "HttpApi"
:param str payload_format_vers... | __init__ | python | aws/aws-sam-cli | samcli/local/apigw/route.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/route.py | Apache-2.0 |
def normalize_method(self, methods):
"""
Normalizes Http Methods. Api Gateway allows a Http Methods of ANY. This is a special verb to denote all
supported Http Methods on Api Gateway.
:param list methods: Http methods
:return list: Either the input http_method or one of the _ANY... |
Normalizes Http Methods. Api Gateway allows a Http Methods of ANY. This is a special verb to denote all
supported Http Methods on Api Gateway.
:param list methods: Http methods
:return list: Either the input http_method or one of the _ANY_HTTP_METHODS (normalized Http Methods)
| normalize_method | python | aws/aws-sam-cli | samcli/local/apigw/route.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/route.py | Apache-2.0 |
def lambda_authorizer_unauthorized() -> Response:
"""
Constructs a Flask response for when a route invokes a Lambda Authorizer, but
is the identity sources provided are not authorized for that method
Returns
-------
Response
A Flask Response object
""... |
Constructs a Flask response for when a route invokes a Lambda Authorizer, but
is the identity sources provided are not authorized for that method
Returns
-------
Response
A Flask Response object
| lambda_authorizer_unauthorized | python | aws/aws-sam-cli | samcli/local/apigw/service_error_responses.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/service_error_responses.py | Apache-2.0 |
def missing_lambda_auth_identity_sources() -> Response:
"""
Constructs a Flask response for when a route contains a Lambda Authorizer
but is missing the required identity services
Returns
-------
Response
A Flask Response object
"""
response_d... |
Constructs a Flask response for when a route contains a Lambda Authorizer
but is missing the required identity services
Returns
-------
Response
A Flask Response object
| missing_lambda_auth_identity_sources | python | aws/aws-sam-cli | samcli/local/apigw/service_error_responses.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/service_error_responses.py | Apache-2.0 |
def lambda_failure_response(*args):
"""
Helper function to create a Lambda Failure Response
:return: A Flask Response
"""
LOG.debug("Lambda execution failed %s", args)
response_data = jsonify(ServiceErrorResponses._LAMBDA_FAILURE)
return make_response(response_da... |
Helper function to create a Lambda Failure Response
:return: A Flask Response
| lambda_failure_response | python | aws/aws-sam-cli | samcli/local/apigw/service_error_responses.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/service_error_responses.py | Apache-2.0 |
def lambda_body_failure_response(*args):
"""
Helper function to create a Lambda Body Failure Response
:return: A Flask Response
"""
response_data = jsonify(ServiceErrorResponses._LAMBDA_FAILURE)
return make_response(response_data, ServiceErrorResponses.HTTP_STATUS_CODE_5... |
Helper function to create a Lambda Body Failure Response
:return: A Flask Response
| lambda_body_failure_response | python | aws/aws-sam-cli | samcli/local/apigw/service_error_responses.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/service_error_responses.py | Apache-2.0 |
def not_implemented_locally(message):
"""
Constructs a Flask Response for for when a Lambda function functionality is
not implemented
:return: a Flask Response
"""
exception_dict = {"message": message}
response_data = jsonify(exception_dict)
return make_r... |
Constructs a Flask Response for for when a Lambda function functionality is
not implemented
:return: a Flask Response
| not_implemented_locally | python | aws/aws-sam-cli | samcli/local/apigw/service_error_responses.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/service_error_responses.py | Apache-2.0 |
def lambda_not_found_response(*args):
"""
Constructs a Flask Response for when a Lambda function is not found for an endpoint
:return: a Flask Response
"""
response_data = jsonify(ServiceErrorResponses._NO_LAMBDA_INTEGRATION)
return make_response(response_data, ServiceEr... |
Constructs a Flask Response for when a Lambda function is not found for an endpoint
:return: a Flask Response
| lambda_not_found_response | python | aws/aws-sam-cli | samcli/local/apigw/service_error_responses.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/service_error_responses.py | Apache-2.0 |
def route_not_found(*args):
"""
Constructs a Flask Response for when a API Route (path+method) is not found. This is usually
HTTP 404 but with API Gateway this is a HTTP 403 (https://forums.aws.amazon.com/thread.jspa?threadID=2166840)
:return: a Flask Response
"""
respon... |
Constructs a Flask Response for when a API Route (path+method) is not found. This is usually
HTTP 404 but with API Gateway this is a HTTP 403 (https://forums.aws.amazon.com/thread.jspa?threadID=2166840)
:return: a Flask Response
| route_not_found | python | aws/aws-sam-cli | samcli/local/apigw/service_error_responses.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/service_error_responses.py | Apache-2.0 |
def container_creation_failed(message):
"""
Constuct a Flask Response for when container creation fails for a Lambda Function
:return: a Flask Response
"""
response_data = jsonify({"message": message})
return make_response(response_data, ServiceErrorResponses.HTTP_STATUS_... |
Constuct a Flask Response for when container creation fails for a Lambda Function
:return: a Flask Response
| container_creation_failed | python | aws/aws-sam-cli | samcli/local/apigw/service_error_responses.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/service_error_responses.py | Apache-2.0 |
def find_identity_value(self, **kwargs) -> Any:
"""
Returns the identity value, if found
""" |
Returns the identity value, if found
| find_identity_value | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def find_identity_value(self, **kwargs) -> Optional[str]:
"""
Finds the header value that the identity source corresponds to
Parameters
----------
kwargs
Keyword arguments that should contain `headers`
Returns
-------
Optional[str]
... |
Finds the header value that the identity source corresponds to
Parameters
----------
kwargs
Keyword arguments that should contain `headers`
Returns
-------
Optional[str]
The string value of the header if it is found, otherwise None
... | find_identity_value | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def is_valid(self, **kwargs) -> bool:
"""
Validates whether the required header is present and matches the
validation expression, if defined.
Parameters
----------
kwargs: dict
Keyword arugments containing the incoming sources and validation expression
... |
Validates whether the required header is present and matches the
validation expression, if defined.
Parameters
----------
kwargs: dict
Keyword arugments containing the incoming sources and validation expression
Returns
-------
bool
... | is_valid | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def find_identity_value(self, **kwargs) -> Optional[str]:
"""
Finds the query string value that the identity source corresponds to
Parameters
----------
kwargs
Keyword arguments that should contain `querystring`
Returns
-------
Optional[str]
... |
Finds the query string value that the identity source corresponds to
Parameters
----------
kwargs
Keyword arguments that should contain `querystring`
Returns
-------
Optional[str]
The string value of the query parameter if one is found, ... | find_identity_value | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def find_identity_value(self, **kwargs) -> Optional[str]:
"""
Finds the context value that the identity source corresponds to
Parameters
----------
kwargs
Keyword arguments that should contain `context`
Returns
-------
Optional[str]
... |
Finds the context value that the identity source corresponds to
Parameters
----------
kwargs
Keyword arguments that should contain `context`
Returns
-------
Optional[str]
The string value of the context variable if it is found, otherwise... | find_identity_value | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def find_identity_value(self, **kwargs) -> Optional[str]:
"""
Finds the stage variable value that the identity source corresponds to
Parameters
----------
kwargs
Keyword arguments that should contain `stageVariables`
Returns
-------
Optional[... |
Finds the stage variable value that the identity source corresponds to
Parameters
----------
kwargs
Keyword arguments that should contain `stageVariables`
Returns
-------
Optional[str]
The stage variable if it is found, otherwise None
... | find_identity_value | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def __init__(
self,
authorizer_name: str,
type: str,
lambda_name: str,
identity_sources: List[str],
payload_version: str,
validation_string: Optional[str] = None,
use_simple_response: bool = False,
):
"""
Creates a Lambda Authorizer cla... |
Creates a Lambda Authorizer class
Parameters
----------
authorizer_name: str
The name of the Lambda Authorizer
type: str
The type of authorizer this is (token or request)
lambda_name: str
The name of the Lambda function this authorize... | __init__ | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def _parse_identity_sources(self, identity_sources: List[str]) -> None:
"""
Helper function to create identity source validation objects
Parameters
----------
identity_sources: List[str]
A list of identity sources to parse
"""
# validate incoming ide... |
Helper function to create identity source validation objects
Parameters
----------
identity_sources: List[str]
A list of identity sources to parse
| _parse_identity_sources | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def is_valid_response(self, response: Union[str, bytes], method_arn: str) -> bool:
"""
Validates whether a Lambda authorizer request is authenticated or not.
Parameters
----------
response: Union[str, bytes]
JSON string containing the output from a Lambda authorizer
... |
Validates whether a Lambda authorizer request is authenticated or not.
Parameters
----------
response: Union[str, bytes]
JSON string containing the output from a Lambda authorizer
method_arn: str
The method ARN of the route that invoked the Lambda author... | is_valid_response | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def _is_resource_authorized(self, response: dict, method_arn: str) -> bool:
"""
Validate if the current method ARN is actually authorized
Parameters
----------
response: dict
The response output from the Lambda authorizer (should be in IAM format)
method_arn:... |
Validate if the current method ARN is actually authorized
Parameters
----------
response: dict
The response output from the Lambda authorizer (should be in IAM format)
method_arn: str
The route's method ARN
Returns
-------
bool
... | _is_resource_authorized | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def _validate_simple_response(self, response: dict) -> bool:
"""
Helper method to validate if a Lambda authorizer response using simple responses is valid and authorized
Parameters
----------
response: dict
JSON object containing required simple response paramters
... |
Helper method to validate if a Lambda authorizer response using simple responses is valid and authorized
Parameters
----------
response: dict
JSON object containing required simple response paramters
Returns
-------
bool
True if the requ... | _validate_simple_response | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def get_context(self, response: Union[str, bytes]) -> Dict[str, Any]:
"""
Returns the context (if set) from the authorizer response and appends the principalId to it.
Parameters
----------
response: Union[str, bytes]
Output from Lambda authorizer
Returns
... |
Returns the context (if set) from the authorizer response and appends the principalId to it.
Parameters
----------
response: Union[str, bytes]
Output from Lambda authorizer
Returns
-------
Dict[str, Any]
The built authorizer context obje... | get_context | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def is_valid(self, response: dict) -> bool:
"""
Validates whether the property is present and of the correct type
Parameters
----------
response: dict
The response output from the Lambda authorizer (should be in IAM format)
Returns
-------
bo... |
Validates whether the property is present and of the correct type
Parameters
----------
response: dict
The response output from the Lambda authorizer (should be in IAM format)
Returns
-------
bool
True if present and of correct type
... | is_valid | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def validate_policy_document(auth_name: str, response: dict) -> None:
"""
Validate the properties of a Lambda authorizer response at the root level
Parameters
----------
auth_name: str
Name of the authorizer
response: dict
The response output from... |
Validate the properties of a Lambda authorizer response at the root level
Parameters
----------
auth_name: str
Name of the authorizer
response: dict
The response output from the Lambda authorizer (should be in IAM format)
| validate_policy_document | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def validate_statement(auth_name: str, response: dict) -> None:
"""
Validate the Statement(s) of a Lambda authorizer response's policy document
Parameters
----------
auth_name: str
Name of the authorizer
response: dict
The response output from the... |
Validate the Statement(s) of a Lambda authorizer response's policy document
Parameters
----------
auth_name: str
Name of the authorizer
response: dict
The response output from the Lambda authorizer (should be in IAM format)
| validate_statement | python | aws/aws-sam-cli | samcli/local/apigw/authorizers/lambda_authorizer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/apigw/authorizers/lambda_authorizer.py | Apache-2.0 |
def is_custom_runtime(runtime):
"""
validated if a runtime is custom or not
Parameters
----------
runtime : str
runtime to be
Returns
-------
_type_
_description_
"""
if not runtime:
return False
provided_runtime = get_provided_runtime_from_custom_runt... |
validated if a runtime is custom or not
Parameters
----------
runtime : str
runtime to be
Returns
-------
_type_
_description_
| is_custom_runtime | python | aws/aws-sam-cli | samcli/local/common/runtime_template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/common/runtime_template.py | Apache-2.0 |
def get_provided_runtime_from_custom_runtime(runtime):
"""
Gets the base lambda runtime for which a custom runtime is based on
Example:
rust (provided.al2) --> provided.al2
java11 --> None
Parameters
----------
runtime : str
Custom runtime or Lambda runtime
Returns
----... |
Gets the base lambda runtime for which a custom runtime is based on
Example:
rust (provided.al2) --> provided.al2
java11 --> None
Parameters
----------
runtime : str
Custom runtime or Lambda runtime
Returns
-------
str
returns the base lambda runtime for which ... | get_provided_runtime_from_custom_runtime | python | aws/aws-sam-cli | samcli/local/common/runtime_template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/common/runtime_template.py | Apache-2.0 |
def create(self, context):
"""
Calls Docker API to creates the Docker container instance. Creating the container does *not* run the container.
Use ``start`` method to run the container
context: samcli.local.docker.container.ContainerContext
Context for the container manageme... |
Calls Docker API to creates the Docker container instance. Creating the container does *not* run the container.
Use ``start`` method to run the container
context: samcli.local.docker.container.ContainerContext
Context for the container management to run (build, invoke)
:re... | create | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def _create_mapped_symlink_files(self) -> Dict[str, Dict[str, str]]:
"""
Resolves top level symlinked files and folders that are found on the
host directory and creates additional bind mounts to correctly map them
inside of the container.
By default only `node_modules` are mounte... |
Resolves top level symlinked files and folders that are found on the
host directory and creates additional bind mounts to correctly map them
inside of the container.
By default only `node_modules` are mounted unless self.mount_symlinks is True
Returns
-------
Di... | _create_mapped_symlink_files | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def stop(self, timeout=3):
"""
Stop a container, with a given number of seconds between sending SIGTERM and SIGKILL.
Parameters
----------
timeout
Optional. Number of seconds between SIGTERM and SIGKILL. Effectively, the amount of time
the container has t... |
Stop a container, with a given number of seconds between sending SIGTERM and SIGKILL.
Parameters
----------
timeout
Optional. Number of seconds between SIGTERM and SIGKILL. Effectively, the amount of time
the container has to perform shutdown steps. Default: 3
... | stop | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def delete(self):
"""
Removes a container that was created earlier.
"""
if not self.is_created():
LOG.debug("Container was not created. Skipping deletion")
return
try:
self.docker_client.containers.get(self.id).remove(force=True) # Remove a c... |
Removes a container that was created earlier.
| delete | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def start(self, input_data=None):
"""
Calls Docker API to start the container. The container must be created at the first place to run.
It waits for the container to complete, fetches both stdout and stderr logs and returns through the
given streams.
Parameters
---------... |
Calls Docker API to start the container. The container must be created at the first place to run.
It waits for the container to complete, fetches both stdout and stderr logs and returns through the
given streams.
Parameters
----------
input_data
Optional. In... | start | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def _wait_for_socket_connection(self) -> None:
"""
Waits for a successful connection to the socket used to communicate with Docker.
"""
start_time = time.time()
while not self._can_connect_to_socket():
time.sleep(0.1)
current_time = time.time()
... |
Waits for a successful connection to the socket used to communicate with Docker.
| _wait_for_socket_connection | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def _can_connect_to_socket(self) -> bool:
"""
Checks if able to connect successully to the socket used to communicate with Docker.
"""
a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
location = (self._container_host, self.rapid_port_host)
# connect_ex return... |
Checks if able to connect successully to the socket used to communicate with Docker.
| _can_connect_to_socket | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def copy(self, from_container_path, to_host_path) -> None:
"""Copies a path from container into host path"""
if not self.is_created():
raise RuntimeError("Container does not exist. Cannot get logs for this container")
real_container = self.docker_client.containers.get(self.id)
... | Copies a path from container into host path | copy | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def _write_container_output(
output_itr: Iterator[Tuple[bytes, bytes]],
stdout: Optional[Union[StreamWriter, io.BytesIO, io.TextIOWrapper]] = None,
stderr: Optional[Union[StreamWriter, io.BytesIO, io.TextIOWrapper]] = None,
event: Optional[threading.Event] = None,
):
"""
... |
Based on the data returned from the Container output, via the iterator, write it to the appropriate streams
Parameters
----------
output_itr: Iterator
Iterator returned by the Docker Attach command
stdout: samcli.lib.utils.stream_writer.StreamWriter, optional
... | _write_container_output | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def is_created(self):
"""
Checks if the real container exists?
Returns
-------
bool
True if the container is created
"""
if self.id:
try:
self.docker_client.containers.get(self.id)
return True
ex... |
Checks if the real container exists?
Returns
-------
bool
True if the container is created
| is_created | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def is_running(self):
"""
Checks if the real container status is running
Returns
-------
bool
True if the container is running
"""
try:
real_container = self.docker_client.containers.get(self.id)
return real_container.status ==... |
Checks if the real container status is running
Returns
-------
bool
True if the container is running
| is_running | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def _resolve_symlinks_for_file(self, file: os.DirEntry) -> bool:
"""
Parameters
----------
file : os.DirEntry
File to check if it should be resolved
Returns
-------
bool
True if the file should be resolved as a symlink to mount in the cont... |
Parameters
----------
file : os.DirEntry
File to check if it should be resolved
Returns
-------
bool
True if the file should be resolved as a symlink to mount in the container.
By default, the only symlinks resolved are `node_modules`... | _resolve_symlinks_for_file | python | aws/aws-sam-cli | samcli/local/docker/container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container.py | Apache-2.0 |
def inspect(self) -> ContainerState:
"""
Inspect the state of a container by calling the "inspect()" API that Docker provides.
Extract relevant information into a ContainerState object.
Returns
-------
ContainerState:
Returns a ContainerState object with rele... |
Inspect the state of a container by calling the "inspect()" API that Docker provides.
Extract relevant information into a ContainerState object.
Returns
-------
ContainerState:
Returns a ContainerState object with relevant container data
| inspect | python | aws/aws-sam-cli | samcli/local/docker/container_analyzer.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/container_analyzer.py | Apache-2.0 |
def to_effective_user_str(self) -> Optional[str]:
"""
Return String representation of the posix effective user, or None for non posix systems
"""
if not self.user_id:
# Return None for non-posix systems
return None
if self.user_id == ROOT_USER_ID or not s... |
Return String representation of the posix effective user, or None for non posix systems
| to_effective_user_str | python | aws/aws-sam-cli | samcli/local/docker/effective_user.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/effective_user.py | Apache-2.0 |
def get_current_effective_user():
"""
Get the posix effective user and group id for current user
"""
if os.name.lower() == "posix":
user_id = os.getuid()
group_ids = os.getgroups()
return EffectiveUser(str(user_id), str(group_ids[0]) if len(group_ids) ... |
Get the posix effective user and group id for current user
| get_current_effective_user | python | aws/aws-sam-cli | samcli/local/docker/effective_user.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/effective_user.py | Apache-2.0 |
def get_container_dirs(source_dir, manifest_dir):
"""
Provides paths to directories within the container that is required by the builder
Parameters
----------
source_dir : str
Path to the function source code
manifest_dir : str
Path to the direct... |
Provides paths to directories within the container that is required by the builder
Parameters
----------
source_dir : str
Path to the function source code
manifest_dir : str
Path to the directory containing manifest
Returns
-------
... | get_container_dirs | python | aws/aws-sam-cli | samcli/local/docker/lambda_build_container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_build_container.py | Apache-2.0 |
def _convert_to_container_dirs(host_paths_to_convert, host_to_container_path_mapping):
"""
Use this method to convert a list of host paths to a list of equivalent paths within the container
where the given host path is mounted. This is necessary when SAM CLI needs to pass path information to
... |
Use this method to convert a list of host paths to a list of equivalent paths within the container
where the given host path is mounted. This is necessary when SAM CLI needs to pass path information to
the Lambda Builder running within the container.
If a host path is not mounted withi... | _convert_to_container_dirs | python | aws/aws-sam-cli | samcli/local/docker/lambda_build_container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_build_container.py | Apache-2.0 |
def get_image_tag(architecture):
"""
Returns the lambda build image tag for an architecture
Parameters
----------
architecture : str
Architecture
Returns
-------
str
Image tag
"""
if not valid_architecture(architec... |
Returns the lambda build image tag for an architecture
Parameters
----------
architecture : str
Architecture
Returns
-------
str
Image tag
| get_image_tag | python | aws/aws-sam-cli | samcli/local/docker/lambda_build_container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_build_container.py | Apache-2.0 |
def _get_default_entry_point() -> List[str]:
"""
Returns default entry point for lambda container, which is the path of the RIE executable with its debugging
configuration. If SAM_CLI_RIE_DEV is set to 1, RIE log level is set to 'debug', otherwise it is kept as 'error'.
"""
rie_l... |
Returns default entry point for lambda container, which is the path of the RIE executable with its debugging
configuration. If SAM_CLI_RIE_DEV is set to 1, RIE log level is set to 'debug', otherwise it is kept as 'error'.
| _get_default_entry_point | python | aws/aws-sam-cli | samcli/local/docker/lambda_container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_container.py | Apache-2.0 |
def _get_exposed_ports(debug_options):
"""
Return Docker container port binding information. If a debug port tuple is given, then we will ask Docker to
bind every given port to same port both inside and outside the container ie.
Runtime process is started in debug mode with at given port... |
Return Docker container port binding information. If a debug port tuple is given, then we will ask Docker to
bind every given port to same port both inside and outside the container ie.
Runtime process is started in debug mode with at given port inside the container
and exposed to the h... | _get_exposed_ports | python | aws/aws-sam-cli | samcli/local/docker/lambda_container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_container.py | Apache-2.0 |
def _get_additional_options(runtime: str, debug_options):
"""
Return additional Docker container options. Used by container debug mode to enable certain container
security options.
:param runtime: The runtime string
:param DebugContext debug_options: DebugContext for the runtime ... |
Return additional Docker container options. Used by container debug mode to enable certain container
security options.
:param runtime: The runtime string
:param DebugContext debug_options: DebugContext for the runtime of the container.
:return dict: Dictionary containing additio... | _get_additional_options | python | aws/aws-sam-cli | samcli/local/docker/lambda_container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_container.py | Apache-2.0 |
def _get_additional_volumes(runtime, debug_options):
"""
Return additional volumes to be mounted in the Docker container. Used by container debug for mapping
debugger executable into the container.
:param runtime: the runtime string
:param DebugContext debug_options: DebugContext... |
Return additional volumes to be mounted in the Docker container. Used by container debug for mapping
debugger executable into the container.
:param runtime: the runtime string
:param DebugContext debug_options: DebugContext for the runtime of the container.
:return dict: Diction... | _get_additional_volumes | python | aws/aws-sam-cli | samcli/local/docker/lambda_container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_container.py | Apache-2.0 |
def _get_image(
lambda_image: LambdaImage,
runtime: str,
packagetype: str,
image: str,
layers: List[str],
architecture: str,
function_name: str,
):
"""
Parameters
----------
lambda_image : LambdaImage
LambdaImage th... |
Parameters
----------
lambda_image : LambdaImage
LambdaImage that can be used to build the image needed for starting the container
runtime : str
Name of the Lambda runtime
packagetype : str
Package type for the lambda function which is either... | _get_image | python | aws/aws-sam-cli | samcli/local/docker/lambda_container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_container.py | Apache-2.0 |
def _get_debug_settings(runtime, debug_options=None): # pylint: disable=too-many-branches
"""
Returns the entry point for the container. The default value for the entry point is already configured in the
Dockerfile. We override this default specifically when enabling debugging. The overridden e... |
Returns the entry point for the container. The default value for the entry point is already configured in the
Dockerfile. We override this default specifically when enabling debugging. The overridden entry point includes
a few extra flags to start the runtime in debug mode.
:param stri... | _get_debug_settings | python | aws/aws-sam-cli | samcli/local/docker/lambda_container.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_container.py | Apache-2.0 |
def get_debug_settings(debug_port, debug_args_list, _container_env_vars, runtime, options):
"""
Get Debug settings based on the Runtime
Parameters
----------
debug_port int
Port to open for debugging in the container
debug_args_list list(str)
Addi... |
Get Debug settings based on the Runtime
Parameters
----------
debug_port int
Port to open for debugging in the container
debug_args_list list(str)
Additional debug args
container_env_vars dict
Additional debug environmental variables
... | get_debug_settings | python | aws/aws-sam-cli | samcli/local/docker/lambda_debug_settings.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_debug_settings.py | Apache-2.0 |
def get_image_name_tag(cls, runtime: str, architecture: str, is_preview: bool = False) -> str:
"""
Returns the image name and tag for a particular runtime
Parameters
----------
runtime : str
AWS Lambda runtime
architecture : str
Architecture for t... |
Returns the image name and tag for a particular runtime
Parameters
----------
runtime : str
AWS Lambda runtime
architecture : str
Architecture for the runtime
is_preview : bool
Flag to use preview tag
Returns
-------
... | get_image_name_tag | python | aws/aws-sam-cli | samcli/local/docker/lambda_image.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_image.py | Apache-2.0 |
def __init__(self, layer_downloader, skip_pull_image, force_image_build, docker_client=None, invoke_images=None):
"""
Parameters
----------
layer_downloader samcli.local.layers.layer_downloader.LayerDownloader
LayerDownloader to download layers locally
skip_pull_imag... |
Parameters
----------
layer_downloader samcli.local.layers.layer_downloader.LayerDownloader
LayerDownloader to download layers locally
skip_pull_image bool
True if the image should not be pulled from DockerHub
force_image_build bool
True to d... | __init__ | python | aws/aws-sam-cli | samcli/local/docker/lambda_image.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_image.py | Apache-2.0 |
def build(self, runtime, packagetype, image, layers, architecture, stream=None, function_name=None):
"""
Build the image if one is not already on the system that matches the runtime and layers
Parameters
----------
runtime : str
Name of the Lambda runtime
pac... |
Build the image if one is not already on the system that matches the runtime and layers
Parameters
----------
runtime : str
Name of the Lambda runtime
packagetype : str
Packagetype for the Lambda
image : str
Pre-defined invocation ima... | build | python | aws/aws-sam-cli | samcli/local/docker/lambda_image.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/lambda_image.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.