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 _generate_docker_image_version(layers, runtime_image_tag): """ Generate the Docker TAG that will be used to create the image Parameters ---------- layers list(samcli.commands.local.lib.provider.Layer) List of the layers runtime_image_tag str ...
Generate the Docker TAG that will be used to create the image Parameters ---------- layers list(samcli.commands.local.lib.provider.Layer) List of the layers runtime_image_tag str Runtime version format to generate image name and tag (including architect...
_generate_docker_image_version
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_image(self, base_image, docker_tag, layers, architecture, stream=None): """ Builds the image Parameters ---------- base_image str Base Image to use for the new image docker_tag str Docker tag (REPOSITORY:TAG) to use when building the im...
Builds the image Parameters ---------- base_image str Base Image to use for the new image docker_tag str Docker tag (REPOSITORY:TAG) to use when building the image layers list(samcli.commands.local.lib.provider.Layer) List of Layers t...
_build_image
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 _generate_dockerfile(base_image, layers, architecture): """ FROM public.ecr.aws/lambda/python:3.9-x86_64 ADD aws-lambda-rie /var/rapid ADD layer1 /opt ADD layer2 /opt Parameters ---------- base_image : str Base Image to use for the new i...
FROM public.ecr.aws/lambda/python:3.9-x86_64 ADD aws-lambda-rie /var/rapid ADD layer1 /opt ADD layer2 /opt Parameters ---------- base_image : str Base Image to use for the new image layers : list List of Layers to be use to moun...
_generate_dockerfile
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 _remove_rapid_images(self, repo: str) -> None: """ Remove all rapid images for given repo Parameters ---------- repo string Repo for which rapid images will be removed """ LOG.info("Removing rapid images for repo %s", repo) try: ...
Remove all rapid images for given repo Parameters ---------- repo string Repo for which rapid images will be removed
_remove_rapid_images
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 is_rapid_image(image_name: str) -> bool: """ Is the image tagged as a RAPID clone? Parameters ---------- image_name : str Name of the image Returns ------- bool True if the image tag starts with the rapid prefix or contains it...
Is the image tagged as a RAPID clone? Parameters ---------- image_name : str Name of the image Returns ------- bool True if the image tag starts with the rapid prefix or contains it in between. False, otherwise
is_rapid_image
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 _check_base_image_is_current(self, image_name: str) -> None: """ Check if the existing base image is up-to-date and update modifier parameters (skip_pull_image, force_image_build) accordingly, printing an informative message depending on the case. Parameters --------...
Check if the existing base image is up-to-date and update modifier parameters (skip_pull_image, force_image_build) accordingly, printing an informative message depending on the case. Parameters ---------- image_name : str Base image name to check
_check_base_image_is_current
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 get_remote_image_digest(self, image_name: str) -> Optional[str]: """ Get the digest of the remote version of an image Parameters ---------- image_name : str Name of the image to get the digest Returns ------- str Image digest,...
Get the digest of the remote version of an image Parameters ---------- image_name : str Name of the image to get the digest Returns ------- str Image digest, including `sha256:` prefix
get_remote_image_digest
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 get_local_image_digest(self, image_name: str) -> Optional[str]: """ Get the digest of the local version of an image Parameters ---------- image_name : str Name of the image to get the digest Returns ------- str Image digest, i...
Get the digest of the local version of an image Parameters ---------- image_name : str Name of the image to get the digest Returns ------- str Image digest, including `sha256:` prefix
get_local_image_digest
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, docker_network_id=None, docker_client=None, skip_pull_image=False, do_shutdown_event=False): """ Instantiate the container manager :param docker_network_id: Optional Docker network to run this container in. :param docker_client: Optional docker client object :...
Instantiate the container manager :param docker_network_id: Optional Docker network to run this container in. :param docker_client: Optional docker client object :param bool skip_pull_image: Should we pull new Docker container image? :param bool do_shutdown_event: Optional. If ...
__init__
python
aws/aws-sam-cli
samcli/local/docker/manager.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/manager.py
Apache-2.0
def create(self, container, context): """ Create a container based on the given configuration. Parameters ---------- container samcli.local.docker.container.Container: Container to be created context: samcli.local.docker.container.ContainerContext ...
Create a container based on the given configuration. Parameters ---------- container samcli.local.docker.container.Container: Container to be created context: samcli.local.docker.container.ContainerContext Context for the container management to run. (bu...
create
python
aws/aws-sam-cli
samcli/local/docker/manager.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/manager.py
Apache-2.0
def run(self, container, context: ContainerContext, input_data=None): """ Run a Docker container based on the given configuration. If the container is not created, it will call Create method to create. Parameters ---------- container: samcli.local.docker.container.Contai...
Run a Docker container based on the given configuration. If the container is not created, it will call Create method to create. Parameters ---------- container: samcli.local.docker.container.Container Container to create and run context: samcli.local.docker....
run
python
aws/aws-sam-cli
samcli/local/docker/manager.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/manager.py
Apache-2.0
def pull_image(self, image_name, tag=None, stream=None): """ Ask Docker to pull the container image with given name. Parameters ---------- image_name str Name of the image stream samcli.lib.utils.stream_writer.StreamWriter Optional stream writer t...
Ask Docker to pull the container image with given name. Parameters ---------- image_name str Name of the image stream samcli.lib.utils.stream_writer.StreamWriter Optional stream writer to output to. Defaults to stderr Raises ------ ...
pull_image
python
aws/aws-sam-cli
samcli/local/docker/manager.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/manager.py
Apache-2.0
def has_image(self, image_name): """ Is the container image with given name available? :param string image_name: Name of the image :return bool: True, if image is available. False, otherwise """ try: self.docker_client.images.get(image_name) retu...
Is the container image with given name available? :param string image_name: Name of the image :return bool: True, if image is available. False, otherwise
has_image
python
aws/aws-sam-cli
samcli/local/docker/manager.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/manager.py
Apache-2.0
def inspect(self, container: str) -> Union[bool, dict]: """ Low-level Docker API for inspecting the container state Parameters ---------- container: str ID of the container Returns ------- Union[bool, dict] Container inspection st...
Low-level Docker API for inspecting the container state Parameters ---------- container: str ID of the container Returns ------- Union[bool, dict] Container inspection state if successful, False otherwise
inspect
python
aws/aws-sam-cli
samcli/local/docker/manager.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/manager.py
Apache-2.0
def to_posix_path(code_path): """ Change the code_path to be of unix-style if running on windows when supplied with an absolute windows path. Parameters ---------- code_path : str Directory in the host operating system that should be mounted within the container. Returns ------- ...
Change the code_path to be of unix-style if running on windows when supplied with an absolute windows path. Parameters ---------- code_path : str Directory in the host operating system that should be mounted within the container. Returns ------- str Posix equivalent of abso...
to_posix_path
python
aws/aws-sam-cli
samcli/local/docker/utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/utils.py
Apache-2.0
def find_free_port(network_interface: str, start: int = 5000, end: int = 9000) -> int: """ Utility function which scans through a port range in a randomized manner and finds the first free port a socket can bind to. :raises NoFreePortException if no free ports found in range. :return: int - free por...
Utility function which scans through a port range in a randomized manner and finds the first free port a socket can bind to. :raises NoFreePortException if no free ports found in range. :return: int - free port
find_free_port
python
aws/aws-sam-cli
samcli/local/docker/utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/utils.py
Apache-2.0
def is_docker_reachable(docker_client): """ Checks if Docker daemon is running. :param docker_client : docker.from_env() - docker client object :returns True, if Docker is available, False otherwise. """ errors = (docker.errors.APIError, requests.exceptions.ConnectionError, requests.exceptions....
Checks if Docker daemon is running. :param docker_client : docker.from_env() - docker client object :returns True, if Docker is available, False otherwise.
is_docker_reachable
python
aws/aws-sam-cli
samcli/local/docker/utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/utils.py
Apache-2.0
def get_rapid_name(architecture: str) -> str: """ Return the name of the rapid binary to use for an architecture Parameters ---------- architecture : str Architecture Returns ------- str "aws-lambda-rie-" + architecture """ validate_architecture(architecture) ...
Return the name of the rapid binary to use for an architecture Parameters ---------- architecture : str Architecture Returns ------- str "aws-lambda-rie-" + architecture
get_rapid_name
python
aws/aws-sam-cli
samcli/local/docker/utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/utils.py
Apache-2.0
def get_image_arch(architecture: str) -> str: """ Returns the docker image architecture value corresponding to the Lambda architecture value Parameters ---------- architecture : str Lambda architecture Returns ------- str Docker image architecture """ valida...
Returns the docker image architecture value corresponding to the Lambda architecture value Parameters ---------- architecture : str Lambda architecture Returns ------- str Docker image architecture
get_image_arch
python
aws/aws-sam-cli
samcli/local/docker/utils.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/docker/utils.py
Apache-2.0
def __init__( self, api_key=None, user_arn=None, cognito_authentication_type=None, caller=None, user_agent="Custom User Agent String", user=None, cognito_identity_pool_id=None, cognito_authentication_provider=None, source_ip="127.0.0.1", ...
Constructs a ContextIdentity :param str api_key: API Key used for the request :param str user_arn: ARN of the caller :param str cognito_authentication_type: Auth Type used :param str caller: Caller that make the request :param str user_agent: User agent (Default: Custom...
__init__
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def to_dict(self): """ Constructs an dictionary representation of the Identity Object to be used in serializing to JSON :return: dict representing the object """ json_dict = { "apiKey": self.api_key, "userArn": self.user_arn, "cognitoAuthentic...
Constructs an dictionary representation of the Identity Object to be used in serializing to JSON :return: dict representing the object
to_dict
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def __init__( self, resource_id="123456", api_id="1234567890", resource_path=None, http_method=None, request_id=str(uuid.uuid4()), account_id="123456789012", stage=None, identity=None, extended_request_id=None, path=None, pr...
Constructs a RequestContext :param str resource_id: Resource Id of the Request (Default: 123456) :param str api_id: Api Id for the Request (Default: 1234567890) :param str resource_path: Path for the Request :param str http_method: HTTPMethod for the request :param str ...
__init__
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def to_dict(self) -> Dict[str, Any]: """ Constructs an dictionary representation of the RequestContext Object to be used in serializing to JSON :return: dict representing the object """ identity_dict = {} if self.identity: identity_dict = self.identity.to_dic...
Constructs an dictionary representation of the RequestContext Object to be used in serializing to JSON :return: dict representing the object
to_dict
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def __init__( self, http_method=None, body=None, resource=None, request_context=None, query_string_params=None, multi_value_query_string_params=None, headers=None, multi_value_headers=None, path_parameters=None, stage_variables=None...
Constructs an ApiGatewayLambdaEvent :param str http_method: HTTPMethod of the request :param str body: Body or data for the request :param str resource: Resource for the reqeust :param RequestContext request_context: RequestContext for the request :param dict query_stri...
__init__
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def to_dict(self) -> Dict[str, Any]: """ Constructs an dictionary representation of the ApiGatewayLambdaEvent Object to be used in serializing to JSON Returns ------- Dict[str, Any] Dict representing the object """ request_context_dict = {} if...
Constructs an dictionary representation of the ApiGatewayLambdaEvent Object to be used in serializing to JSON Returns ------- Dict[str, Any] Dict representing the object
to_dict
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def __init__( self, method=None, path=None, protocol="HTTP/1.1", source_ip="127.0.0.1", user_agent="Custom User Agent String" ): """ Constructs a ContextHTTP :param str method: HTTP Method for the request :param str path: HTTP Path for the request :param str protocol...
Constructs a ContextHTTP :param str method: HTTP Method for the request :param str path: HTTP Path for the request :param str protocol: HTTP Protocol for the request (Default: HTTP/1.1) :param str source_ip: Source IP for the request (Default: 127.0.0.1) :param str user...
__init__
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def to_dict(self): """ Constructs an dictionary representation of the HTTP Object to be used in serializing to JSON :return: dict representing the object """ json_dict = { "method": self.method, "path": self.path, "protocol": self.prot...
Constructs an dictionary representation of the HTTP Object to be used in serializing to JSON :return: dict representing the object
to_dict
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def __init__( self, account_id="123456789012", api_id="1234567890", http=None, request_id=str(uuid.uuid4()), route_key=None, stage=None, request_time_epoch=None, request_time=None, domain_name="localhost", domain_prefix="localhost",...
Constructs a RequestContext Version 2. :param str account_id: Account Id of the Request (Default: 123456789012) :param str api_id: Api Id for the Request (Default: 1234567890) :param ContextHTTP http: HTTP for the request :param str request_id: Request Id for the request (Defau...
__init__
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def to_dict(self) -> Dict[str, Any]: """ Constructs an dictionary representation of the RequestContext Version 2 Object to be used in serializing to JSON :return: dict representing the object """ http_dict = {} if self.http: http_dict = self.http.to_d...
Constructs an dictionary representation of the RequestContext Version 2 Object to be used in serializing to JSON :return: dict representing the object
to_dict
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def __init__( self, route_key=None, raw_path=None, raw_query_string=None, cookies=None, headers=None, query_string_params=None, request_context=None, body=None, path_parameters=None, stage_variables=None, is_base_64_encoded=...
Constructs an ApiGatewayV2LambdaEvent. :param str route_key: The route key for the route. :param str raw_path: The raw path of the request. :param str raw_query_string: The raw query string of the request. :param list cookies: All cookie headers in the request are combined with...
__init__
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def to_dict(self) -> Dict[str, Any]: """ Constructs an dictionary representation of the ApiGatewayLambdaEvent Version 2 Object to be used in serializing to JSON Returns ------- Dict[str, Any] Dict representing the object """ request_context_di...
Constructs an dictionary representation of the ApiGatewayLambdaEvent Version 2 Object to be used in serializing to JSON Returns ------- Dict[str, Any] Dict representing the object
to_dict
python
aws/aws-sam-cli
samcli/local/events/api_event.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/events/api_event.py
Apache-2.0
def __init__( self, function_name=None, function_memory=None, function_timeout=None, function_handler=None, function_logging_config=None, variables=None, shell_env_values=None, override_values=None, aws_creds=None, ): """ ...
Initializes this class. It takes in two sets of properties: a) (Required) Function information b) (Optional) Environment variable configured on the function :param str function_name: The name of the function :param integer function_memory: Memory size of the function in...
__init__
python
aws/aws-sam-cli
samcli/local/lambdafn/env_vars.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/env_vars.py
Apache-2.0
def resolve(self): """ Resolves the values from different sources and returns a dict of environment variables to use when running the function locally. :return dict: Dict where key is the variable name and value is the value of the variable. Both key and values are strings ...
Resolves the values from different sources and returns a dict of environment variables to use when running the function locally. :return dict: Dict where key is the variable name and value is the value of the variable. Both key and values are strings
resolve
python
aws/aws-sam-cli
samcli/local/lambdafn/env_vars.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/env_vars.py
Apache-2.0
def _get_aws_variables(self): """ Returns the AWS specific environment variables that should be available in the Lambda runtime. They are prefixed it "AWS_*". :return dict: Name and value of AWS environment variable """ result = { # Variable that says this f...
Returns the AWS specific environment variables that should be available in the Lambda runtime. They are prefixed it "AWS_*". :return dict: Name and value of AWS environment variable
_get_aws_variables
python
aws/aws-sam-cli
samcli/local/lambdafn/env_vars.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/env_vars.py
Apache-2.0
def _stringify_value(self, value): """ This method stringifies values of environment variables. If the value of the method is a list or dictionary, then this method will replace it with empty string. Values of environment variables in Lambda must be a string. List or dictionary usually m...
This method stringifies values of environment variables. If the value of the method is a list or dictionary, then this method will replace it with empty string. Values of environment variables in Lambda must be a string. List or dictionary usually means they are intrinsic functions which have n...
_stringify_value
python
aws/aws-sam-cli
samcli/local/lambdafn/env_vars.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/env_vars.py
Apache-2.0
def unzip_from_uri(uri, layer_zip_path, unzip_output_dir, progressbar_label): """ Download the LayerVersion Zip to the Layer Pkg Cache Parameters ---------- uri str Uri to download from layer_zip_path str Path to where the content from the uri should be downloaded to unzip_o...
Download the LayerVersion Zip to the Layer Pkg Cache Parameters ---------- uri str Uri to download from layer_zip_path str Path to where the content from the uri should be downloaded to unzip_output_dir str Path to unzip the zip to progressbar_label str Labe...
unzip_from_uri
python
aws/aws-sam-cli
samcli/local/lambdafn/remote_files.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/remote_files.py
Apache-2.0
def __init__(self, container_manager, image_builder, mount_symlinks=False, no_mem_limit=False): """ Initialize the Local Lambda runtime Parameters ---------- container_manager samcli.local.docker.manager.ContainerManager Instance of the ContainerManager class that ca...
Initialize the Local Lambda runtime Parameters ---------- container_manager samcli.local.docker.manager.ContainerManager Instance of the ContainerManager class that can run a local Docker container image_builder samcli.local.docker.lambda_image.LambdaImage ...
__init__
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def run( self, container, function_config, debug_context, container_host=None, container_host_interface=None, extra_hosts=None, ): """ Find the created container for the passed Lambda function, then using the ContainerManager run this c...
Find the created container for the passed Lambda function, then using the ContainerManager run this container. If the Container is not created, it will create it first then start it. Parameters ---------- container Container the created container to be run ...
run
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def invoke( self, function_config, event, debug_context=None, stdout: Optional[StreamWriter] = None, stderr: Optional[StreamWriter] = None, container_host=None, container_host_interface=None, extra_hosts=None, ): """ Invoke the ...
Invoke the given Lambda function locally. ##### NOTE: THIS IS A LONG BLOCKING CALL ##### This method will block until either the Lambda function completes or timed out, which could be seconds. A blocking call will block the thread preventing any other operations from happening. If you ...
invoke
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _on_invoke_done(self, container): """ Cleanup the created resources, just before the invoke function ends Parameters ---------- container: Container The current running container """ if container: self._check_exit_state(container) ...
Cleanup the created resources, just before the invoke function ends Parameters ---------- container: Container The current running container
_on_invoke_done
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _check_exit_state(self, container: Container): """ Check and validate the exit state of the invoke container. Parameters ---------- container: Container Docker container to be checked Raises ------- ContainerFailureError If th...
Check and validate the exit state of the invoke container. Parameters ---------- container: Container Docker container to be checked Raises ------- ContainerFailureError If the exit reason is due to out-of-memory, return exit code 1 ...
_check_exit_state
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _configure_interrupt(self, function_full_path, timeout, container, is_debugging): """ When a Lambda function is executing, we setup certain interrupt handlers to stop the execution. Usually, we setup a function timeout interrupt to kill the container after timeout expires. If debugging thoug...
When a Lambda function is executing, we setup certain interrupt handlers to stop the execution. Usually, we setup a function timeout interrupt to kill the container after timeout expires. If debugging though, we don't enforce a timeout. But we setup a SIGINT interrupt to catch Ctrl+C and termin...
_configure_interrupt
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _get_code_dir(self, code_path: str) -> str: """ Method to get a path to a directory where the function/layer code is available. This directory will be mounted directly inside the Docker container. This method handles a few different cases for ``code_path``: - ``code_path...
Method to get a path to a directory where the function/layer code is available. This directory will be mounted directly inside the Docker container. This method handles a few different cases for ``code_path``: - ``code_path``is a existent zip/jar file: Unzip in a temp directory and...
_get_code_dir
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _unarchived_layer(self, layer: Union[str, Dict, LayerVersion]) -> Union[str, Dict, LayerVersion]: """ If the layer's content uri points to a supported local archive file, use self._get_code_dir() to un-archive it and so that it can be mounted directly inside the Docker container. Par...
If the layer's content uri points to a supported local archive file, use self._get_code_dir() to un-archive it and so that it can be mounted directly inside the Docker container. Parameters ---------- layer a str, dict or a LayerVersion object representing a layer ...
_unarchived_layer
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _clean_decompressed_paths(self): """ Clean the temporary decompressed code dirs """ LOG.debug("Cleaning all decompressed code dirs") with self._lock: for decompressed_dir in self._temp_uncompressed_paths_to_be_cleaned: shutil.rmtree(decompressed_di...
Clean the temporary decompressed code dirs
_clean_decompressed_paths
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def __init__(self, container_manager, image_builder, observer=None, mount_symlinks=False, no_mem_limit=False): """ Initialize the Local Lambda runtime Parameters ---------- container_manager samcli.local.docker.manager.ContainerManager Instance of the ContainerManage...
Initialize the Local Lambda runtime Parameters ---------- container_manager samcli.local.docker.manager.ContainerManager Instance of the ContainerManager class that can run a local Docker container image_builder samcli.local.docker.lambda_image.LambdaImage ...
__init__
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def create( self, function_config, debug_context=None, container_host=None, container_host_interface=None, extra_hosts=None ): """ Create a new Container for the passed function, then store it in a dictionary using the function name, so it can be retrieved later and used in the other...
Create a new Container for the passed function, then store it in a dictionary using the function name, so it can be retrieved later and used in the other functions. Make sure to use the debug_context only if the function_config.name equals debug_context.debug-function or the warm_containers opt...
create
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _on_invoke_done(self, container): """ Cleanup the created resources, just before the invoke function ends. In warm containers, the running containers will be closed just before the end of te command execution, so no action is done here Parameters ---------- c...
Cleanup the created resources, just before the invoke function ends. In warm containers, the running containers will be closed just before the end of te command execution, so no action is done here Parameters ---------- container: Container The current runnin...
_on_invoke_done
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _configure_interrupt(self, function_full_path, timeout, container, is_debugging): """ When a Lambda function is executing, we setup certain interrupt handlers to stop the execution. Usually, we setup a function timeout interrupt to kill the container after timeout expires. If debugging thoug...
When a Lambda function is executing, we setup certain interrupt handlers to stop the execution. Usually, we setup a function timeout interrupt to kill the container after timeout expires. If debugging though, we don't enforce a timeout. But we setup a SIGINT interrupt to catch Ctrl+C and termin...
_configure_interrupt
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def clean_running_containers_and_related_resources(self): """ Clean the running containers, the decompressed code dirs, and stop the created observer """ LOG.debug("Terminating all running warm containers") for function_name, container in self._containers.items(): LOG...
Clean the running containers, the decompressed code dirs, and stop the created observer
clean_running_containers_and_related_resources
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _on_code_change(self, functions): """ Handles the lambda function code change event. it determines if there is a real change in the code by comparing the checksum of the code path before and after the event. Parameters ---------- functions: list [FunctionConfig] ...
Handles the lambda function code change event. it determines if there is a real change in the code by comparing the checksum of the code path before and after the event. Parameters ---------- functions: list [FunctionConfig] the lambda functions that their source co...
_on_code_change
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _unzip_file(filepath): """ Helper method to unzip a file to a temporary directory :param string filepath: Absolute path to this file :return string: Path to the temporary directory where it was unzipped """ temp_dir = tempfile.mkdtemp() if os.name == "posix": os.chmod(temp_dir...
Helper method to unzip a file to a temporary directory :param string filepath: Absolute path to this file :return string: Path to the temporary directory where it was unzipped
_unzip_file
python
aws/aws-sam-cli
samcli/local/lambdafn/runtime.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/runtime.py
Apache-2.0
def _extract(file_info, output_dir, zip_ref): """ Unzip the given file into the given directory while preserving file permissions in the process. Parameters ---------- file_info : zipfile.ZipInfo The ZipInfo for a ZipFile output_dir : str Path to the directory where the it shoul...
Unzip the given file into the given directory while preserving file permissions in the process. Parameters ---------- file_info : zipfile.ZipInfo The ZipInfo for a ZipFile output_dir : str Path to the directory where the it should be unzipped to zip_ref : zipfile.ZipFile ...
_extract
python
aws/aws-sam-cli
samcli/local/lambdafn/zip.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/zip.py
Apache-2.0
def unzip(zip_file_path, output_dir, permission=None): """ Unzip the given file into the given directory while preserving file permissions in the process. Parameters ---------- zip_file_path : str Path to the zip file output_dir : str Path to the directory where the it should be...
Unzip the given file into the given directory while preserving file permissions in the process. Parameters ---------- zip_file_path : str Path to the zip file output_dir : str Path to the directory where the it should be unzipped to permission : int Permission to set in...
unzip
python
aws/aws-sam-cli
samcli/local/lambdafn/zip.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/zip.py
Apache-2.0
def _set_permissions(zip_file_info, extracted_path): """ Sets permissions on the extracted file by reading the ``external_attr`` property of given file info. Parameters ---------- zip_file_info : zipfile.ZipInfo Object containing information about a file within a zip archive extracted_...
Sets permissions on the extracted file by reading the ``external_attr`` property of given file info. Parameters ---------- zip_file_info : zipfile.ZipInfo Object containing information about a file within a zip archive extracted_path : str Path where the file has been extracted to...
_set_permissions
python
aws/aws-sam-cli
samcli/local/lambdafn/zip.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambdafn/zip.py
Apache-2.0
def resource_not_found(function_name): """ Creates a Lambda Service ResourceNotFound Response Parameters ---------- function_name str Name of the function that was requested to invoke Returns ------- Flask.Response A response obje...
Creates a Lambda Service ResourceNotFound Response Parameters ---------- function_name str Name of the function that was requested to invoke Returns ------- Flask.Response A response object representing the ResourceNotFound Error ...
resource_not_found
python
aws/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/lambda_error_responses.py
Apache-2.0
def invalid_request_content(message): """ Creates a Lambda Service InvalidRequestContent Response Parameters ---------- message str Message to be added to the body of the response Returns ------- Flask.Response A response object r...
Creates a Lambda Service InvalidRequestContent Response Parameters ---------- message str Message to be added to the body of the response Returns ------- Flask.Response A response object representing the InvalidRequestContent Error ...
invalid_request_content
python
aws/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/lambda_error_responses.py
Apache-2.0
def unsupported_media_type(content_type): """ Creates a Lambda Service UnsupportedMediaType Response Parameters ---------- content_type str Content Type of the request that was made Returns ------- Flask.Response A response object...
Creates a Lambda Service UnsupportedMediaType Response Parameters ---------- content_type str Content Type of the request that was made Returns ------- Flask.Response A response object representing the UnsupportedMediaType Error
unsupported_media_type
python
aws/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/lambda_error_responses.py
Apache-2.0
def generic_service_exception(*args): """ Creates a Lambda Service Generic ServiceException Response Parameters ---------- args list List of arguments Flask passes to the method Returns ------- Flask.Response A response object rep...
Creates a Lambda Service Generic ServiceException Response Parameters ---------- args list List of arguments Flask passes to the method Returns ------- Flask.Response A response object representing the GenericServiceException Error ...
generic_service_exception
python
aws/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/lambda_error_responses.py
Apache-2.0
def not_implemented_locally(message): """ Creates a Lambda Service NotImplementedLocally Response Parameters ---------- message str Message to be added to the body of the response Returns ------- Flask.Response A response object r...
Creates a Lambda Service NotImplementedLocally Response Parameters ---------- message str Message to be added to the body of the response Returns ------- Flask.Response A response object representing the NotImplementedLocally Error ...
not_implemented_locally
python
aws/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/lambda_error_responses.py
Apache-2.0
def generic_path_not_found(*args): """ Creates a Lambda Service Generic PathNotFound Response Parameters ---------- args list List of arguments Flask passes to the method Returns ------- Flask.Response A response object representi...
Creates a Lambda Service Generic PathNotFound Response Parameters ---------- args list List of arguments Flask passes to the method Returns ------- Flask.Response A response object representing the GenericPathNotFound Error
generic_path_not_found
python
aws/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/lambda_error_responses.py
Apache-2.0
def generic_method_not_allowed(*args): """ Creates a Lambda Service Generic MethodNotAllowed Response Parameters ---------- args list List of arguments Flask passes to the method Returns ------- Flask.Response A response object re...
Creates a Lambda Service Generic MethodNotAllowed Response Parameters ---------- args list List of arguments Flask passes to the method Returns ------- Flask.Response A response object representing the GenericMethodNotAllowed Error ...
generic_method_not_allowed
python
aws/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/lambda_error_responses.py
Apache-2.0
def container_creation_failed(message): """ Creates a Container Creation Failed response Parameters ---------- args list List of arguments Flask passes to the method Returns ------- Flask.Response A response object representing the ...
Creates a Container Creation Failed response Parameters ---------- args list List of arguments Flask passes to the method Returns ------- Flask.Response A response object representing the ContainerCreationFailed Error
container_creation_failed
python
aws/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/lambda_error_responses.py
Apache-2.0
def _construct_error_response_body(error_type, error_message): """ Constructs a string to be used in the body of the Response that conforms to the structure of the Lambda Service Responses Parameters ---------- error_type str The type of error error_m...
Constructs a string to be used in the body of the Response that conforms to the structure of the Lambda Service Responses Parameters ---------- error_type str The type of error error_message str Message of the error that occured Returns ...
_construct_error_response_body
python
aws/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/lambda_error_responses.py
Apache-2.0
def __init__(self, lambda_runner, port, host, stderr=None, ssl_context=None): """ Creates a Local Lambda Service that will only response to invoking a function Parameters ---------- lambda_runner samcli.commands.local.lib.local_lambda.LocalLambdaRunner The Lambda run...
Creates a Local Lambda Service that will only response to invoking a function Parameters ---------- lambda_runner samcli.commands.local.lib.local_lambda.LocalLambdaRunner The Lambda runner class capable of invoking the function port int Optional. port fo...
__init__
python
aws/aws-sam-cli
samcli/local/lambda_service/local_lambda_invoke_service.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/local_lambda_invoke_service.py
Apache-2.0
def validate_request(): """ Validates the incoming request The following are invalid 1. The Request data is not json serializable 2. Query Parameters are sent to the endpoint 3. The Request Content-Type is not application/json 4. 'X-Amz-Log-Type' ...
Validates the incoming request The following are invalid 1. The Request data is not json serializable 2. Query Parameters are sent to the endpoint 3. The Request Content-Type is not application/json 4. 'X-Amz-Log-Type' header is not 'None' 5....
validate_request
python
aws/aws-sam-cli
samcli/local/lambda_service/local_lambda_invoke_service.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/local_lambda_invoke_service.py
Apache-2.0
def _construct_error_handling(self): """ Updates the Flask app with Error Handlers for different Error Codes """ self._app.register_error_handler(500, LambdaErrorResponses.generic_service_exception) self._app.register_error_handler(404, LambdaErrorResponses.generic_path_not_foun...
Updates the Flask app with Error Handlers for different Error Codes
_construct_error_handling
python
aws/aws-sam-cli
samcli/local/lambda_service/local_lambda_invoke_service.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/local_lambda_invoke_service.py
Apache-2.0
def _invoke_request_handler(self, function_name): """ Request Handler for the Local Lambda Invoke path. This method is responsible for understanding the incoming request and invoking the Local Lambda Function Parameters ---------- function_name str Name of th...
Request Handler for the Local Lambda Invoke path. This method is responsible for understanding the incoming request and invoking the Local Lambda Function Parameters ---------- function_name str Name of the function to invoke Returns ------- ...
_invoke_request_handler
python
aws/aws-sam-cli
samcli/local/lambda_service/local_lambda_invoke_service.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/lambda_service/local_lambda_invoke_service.py
Apache-2.0
def __init__(self, layer_cache, cwd, stacks: List[Stack], lambda_client=None): """ Parameters ---------- layer_cache str path where to cache layers cwd str Current working directory stacks List[Stack] List of all stacks lambda_...
Parameters ---------- layer_cache str path where to cache layers cwd str Current working directory stacks List[Stack] List of all stacks lambda_client boto3.client('lambda') Boto3 Client for AWS Lambda
__init__
python
aws/aws-sam-cli
samcli/local/layers/layer_downloader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/layers/layer_downloader.py
Apache-2.0
def download_all(self, layers, force=False): """ Download a list of layers to the cache Parameters ---------- layers list(samcli.commands.local.lib.provider.Layer) List of Layers representing the layer to be downloaded force bool True to download ...
Download a list of layers to the cache Parameters ---------- layers list(samcli.commands.local.lib.provider.Layer) List of Layers representing the layer to be downloaded force bool True to download the layer even if it exists already on the system ...
download_all
python
aws/aws-sam-cli
samcli/local/layers/layer_downloader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/layers/layer_downloader.py
Apache-2.0
def download(self, layer: LayerVersion, force=False) -> LayerVersion: """ Download a given layer to the local cache. Parameters ---------- layer samcli.commands.local.lib.provider.Layer Layer representing the layer to be downloaded. force bool Tru...
Download a given layer to the local cache. Parameters ---------- layer samcli.commands.local.lib.provider.Layer Layer representing the layer to be downloaded. force bool True to download the layer even if it exists already on the system Returns ...
download
python
aws/aws-sam-cli
samcli/local/layers/layer_downloader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/layers/layer_downloader.py
Apache-2.0
def _fetch_layer_uri(self, layer): """ Fetch the Layer Uri based on the LayerVersion Arn Parameters ---------- layer samcli.commands.local.lib.provider.LayerVersion LayerVersion to fetch Returns ------- str The Uri to download the...
Fetch the Layer Uri based on the LayerVersion Arn Parameters ---------- layer samcli.commands.local.lib.provider.LayerVersion LayerVersion to fetch Returns ------- str The Uri to download the LayerVersion Content from Raises ...
_fetch_layer_uri
python
aws/aws-sam-cli
samcli/local/layers/layer_downloader.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/layers/layer_downloader.py
Apache-2.0
def __init__(self, is_debugging, port, host, ssl_context): """ Creates a BaseLocalService class Parameters ---------- is_debugging bool Flag to run in debug mode or not port int Optional. port for the service to start listening on Defaults to 3000...
Creates a BaseLocalService class Parameters ---------- is_debugging bool Flag to run in debug mode or not port int Optional. port for the service to start listening on Defaults to 3000 host str Optional. host to start the service on D...
__init__
python
aws/aws-sam-cli
samcli/local/services/base_local_service.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/services/base_local_service.py
Apache-2.0
def run(self): """ This starts up the (threaded) Local Server. Note: This is a **blocking call** Raises ------ RuntimeError if the service was not created """ if not self._app: raise RuntimeError("The application must be created be...
This starts up the (threaded) Local Server. Note: This is a **blocking call** Raises ------ RuntimeError if the service was not created
run
python
aws/aws-sam-cli
samcli/local/services/base_local_service.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/services/base_local_service.py
Apache-2.0
def service_response(body, headers, status_code): """ Constructs a Flask Response from the body, headers, and status_code. :param str body: Response body as a string :param werkzeug.datastructures.Headers headers: headers for the response :param int status_code: status_code for ...
Constructs a Flask Response from the body, headers, and status_code. :param str body: Response body as a string :param werkzeug.datastructures.Headers headers: headers for the response :param int status_code: status_code for response :return: Flask Response
service_response
python
aws/aws-sam-cli
samcli/local/services/base_local_service.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/services/base_local_service.py
Apache-2.0
def get_lambda_output( stdout_stream_str: io.StringIO, stdout_stream_bytes: Optional[io.BytesIO] = None ) -> Tuple[Union[str, bytes], bool]: """ This method will extract read the given stream and return the response from Lambda function separated out from any log statements it might ...
This method will extract read the given stream and return the response from Lambda function separated out from any log statements it might have outputted. Logs end up in the stdout stream if the Lambda function wrote directly to stdout using System.out.println or equivalents. Parameter...
get_lambda_output
python
aws/aws-sam-cli
samcli/local/services/base_local_service.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/services/base_local_service.py
Apache-2.0
def is_lambda_error_response(lambda_response): """ Check to see if the output from the container is in the form of an Error/Exception from the Lambda invoke Parameters ---------- lambda_response str The response the container returned Returns -------...
Check to see if the output from the container is in the form of an Error/Exception from the Lambda invoke Parameters ---------- lambda_response str The response the container returned Returns ------- bool True if the output matches the E...
is_lambda_error_response
python
aws/aws-sam-cli
samcli/local/services/base_local_service.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/local/services/base_local_service.py
Apache-2.0
def __init__(self, app_metadata): """ Initialize the object given SAR metadata properties. :param app_metadata: Dictionary containing SAR metadata properties :type app_metadata: dict """ self.template_dict = app_metadata # save the original template definitions ...
Initialize the object given SAR metadata properties. :param app_metadata: Dictionary containing SAR metadata properties :type app_metadata: dict
__init__
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/application_metadata.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/application_metadata.py
Apache-2.0
def validate(self, required_props): """ Check if the required application metadata properties have been populated. :param required_props: List of required properties :type required_props: list :return: True, if the metadata is valid :raises: InvalidApplicationMetadataErr...
Check if the required application metadata properties have been populated. :param required_props: List of required properties :type required_props: list :return: True, if the metadata is valid :raises: InvalidApplicationMetadataError
validate
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/application_metadata.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/application_metadata.py
Apache-2.0
def parse_template(template_str): """ Parse the SAM template. :param template_str: A packaged YAML or json CloudFormation template :type template_str: str :return: Dictionary with keys defined in the template :rtype: dict """ try: # PyYAML doesn't support json as well as it shou...
Parse the SAM template. :param template_str: A packaged YAML or json CloudFormation template :type template_str: str :return: Dictionary with keys defined in the template :rtype: dict
parse_template
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/parser.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/parser.py
Apache-2.0
def get_app_metadata(template_dict): """ Get the application metadata from a SAM template. :param template_dict: SAM template as a dictionary :type template_dict: dict :return: Application metadata as defined in the template :rtype: ApplicationMetadata :raises ApplicationMetadataNotFoundErr...
Get the application metadata from a SAM template. :param template_dict: SAM template as a dictionary :type template_dict: dict :return: Application metadata as defined in the template :rtype: ApplicationMetadata :raises ApplicationMetadataNotFoundError
get_app_metadata
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/parser.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/parser.py
Apache-2.0
def parse_application_id(text): """ Extract the application id from input text. :param text: text to parse :type text: str :return: application id if found in the input :rtype: str """ result = re.search(APPLICATION_ID_PATTERN, text) return result.group(0) if result else None
Extract the application id from input text. :param text: text to parse :type text: str :return: application id if found in the input :rtype: str
parse_application_id
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/parser.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/parser.py
Apache-2.0
def strip_app_metadata(template_dict): """ Strip the "AWS::ServerlessRepo::Application" metadata section from template. :param template_dict: SAM template as a dictionary :type template_dict: dict :return: stripped template content :rtype: str """ if SERVERLESS_REPO_APPLICATION not in t...
Strip the "AWS::ServerlessRepo::Application" metadata section from template. :param template_dict: SAM template as a dictionary :type template_dict: dict :return: stripped template content :rtype: str
strip_app_metadata
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/parser.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/parser.py
Apache-2.0
def publish_application(template, sar_client=None, fail_on_same_version=False): """ Create a new application or new application version in SAR. Parameters ---------- template: str | dict Content of a packaged YAML or JSON SAM template sar_client: boto3.client The boto3 client u...
Create a new application or new application version in SAR. Parameters ---------- template: str | dict Content of a packaged YAML or JSON SAM template sar_client: boto3.client The boto3 client used to access SAR fail_on_same_version: bool Whether or not publish hard f...
publish_application
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/publish.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/publish.py
Apache-2.0
def _check_app_with_semantic_version_exists(sar_client, application_id, semantic_version): """ Checks if a given SAR application exists with a given semantic version Parameters ---------- sar_client: boto3.client The boto3 client used to access SAR application_id: str Applicati...
Checks if a given SAR application exists with a given semantic version Parameters ---------- sar_client: boto3.client The boto3 client used to access SAR application_id: str Application Id to check semantic_version: str The semantic version to check with Application I...
_check_app_with_semantic_version_exists
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/publish.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/publish.py
Apache-2.0
def _get_template_dict(template): """ Parse string template and or copy dictionary template. Parameters ---------- template: str | dict Content of a packaged YAML or JSON SAM template Returns ------- dict Template as a dictionary Raises ------ ValueError ...
Parse string template and or copy dictionary template. Parameters ---------- template: str | dict Content of a packaged YAML or JSON SAM template Returns ------- dict Template as a dictionary Raises ------ ValueError If the supplied template is not a s...
_get_template_dict
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/publish.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/publish.py
Apache-2.0
def _create_application_request(app_metadata, template): """ Construct the request body to create application. Parameters ---------- app_metadata: ApplicationMetadata Object containing app metadata template: str A packaged YAML or JSON SAM template Returns ------- ...
Construct the request body to create application. Parameters ---------- app_metadata: ApplicationMetadata Object containing app metadata template: str A packaged YAML or JSON SAM template Returns ------- dict SAR CreateApplication request body
_create_application_request
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/publish.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/publish.py
Apache-2.0
def _update_application_request(app_metadata, application_id): """ Construct the request body to update application. Parameters ---------- app_metadata: ApplicationMetadata Object containing app metadata application_id: str The Amazon Resource Name (ARN) of the application ...
Construct the request body to update application. Parameters ---------- app_metadata: ApplicationMetadata Object containing app metadata application_id: str The Amazon Resource Name (ARN) of the application Returns ------- dict SAR CreateApplication request bo...
_update_application_request
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/publish.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/publish.py
Apache-2.0
def _create_application_version_request(app_metadata, application_id, template): """ Construct the request body to create application version. Parameters ---------- app_metadata: ApplicationMetadata Object containing app metadata application_id: str The Amazon Resource Name (AR...
Construct the request body to create application version. Parameters ---------- app_metadata: ApplicationMetadata Object containing app metadata application_id: str The Amazon Resource Name (ARN) of the application template: str A packaged YAML or JSON SAM template ...
_create_application_version_request
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/publish.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/publish.py
Apache-2.0
def _is_conflict_exception(e): """ Check whether the botocore ClientError is ConflictException. Parameters ---------- e: ClientError botocore exception Returns ------- bool True if e is ConflictException, False otherwise """ error_code = e.response["Error"]["Cod...
Check whether the botocore ClientError is ConflictException. Parameters ---------- e: ClientError botocore exception Returns ------- bool True if e is ConflictException, False otherwise
_is_conflict_exception
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/publish.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/publish.py
Apache-2.0
def _wrap_client_error(e): """ Wrap botocore ClientError exception into ServerlessRepoClientError. Parameters ---------- e: ClientError botocore exception Returns ------- ServerlessRepoError S3PermissionsRequired or InvalidS3UriError or general ServerlessRepoClientError ...
Wrap botocore ClientError exception into ServerlessRepoClientError. Parameters ---------- e: ClientError botocore exception Returns ------- ServerlessRepoError S3PermissionsRequired or InvalidS3UriError or general ServerlessRepoClientError
_wrap_client_error
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/publish.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/publish.py
Apache-2.0
def _get_publish_details(actions, app_metadata_template): """ Get the changed application details after publishing. Parameters ---------- actions: str | list Actions taken during publishing app_metadata_template: dict Original template definitions of app metadata Returns ...
Get the changed application details after publishing. Parameters ---------- actions: str | list Actions taken during publishing app_metadata_template: dict Original template definitions of app metadata Returns ------- dict Updated fields and values of the appl...
_get_publish_details
python
aws/aws-sam-cli
samcli/vendor/serverlessrepo/publish.py
https://github.com/aws/aws-sam-cli/blob/master/samcli/vendor/serverlessrepo/publish.py
Apache-2.0
def to_schema(self) -> Dict[str, Any]: """Return the JSON schema representation of the SAM CLI parameter.""" param: Dict[str, Any] = {} param.update({"title": self.name, "type": self.type, "description": self.description}) if self.default: param.update({"default": self.defaul...
Return the JSON schema representation of the SAM CLI parameter.
to_schema
python
aws/aws-sam-cli
schema/make_schema.py
https://github.com/aws/aws-sam-cli/blob/master/schema/make_schema.py
Apache-2.0
def to_schema(self) -> dict: """Return the JSON schema representation of the SAM CLI command.""" split_cmd_name = self.name.split("_") formatted_cmd_name = " ".join(split_cmd_name) formatted_params_list = "* " + "\n* ".join([f"{param.name}:\n{param.description}" for param in self.paramet...
Return the JSON schema representation of the SAM CLI command.
to_schema
python
aws/aws-sam-cli
schema/make_schema.py
https://github.com/aws/aws-sam-cli/blob/master/schema/make_schema.py
Apache-2.0
def clean_text(text: str) -> str: """Clean up a string of text to be formatted for the JSON schema.""" if not text: return "" for char_to_delete in CHARS_TO_CLEAN: text = text.replace(char_to_delete, "") return text.strip("\n").strip()
Clean up a string of text to be formatted for the JSON schema.
clean_text
python
aws/aws-sam-cli
schema/make_schema.py
https://github.com/aws/aws-sam-cli/blob/master/schema/make_schema.py
Apache-2.0
def format_param(param: click.core.Option) -> SamCliParameterSchema: """Format a click Option parameter to a SamCliParameter object. A parameter object should contain the following information that will be necessary for including in the JSON schema: * name - The name of the parameter * help - The p...
Format a click Option parameter to a SamCliParameter object. A parameter object should contain the following information that will be necessary for including in the JSON schema: * name - The name of the parameter * help - The parameter's description (may vary between commands) * type - The data typ...
format_param
python
aws/aws-sam-cli
schema/make_schema.py
https://github.com/aws/aws-sam-cli/blob/master/schema/make_schema.py
Apache-2.0
def get_params_from_command(cli) -> List[SamCliParameterSchema]: """Given a CLI object, return a list of all parameters in that CLI, formatted as SamCliParameterSchema objects.""" return [ format_param(param) for param in cli.params if param.name and isinstance(param, click.core.Option) ...
Given a CLI object, return a list of all parameters in that CLI, formatted as SamCliParameterSchema objects.
get_params_from_command
python
aws/aws-sam-cli
schema/make_schema.py
https://github.com/aws/aws-sam-cli/blob/master/schema/make_schema.py
Apache-2.0
def retrieve_command_structure(package_name: str) -> List[SamCliCommandSchema]: """Given a SAM CLI package name, retrieve its structure. Such a structure is the list of all subcommands as `SamCliCommandSchema`, which includes the command's name, description, and its parameters. Parameters --------...
Given a SAM CLI package name, retrieve its structure. Such a structure is the list of all subcommands as `SamCliCommandSchema`, which includes the command's name, description, and its parameters. Parameters ---------- package_name: str The name of the command package to retrieve. Retu...
retrieve_command_structure
python
aws/aws-sam-cli
schema/make_schema.py
https://github.com/aws/aws-sam-cli/blob/master/schema/make_schema.py
Apache-2.0
def generate_schema() -> dict: """Generate a JSON schema for all SAM CLI commands. Returns ------- dict A dictionary representation of the JSON schema. """ schema: dict = {} commands: List[SamCliCommandSchema] = [] # Populate schema with relevant attributes schema["$schema"...
Generate a JSON schema for all SAM CLI commands. Returns ------- dict A dictionary representation of the JSON schema.
generate_schema
python
aws/aws-sam-cli
schema/make_schema.py
https://github.com/aws/aws-sam-cli/blob/master/schema/make_schema.py
Apache-2.0
def write_schema(): """Generate the SAM CLI JSON schema and write it to file.""" schema = generate_schema() with open(SchemaKeys.SCHEMA_FILE_NAME.value, "w+", encoding="utf-8") as outfile: json.dump(schema, outfile, indent=2)
Generate the SAM CLI JSON schema and write it to file.
write_schema
python
aws/aws-sam-cli
schema/make_schema.py
https://github.com/aws/aws-sam-cli/blob/master/schema/make_schema.py
Apache-2.0