id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
29,900
awslabs/aws-sam-cli
samcli/commands/init/__init__.py
cli
def cli(ctx, location, runtime, dependency_manager, output_dir, name, no_input): """ \b Initialize a serverless application with a SAM template, folder structure for your Lambda functions, connected to an event source such as APIs, S3 Buckets or DynamoDB Tables. This application includes eve...
python
def cli(ctx, location, runtime, dependency_manager, output_dir, name, no_input): """ \b Initialize a serverless application with a SAM template, folder structure for your Lambda functions, connected to an event source such as APIs, S3 Buckets or DynamoDB Tables. This application includes eve...
[ "def", "cli", "(", "ctx", ",", "location", ",", "runtime", ",", "dependency_manager", ",", "output_dir", ",", "name", ",", "no_input", ")", ":", "# All logic must be implemented in the `do_cli` method. This helps ease unit tests", "do_cli", "(", "ctx", ",", "location", ...
\b Initialize a serverless application with a SAM template, folder structure for your Lambda functions, connected to an event source such as APIs, S3 Buckets or DynamoDB Tables. This application includes everything you need to get started with serverless and eventually grow into a produc...
[ "\\", "b", "Initialize", "a", "serverless", "application", "with", "a", "SAM", "template", "folder", "structure", "for", "your", "Lambda", "functions", "connected", "to", "an", "event", "source", "such", "as", "APIs", "S3", "Buckets", "or", "DynamoDB", "Tables...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/init/__init__.py#L30-L76
29,901
awslabs/aws-sam-cli
samcli/commands/local/lib/swagger/parser.py
SwaggerParser.get_apis
def get_apis(self): """ Parses a swagger document and returns a list of APIs configured in the document. Swagger documents have the following structure { "/path1": { # path "get": { # method "x-amazon-apigateway-integration": { # in...
python
def get_apis(self): """ Parses a swagger document and returns a list of APIs configured in the document. Swagger documents have the following structure { "/path1": { # path "get": { # method "x-amazon-apigateway-integration": { # in...
[ "def", "get_apis", "(", "self", ")", ":", "result", "=", "[", "]", "paths_dict", "=", "self", ".", "swagger", ".", "get", "(", "\"paths\"", ",", "{", "}", ")", "binary_media_types", "=", "self", ".", "get_binary_media_types", "(", ")", "for", "full_path"...
Parses a swagger document and returns a list of APIs configured in the document. Swagger documents have the following structure { "/path1": { # path "get": { # method "x-amazon-apigateway-integration": { # integration "type"...
[ "Parses", "a", "swagger", "document", "and", "returns", "a", "list", "of", "APIs", "configured", "in", "the", "document", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/swagger/parser.py#L38-L92
29,902
awslabs/aws-sam-cli
samcli/commands/local/lib/swagger/parser.py
SwaggerParser._get_integration_function_name
def _get_integration_function_name(self, method_config): """ Tries to parse the Lambda Function name from the Integration defined in the method configuration. Integration configuration is defined under the special "x-amazon-apigateway-integration" key. We care only about Lambda integrati...
python
def _get_integration_function_name(self, method_config): """ Tries to parse the Lambda Function name from the Integration defined in the method configuration. Integration configuration is defined under the special "x-amazon-apigateway-integration" key. We care only about Lambda integrati...
[ "def", "_get_integration_function_name", "(", "self", ",", "method_config", ")", ":", "if", "not", "isinstance", "(", "method_config", ",", "dict", ")", "or", "self", ".", "_INTEGRATION_KEY", "not", "in", "method_config", ":", "return", "None", "integration", "=...
Tries to parse the Lambda Function name from the Integration defined in the method configuration. Integration configuration is defined under the special "x-amazon-apigateway-integration" key. We care only about Lambda integrations, which are of type aws_proxy, and ignore the rest. Integration URI is com...
[ "Tries", "to", "parse", "the", "Lambda", "Function", "name", "from", "the", "Integration", "defined", "in", "the", "method", "configuration", ".", "Integration", "configuration", "is", "defined", "under", "the", "special", "x", "-", "amazon", "-", "apigateway", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/swagger/parser.py#L94-L121
29,903
awslabs/aws-sam-cli
samcli/lib/logs/formatter.py
LogsFormatter.do_format
def do_format(self, event_iterable): """ Formats the given CloudWatch Logs Event dictionary as necessary and returns an iterable that will return the formatted string. This can be used to parse and format the events based on context ie. In Lambda Function logs, a formatter may wish to co...
python
def do_format(self, event_iterable): """ Formats the given CloudWatch Logs Event dictionary as necessary and returns an iterable that will return the formatted string. This can be used to parse and format the events based on context ie. In Lambda Function logs, a formatter may wish to co...
[ "def", "do_format", "(", "self", ",", "event_iterable", ")", ":", "for", "operation", "in", "self", ".", "formatter_chain", ":", "# Make sure the operation has access to certain basic objects like colored", "partial_op", "=", "functools", ".", "partial", "(", "operation",...
Formats the given CloudWatch Logs Event dictionary as necessary and returns an iterable that will return the formatted string. This can be used to parse and format the events based on context ie. In Lambda Function logs, a formatter may wish to color the "ERROR" keywords red, or highlight a filt...
[ "Formats", "the", "given", "CloudWatch", "Logs", "Event", "dictionary", "as", "necessary", "and", "returns", "an", "iterable", "that", "will", "return", "the", "formatted", "string", ".", "This", "can", "be", "used", "to", "parse", "and", "format", "the", "e...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/logs/formatter.py#L83-L111
29,904
awslabs/aws-sam-cli
samcli/lib/logs/formatter.py
LogsFormatter._pretty_print_event
def _pretty_print_event(event, colored): """ Basic formatter to convert an event object to string """ event.timestamp = colored.yellow(event.timestamp) event.log_stream_name = colored.cyan(event.log_stream_name) return ' '.join([event.log_stream_name, event.timestamp, ev...
python
def _pretty_print_event(event, colored): """ Basic formatter to convert an event object to string """ event.timestamp = colored.yellow(event.timestamp) event.log_stream_name = colored.cyan(event.log_stream_name) return ' '.join([event.log_stream_name, event.timestamp, ev...
[ "def", "_pretty_print_event", "(", "event", ",", "colored", ")", ":", "event", ".", "timestamp", "=", "colored", ".", "yellow", "(", "event", ".", "timestamp", ")", "event", ".", "log_stream_name", "=", "colored", ".", "cyan", "(", "event", ".", "log_strea...
Basic formatter to convert an event object to string
[ "Basic", "formatter", "to", "convert", "an", "event", "object", "to", "string" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/logs/formatter.py#L114-L121
29,905
awslabs/aws-sam-cli
samcli/lib/logs/formatter.py
KeywordHighlighter.highlight_keywords
def highlight_keywords(self, event, colored): """ Highlight the keyword in the log statement by drawing an underline """ if self.keyword: highlight = colored.underline(self.keyword) event.message = event.message.replace(self.keyword, highlight) return eve...
python
def highlight_keywords(self, event, colored): """ Highlight the keyword in the log statement by drawing an underline """ if self.keyword: highlight = colored.underline(self.keyword) event.message = event.message.replace(self.keyword, highlight) return eve...
[ "def", "highlight_keywords", "(", "self", ",", "event", ",", "colored", ")", ":", "if", "self", ".", "keyword", ":", "highlight", "=", "colored", ".", "underline", "(", "self", ".", "keyword", ")", "event", ".", "message", "=", "event", ".", "message", ...
Highlight the keyword in the log statement by drawing an underline
[ "Highlight", "the", "keyword", "in", "the", "log", "statement", "by", "drawing", "an", "underline" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/logs/formatter.py#L157-L165
29,906
awslabs/aws-sam-cli
samcli/lib/logs/formatter.py
JSONMsgFormatter.format_json
def format_json(event, colored): """ If the event message is a JSON string, then pretty print the JSON with 2 indents and sort the keys. This makes it very easy to visually parse and search JSON data """ try: if event.message.startswith("{"): msg_dict...
python
def format_json(event, colored): """ If the event message is a JSON string, then pretty print the JSON with 2 indents and sort the keys. This makes it very easy to visually parse and search JSON data """ try: if event.message.startswith("{"): msg_dict...
[ "def", "format_json", "(", "event", ",", "colored", ")", ":", "try", ":", "if", "event", ".", "message", ".", "startswith", "(", "\"{\"", ")", ":", "msg_dict", "=", "json", ".", "loads", "(", "event", ".", "message", ")", "event", ".", "message", "="...
If the event message is a JSON string, then pretty print the JSON with 2 indents and sort the keys. This makes it very easy to visually parse and search JSON data
[ "If", "the", "event", "message", "is", "a", "JSON", "string", "then", "pretty", "print", "the", "JSON", "with", "2", "indents", "and", "sort", "the", "keys", ".", "This", "makes", "it", "very", "easy", "to", "visually", "parse", "and", "search", "JSON", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/logs/formatter.py#L174-L188
29,907
awslabs/aws-sam-cli
samcli/commands/_utils/template.py
_resolve_relative_to
def _resolve_relative_to(path, original_root, new_root): """ If the given ``path`` is a relative path, then assume it is relative to ``original_root``. This method will update the path to be resolve it relative to ``new_root`` and return. Examples ------- # Assume a file called template.txt...
python
def _resolve_relative_to(path, original_root, new_root): """ If the given ``path`` is a relative path, then assume it is relative to ``original_root``. This method will update the path to be resolve it relative to ``new_root`` and return. Examples ------- # Assume a file called template.txt...
[ "def", "_resolve_relative_to", "(", "path", ",", "original_root", ",", "new_root", ")", ":", "if", "not", "isinstance", "(", "path", ",", "six", ".", "string_types", ")", "or", "path", ".", "startswith", "(", "\"s3://\"", ")", "or", "os", ".", "path", "....
If the given ``path`` is a relative path, then assume it is relative to ``original_root``. This method will update the path to be resolve it relative to ``new_root`` and return. Examples ------- # Assume a file called template.txt at location /tmp/original/root/template.txt expressed as relative pa...
[ "If", "the", "given", "path", "is", "a", "relative", "path", "then", "assume", "it", "is", "relative", "to", "original_root", ".", "This", "method", "will", "update", "the", "path", "to", "be", "resolve", "it", "relative", "to", "new_root", "and", "return"...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/_utils/template.py#L208-L237
29,908
awslabs/aws-sam-cli
samcli/commands/local/lib/swagger/reader.py
SamSwaggerReader.read
def read(self): """ Gets the Swagger document from either of the given locations. If we fail to retrieve or parse the Swagger file, this method will return None. Returns ------- dict: Swagger document. None, if we cannot retrieve the document """ ...
python
def read(self): """ Gets the Swagger document from either of the given locations. If we fail to retrieve or parse the Swagger file, this method will return None. Returns ------- dict: Swagger document. None, if we cannot retrieve the document """ ...
[ "def", "read", "(", "self", ")", ":", "swagger", "=", "None", "# First check if there is inline swagger", "if", "self", ".", "definition_body", ":", "swagger", "=", "self", ".", "_read_from_definition_body", "(", ")", "if", "not", "swagger", "and", "self", ".", ...
Gets the Swagger document from either of the given locations. If we fail to retrieve or parse the Swagger file, this method will return None. Returns ------- dict: Swagger document. None, if we cannot retrieve the document
[ "Gets", "the", "Swagger", "document", "from", "either", "of", "the", "given", "locations", ".", "If", "we", "fail", "to", "retrieve", "or", "parse", "the", "Swagger", "file", "this", "method", "will", "return", "None", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/swagger/reader.py#L92-L113
29,909
awslabs/aws-sam-cli
samcli/commands/local/lib/swagger/reader.py
SamSwaggerReader._download_swagger
def _download_swagger(self, location): """ Download the file from given local or remote location and return it Parameters ---------- location : str or dict Local path or S3 path to Swagger file to download. Consult the ``__init__.py`` documentation for specifics ...
python
def _download_swagger(self, location): """ Download the file from given local or remote location and return it Parameters ---------- location : str or dict Local path or S3 path to Swagger file to download. Consult the ``__init__.py`` documentation for specifics ...
[ "def", "_download_swagger", "(", "self", ",", "location", ")", ":", "if", "not", "location", ":", "return", "bucket", ",", "key", ",", "version", "=", "self", ".", "_parse_s3_location", "(", "location", ")", "if", "bucket", "and", "key", ":", "LOG", ".",...
Download the file from given local or remote location and return it Parameters ---------- location : str or dict Local path or S3 path to Swagger file to download. Consult the ``__init__.py`` documentation for specifics on structure of this property. Returns ...
[ "Download", "the", "file", "from", "given", "local", "or", "remote", "location", "and", "return", "it" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/swagger/reader.py#L138-L180
29,910
awslabs/aws-sam-cli
samcli/commands/local/lib/swagger/reader.py
SamSwaggerReader._download_from_s3
def _download_from_s3(bucket, key, version=None): """ Download a file from given S3 location, if available. Parameters ---------- bucket : str S3 Bucket name key : str S3 Bucket Key aka file path version : str Optional Versio...
python
def _download_from_s3(bucket, key, version=None): """ Download a file from given S3 location, if available. Parameters ---------- bucket : str S3 Bucket name key : str S3 Bucket Key aka file path version : str Optional Versio...
[ "def", "_download_from_s3", "(", "bucket", ",", "key", ",", "version", "=", "None", ")", ":", "s3", "=", "boto3", ".", "client", "(", "'s3'", ")", "extra_args", "=", "{", "}", "if", "version", ":", "extra_args", "[", "\"VersionId\"", "]", "=", "version...
Download a file from given S3 location, if available. Parameters ---------- bucket : str S3 Bucket name key : str S3 Bucket Key aka file path version : str Optional Version ID of the file Returns ------- str ...
[ "Download", "a", "file", "from", "given", "S3", "location", "if", "available", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/swagger/reader.py#L183-L229
29,911
awslabs/aws-sam-cli
samcli/cli/context.py
Context.debug
def debug(self, value): """ Turn on debug logging if necessary. :param value: Value of debug flag """ self._debug = value if self._debug: # Turn on debug logging logging.getLogger().setLevel(logging.DEBUG)
python
def debug(self, value): """ Turn on debug logging if necessary. :param value: Value of debug flag """ self._debug = value if self._debug: # Turn on debug logging logging.getLogger().setLevel(logging.DEBUG)
[ "def", "debug", "(", "self", ",", "value", ")", ":", "self", ".", "_debug", "=", "value", "if", "self", ".", "_debug", ":", "# Turn on debug logging", "logging", ".", "getLogger", "(", ")", ".", "setLevel", "(", "logging", ".", "DEBUG", ")" ]
Turn on debug logging if necessary. :param value: Value of debug flag
[ "Turn", "on", "debug", "logging", "if", "necessary", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/cli/context.py#L35-L45
29,912
awslabs/aws-sam-cli
samcli/local/init/__init__.py
generate_project
def generate_project( location=None, runtime="nodejs", dependency_manager=None, output_dir=".", name='sam-sample-app', no_input=False): """Generates project using cookiecutter and options given Generate project scaffolds a project using default templates if user doesn't provide one via loca...
python
def generate_project( location=None, runtime="nodejs", dependency_manager=None, output_dir=".", name='sam-sample-app', no_input=False): """Generates project using cookiecutter and options given Generate project scaffolds a project using default templates if user doesn't provide one via loca...
[ "def", "generate_project", "(", "location", "=", "None", ",", "runtime", "=", "\"nodejs\"", ",", "dependency_manager", "=", "None", ",", "output_dir", "=", "\".\"", ",", "name", "=", "'sam-sample-app'", ",", "no_input", "=", "False", ")", ":", "template", "=...
Generates project using cookiecutter and options given Generate project scaffolds a project using default templates if user doesn't provide one via location parameter. Default templates are automatically chosen depending on runtime given by the user. Parameters ---------- location: Path, optio...
[ "Generates", "project", "using", "cookiecutter", "and", "options", "given" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/init/__init__.py#L16-L83
29,913
awslabs/aws-sam-cli
samcli/lib/utils/time.py
to_utc
def to_utc(some_time): """ Convert the given date to UTC, if the date contains a timezone. Parameters ---------- some_time : datetime.datetime datetime object to convert to UTC Returns ------- datetime.datetime Converted datetime object """ # Convert timezone a...
python
def to_utc(some_time): """ Convert the given date to UTC, if the date contains a timezone. Parameters ---------- some_time : datetime.datetime datetime object to convert to UTC Returns ------- datetime.datetime Converted datetime object """ # Convert timezone a...
[ "def", "to_utc", "(", "some_time", ")", ":", "# Convert timezone aware objects to UTC", "if", "some_time", ".", "tzinfo", "and", "some_time", ".", "utcoffset", "(", ")", ":", "some_time", "=", "some_time", ".", "astimezone", "(", "tzutc", "(", ")", ")", "# Now...
Convert the given date to UTC, if the date contains a timezone. Parameters ---------- some_time : datetime.datetime datetime object to convert to UTC Returns ------- datetime.datetime Converted datetime object
[ "Convert", "the", "given", "date", "to", "UTC", "if", "the", "date", "contains", "a", "timezone", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/time.py#L68-L88
29,914
awslabs/aws-sam-cli
samcli/lib/utils/time.py
parse_date
def parse_date(date_string): """ Parse the given string as datetime object. This parser supports in almost any string formats. For relative times, like `10min ago`, this parser computes the actual time relative to current UTC time. This allows time to always be in UTC if an explicit time zone is not pr...
python
def parse_date(date_string): """ Parse the given string as datetime object. This parser supports in almost any string formats. For relative times, like `10min ago`, this parser computes the actual time relative to current UTC time. This allows time to always be in UTC if an explicit time zone is not pr...
[ "def", "parse_date", "(", "date_string", ")", ":", "parser_settings", "=", "{", "# Relative times like '10m ago' must subtract from the current UTC time. Without this setting, dateparser", "# will use current local time as the base for subtraction, but falsely assume it is a UTC time. Therefore"...
Parse the given string as datetime object. This parser supports in almost any string formats. For relative times, like `10min ago`, this parser computes the actual time relative to current UTC time. This allows time to always be in UTC if an explicit time zone is not provided. Parameters ---------- ...
[ "Parse", "the", "given", "string", "as", "datetime", "object", ".", "This", "parser", "supports", "in", "almost", "any", "string", "formats", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/time.py#L91-L117
29,915
awslabs/aws-sam-cli
samcli/commands/local/cli_common/invoke_context.py
InvokeContext.function_name
def function_name(self): """ Returns name of the function to invoke. If no function identifier is provided, this method will return name of the only function from the template :return string: Name of the function :raises InvokeContextException: If function identifier is not prov...
python
def function_name(self): """ Returns name of the function to invoke. If no function identifier is provided, this method will return name of the only function from the template :return string: Name of the function :raises InvokeContextException: If function identifier is not prov...
[ "def", "function_name", "(", "self", ")", ":", "if", "self", ".", "_function_identifier", ":", "return", "self", ".", "_function_identifier", "# Function Identifier is *not* provided. If there is only one function in the template,", "# default to it.", "all_functions", "=", "["...
Returns name of the function to invoke. If no function identifier is provided, this method will return name of the only function from the template :return string: Name of the function :raises InvokeContextException: If function identifier is not provided
[ "Returns", "name", "of", "the", "function", "to", "invoke", ".", "If", "no", "function", "identifier", "is", "provided", "this", "method", "will", "return", "name", "of", "the", "only", "function", "from", "the", "template" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/cli_common/invoke_context.py#L157-L180
29,916
awslabs/aws-sam-cli
samcli/commands/local/cli_common/invoke_context.py
InvokeContext.local_lambda_runner
def local_lambda_runner(self): """ Returns an instance of the runner capable of running Lambda functions locally :return samcli.commands.local.lib.local_lambda.LocalLambdaRunner: Runner configured to run Lambda functions locally """ layer_downloader = LayerDownloade...
python
def local_lambda_runner(self): """ Returns an instance of the runner capable of running Lambda functions locally :return samcli.commands.local.lib.local_lambda.LocalLambdaRunner: Runner configured to run Lambda functions locally """ layer_downloader = LayerDownloade...
[ "def", "local_lambda_runner", "(", "self", ")", ":", "layer_downloader", "=", "LayerDownloader", "(", "self", ".", "_layer_cache_basedir", ",", "self", ".", "get_cwd", "(", ")", ")", "image_builder", "=", "LambdaImage", "(", "layer_downloader", ",", "self", ".",...
Returns an instance of the runner capable of running Lambda functions locally :return samcli.commands.local.lib.local_lambda.LocalLambdaRunner: Runner configured to run Lambda functions locally
[ "Returns", "an", "instance", "of", "the", "runner", "capable", "of", "running", "Lambda", "functions", "locally" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/cli_common/invoke_context.py#L183-L201
29,917
awslabs/aws-sam-cli
samcli/commands/local/cli_common/invoke_context.py
InvokeContext.stdout
def stdout(self): """ Returns stream writer for stdout to output Lambda function logs to Returns ------- samcli.lib.utils.stream_writer.StreamWriter Stream writer for stdout """ stream = self._log_file_handle if self._log_file_handle else osutils.stdo...
python
def stdout(self): """ Returns stream writer for stdout to output Lambda function logs to Returns ------- samcli.lib.utils.stream_writer.StreamWriter Stream writer for stdout """ stream = self._log_file_handle if self._log_file_handle else osutils.stdo...
[ "def", "stdout", "(", "self", ")", ":", "stream", "=", "self", ".", "_log_file_handle", "if", "self", ".", "_log_file_handle", "else", "osutils", ".", "stdout", "(", ")", "return", "StreamWriter", "(", "stream", ",", "self", ".", "_is_debugging", ")" ]
Returns stream writer for stdout to output Lambda function logs to Returns ------- samcli.lib.utils.stream_writer.StreamWriter Stream writer for stdout
[ "Returns", "stream", "writer", "for", "stdout", "to", "output", "Lambda", "function", "logs", "to" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/cli_common/invoke_context.py#L204-L214
29,918
awslabs/aws-sam-cli
samcli/commands/local/cli_common/invoke_context.py
InvokeContext.stderr
def stderr(self): """ Returns stream writer for stderr to output Lambda function errors to Returns ------- samcli.lib.utils.stream_writer.StreamWriter Stream writer for stderr """ stream = self._log_file_handle if self._log_file_handle else osutils.st...
python
def stderr(self): """ Returns stream writer for stderr to output Lambda function errors to Returns ------- samcli.lib.utils.stream_writer.StreamWriter Stream writer for stderr """ stream = self._log_file_handle if self._log_file_handle else osutils.st...
[ "def", "stderr", "(", "self", ")", ":", "stream", "=", "self", ".", "_log_file_handle", "if", "self", ".", "_log_file_handle", "else", "osutils", ".", "stderr", "(", ")", "return", "StreamWriter", "(", "stream", ",", "self", ".", "_is_debugging", ")" ]
Returns stream writer for stderr to output Lambda function errors to Returns ------- samcli.lib.utils.stream_writer.StreamWriter Stream writer for stderr
[ "Returns", "stream", "writer", "for", "stderr", "to", "output", "Lambda", "function", "errors", "to" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/cli_common/invoke_context.py#L217-L227
29,919
awslabs/aws-sam-cli
samcli/commands/local/cli_common/invoke_context.py
InvokeContext.get_cwd
def get_cwd(self): """ Get the working directory. This is usually relative to the directory that contains the template. If a Docker volume location is specified, it takes preference All Lambda function code paths are resolved relative to this working directory :return string: W...
python
def get_cwd(self): """ Get the working directory. This is usually relative to the directory that contains the template. If a Docker volume location is specified, it takes preference All Lambda function code paths are resolved relative to this working directory :return string: W...
[ "def", "get_cwd", "(", "self", ")", ":", "cwd", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "self", ".", "_template_file", ")", ")", "if", "self", ".", "_docker_volume_basedir", ":", "cwd", "=", "self", ".", ...
Get the working directory. This is usually relative to the directory that contains the template. If a Docker volume location is specified, it takes preference All Lambda function code paths are resolved relative to this working directory :return string: Working directory
[ "Get", "the", "working", "directory", ".", "This", "is", "usually", "relative", "to", "the", "directory", "that", "contains", "the", "template", ".", "If", "a", "Docker", "volume", "location", "is", "specified", "it", "takes", "preference" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/cli_common/invoke_context.py#L238-L252
29,920
awslabs/aws-sam-cli
samcli/commands/local/cli_common/invoke_context.py
InvokeContext._get_env_vars_value
def _get_env_vars_value(filename): """ If the user provided a file containing values of environment variables, this method will read the file and return its value :param string filename: Path to file containing environment variable values :return dict: Value of environment varia...
python
def _get_env_vars_value(filename): """ If the user provided a file containing values of environment variables, this method will read the file and return its value :param string filename: Path to file containing environment variable values :return dict: Value of environment varia...
[ "def", "_get_env_vars_value", "(", "filename", ")", ":", "if", "not", "filename", ":", "return", "None", "# Try to read the file and parse it as JSON", "try", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "fp", ":", "return", "json", ".", "load"...
If the user provided a file containing values of environment variables, this method will read the file and return its value :param string filename: Path to file containing environment variable values :return dict: Value of environment variables, if provided. None otherwise :raises Invok...
[ "If", "the", "user", "provided", "a", "file", "containing", "values", "of", "environment", "variables", "this", "method", "will", "read", "the", "file", "and", "return", "its", "value" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/cli_common/invoke_context.py#L282-L303
29,921
awslabs/aws-sam-cli
samcli/commands/local/cli_common/invoke_context.py
InvokeContext._get_debug_context
def _get_debug_context(debug_port, debug_args, debugger_path): """ Creates a DebugContext if the InvokeContext is in a debugging mode Parameters ---------- debug_port int Port to bind the debugger to debug_args str Additional arguments passed to ...
python
def _get_debug_context(debug_port, debug_args, debugger_path): """ Creates a DebugContext if the InvokeContext is in a debugging mode Parameters ---------- debug_port int Port to bind the debugger to debug_args str Additional arguments passed to ...
[ "def", "_get_debug_context", "(", "debug_port", ",", "debug_args", ",", "debugger_path", ")", ":", "if", "debug_port", "and", "debugger_path", ":", "try", ":", "debugger", "=", "Path", "(", "debugger_path", ")", ".", "resolve", "(", "strict", "=", "True", ")...
Creates a DebugContext if the InvokeContext is in a debugging mode Parameters ---------- debug_port int Port to bind the debugger to debug_args str Additional arguments passed to the debugger debugger_path str Path to the directory of the deb...
[ "Creates", "a", "DebugContext", "if", "the", "InvokeContext", "is", "in", "a", "debugging", "mode" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/cli_common/invoke_context.py#L319-L356
29,922
awslabs/aws-sam-cli
samcli/local/docker/attach_api.py
_read_payload
def _read_payload(socket, payload_size): """ From the given socket, reads and yields payload of the given size. With sockets, we don't receive all data at once. Therefore this method will yield each time we read some data from the socket until the payload_size has reached or socket has no more data. ...
python
def _read_payload(socket, payload_size): """ From the given socket, reads and yields payload of the given size. With sockets, we don't receive all data at once. Therefore this method will yield each time we read some data from the socket until the payload_size has reached or socket has no more data. ...
[ "def", "_read_payload", "(", "socket", ",", "payload_size", ")", ":", "remaining", "=", "payload_size", "while", "remaining", ">", "0", ":", "# Try and read as much as possible", "data", "=", "read", "(", "socket", ",", "remaining", ")", "if", "data", "is", "N...
From the given socket, reads and yields payload of the given size. With sockets, we don't receive all data at once. Therefore this method will yield each time we read some data from the socket until the payload_size has reached or socket has no more data. Parameters ---------- socket Socket...
[ "From", "the", "given", "socket", "reads", "and", "yields", "payload", "of", "the", "given", "size", ".", "With", "sockets", "we", "don", "t", "receive", "all", "data", "at", "once", ".", "Therefore", "this", "method", "will", "yield", "each", "time", "w...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/attach_api.py#L119-L155
29,923
awslabs/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
LambdaErrorResponses.resource_not_found
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...
python
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...
[ "def", "resource_not_found", "(", "function_name", ")", ":", "exception_tuple", "=", "LambdaErrorResponses", ".", "ResourceNotFoundException", "return", "BaseLocalService", ".", "service_response", "(", "LambdaErrorResponses", ".", "_construct_error_response_body", "(", "Lamb...
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
[ "Creates", "a", "Lambda", "Service", "ResourceNotFound", "Response" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/lambda_error_responses.py#L39-L62
29,924
awslabs/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
LambdaErrorResponses.invalid_request_content
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...
python
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...
[ "def", "invalid_request_content", "(", "message", ")", ":", "exception_tuple", "=", "LambdaErrorResponses", ".", "InvalidRequestContentException", "return", "BaseLocalService", ".", "service_response", "(", "LambdaErrorResponses", ".", "_construct_error_response_body", "(", "...
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
[ "Creates", "a", "Lambda", "Service", "InvalidRequestContent", "Response" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/lambda_error_responses.py#L65-L85
29,925
awslabs/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
LambdaErrorResponses.unsupported_media_type
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...
python
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...
[ "def", "unsupported_media_type", "(", "content_type", ")", ":", "exception_tuple", "=", "LambdaErrorResponses", ".", "UnsupportedMediaTypeException", "return", "BaseLocalService", ".", "service_response", "(", "LambdaErrorResponses", ".", "_construct_error_response_body", "(", ...
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
[ "Creates", "a", "Lambda", "Service", "UnsupportedMediaType", "Response" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/lambda_error_responses.py#L88-L109
29,926
awslabs/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
LambdaErrorResponses.generic_service_exception
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...
python
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...
[ "def", "generic_service_exception", "(", "*", "args", ")", ":", "exception_tuple", "=", "LambdaErrorResponses", ".", "ServiceException", "return", "BaseLocalService", ".", "service_response", "(", "LambdaErrorResponses", ".", "_construct_error_response_body", "(", "LambdaEr...
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
[ "Creates", "a", "Lambda", "Service", "Generic", "ServiceException", "Response" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/lambda_error_responses.py#L112-L132
29,927
awslabs/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
LambdaErrorResponses.generic_path_not_found
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...
python
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...
[ "def", "generic_path_not_found", "(", "*", "args", ")", ":", "exception_tuple", "=", "LambdaErrorResponses", ".", "PathNotFoundException", "return", "BaseLocalService", ".", "service_response", "(", "LambdaErrorResponses", ".", "_construct_error_response_body", "(", "Lambda...
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
[ "Creates", "a", "Lambda", "Service", "Generic", "PathNotFound", "Response" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/lambda_error_responses.py#L158-L179
29,928
awslabs/aws-sam-cli
samcli/local/lambda_service/lambda_error_responses.py
LambdaErrorResponses.generic_method_not_allowed
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...
python
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...
[ "def", "generic_method_not_allowed", "(", "*", "args", ")", ":", "exception_tuple", "=", "LambdaErrorResponses", ".", "MethodNotAllowedException", "return", "BaseLocalService", ".", "service_response", "(", "LambdaErrorResponses", ".", "_construct_error_response_body", "(", ...
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
[ "Creates", "a", "Lambda", "Service", "Generic", "MethodNotAllowed", "Response" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/lambda_error_responses.py#L182-L203
29,929
awslabs/aws-sam-cli
samcli/lib/utils/codeuri.py
resolve_code_path
def resolve_code_path(cwd, codeuri): """ Returns path to the function code resolved based on current working directory. Parameters ---------- cwd str Current working directory codeuri CodeURI of the function. This should contain the path to the function code Returns ---...
python
def resolve_code_path(cwd, codeuri): """ Returns path to the function code resolved based on current working directory. Parameters ---------- cwd str Current working directory codeuri CodeURI of the function. This should contain the path to the function code Returns ---...
[ "def", "resolve_code_path", "(", "cwd", ",", "codeuri", ")", ":", "LOG", ".", "debug", "(", "\"Resolving code path. Cwd=%s, CodeUri=%s\"", ",", "cwd", ",", "codeuri", ")", "# First, let us figure out the current working directory.", "# If current working directory is not provid...
Returns path to the function code resolved based on current working directory. Parameters ---------- cwd str Current working directory codeuri CodeURI of the function. This should contain the path to the function code Returns ------- str Absolute path to the functio...
[ "Returns", "path", "to", "the", "function", "code", "resolved", "based", "on", "current", "working", "directory", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/codeuri.py#L13-L46
29,930
awslabs/aws-sam-cli
samcli/local/apigw/path_converter.py
PathConverter.convert_path_to_flask
def convert_path_to_flask(path): """ Converts a Path from an Api Gateway defined path to one that is accepted by Flask Examples: '/id/{id}' => '/id/<id>' '/{proxy+}' => '/<path:proxy>' :param str path: Path to convert to Flask defined path :return str: Path rep...
python
def convert_path_to_flask(path): """ Converts a Path from an Api Gateway defined path to one that is accepted by Flask Examples: '/id/{id}' => '/id/<id>' '/{proxy+}' => '/<path:proxy>' :param str path: Path to convert to Flask defined path :return str: Path rep...
[ "def", "convert_path_to_flask", "(", "path", ")", ":", "proxy_sub_path", "=", "APIGW_TO_FLASK_REGEX", ".", "sub", "(", "FLASK_CAPTURE_ALL_PATH", ",", "path", ")", "# Replace the '{' and '}' with '<' and '>' respectively", "return", "proxy_sub_path", ".", "replace", "(", "...
Converts a Path from an Api Gateway defined path to one that is accepted by Flask Examples: '/id/{id}' => '/id/<id>' '/{proxy+}' => '/<path:proxy>' :param str path: Path to convert to Flask defined path :return str: Path representing a Flask path
[ "Converts", "a", "Path", "from", "an", "Api", "Gateway", "defined", "path", "to", "one", "that", "is", "accepted", "by", "Flask" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/path_converter.py#L37-L52
29,931
awslabs/aws-sam-cli
samcli/local/apigw/path_converter.py
PathConverter.convert_path_to_api_gateway
def convert_path_to_api_gateway(path): """ Converts a Path from a Flask defined path to one that is accepted by Api Gateway Examples: '/id/<id>' => '/id/{id}' '/<path:proxy>' => '/{proxy+}' :param str path: Path to convert to Api Gateway defined path :return st...
python
def convert_path_to_api_gateway(path): """ Converts a Path from a Flask defined path to one that is accepted by Api Gateway Examples: '/id/<id>' => '/id/{id}' '/<path:proxy>' => '/{proxy+}' :param str path: Path to convert to Api Gateway defined path :return st...
[ "def", "convert_path_to_api_gateway", "(", "path", ")", ":", "proxy_sub_path", "=", "FLASK_TO_APIGW_REGEX", ".", "sub", "(", "PROXY_PATH_PARAMS", ",", "path", ")", "# Replace the '<' and '>' with '{' and '}' respectively", "return", "proxy_sub_path", ".", "replace", "(", ...
Converts a Path from a Flask defined path to one that is accepted by Api Gateway Examples: '/id/<id>' => '/id/{id}' '/<path:proxy>' => '/{proxy+}' :param str path: Path to convert to Api Gateway defined path :return str: Path representing an Api Gateway path
[ "Converts", "a", "Path", "from", "a", "Flask", "defined", "path", "to", "one", "that", "is", "accepted", "by", "Api", "Gateway" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/path_converter.py#L55-L70
29,932
awslabs/aws-sam-cli
samcli/commands/local/lib/swagger/integration_uri.py
LambdaUri.get_function_name
def get_function_name(integration_uri): """ Gets the name of the function from the Integration URI ARN. This is a best effort service which returns None if function name could not be parsed. This can happen when the ARN is an intrinsic function which is too complex or the ARN is not a La...
python
def get_function_name(integration_uri): """ Gets the name of the function from the Integration URI ARN. This is a best effort service which returns None if function name could not be parsed. This can happen when the ARN is an intrinsic function which is too complex or the ARN is not a La...
[ "def", "get_function_name", "(", "integration_uri", ")", ":", "arn", "=", "LambdaUri", ".", "_get_function_arn", "(", "integration_uri", ")", "LOG", ".", "debug", "(", "\"Extracted Function ARN: %s\"", ",", "arn", ")", "return", "LambdaUri", ".", "_get_function_name...
Gets the name of the function from the Integration URI ARN. This is a best effort service which returns None if function name could not be parsed. This can happen when the ARN is an intrinsic function which is too complex or the ARN is not a Lambda integration. Parameters ---------- ...
[ "Gets", "the", "name", "of", "the", "function", "from", "the", "Integration", "URI", "ARN", ".", "This", "is", "a", "best", "effort", "service", "which", "returns", "None", "if", "function", "name", "could", "not", "be", "parsed", ".", "This", "can", "ha...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/swagger/integration_uri.py#L42-L64
29,933
awslabs/aws-sam-cli
samcli/commands/local/lib/swagger/integration_uri.py
LambdaUri._get_function_name_from_arn
def _get_function_name_from_arn(function_arn): """ Given the integration ARN, extract the Lambda function name from the ARN. If there are stage variables, or other unsupported formats, this function will return None. Parameters ---------- function_arn : basestring or Non...
python
def _get_function_name_from_arn(function_arn): """ Given the integration ARN, extract the Lambda function name from the ARN. If there are stage variables, or other unsupported formats, this function will return None. Parameters ---------- function_arn : basestring or Non...
[ "def", "_get_function_name_from_arn", "(", "function_arn", ")", ":", "if", "not", "function_arn", ":", "return", "None", "matches", "=", "re", ".", "match", "(", "LambdaUri", ".", "_REGEX_GET_FUNCTION_NAME", ",", "function_arn", ")", "if", "not", "matches", "or"...
Given the integration ARN, extract the Lambda function name from the ARN. If there are stage variables, or other unsupported formats, this function will return None. Parameters ---------- function_arn : basestring or None Function ARN from the swagger document Retur...
[ "Given", "the", "integration", "ARN", "extract", "the", "Lambda", "function", "name", "from", "the", "ARN", ".", "If", "there", "are", "stage", "variables", "or", "other", "unsupported", "formats", "this", "function", "will", "return", "None", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/swagger/integration_uri.py#L131-L170
29,934
awslabs/aws-sam-cli
samcli/commands/local/invoke/cli.py
_get_event
def _get_event(event_file_name): """ Read the event JSON data from the given file. If no file is provided, read the event from stdin. :param string event_file_name: Path to event file, or '-' for stdin :return string: Contents of the event file or stdin """ if event_file_name == STDIN_FILE_NAM...
python
def _get_event(event_file_name): """ Read the event JSON data from the given file. If no file is provided, read the event from stdin. :param string event_file_name: Path to event file, or '-' for stdin :return string: Contents of the event file or stdin """ if event_file_name == STDIN_FILE_NAM...
[ "def", "_get_event", "(", "event_file_name", ")", ":", "if", "event_file_name", "==", "STDIN_FILE_NAME", ":", "# If event is empty, listen to stdin for event data until EOF", "LOG", ".", "info", "(", "\"Reading invoke payload from stdin (you can also pass it from file with --event)\"...
Read the event JSON data from the given file. If no file is provided, read the event from stdin. :param string event_file_name: Path to event file, or '-' for stdin :return string: Contents of the event file or stdin
[ "Read", "the", "event", "JSON", "data", "from", "the", "given", "file", ".", "If", "no", "file", "is", "provided", "read", "the", "event", "from", "stdin", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/invoke/cli.py#L112-L127
29,935
awslabs/aws-sam-cli
samcli/lib/samlib/resource_metadata_normalizer.py
ResourceMetadataNormalizer.normalize
def normalize(template_dict): """ Normalize all Resources in the template with the Metadata Key on the resource. This method will mutate the template Parameters ---------- template_dict dict Dictionary representing the template """ resources...
python
def normalize(template_dict): """ Normalize all Resources in the template with the Metadata Key on the resource. This method will mutate the template Parameters ---------- template_dict dict Dictionary representing the template """ resources...
[ "def", "normalize", "(", "template_dict", ")", ":", "resources", "=", "template_dict", ".", "get", "(", "RESOURCES_KEY", ",", "{", "}", ")", "for", "logical_id", ",", "resource", "in", "resources", ".", "items", "(", ")", ":", "resource_metadata", "=", "re...
Normalize all Resources in the template with the Metadata Key on the resource. This method will mutate the template Parameters ---------- template_dict dict Dictionary representing the template
[ "Normalize", "all", "Resources", "in", "the", "template", "with", "the", "Metadata", "Key", "on", "the", "resource", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/samlib/resource_metadata_normalizer.py#L19-L38
29,936
awslabs/aws-sam-cli
samcli/lib/samlib/resource_metadata_normalizer.py
ResourceMetadataNormalizer._replace_property
def _replace_property(property_key, property_value, resource, logical_id): """ Replace a property with an asset on a given resource This method will mutate the template Parameters ---------- property str The property to replace on the resource proper...
python
def _replace_property(property_key, property_value, resource, logical_id): """ Replace a property with an asset on a given resource This method will mutate the template Parameters ---------- property str The property to replace on the resource proper...
[ "def", "_replace_property", "(", "property_key", ",", "property_value", ",", "resource", ",", "logical_id", ")", ":", "if", "property_key", "and", "property_value", ":", "resource", ".", "get", "(", "PROPERTIES_KEY", ",", "{", "}", ")", "[", "property_key", "]...
Replace a property with an asset on a given resource This method will mutate the template Parameters ---------- property str The property to replace on the resource property_value str The new value of the property resource dict Dictio...
[ "Replace", "a", "property", "with", "an", "asset", "on", "a", "given", "resource" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/samlib/resource_metadata_normalizer.py#L41-L63
29,937
awslabs/aws-sam-cli
samcli/cli/command.py
BaseCommand._set_commands
def _set_commands(package_names): """ Extract the command name from package name. Last part of the module path is the command ie. if path is foo.bar.baz, then "baz" is the command name. :param package_names: List of package names :return: Dictionary with command name as key and ...
python
def _set_commands(package_names): """ Extract the command name from package name. Last part of the module path is the command ie. if path is foo.bar.baz, then "baz" is the command name. :param package_names: List of package names :return: Dictionary with command name as key and ...
[ "def", "_set_commands", "(", "package_names", ")", ":", "commands", "=", "{", "}", "for", "pkg_name", "in", "package_names", ":", "cmd_name", "=", "pkg_name", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", "commands", "[", "cmd_name", "]", "=", "pk...
Extract the command name from package name. Last part of the module path is the command ie. if path is foo.bar.baz, then "baz" is the command name. :param package_names: List of package names :return: Dictionary with command name as key and the package name as value.
[ "Extract", "the", "command", "name", "from", "package", "name", ".", "Last", "part", "of", "the", "module", "path", "is", "the", "command", "ie", ".", "if", "path", "is", "foo", ".", "bar", ".", "baz", "then", "baz", "is", "the", "command", "name", "...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/cli/command.py#L62-L77
29,938
awslabs/aws-sam-cli
samcli/cli/command.py
BaseCommand.get_command
def get_command(self, ctx, cmd_name): """ Overrides method from ``click.MultiCommand`` that returns Click CLI object for given command name, if found. :param ctx: Click context :param cmd_name: Top-level command name :return: Click object representing the command """ ...
python
def get_command(self, ctx, cmd_name): """ Overrides method from ``click.MultiCommand`` that returns Click CLI object for given command name, if found. :param ctx: Click context :param cmd_name: Top-level command name :return: Click object representing the command """ ...
[ "def", "get_command", "(", "self", ",", "ctx", ",", "cmd_name", ")", ":", "if", "cmd_name", "not", "in", "self", ".", "_commands", ":", "logger", ".", "error", "(", "\"Command %s not available\"", ",", "cmd_name", ")", "return", "pkg_name", "=", "self", "....
Overrides method from ``click.MultiCommand`` that returns Click CLI object for given command name, if found. :param ctx: Click context :param cmd_name: Top-level command name :return: Click object representing the command
[ "Overrides", "method", "from", "click", ".", "MultiCommand", "that", "returns", "Click", "CLI", "object", "for", "given", "command", "name", "if", "found", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/cli/command.py#L88-L112
29,939
awslabs/aws-sam-cli
samcli/lib/utils/stream_writer.py
StreamWriter.write
def write(self, output): """ Writes specified text to the underlying stream Parameters ---------- output bytes-like object Bytes to write """ self._stream.write(output) if self._auto_flush: self._stream.flush()
python
def write(self, output): """ Writes specified text to the underlying stream Parameters ---------- output bytes-like object Bytes to write """ self._stream.write(output) if self._auto_flush: self._stream.flush()
[ "def", "write", "(", "self", ",", "output", ")", ":", "self", ".", "_stream", ".", "write", "(", "output", ")", "if", "self", ".", "_auto_flush", ":", "self", ".", "_stream", ".", "flush", "(", ")" ]
Writes specified text to the underlying stream Parameters ---------- output bytes-like object Bytes to write
[ "Writes", "specified", "text", "to", "the", "underlying", "stream" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/stream_writer.py#L22-L34
29,940
awslabs/aws-sam-cli
samcli/lib/build/workflow_config.py
get_workflow_config
def get_workflow_config(runtime, code_dir, project_dir): """ Get a workflow config that corresponds to the runtime provided. This method examines contents of the project and code directories to determine the most appropriate workflow for the given runtime. Currently the decision is based on the presence...
python
def get_workflow_config(runtime, code_dir, project_dir): """ Get a workflow config that corresponds to the runtime provided. This method examines contents of the project and code directories to determine the most appropriate workflow for the given runtime. Currently the decision is based on the presence...
[ "def", "get_workflow_config", "(", "runtime", ",", "code_dir", ",", "project_dir", ")", ":", "selectors_by_runtime", "=", "{", "\"python2.7\"", ":", "BasicWorkflowSelector", "(", "PYTHON_PIP_CONFIG", ")", ",", "\"python3.6\"", ":", "BasicWorkflowSelector", "(", "PYTHO...
Get a workflow config that corresponds to the runtime provided. This method examines contents of the project and code directories to determine the most appropriate workflow for the given runtime. Currently the decision is based on the presence of a supported manifest file. For runtimes that have more than one w...
[ "Get", "a", "workflow", "config", "that", "corresponds", "to", "the", "runtime", "provided", ".", "This", "method", "examines", "contents", "of", "the", "project", "and", "code", "directories", "to", "determine", "the", "most", "appropriate", "workflow", "for", ...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/build/workflow_config.py#L70-L125
29,941
awslabs/aws-sam-cli
samcli/lib/build/workflow_config.py
supports_build_in_container
def supports_build_in_container(config): """ Given a workflow config, this method provides a boolean on whether the workflow can run within a container or not. Parameters ---------- config namedtuple(Capability) Config specifying the particular build workflow Returns ------- tu...
python
def supports_build_in_container(config): """ Given a workflow config, this method provides a boolean on whether the workflow can run within a container or not. Parameters ---------- config namedtuple(Capability) Config specifying the particular build workflow Returns ------- tu...
[ "def", "supports_build_in_container", "(", "config", ")", ":", "def", "_key", "(", "c", ")", ":", "return", "str", "(", "c", ".", "language", ")", "+", "str", "(", "c", ".", "dependency_manager", ")", "+", "str", "(", "c", ".", "application_framework", ...
Given a workflow config, this method provides a boolean on whether the workflow can run within a container or not. Parameters ---------- config namedtuple(Capability) Config specifying the particular build workflow Returns ------- tuple(bool, str) True, if this workflow can be ...
[ "Given", "a", "workflow", "config", "this", "method", "provides", "a", "boolean", "on", "whether", "the", "workflow", "can", "run", "within", "a", "container", "or", "not", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/build/workflow_config.py#L128-L161
29,942
awslabs/aws-sam-cli
samcli/lib/build/workflow_config.py
ManifestWorkflowSelector.get_config
def get_config(self, code_dir, project_dir): """ Finds a configuration by looking for a manifest in the given directories. Returns ------- samcli.lib.build.workflow_config.CONFIG A supported configuration if one is found Raises ------ ValueEr...
python
def get_config(self, code_dir, project_dir): """ Finds a configuration by looking for a manifest in the given directories. Returns ------- samcli.lib.build.workflow_config.CONFIG A supported configuration if one is found Raises ------ ValueEr...
[ "def", "get_config", "(", "self", ",", "code_dir", ",", "project_dir", ")", ":", "# Search for manifest first in code directory and then in the project directory.", "# Search order is important here because we want to prefer the manifest present within the code directory over", "# a manifest...
Finds a configuration by looking for a manifest in the given directories. Returns ------- samcli.lib.build.workflow_config.CONFIG A supported configuration if one is found Raises ------ ValueError If none of the supported manifests files are foun...
[ "Finds", "a", "configuration", "by", "looking", "for", "a", "manifest", "in", "the", "given", "directories", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/build/workflow_config.py#L188-L216
29,943
awslabs/aws-sam-cli
samcli/yamlhelper.py
intrinsics_multi_constructor
def intrinsics_multi_constructor(loader, tag_prefix, node): """ YAML constructor to parse CloudFormation intrinsics. This will return a dictionary with key being the instrinsic name """ # Get the actual tag name excluding the first exclamation tag = node.tag[1:] # Some intrinsic functions ...
python
def intrinsics_multi_constructor(loader, tag_prefix, node): """ YAML constructor to parse CloudFormation intrinsics. This will return a dictionary with key being the instrinsic name """ # Get the actual tag name excluding the first exclamation tag = node.tag[1:] # Some intrinsic functions ...
[ "def", "intrinsics_multi_constructor", "(", "loader", ",", "tag_prefix", ",", "node", ")", ":", "# Get the actual tag name excluding the first exclamation", "tag", "=", "node", ".", "tag", "[", "1", ":", "]", "# Some intrinsic functions doesn't support prefix \"Fn::\"", "pr...
YAML constructor to parse CloudFormation intrinsics. This will return a dictionary with key being the instrinsic name
[ "YAML", "constructor", "to", "parse", "CloudFormation", "intrinsics", ".", "This", "will", "return", "a", "dictionary", "with", "key", "being", "the", "instrinsic", "name" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/yamlhelper.py#L12-L46
29,944
awslabs/aws-sam-cli
samcli/yamlhelper.py
yaml_parse
def yaml_parse(yamlstr): """Parse a yaml string""" try: # PyYAML doesn't support json as well as it should, so if the input # is actually just json it is better to parse it with the standard # json parser. return json.loads(yamlstr) except ValueError: yaml.SafeLoader....
python
def yaml_parse(yamlstr): """Parse a yaml string""" try: # PyYAML doesn't support json as well as it should, so if the input # is actually just json it is better to parse it with the standard # json parser. return json.loads(yamlstr) except ValueError: yaml.SafeLoader....
[ "def", "yaml_parse", "(", "yamlstr", ")", ":", "try", ":", "# PyYAML doesn't support json as well as it should, so if the input", "# is actually just json it is better to parse it with the standard", "# json parser.", "return", "json", ".", "loads", "(", "yamlstr", ")", "except",...
Parse a yaml string
[ "Parse", "a", "yaml", "string" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/yamlhelper.py#L58-L67
29,945
awslabs/aws-sam-cli
samcli/commands/local/lib/generated_sample_events/events.py
Events.encode
def encode(self, tags, encoding, values_to_sub): """ reads the encoding type from the event-mapping.json and determines whether a value needs encoding Parameters ---------- tags: dict the values of a particular event that can be substituted within...
python
def encode(self, tags, encoding, values_to_sub): """ reads the encoding type from the event-mapping.json and determines whether a value needs encoding Parameters ---------- tags: dict the values of a particular event that can be substituted within...
[ "def", "encode", "(", "self", ",", "tags", ",", "encoding", ",", "values_to_sub", ")", ":", "for", "tag", "in", "tags", ":", "if", "tags", "[", "tag", "]", ".", "get", "(", "encoding", ")", "!=", "\"None\"", ":", "if", "tags", "[", "tag", "]", "....
reads the encoding type from the event-mapping.json and determines whether a value needs encoding Parameters ---------- tags: dict the values of a particular event that can be substituted within the event json encoding: string string that help...
[ "reads", "the", "encoding", "type", "from", "the", "event", "-", "mapping", ".", "json", "and", "determines", "whether", "a", "value", "needs", "encoding" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/generated_sample_events/events.py#L36-L62
29,946
awslabs/aws-sam-cli
samcli/commands/local/lib/generated_sample_events/events.py
Events.generate_event
def generate_event(self, service_name, event_type, values_to_sub): """ opens the event json, substitutes the values in, and returns the customized event json Parameters ---------- service_name: string name of the top level service (S3, apigateway, etc) ...
python
def generate_event(self, service_name, event_type, values_to_sub): """ opens the event json, substitutes the values in, and returns the customized event json Parameters ---------- service_name: string name of the top level service (S3, apigateway, etc) ...
[ "def", "generate_event", "(", "self", ",", "service_name", ",", "event_type", ",", "values_to_sub", ")", ":", "# set variables for easy calling", "tags", "=", "self", ".", "event_mapping", "[", "service_name", "]", "[", "event_type", "]", "[", "'tags'", "]", "va...
opens the event json, substitutes the values in, and returns the customized event json Parameters ---------- service_name: string name of the top level service (S3, apigateway, etc) event_type: string name of the event underneath the service value...
[ "opens", "the", "event", "json", "substitutes", "the", "values", "in", "and", "returns", "the", "customized", "event", "json" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/generated_sample_events/events.py#L94-L129
29,947
awslabs/aws-sam-cli
samcli/lib/utils/colors.py
Colored.underline
def underline(self, msg): """Underline the input""" return click.style(msg, underline=True) if self.colorize else msg
python
def underline(self, msg): """Underline the input""" return click.style(msg, underline=True) if self.colorize else msg
[ "def", "underline", "(", "self", ",", "msg", ")", ":", "return", "click", ".", "style", "(", "msg", ",", "underline", "=", "True", ")", "if", "self", ".", "colorize", "else", "msg" ]
Underline the input
[ "Underline", "the", "input" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/colors.py#L57-L59
29,948
awslabs/aws-sam-cli
samcli/lib/utils/colors.py
Colored._color
def _color(self, msg, color): """Internal helper method to add colors to input""" kwargs = {'fg': color} return click.style(msg, **kwargs) if self.colorize else msg
python
def _color(self, msg, color): """Internal helper method to add colors to input""" kwargs = {'fg': color} return click.style(msg, **kwargs) if self.colorize else msg
[ "def", "_color", "(", "self", ",", "msg", ",", "color", ")", ":", "kwargs", "=", "{", "'fg'", ":", "color", "}", "return", "click", ".", "style", "(", "msg", ",", "*", "*", "kwargs", ")", "if", "self", ".", "colorize", "else", "msg" ]
Internal helper method to add colors to input
[ "Internal", "helper", "method", "to", "add", "colors", "to", "input" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/colors.py#L61-L64
29,949
awslabs/aws-sam-cli
samcli/commands/local/lib/provider.py
LayerVersion._compute_layer_version
def _compute_layer_version(is_defined_within_template, arn): """ Parses out the Layer version from the arn Parameters ---------- is_defined_within_template bool True if the resource is a Ref to a resource otherwise False arn str ARN of the Resourc...
python
def _compute_layer_version(is_defined_within_template, arn): """ Parses out the Layer version from the arn Parameters ---------- is_defined_within_template bool True if the resource is a Ref to a resource otherwise False arn str ARN of the Resourc...
[ "def", "_compute_layer_version", "(", "is_defined_within_template", ",", "arn", ")", ":", "if", "is_defined_within_template", ":", "return", "None", "try", ":", "_", ",", "layer_version", "=", "arn", ".", "rsplit", "(", "':'", ",", "1", ")", "layer_version", "...
Parses out the Layer version from the arn Parameters ---------- is_defined_within_template bool True if the resource is a Ref to a resource otherwise False arn str ARN of the Resource Returns ------- int The Version of the Lay...
[ "Parses", "out", "the", "Layer", "version", "from", "the", "arn" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/provider.py#L72-L99
29,950
awslabs/aws-sam-cli
samcli/commands/local/lib/provider.py
LayerVersion._compute_layer_name
def _compute_layer_name(is_defined_within_template, arn): """ Computes a unique name based on the LayerVersion Arn Format: <Name of the LayerVersion>-<Version of the LayerVersion>-<sha256 of the arn> Parameters ---------- is_defined_within_template bool ...
python
def _compute_layer_name(is_defined_within_template, arn): """ Computes a unique name based on the LayerVersion Arn Format: <Name of the LayerVersion>-<Version of the LayerVersion>-<sha256 of the arn> Parameters ---------- is_defined_within_template bool ...
[ "def", "_compute_layer_name", "(", "is_defined_within_template", ",", "arn", ")", ":", "# If the Layer is defined in the template, the arn will represent the LogicalId of the LayerVersion Resource,", "# which does not require creating a name based on the arn.", "if", "is_defined_within_templat...
Computes a unique name based on the LayerVersion Arn Format: <Name of the LayerVersion>-<Version of the LayerVersion>-<sha256 of the arn> Parameters ---------- is_defined_within_template bool True if the resource is a Ref to a resource otherwise False arn st...
[ "Computes", "a", "unique", "name", "based", "on", "the", "LayerVersion", "Arn" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/provider.py#L102-L134
29,951
awslabs/aws-sam-cli
samcli/lib/utils/osutils.py
mkdir_temp
def mkdir_temp(mode=0o755): """ Context manager that makes a temporary directory and yields it name. Directory is deleted after the context exits Parameters ---------- mode : octal Permissions to apply to the directory. Defaults to '755' because don't want directories world writable ...
python
def mkdir_temp(mode=0o755): """ Context manager that makes a temporary directory and yields it name. Directory is deleted after the context exits Parameters ---------- mode : octal Permissions to apply to the directory. Defaults to '755' because don't want directories world writable ...
[ "def", "mkdir_temp", "(", "mode", "=", "0o755", ")", ":", "temp_dir", "=", "None", "try", ":", "temp_dir", "=", "tempfile", ".", "mkdtemp", "(", ")", "os", ".", "chmod", "(", "temp_dir", ",", "mode", ")", "yield", "temp_dir", "finally", ":", "if", "t...
Context manager that makes a temporary directory and yields it name. Directory is deleted after the context exits Parameters ---------- mode : octal Permissions to apply to the directory. Defaults to '755' because don't want directories world writable Returns ------- str Pa...
[ "Context", "manager", "that", "makes", "a", "temporary", "directory", "and", "yields", "it", "name", ".", "Directory", "is", "deleted", "after", "the", "context", "exits" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/utils/osutils.py#L14-L40
29,952
awslabs/aws-sam-cli
samcli/local/layers/layer_downloader.py
LayerDownloader.download_all
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 ...
python
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 ...
[ "def", "download_all", "(", "self", ",", "layers", ",", "force", "=", "False", ")", ":", "layer_dirs", "=", "[", "]", "for", "layer", "in", "layers", ":", "layer_dirs", ".", "append", "(", "self", ".", "download", "(", "layer", ",", "force", ")", ")"...
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 Return...
[ "Download", "a", "list", "of", "layers", "to", "the", "cache" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/layers/layer_downloader.py#L54-L74
29,953
awslabs/aws-sam-cli
samcli/local/layers/layer_downloader.py
LayerDownloader.download
def download(self, layer, force=False): """ 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 i...
python
def download(self, layer, force=False): """ 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 i...
[ "def", "download", "(", "self", ",", "layer", ",", "force", "=", "False", ")", ":", "if", "layer", ".", "is_defined_within_template", ":", "LOG", ".", "info", "(", "\"%s is a local Layer in the template\"", ",", "layer", ".", "name", ")", "layer", ".", "code...
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", "a", "given", "layer", "to", "the", "local", "cache", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/layers/layer_downloader.py#L76-L113
29,954
awslabs/aws-sam-cli
samcli/local/layers/layer_downloader.py
LayerDownloader._fetch_layer_uri
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...
python
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...
[ "def", "_fetch_layer_uri", "(", "self", ",", "layer", ")", ":", "try", ":", "layer_version_response", "=", "self", ".", "lambda_client", ".", "get_layer_version", "(", "LayerName", "=", "layer", ".", "layer_arn", ",", "VersionNumber", "=", "layer", ".", "versi...
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", "the", "Layer", "Uri", "based", "on", "the", "LayerVersion", "Arn" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/layers/layer_downloader.py#L115-L154
29,955
awslabs/aws-sam-cli
samcli/local/layers/layer_downloader.py
LayerDownloader._create_cache
def _create_cache(layer_cache): """ Create the Cache directory if it does not exist. Parameters ---------- layer_cache Directory to where the layers should be cached Returns ------- None """ Path(layer_cache).mkdir(mode=0o700...
python
def _create_cache(layer_cache): """ Create the Cache directory if it does not exist. Parameters ---------- layer_cache Directory to where the layers should be cached Returns ------- None """ Path(layer_cache).mkdir(mode=0o700...
[ "def", "_create_cache", "(", "layer_cache", ")", ":", "Path", "(", "layer_cache", ")", ".", "mkdir", "(", "mode", "=", "0o700", ",", "parents", "=", "True", ",", "exist_ok", "=", "True", ")" ]
Create the Cache directory if it does not exist. Parameters ---------- layer_cache Directory to where the layers should be cached Returns ------- None
[ "Create", "the", "Cache", "directory", "if", "it", "does", "not", "exist", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/layers/layer_downloader.py#L174-L188
29,956
awslabs/aws-sam-cli
samcli/commands/validate/lib/sam_template_validator.py
SamTemplateValidator.is_valid
def is_valid(self): """ Runs the SAM Translator to determine if the template provided is valid. This is similar to running a ChangeSet in CloudFormation for a SAM Template Raises ------- InvalidSamDocumentException If the template is not valid, an InvalidSam...
python
def is_valid(self): """ Runs the SAM Translator to determine if the template provided is valid. This is similar to running a ChangeSet in CloudFormation for a SAM Template Raises ------- InvalidSamDocumentException If the template is not valid, an InvalidSam...
[ "def", "is_valid", "(", "self", ")", ":", "managed_policy_map", "=", "self", ".", "managed_policy_loader", ".", "load", "(", ")", "sam_translator", "=", "Translator", "(", "managed_policy_map", "=", "managed_policy_map", ",", "sam_parser", "=", "self", ".", "sam...
Runs the SAM Translator to determine if the template provided is valid. This is similar to running a ChangeSet in CloudFormation for a SAM Template Raises ------- InvalidSamDocumentException If the template is not valid, an InvalidSamDocumentException is raised
[ "Runs", "the", "SAM", "Translator", "to", "determine", "if", "the", "template", "provided", "is", "valid", ".", "This", "is", "similar", "to", "running", "a", "ChangeSet", "in", "CloudFormation", "for", "a", "SAM", "Template" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/validate/lib/sam_template_validator.py#L44-L68
29,957
awslabs/aws-sam-cli
samcli/commands/validate/lib/sam_template_validator.py
SamTemplateValidator._update_to_s3_uri
def _update_to_s3_uri(property_key, resource_property_dict, s3_uri_value="s3://bucket/value"): """ Updates the 'property_key' in the 'resource_property_dict' to the value of 's3_uri_value' Note: The function will mutate the resource_property_dict that is pass in Parameters ----...
python
def _update_to_s3_uri(property_key, resource_property_dict, s3_uri_value="s3://bucket/value"): """ Updates the 'property_key' in the 'resource_property_dict' to the value of 's3_uri_value' Note: The function will mutate the resource_property_dict that is pass in Parameters ----...
[ "def", "_update_to_s3_uri", "(", "property_key", ",", "resource_property_dict", ",", "s3_uri_value", "=", "\"s3://bucket/value\"", ")", ":", "uri_property", "=", "resource_property_dict", ".", "get", "(", "property_key", ",", "\".\"", ")", "# ignore if dict or already an ...
Updates the 'property_key' in the 'resource_property_dict' to the value of 's3_uri_value' Note: The function will mutate the resource_property_dict that is pass in Parameters ---------- property_key str, required Key in the resource_property_dict resource_property_d...
[ "Updates", "the", "property_key", "in", "the", "resource_property_dict", "to", "the", "value", "of", "s3_uri_value" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/validate/lib/sam_template_validator.py#L115-L136
29,958
awslabs/aws-sam-cli
samcli/commands/logs/logs_context.py
LogsCommandContext.formatter
def formatter(self): """ Creates and returns a Formatter capable of nicely formatting Lambda function logs Returns ------- LogsFormatter """ formatter_chain = [ LambdaLogMsgFormatters.colorize_errors, # Format JSON "before" highlighting t...
python
def formatter(self): """ Creates and returns a Formatter capable of nicely formatting Lambda function logs Returns ------- LogsFormatter """ formatter_chain = [ LambdaLogMsgFormatters.colorize_errors, # Format JSON "before" highlighting t...
[ "def", "formatter", "(", "self", ")", ":", "formatter_chain", "=", "[", "LambdaLogMsgFormatters", ".", "colorize_errors", ",", "# Format JSON \"before\" highlighting the keywords. Otherwise, JSON will be invalid from all the", "# ANSI color codes and fail to pretty print", "JSONMsgForm...
Creates and returns a Formatter capable of nicely formatting Lambda function logs Returns ------- LogsFormatter
[ "Creates", "and", "returns", "a", "Formatter", "capable", "of", "nicely", "formatting", "Lambda", "function", "logs" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/logs/logs_context.py#L103-L121
29,959
awslabs/aws-sam-cli
samcli/commands/logs/logs_context.py
LogsCommandContext.log_group_name
def log_group_name(self): """ Name of the AWS CloudWatch Log Group that we will be querying. It generates the name based on the Lambda Function name and stack name provided. Returns ------- str Name of the CloudWatch Log Group """ function_id...
python
def log_group_name(self): """ Name of the AWS CloudWatch Log Group that we will be querying. It generates the name based on the Lambda Function name and stack name provided. Returns ------- str Name of the CloudWatch Log Group """ function_id...
[ "def", "log_group_name", "(", "self", ")", ":", "function_id", "=", "self", ".", "_function_name", "if", "self", ".", "_stack_name", ":", "function_id", "=", "self", ".", "_get_resource_id_from_stack", "(", "self", ".", "_cfn_client", ",", "self", ".", "_stack...
Name of the AWS CloudWatch Log Group that we will be querying. It generates the name based on the Lambda Function name and stack name provided. Returns ------- str Name of the CloudWatch Log Group
[ "Name", "of", "the", "AWS", "CloudWatch", "Log", "Group", "that", "we", "will", "be", "querying", ".", "It", "generates", "the", "name", "based", "on", "the", "Lambda", "Function", "name", "and", "stack", "name", "provided", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/logs/logs_context.py#L132-L149
29,960
awslabs/aws-sam-cli
samcli/commands/logs/logs_context.py
LogsCommandContext._parse_time
def _parse_time(time_str, property_name): """ Parse the time from the given string, convert to UTC, and return the datetime object Parameters ---------- time_str : str The time to parse property_name : str Name of the property where this time cam...
python
def _parse_time(time_str, property_name): """ Parse the time from the given string, convert to UTC, and return the datetime object Parameters ---------- time_str : str The time to parse property_name : str Name of the property where this time cam...
[ "def", "_parse_time", "(", "time_str", ",", "property_name", ")", ":", "if", "not", "time_str", ":", "return", "parsed", "=", "parse_date", "(", "time_str", ")", "if", "not", "parsed", ":", "raise", "UserException", "(", "\"Unable to parse the time provided by '{}...
Parse the time from the given string, convert to UTC, and return the datetime object Parameters ---------- time_str : str The time to parse property_name : str Name of the property where this time came from. Used in the exception raised if time is not parseable ...
[ "Parse", "the", "time", "from", "the", "given", "string", "convert", "to", "UTC", "and", "return", "the", "datetime", "object" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/logs/logs_context.py#L191-L220
29,961
awslabs/aws-sam-cli
samcli/commands/logs/logs_context.py
LogsCommandContext._get_resource_id_from_stack
def _get_resource_id_from_stack(cfn_client, stack_name, logical_id): """ Given the LogicalID of a resource, call AWS CloudFormation to get physical ID of the resource within the specified stack. Parameters ---------- cfn_client CloudFormation client provided ...
python
def _get_resource_id_from_stack(cfn_client, stack_name, logical_id): """ Given the LogicalID of a resource, call AWS CloudFormation to get physical ID of the resource within the specified stack. Parameters ---------- cfn_client CloudFormation client provided ...
[ "def", "_get_resource_id_from_stack", "(", "cfn_client", ",", "stack_name", ",", "logical_id", ")", ":", "LOG", ".", "debug", "(", "\"Getting resource's PhysicalId from AWS CloudFormation stack. StackName=%s, LogicalId=%s\"", ",", "stack_name", ",", "logical_id", ")", "try", ...
Given the LogicalID of a resource, call AWS CloudFormation to get physical ID of the resource within the specified stack. Parameters ---------- cfn_client CloudFormation client provided by AWS SDK stack_name : str Name of the stack to query logi...
[ "Given", "the", "LogicalID", "of", "a", "resource", "call", "AWS", "CloudFormation", "to", "get", "physical", "ID", "of", "the", "resource", "within", "the", "specified", "stack", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/logs/logs_context.py#L223-L264
29,962
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_base_provider.py
SamBaseProvider.get_template
def get_template(template_dict, parameter_overrides=None): """ Given a SAM template dictionary, return a cleaned copy of the template where SAM plugins have been run and parameter values have been substituted. Parameters ---------- template_dict : dict unproc...
python
def get_template(template_dict, parameter_overrides=None): """ Given a SAM template dictionary, return a cleaned copy of the template where SAM plugins have been run and parameter values have been substituted. Parameters ---------- template_dict : dict unproc...
[ "def", "get_template", "(", "template_dict", ",", "parameter_overrides", "=", "None", ")", ":", "template_dict", "=", "template_dict", "or", "{", "}", "if", "template_dict", ":", "template_dict", "=", "SamTranslatorWrapper", "(", "template_dict", ")", ".", "run_pl...
Given a SAM template dictionary, return a cleaned copy of the template where SAM plugins have been run and parameter values have been substituted. Parameters ---------- template_dict : dict unprocessed SAM template dictionary parameter_overrides: dict Op...
[ "Given", "a", "SAM", "template", "dictionary", "return", "a", "cleaned", "copy", "of", "the", "template", "where", "SAM", "plugins", "have", "been", "run", "and", "parameter", "values", "have", "been", "substituted", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_base_provider.py#L41-L66
29,963
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_base_provider.py
SamBaseProvider._resolve_parameters
def _resolve_parameters(template_dict, parameter_overrides): """ In the given template, apply parameter values to resolve intrinsic functions Parameters ---------- template_dict : dict SAM Template parameter_overrides : dict Values for template p...
python
def _resolve_parameters(template_dict, parameter_overrides): """ In the given template, apply parameter values to resolve intrinsic functions Parameters ---------- template_dict : dict SAM Template parameter_overrides : dict Values for template p...
[ "def", "_resolve_parameters", "(", "template_dict", ",", "parameter_overrides", ")", ":", "parameter_values", "=", "SamBaseProvider", ".", "_get_parameter_values", "(", "template_dict", ",", "parameter_overrides", ")", "supported_intrinsics", "=", "{", "action", ".", "i...
In the given template, apply parameter values to resolve intrinsic functions Parameters ---------- template_dict : dict SAM Template parameter_overrides : dict Values for template parameters provided by user Returns ------- dict ...
[ "In", "the", "given", "template", "apply", "parameter", "values", "to", "resolve", "intrinsic", "functions" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_base_provider.py#L69-L93
29,964
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_base_provider.py
SamBaseProvider._get_parameter_values
def _get_parameter_values(template_dict, parameter_overrides): """ Construct a final list of values for CloudFormation template parameters based on user-supplied values, default values provided in template, and sane defaults for pseudo-parameters. Parameters ---------- t...
python
def _get_parameter_values(template_dict, parameter_overrides): """ Construct a final list of values for CloudFormation template parameters based on user-supplied values, default values provided in template, and sane defaults for pseudo-parameters. Parameters ---------- t...
[ "def", "_get_parameter_values", "(", "template_dict", ",", "parameter_overrides", ")", ":", "default_values", "=", "SamBaseProvider", ".", "_get_default_parameter_values", "(", "template_dict", ")", "# NOTE: Ordering of following statements is important. It makes sure that any user-s...
Construct a final list of values for CloudFormation template parameters based on user-supplied values, default values provided in template, and sane defaults for pseudo-parameters. Parameters ---------- template_dict : dict SAM template dictionary parameter_override...
[ "Construct", "a", "final", "list", "of", "values", "for", "CloudFormation", "template", "parameters", "based", "on", "user", "-", "supplied", "values", "default", "values", "provided", "in", "template", "and", "sane", "defaults", "for", "pseudo", "-", "parameter...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_base_provider.py#L96-L124
29,965
awslabs/aws-sam-cli
samcli/local/docker/utils.py
to_posix_path
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 ------- ...
python
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 ------- ...
[ "def", "to_posix_path", "(", "code_path", ")", ":", "return", "re", ".", "sub", "(", "\"^([A-Za-z])+:\"", ",", "lambda", "match", ":", "posixpath", ".", "sep", "+", "match", ".", "group", "(", ")", ".", "replace", "(", "\":\"", ",", "\"\"", ")", ".", ...
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 absolute ...
[ "Change", "the", "code_path", "to", "be", "of", "unix", "-", "style", "if", "running", "on", "windows", "when", "supplied", "with", "an", "absolute", "windows", "path", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/utils.py#L14-L36
29,966
awslabs/aws-sam-cli
samcli/local/docker/lambda_container.py
LambdaContainer._get_entry_point
def _get_entry_point(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 entr...
python
def _get_entry_point(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 entr...
[ "def", "_get_entry_point", "(", "runtime", ",", "debug_options", "=", "None", ")", ":", "# pylint: disable=too-many-branches", "if", "not", "debug_options", ":", "return", "None", "if", "runtime", "not", "in", "LambdaContainer", ".", "_supported_runtimes", "(", ")",...
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 string runtim...
[ "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...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_container.py#L161-L305
29,967
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_api_provider.py
SamApiProvider._extract_apis
def _extract_apis(self, resources): """ Extract all Implicit Apis (Apis defined through Serverless Function with an Api Event :param dict resources: Dictionary of SAM/CloudFormation resources :return: List of nametuple Api """ # Some properties like BinaryMediaTypes, Co...
python
def _extract_apis(self, resources): """ Extract all Implicit Apis (Apis defined through Serverless Function with an Api Event :param dict resources: Dictionary of SAM/CloudFormation resources :return: List of nametuple Api """ # Some properties like BinaryMediaTypes, Co...
[ "def", "_extract_apis", "(", "self", ",", "resources", ")", ":", "# Some properties like BinaryMediaTypes, Cors are set once on the resource but need to be applied to each API.", "# For Implicit APIs, which are defined on the Function resource, these properties", "# are defined on a AWS::Serverl...
Extract all Implicit Apis (Apis defined through Serverless Function with an Api Event :param dict resources: Dictionary of SAM/CloudFormation resources :return: List of nametuple Api
[ "Extract", "all", "Implicit", "Apis", "(", "Apis", "defined", "through", "Serverless", "Function", "with", "an", "Api", "Event" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L76-L107
29,968
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_api_provider.py
SamApiProvider._merge_apis
def _merge_apis(collector): """ Quite often, an API is defined both in Implicit and Explicit API definitions. In such cases, Implicit API definition wins because that conveys clear intent that the API is backed by a function. This method will merge two such list of Apis with the right or...
python
def _merge_apis(collector): """ Quite often, an API is defined both in Implicit and Explicit API definitions. In such cases, Implicit API definition wins because that conveys clear intent that the API is backed by a function. This method will merge two such list of Apis with the right or...
[ "def", "_merge_apis", "(", "collector", ")", ":", "implicit_apis", "=", "[", "]", "explicit_apis", "=", "[", "]", "# Store implicit and explicit APIs separately in order to merge them later in the correct order", "# Implicit APIs are defined on a resource with logicalID ServerlessRestA...
Quite often, an API is defined both in Implicit and Explicit API definitions. In such cases, Implicit API definition wins because that conveys clear intent that the API is backed by a function. This method will merge two such list of Apis with the right order of precedence. If a Path+Method combination ...
[ "Quite", "often", "an", "API", "is", "defined", "both", "in", "Implicit", "and", "Explicit", "API", "definitions", ".", "In", "such", "cases", "Implicit", "API", "definition", "wins", "because", "that", "conveys", "clear", "intent", "that", "the", "API", "is...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L150-L198
29,969
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_api_provider.py
SamApiProvider._normalize_apis
def _normalize_apis(apis): """ Normalize the APIs to use standard method name Parameters ---------- apis : list of samcli.commands.local.lib.provider.Api List of APIs to replace normalize Returns ------- list of samcli.commands.local.lib.prov...
python
def _normalize_apis(apis): """ Normalize the APIs to use standard method name Parameters ---------- apis : list of samcli.commands.local.lib.provider.Api List of APIs to replace normalize Returns ------- list of samcli.commands.local.lib.prov...
[ "def", "_normalize_apis", "(", "apis", ")", ":", "result", "=", "list", "(", ")", "for", "api", "in", "apis", ":", "for", "normalized_method", "in", "SamApiProvider", ".", "_normalize_http_methods", "(", "api", ".", "method", ")", ":", "# _replace returns a co...
Normalize the APIs to use standard method name Parameters ---------- apis : list of samcli.commands.local.lib.provider.Api List of APIs to replace normalize Returns ------- list of samcli.commands.local.lib.provider.Api List of normalized APIs
[ "Normalize", "the", "APIs", "to", "use", "standard", "method", "name" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L201-L222
29,970
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_api_provider.py
SamApiProvider._extract_apis_from_function
def _extract_apis_from_function(logical_id, function_resource, collector): """ Fetches a list of APIs configured for this SAM Function resource. Parameters ---------- logical_id : str Logical ID of the resource function_resource : dict Contents o...
python
def _extract_apis_from_function(logical_id, function_resource, collector): """ Fetches a list of APIs configured for this SAM Function resource. Parameters ---------- logical_id : str Logical ID of the resource function_resource : dict Contents o...
[ "def", "_extract_apis_from_function", "(", "logical_id", ",", "function_resource", ",", "collector", ")", ":", "resource_properties", "=", "function_resource", ".", "get", "(", "\"Properties\"", ",", "{", "}", ")", "serverless_function_events", "=", "resource_properties...
Fetches a list of APIs configured for this SAM Function resource. Parameters ---------- logical_id : str Logical ID of the resource function_resource : dict Contents of the function resource including its properties collector : ApiCollector ...
[ "Fetches", "a", "list", "of", "APIs", "configured", "for", "this", "SAM", "Function", "resource", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L225-L243
29,971
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_api_provider.py
SamApiProvider._normalize_http_methods
def _normalize_http_methods(http_method): """ Normalizes Http Methods. Api Gateway allows a Http Methods of ANY. This is a special verb to denote all supported Http Methods on Api Gateway. :param str http_method: Http method :yield str: Either the input http_method or one of the...
python
def _normalize_http_methods(http_method): """ Normalizes Http Methods. Api Gateway allows a Http Methods of ANY. This is a special verb to denote all supported Http Methods on Api Gateway. :param str http_method: Http method :yield str: Either the input http_method or one of the...
[ "def", "_normalize_http_methods", "(", "http_method", ")", ":", "if", "http_method", ".", "upper", "(", ")", "==", "'ANY'", ":", "for", "method", "in", "SamApiProvider", ".", "_ANY_HTTP_METHODS", ":", "yield", "method", ".", "upper", "(", ")", "else", ":", ...
Normalizes Http Methods. Api Gateway allows a Http Methods of ANY. This is a special verb to denote all supported Http Methods on Api Gateway. :param str http_method: Http method :yield str: Either the input http_method or one of the _ANY_HTTP_METHODS (normalized Http Methods)
[ "Normalizes", "Http", "Methods", ".", "Api", "Gateway", "allows", "a", "Http", "Methods", "of", "ANY", ".", "This", "is", "a", "special", "verb", "to", "denote", "all", "supported", "Http", "Methods", "on", "Api", "Gateway", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L301-L314
29,972
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_api_provider.py
ApiCollector.add_apis
def add_apis(self, logical_id, apis): """ Stores the given APIs tagged under the given logicalId Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource apis : list of samcli.commands.local.lib.provider.Api List of A...
python
def add_apis(self, logical_id, apis): """ Stores the given APIs tagged under the given logicalId Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource apis : list of samcli.commands.local.lib.provider.Api List of A...
[ "def", "add_apis", "(", "self", ",", "logical_id", ",", "apis", ")", ":", "properties", "=", "self", ".", "_get_properties", "(", "logical_id", ")", "properties", ".", "apis", ".", "extend", "(", "apis", ")" ]
Stores the given APIs tagged under the given logicalId Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource apis : list of samcli.commands.local.lib.provider.Api List of APIs available in this resource
[ "Stores", "the", "given", "APIs", "tagged", "under", "the", "given", "logicalId" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L350-L363
29,973
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_api_provider.py
ApiCollector.add_binary_media_types
def add_binary_media_types(self, logical_id, binary_media_types): """ Stores the binary media type configuration for the API with given logical ID Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource binary_media_types : list...
python
def add_binary_media_types(self, logical_id, binary_media_types): """ Stores the binary media type configuration for the API with given logical ID Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource binary_media_types : list...
[ "def", "add_binary_media_types", "(", "self", ",", "logical_id", ",", "binary_media_types", ")", ":", "properties", "=", "self", ".", "_get_properties", "(", "logical_id", ")", "binary_media_types", "=", "binary_media_types", "or", "[", "]", "for", "value", "in", ...
Stores the binary media type configuration for the API with given logical ID Parameters ---------- logical_id : str LogicalId of the AWS::Serverless::Api resource binary_media_types : list of str List of binary media types supported by this resource
[ "Stores", "the", "binary", "media", "type", "configuration", "for", "the", "API", "with", "given", "logical", "ID" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L365-L388
29,974
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_api_provider.py
ApiCollector._get_apis_with_config
def _get_apis_with_config(self, logical_id): """ Returns the list of APIs in this resource along with other extra configuration such as binary media types, cors etc. Additional configuration is merged directly into the API data because these properties, although defined globally, actuall...
python
def _get_apis_with_config(self, logical_id): """ Returns the list of APIs in this resource along with other extra configuration such as binary media types, cors etc. Additional configuration is merged directly into the API data because these properties, although defined globally, actuall...
[ "def", "_get_apis_with_config", "(", "self", ",", "logical_id", ")", ":", "properties", "=", "self", ".", "_get_properties", "(", "logical_id", ")", "# These configs need to be applied to each API", "binary_media", "=", "sorted", "(", "list", "(", "properties", ".", ...
Returns the list of APIs in this resource along with other extra configuration such as binary media types, cors etc. Additional configuration is merged directly into the API data because these properties, although defined globally, actually apply to each API. Parameters ---------- ...
[ "Returns", "the", "list", "of", "APIs", "in", "this", "resource", "along", "with", "other", "extra", "configuration", "such", "as", "binary", "media", "types", "cors", "etc", ".", "Additional", "configuration", "is", "merged", "directly", "into", "the", "API",...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L390-L421
29,975
awslabs/aws-sam-cli
samcli/commands/local/lib/sam_api_provider.py
ApiCollector._get_properties
def _get_properties(self, logical_id): """ Returns the properties of resource with given logical ID. If a resource is not found, then it returns an empty data. Parameters ---------- logical_id : str Logical ID of the resource Returns ------- ...
python
def _get_properties(self, logical_id): """ Returns the properties of resource with given logical ID. If a resource is not found, then it returns an empty data. Parameters ---------- logical_id : str Logical ID of the resource Returns ------- ...
[ "def", "_get_properties", "(", "self", ",", "logical_id", ")", ":", "if", "logical_id", "not", "in", "self", ".", "by_resource", ":", "self", ".", "by_resource", "[", "logical_id", "]", "=", "self", ".", "Properties", "(", "apis", "=", "[", "]", ",", "...
Returns the properties of resource with given logical ID. If a resource is not found, then it returns an empty data. Parameters ---------- logical_id : str Logical ID of the resource Returns ------- samcli.commands.local.lib.sam_api_provider.ApiColle...
[ "Returns", "the", "properties", "of", "resource", "with", "given", "logical", "ID", ".", "If", "a", "resource", "is", "not", "found", "then", "it", "returns", "an", "empty", "data", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/sam_api_provider.py#L423-L445
29,976
awslabs/aws-sam-cli
samcli/local/lambdafn/runtime.py
_unzip_file
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...
python
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...
[ "def", "_unzip_file", "(", "filepath", ")", ":", "temp_dir", "=", "tempfile", ".", "mkdtemp", "(", ")", "if", "os", ".", "name", "==", "'posix'", ":", "os", ".", "chmod", "(", "temp_dir", ",", "0o755", ")", "LOG", ".", "info", "(", "\"Decompressing %s\...
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
[ "Helper", "method", "to", "unzip", "a", "file", "to", "a", "temporary", "directory" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/runtime.py#L184-L205
29,977
awslabs/aws-sam-cli
samcli/local/lambdafn/runtime.py
LambdaRuntime.invoke
def invoke(self, function_config, event, debug_context=None, stdout=None, stderr=None): """ Invoke the given Lambda function locally. ##### NOTE: THIS IS A LONG BLOCKING CALL ##### This method will block until ei...
python
def invoke(self, function_config, event, debug_context=None, stdout=None, stderr=None): """ Invoke the given Lambda function locally. ##### NOTE: THIS IS A LONG BLOCKING CALL ##### This method will block until ei...
[ "def", "invoke", "(", "self", ",", "function_config", ",", "event", ",", "debug_context", "=", "None", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ")", ":", "timer", "=", "None", "# Update with event input", "environ", "=", "function_config", "."...
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 are using...
[ "Invoke", "the", "given", "Lambda", "function", "locally", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/runtime.py#L42-L116
29,978
awslabs/aws-sam-cli
samcli/local/lambdafn/runtime.py
LambdaRuntime._configure_interrupt
def _configure_interrupt(self, function_name, 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 though, ...
python
def _configure_interrupt(self, function_name, 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 though, ...
[ "def", "_configure_interrupt", "(", "self", ",", "function_name", ",", "timeout", ",", "container", ",", "is_debugging", ")", ":", "def", "timer_handler", "(", ")", ":", "# NOTE: This handler runs in a separate thread. So don't try to mutate any non-thread-safe data structures"...
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 terminate the c...
[ "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", "timeo...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/runtime.py#L118-L149
29,979
awslabs/aws-sam-cli
samcli/local/lambdafn/runtime.py
LambdaRuntime._get_code_dir
def _get_code_dir(self, code_path): """ Method to get a path to a directory where the Lambda function 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 exis...
python
def _get_code_dir(self, code_path): """ Method to get a path to a directory where the Lambda function 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 exis...
[ "def", "_get_code_dir", "(", "self", ",", "code_path", ")", ":", "decompressed_dir", "=", "None", "try", ":", "if", "os", ".", "path", ".", "isfile", "(", "code_path", ")", "and", "code_path", ".", "endswith", "(", "self", ".", "SUPPORTED_ARCHIVE_EXTENSIONS"...
Method to get a path to a directory where the Lambda function 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 return ...
[ "Method", "to", "get", "a", "path", "to", "a", "directory", "where", "the", "Lambda", "function", "code", "is", "available", ".", "This", "directory", "will", "be", "mounted", "directly", "inside", "the", "Docker", "container", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/runtime.py#L152-L181
29,980
awslabs/aws-sam-cli
samcli/local/docker/lambda_image.py
LambdaImage.build
def build(self, runtime, layers): """ 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 layers list(samcli.commands.local.lib.provider.Layer) List o...
python
def build(self, runtime, layers): """ 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 layers list(samcli.commands.local.lib.provider.Layer) List o...
[ "def", "build", "(", "self", ",", "runtime", ",", "layers", ")", ":", "base_image", "=", "\"{}:{}\"", ".", "format", "(", "self", ".", "_DOCKER_LAMBDA_REPO_NAME", ",", "runtime", ")", "# Don't build the image if there are no layers.", "if", "not", "layers", ":", ...
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 layers list(samcli.commands.local.lib.provider.Layer) List of layers Returns ------- str ...
[ "Build", "the", "image", "if", "one", "is", "not", "already", "on", "the", "system", "that", "matches", "the", "runtime", "and", "layers" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_image.py#L73-L115
29,981
awslabs/aws-sam-cli
samcli/local/docker/lambda_image.py
LambdaImage._generate_docker_image_version
def _generate_docker_image_version(layers, runtime): """ 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 str Runtime of the image...
python
def _generate_docker_image_version(layers, runtime): """ 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 str Runtime of the image...
[ "def", "_generate_docker_image_version", "(", "layers", ",", "runtime", ")", ":", "# Docker has a concept of a TAG on an image. This is plus the REPOSITORY is a way to determine", "# a version of the image. We will produced a TAG for a combination of the runtime with the layers", "# specified in...
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 str Runtime of the image to create Returns ------- str Strin...
[ "Generate", "the", "Docker", "TAG", "that", "will", "be", "used", "to", "create", "the", "image" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_image.py#L118-L142
29,982
awslabs/aws-sam-cli
samcli/local/docker/lambda_image.py
LambdaImage._build_image
def _build_image(self, base_image, docker_tag, layers): """ Builds the image Parameters ---------- base_image str Base Image to use for the new image docker_tag Docker tag (REPOSITORY:TAG) to use when building the image layers list(samcli....
python
def _build_image(self, base_image, docker_tag, layers): """ Builds the image Parameters ---------- base_image str Base Image to use for the new image docker_tag Docker tag (REPOSITORY:TAG) to use when building the image layers list(samcli....
[ "def", "_build_image", "(", "self", ",", "base_image", ",", "docker_tag", ",", "layers", ")", ":", "dockerfile_content", "=", "self", ".", "_generate_dockerfile", "(", "base_image", ",", "layers", ")", "# Create dockerfile in the same directory of the layer cache", "doc...
Builds the image Parameters ---------- base_image str Base Image to use for the new image docker_tag Docker tag (REPOSITORY:TAG) to use when building the image layers list(samcli.commands.local.lib.provider.Layer) List of Layers to be use to m...
[ "Builds", "the", "image" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_image.py#L144-L192
29,983
awslabs/aws-sam-cli
samcli/local/docker/lambda_image.py
LambdaImage._generate_dockerfile
def _generate_dockerfile(base_image, layers): """ Generate the Dockerfile contents A generated Dockerfile will look like the following: ``` FROM lambci/lambda:python3.6 ADD --chown=sbx_user1051:495 layer1 /opt ADD --chown=sbx_user1051:495 layer2 /opt ```...
python
def _generate_dockerfile(base_image, layers): """ Generate the Dockerfile contents A generated Dockerfile will look like the following: ``` FROM lambci/lambda:python3.6 ADD --chown=sbx_user1051:495 layer1 /opt ADD --chown=sbx_user1051:495 layer2 /opt ```...
[ "def", "_generate_dockerfile", "(", "base_image", ",", "layers", ")", ":", "dockerfile_content", "=", "\"FROM {}\\n\"", ".", "format", "(", "base_image", ")", "for", "layer", "in", "layers", ":", "dockerfile_content", "=", "dockerfile_content", "+", "\"ADD --chown=s...
Generate the Dockerfile contents A generated Dockerfile will look like the following: ``` FROM lambci/lambda:python3.6 ADD --chown=sbx_user1051:495 layer1 /opt ADD --chown=sbx_user1051:495 layer2 /opt ``` Parameters ---------- base_image str ...
[ "Generate", "the", "Dockerfile", "contents" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/docker/lambda_image.py#L195-L225
29,984
awslabs/aws-sam-cli
samcli/commands/local/lib/local_api_service.py
LocalApiService.start
def start(self): """ Creates and starts the local API Gateway service. This method will block until the service is stopped manually using an interrupt. After the service is started, callers can make HTTP requests to the endpoint to invoke the Lambda function and receive a response. ...
python
def start(self): """ Creates and starts the local API Gateway service. This method will block until the service is stopped manually using an interrupt. After the service is started, callers can make HTTP requests to the endpoint to invoke the Lambda function and receive a response. ...
[ "def", "start", "(", "self", ")", ":", "routing_list", "=", "self", ".", "_make_routing_list", "(", "self", ".", "api_provider", ")", "if", "not", "routing_list", ":", "raise", "NoApisDefined", "(", "\"No APIs available in SAM template\"", ")", "static_dir_path", ...
Creates and starts the local API Gateway service. This method will block until the service is stopped manually using an interrupt. After the service is started, callers can make HTTP requests to the endpoint to invoke the Lambda function and receive a response. NOTE: This is a blocking call tha...
[ "Creates", "and", "starts", "the", "local", "API", "Gateway", "service", ".", "This", "method", "will", "block", "until", "the", "service", "is", "stopped", "manually", "using", "an", "interrupt", ".", "After", "the", "service", "is", "started", "callers", "...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_api_service.py#L47-L83
29,985
awslabs/aws-sam-cli
samcli/commands/local/lib/local_api_service.py
LocalApiService._make_routing_list
def _make_routing_list(api_provider): """ Returns a list of routes to configure the Local API Service based on the APIs configured in the template. Parameters ---------- api_provider : samcli.commands.local.lib.sam_api_provider.SamApiProvider Returns ------- ...
python
def _make_routing_list(api_provider): """ Returns a list of routes to configure the Local API Service based on the APIs configured in the template. Parameters ---------- api_provider : samcli.commands.local.lib.sam_api_provider.SamApiProvider Returns ------- ...
[ "def", "_make_routing_list", "(", "api_provider", ")", ":", "routes", "=", "[", "]", "for", "api", "in", "api_provider", ".", "get_all", "(", ")", ":", "route", "=", "Route", "(", "methods", "=", "[", "api", ".", "method", "]", ",", "function_name", "=...
Returns a list of routes to configure the Local API Service based on the APIs configured in the template. Parameters ---------- api_provider : samcli.commands.local.lib.sam_api_provider.SamApiProvider Returns ------- list(samcli.local.apigw.service.Route) Li...
[ "Returns", "a", "list", "of", "routes", "to", "configure", "the", "Local", "API", "Service", "based", "on", "the", "APIs", "configured", "in", "the", "template", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_api_service.py#L86-L106
29,986
awslabs/aws-sam-cli
samcli/commands/local/lib/local_api_service.py
LocalApiService._print_routes
def _print_routes(api_provider, host, port): """ Helper method to print the APIs that will be mounted. This method is purely for printing purposes. This method takes in a list of Route Configurations and prints out the Routes grouped by path. Grouping routes by Function Name + Path is th...
python
def _print_routes(api_provider, host, port): """ Helper method to print the APIs that will be mounted. This method is purely for printing purposes. This method takes in a list of Route Configurations and prints out the Routes grouped by path. Grouping routes by Function Name + Path is th...
[ "def", "_print_routes", "(", "api_provider", ",", "host", ",", "port", ")", ":", "grouped_api_configs", "=", "{", "}", "for", "api", "in", "api_provider", ".", "get_all", "(", ")", ":", "key", "=", "\"{}-{}\"", ".", "format", "(", "api", ".", "function_n...
Helper method to print the APIs that will be mounted. This method is purely for printing purposes. This method takes in a list of Route Configurations and prints out the Routes grouped by path. Grouping routes by Function Name + Path is the bulk of the logic. Example output: Mountin...
[ "Helper", "method", "to", "print", "the", "APIs", "that", "will", "be", "mounted", ".", "This", "method", "is", "purely", "for", "printing", "purposes", ".", "This", "method", "takes", "in", "a", "list", "of", "Route", "Configurations", "and", "prints", "o...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_api_service.py#L109-L151
29,987
awslabs/aws-sam-cli
samcli/commands/local/lib/local_api_service.py
LocalApiService._make_static_dir_path
def _make_static_dir_path(cwd, static_dir): """ This method returns the path to the directory where static files are to be served from. If static_dir is a relative path, then it is resolved to be relative to the current working directory. If no static directory is provided, or if the res...
python
def _make_static_dir_path(cwd, static_dir): """ This method returns the path to the directory where static files are to be served from. If static_dir is a relative path, then it is resolved to be relative to the current working directory. If no static directory is provided, or if the res...
[ "def", "_make_static_dir_path", "(", "cwd", ",", "static_dir", ")", ":", "if", "not", "static_dir", ":", "return", "None", "static_dir_path", "=", "os", ".", "path", ".", "join", "(", "cwd", ",", "static_dir", ")", "if", "os", ".", "path", ".", "exists",...
This method returns the path to the directory where static files are to be served from. If static_dir is a relative path, then it is resolved to be relative to the current working directory. If no static directory is provided, or if the resolved directory does not exist, this method will return None ...
[ "This", "method", "returns", "the", "path", "to", "the", "directory", "where", "static", "files", "are", "to", "be", "served", "from", ".", "If", "static_dir", "is", "a", "relative", "path", "then", "it", "is", "resolved", "to", "be", "relative", "to", "...
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_api_service.py#L154-L170
29,988
awslabs/aws-sam-cli
samcli/local/lambda_service/local_lambda_invoke_service.py
LocalLambdaInvokeService.validate_request
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' ...
python
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' ...
[ "def", "validate_request", "(", ")", ":", "flask_request", "=", "request", "request_data", "=", "flask_request", ".", "get_data", "(", ")", "if", "not", "request_data", ":", "request_data", "=", "b'{}'", "request_data", "=", "request_data", ".", "decode", "(", ...
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. 'X-Amz-I...
[ "Validates", "the", "incoming", "request" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/local_lambda_invoke_service.py#L57-L107
29,989
awslabs/aws-sam-cli
samcli/local/lambda_service/local_lambda_invoke_service.py
LocalLambdaInvokeService._invoke_request_handler
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...
python
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...
[ "def", "_invoke_request_handler", "(", "self", ",", "function_name", ")", ":", "flask_request", "=", "request", "request_data", "=", "flask_request", ".", "get_data", "(", ")", "if", "not", "request_data", ":", "request_data", "=", "b'{}'", "request_data", "=", ...
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 ------- A Flask ...
[ "Request", "Handler", "for", "the", "Local", "Lambda", "Invoke", "path", ".", "This", "method", "is", "responsible", "for", "understanding", "the", "incoming", "request", "and", "invoking", "the", "Local", "Lambda", "Function" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambda_service/local_lambda_invoke_service.py#L118-L162
29,990
awslabs/aws-sam-cli
samcli/local/lambdafn/zip.py
unzip
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 b...
python
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 b...
[ "def", "unzip", "(", "zip_file_path", ",", "output_dir", ",", "permission", "=", "None", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "zip_file_path", ",", "'r'", ")", "as", "zip_ref", ":", "# For each item in the zip file, extract the file and set permissions if...
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 : octal int Permission to set
[ "Unzip", "the", "given", "file", "into", "the", "given", "directory", "while", "preserving", "file", "permissions", "in", "the", "process", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/zip.py#L23-L51
29,991
awslabs/aws-sam-cli
samcli/local/lambdafn/zip.py
_set_permissions
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_...
python
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_...
[ "def", "_set_permissions", "(", "zip_file_info", ",", "extracted_path", ")", ":", "# Permission information is stored in first two bytes.", "permission", "=", "zip_file_info", ".", "external_attr", ">>", "16", "if", "not", "permission", ":", "# Zips created on certain Windows...
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
[ "Sets", "permissions", "on", "the", "extracted", "file", "by", "reading", "the", "external_attr", "property", "of", "given", "file", "info", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/zip.py#L70-L91
29,992
awslabs/aws-sam-cli
samcli/local/lambdafn/zip.py
unzip_from_uri
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...
python
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...
[ "def", "unzip_from_uri", "(", "uri", ",", "layer_zip_path", ",", "unzip_output_dir", ",", "progressbar_label", ")", ":", "try", ":", "get_request", "=", "requests", ".", "get", "(", "uri", ",", "stream", "=", "True", ",", "verify", "=", "os", ".", "environ...
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 Label to ...
[ "Download", "the", "LayerVersion", "Zip", "to", "the", "Layer", "Pkg", "Cache" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/lambdafn/zip.py#L94-L130
29,993
awslabs/aws-sam-cli
samcli/local/apigw/local_apigw_service.py
LocalApigwService._generate_route_keys
def _generate_route_keys(self, methods, path): """ Generates the key to the _dict_of_routes based on the list of methods and path supplied :param list(str) methods: List of HTTP Methods :param str path: Path off the base url :return: str of Path:Method """ ...
python
def _generate_route_keys(self, methods, path): """ Generates the key to the _dict_of_routes based on the list of methods and path supplied :param list(str) methods: List of HTTP Methods :param str path: Path off the base url :return: str of Path:Method """ ...
[ "def", "_generate_route_keys", "(", "self", ",", "methods", ",", "path", ")", ":", "for", "method", "in", "methods", ":", "yield", "self", ".", "_route_key", "(", "method", ",", "path", ")" ]
Generates the key to the _dict_of_routes based on the list of methods and path supplied :param list(str) methods: List of HTTP Methods :param str path: Path off the base url :return: str of Path:Method
[ "Generates", "the", "key", "to", "the", "_dict_of_routes", "based", "on", "the", "list", "of", "methods", "and", "path", "supplied" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L92-L102
29,994
awslabs/aws-sam-cli
samcli/local/apigw/local_apigw_service.py
LocalApigwService._parse_lambda_output
def _parse_lambda_output(lambda_output, binary_types, flask_request): """ Parses the output from the Lambda Container :param str lambda_output: Output from Lambda Invoke :return: Tuple(int, dict, str, bool) """ json_output = json.loads(lambda_output) if not isin...
python
def _parse_lambda_output(lambda_output, binary_types, flask_request): """ Parses the output from the Lambda Container :param str lambda_output: Output from Lambda Invoke :return: Tuple(int, dict, str, bool) """ json_output = json.loads(lambda_output) if not isin...
[ "def", "_parse_lambda_output", "(", "lambda_output", ",", "binary_types", ",", "flask_request", ")", ":", "json_output", "=", "json", ".", "loads", "(", "lambda_output", ")", "if", "not", "isinstance", "(", "json_output", ",", "dict", ")", ":", "raise", "TypeE...
Parses the output from the Lambda Container :param str lambda_output: Output from Lambda Invoke :return: Tuple(int, dict, str, bool)
[ "Parses", "the", "output", "from", "the", "Lambda", "Container" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L197-L231
29,995
awslabs/aws-sam-cli
samcli/local/apigw/local_apigw_service.py
LocalApigwService._should_base64_decode_body
def _should_base64_decode_body(binary_types, flask_request, lamba_response_headers, is_base_64_encoded): """ Whether or not the body should be decoded from Base64 to Binary Parameters ---------- binary_types list(basestring) Corresponds to self.binary_types (aka. wha...
python
def _should_base64_decode_body(binary_types, flask_request, lamba_response_headers, is_base_64_encoded): """ Whether or not the body should be decoded from Base64 to Binary Parameters ---------- binary_types list(basestring) Corresponds to self.binary_types (aka. wha...
[ "def", "_should_base64_decode_body", "(", "binary_types", ",", "flask_request", ",", "lamba_response_headers", ",", "is_base_64_encoded", ")", ":", "best_match_mimetype", "=", "flask_request", ".", "accept_mimetypes", ".", "best_match", "(", "[", "lamba_response_headers", ...
Whether or not the body should be decoded from Base64 to Binary Parameters ---------- binary_types list(basestring) Corresponds to self.binary_types (aka. what is parsed from SAM Template flask_request flask.request Flask request lamba_response_headers di...
[ "Whether", "or", "not", "the", "body", "should", "be", "decoded", "from", "Base64", "to", "Binary" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L234-L257
29,996
awslabs/aws-sam-cli
samcli/local/apigw/local_apigw_service.py
LocalApigwService._construct_event
def _construct_event(flask_request, port, binary_types): """ Helper method that constructs the Event to be passed to Lambda :param request flask_request: Flask Request :return: String representing the event """ identity = ContextIdentity(source_ip=flask_request.remote_a...
python
def _construct_event(flask_request, port, binary_types): """ Helper method that constructs the Event to be passed to Lambda :param request flask_request: Flask Request :return: String representing the event """ identity = ContextIdentity(source_ip=flask_request.remote_a...
[ "def", "_construct_event", "(", "flask_request", ",", "port", ",", "binary_types", ")", ":", "identity", "=", "ContextIdentity", "(", "source_ip", "=", "flask_request", ".", "remote_addr", ")", "endpoint", "=", "PathConverter", ".", "convert_path_to_api_gateway", "(...
Helper method that constructs the Event to be passed to Lambda :param request flask_request: Flask Request :return: String representing the event
[ "Helper", "method", "that", "constructs", "the", "Event", "to", "be", "passed", "to", "Lambda" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L260-L314
29,997
awslabs/aws-sam-cli
samcli/local/apigw/local_apigw_service.py
LocalApigwService._query_string_params
def _query_string_params(flask_request): """ Constructs an APIGW equivalent query string dictionary Parameters ---------- flask_request request Request from Flask Returns dict (str: str) ------- Empty dict if no query params where in the ...
python
def _query_string_params(flask_request): """ Constructs an APIGW equivalent query string dictionary Parameters ---------- flask_request request Request from Flask Returns dict (str: str) ------- Empty dict if no query params where in the ...
[ "def", "_query_string_params", "(", "flask_request", ")", ":", "query_string_dict", "=", "{", "}", "# Flask returns an ImmutableMultiDict so convert to a dictionary that becomes", "# a dict(str: list) then iterate over", "for", "query_string_key", ",", "query_string_list", "in", "f...
Constructs an APIGW equivalent query string dictionary Parameters ---------- flask_request request Request from Flask Returns dict (str: str) ------- Empty dict if no query params where in the request otherwise returns a dictionary of key to value
[ "Constructs", "an", "APIGW", "equivalent", "query", "string", "dictionary" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/local/apigw/local_apigw_service.py#L317-L345
29,998
awslabs/aws-sam-cli
samcli/commands/local/lib/local_lambda.py
LocalLambdaRunner.invoke
def invoke(self, function_name, event, stdout=None, stderr=None): """ Find the Lambda function with given name and invoke it. Pass the given event to the function and return response through the given streams. This function will block until either the function completes or times out. ...
python
def invoke(self, function_name, event, stdout=None, stderr=None): """ Find the Lambda function with given name and invoke it. Pass the given event to the function and return response through the given streams. This function will block until either the function completes or times out. ...
[ "def", "invoke", "(", "self", ",", "function_name", ",", "event", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ")", ":", "# Generate the correct configuration based on given inputs", "function", "=", "self", ".", "provider", ".", "get", "(", "function...
Find the Lambda function with given name and invoke it. Pass the given event to the function and return response through the given streams. This function will block until either the function completes or times out. Parameters ---------- function_name str Name of the...
[ "Find", "the", "Lambda", "function", "with", "given", "name", "and", "invoke", "it", ".", "Pass", "the", "given", "event", "to", "the", "function", "and", "return", "response", "through", "the", "given", "streams", "." ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_lambda.py#L49-L89
29,999
awslabs/aws-sam-cli
samcli/commands/local/lib/local_lambda.py
LocalLambdaRunner._get_invoke_config
def _get_invoke_config(self, function): """ Returns invoke configuration to pass to Lambda Runtime to invoke the given function :param samcli.commands.local.lib.provider.Function function: Lambda function to generate the configuration for :return samcli.local.lambdafn.config.FunctionCon...
python
def _get_invoke_config(self, function): """ Returns invoke configuration to pass to Lambda Runtime to invoke the given function :param samcli.commands.local.lib.provider.Function function: Lambda function to generate the configuration for :return samcli.local.lambdafn.config.FunctionCon...
[ "def", "_get_invoke_config", "(", "self", ",", "function", ")", ":", "env_vars", "=", "self", ".", "_make_env_vars", "(", "function", ")", "code_abs_path", "=", "resolve_code_path", "(", "self", ".", "cwd", ",", "function", ".", "codeuri", ")", "LOG", ".", ...
Returns invoke configuration to pass to Lambda Runtime to invoke the given function :param samcli.commands.local.lib.provider.Function function: Lambda function to generate the configuration for :return samcli.local.lambdafn.config.FunctionConfig: Function configuration to pass to Lambda runtime
[ "Returns", "invoke", "configuration", "to", "pass", "to", "Lambda", "Runtime", "to", "invoke", "the", "given", "function" ]
c05af5e7378c6f05f7d82ad3f0bca17204177db6
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/lib/local_lambda.py#L103-L131