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 _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
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 create(self): """ Creates a Flask Application that can be started. """ self._app = Flask(__name__) # add converter to support nested stack function path self._app.url_map.converters["function_path"] = FunctionNamePathConverter path = "/2015-03-31/functions/<...
Creates a Flask Application that can be started.
create
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