partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | is_type | Returns a validator function that succeeds only for inputs of the provided valid_type.
:param type valid_type: the type that should be considered valid for the validator
:returns: a function which returns True its input is an instance of valid_type, and raises TypeError otherwise
:rtype: callable | samtranslator/model/types.py | def is_type(valid_type):
"""Returns a validator function that succeeds only for inputs of the provided valid_type.
:param type valid_type: the type that should be considered valid for the validator
:returns: a function which returns True its input is an instance of valid_type, and raises TypeError otherwis... | def is_type(valid_type):
"""Returns a validator function that succeeds only for inputs of the provided valid_type.
:param type valid_type: the type that should be considered valid for the validator
:returns: a function which returns True its input is an instance of valid_type, and raises TypeError otherwis... | [
"Returns",
"a",
"validator",
"function",
"that",
"succeeds",
"only",
"for",
"inputs",
"of",
"the",
"provided",
"valid_type",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/types.py#L15-L29 | [
"def",
"is_type",
"(",
"valid_type",
")",
":",
"def",
"validate",
"(",
"value",
",",
"should_raise",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"valid_type",
")",
":",
"if",
"should_raise",
":",
"raise",
"TypeError",
"(",
"\"Exp... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | list_of | Returns a validator function that succeeds only if the input is a list, and each item in the list passes as input
to the provided validator validate_item.
:param callable validate_item: the validator function for items in the list
:returns: a function which returns True its input is an list of valid items,... | samtranslator/model/types.py | def list_of(validate_item):
"""Returns a validator function that succeeds only if the input is a list, and each item in the list passes as input
to the provided validator validate_item.
:param callable validate_item: the validator function for items in the list
:returns: a function which returns True i... | def list_of(validate_item):
"""Returns a validator function that succeeds only if the input is a list, and each item in the list passes as input
to the provided validator validate_item.
:param callable validate_item: the validator function for items in the list
:returns: a function which returns True i... | [
"Returns",
"a",
"validator",
"function",
"that",
"succeeds",
"only",
"if",
"the",
"input",
"is",
"a",
"list",
"and",
"each",
"item",
"in",
"the",
"list",
"passes",
"as",
"input",
"to",
"the",
"provided",
"validator",
"validate_item",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/types.py#L32-L54 | [
"def",
"list_of",
"(",
"validate_item",
")",
":",
"def",
"validate",
"(",
"value",
",",
"should_raise",
"=",
"True",
")",
":",
"validate_type",
"=",
"is_type",
"(",
"list",
")",
"if",
"not",
"validate_type",
"(",
"value",
",",
"should_raise",
"=",
"should_... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | dict_of | Returns a validator function that succeeds only if the input is a dict, and each key and value in the dict passes
as input to the provided validators validate_key and validate_item, respectively.
:param callable validate_key: the validator function for keys in the dict
:param callable validate_item: the va... | samtranslator/model/types.py | def dict_of(validate_key, validate_item):
"""Returns a validator function that succeeds only if the input is a dict, and each key and value in the dict passes
as input to the provided validators validate_key and validate_item, respectively.
:param callable validate_key: the validator function for keys in t... | def dict_of(validate_key, validate_item):
"""Returns a validator function that succeeds only if the input is a dict, and each key and value in the dict passes
as input to the provided validators validate_key and validate_item, respectively.
:param callable validate_key: the validator function for keys in t... | [
"Returns",
"a",
"validator",
"function",
"that",
"succeeds",
"only",
"if",
"the",
"input",
"is",
"a",
"dict",
"and",
"each",
"key",
"and",
"value",
"in",
"the",
"dict",
"passes",
"as",
"input",
"to",
"the",
"provided",
"validators",
"validate_key",
"and",
... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/types.py#L57-L88 | [
"def",
"dict_of",
"(",
"validate_key",
",",
"validate_item",
")",
":",
"def",
"validate",
"(",
"value",
",",
"should_raise",
"=",
"True",
")",
":",
"validate_type",
"=",
"is_type",
"(",
"dict",
")",
"if",
"not",
"validate_type",
"(",
"value",
",",
"should_... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | one_of | Returns a validator function that succeeds only if the input passes at least one of the provided validators.
:param callable validators: the validator functions
:returns: a function which returns True its input passes at least one of the validators, and raises TypeError
otherwise
:rtype: call... | samtranslator/model/types.py | def one_of(*validators):
"""Returns a validator function that succeeds only if the input passes at least one of the provided validators.
:param callable validators: the validator functions
:returns: a function which returns True its input passes at least one of the validators, and raises TypeError
... | def one_of(*validators):
"""Returns a validator function that succeeds only if the input passes at least one of the provided validators.
:param callable validators: the validator functions
:returns: a function which returns True its input passes at least one of the validators, and raises TypeError
... | [
"Returns",
"a",
"validator",
"function",
"that",
"succeeds",
"only",
"if",
"the",
"input",
"passes",
"at",
"least",
"one",
"of",
"the",
"provided",
"validators",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/types.py#L91-L106 | [
"def",
"one_of",
"(",
"*",
"validators",
")",
":",
"def",
"validate",
"(",
"value",
",",
"should_raise",
"=",
"True",
")",
":",
"if",
"any",
"(",
"validate",
"(",
"value",
",",
"should_raise",
"=",
"False",
")",
"for",
"validate",
"in",
"validators",
"... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Template.to_statement | With the given values for each parameter, this method will return a policy statement that can be used
directly with IAM.
:param dict parameter_values: Dict containing values for each parameter defined in the template
:return dict: Dictionary containing policy statement
:raises InvalidPa... | samtranslator/policy_template_processor/template.py | def to_statement(self, parameter_values):
"""
With the given values for each parameter, this method will return a policy statement that can be used
directly with IAM.
:param dict parameter_values: Dict containing values for each parameter defined in the template
:return dict: Di... | def to_statement(self, parameter_values):
"""
With the given values for each parameter, this method will return a policy statement that can be used
directly with IAM.
:param dict parameter_values: Dict containing values for each parameter defined in the template
:return dict: Di... | [
"With",
"the",
"given",
"values",
"for",
"each",
"parameter",
"this",
"method",
"will",
"return",
"a",
"policy",
"statement",
"that",
"can",
"be",
"used",
"directly",
"with",
"IAM",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/policy_template_processor/template.py#L30-L62 | [
"def",
"to_statement",
"(",
"self",
",",
"parameter_values",
")",
":",
"missing",
"=",
"self",
".",
"missing_parameter_values",
"(",
"parameter_values",
")",
"if",
"len",
"(",
"missing",
")",
">",
"0",
":",
"# str() of elements of list to prevent any `u` prefix from b... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Template.missing_parameter_values | Checks if the given input contains values for all parameters used by this template
:param dict parameter_values: Dictionary of values for each parameter used in the template
:return list: List of names of parameters that are missing.
:raises InvalidParameterValues: When parameter values is not ... | samtranslator/policy_template_processor/template.py | def missing_parameter_values(self, parameter_values):
"""
Checks if the given input contains values for all parameters used by this template
:param dict parameter_values: Dictionary of values for each parameter used in the template
:return list: List of names of parameters that are miss... | def missing_parameter_values(self, parameter_values):
"""
Checks if the given input contains values for all parameters used by this template
:param dict parameter_values: Dictionary of values for each parameter used in the template
:return list: List of names of parameters that are miss... | [
"Checks",
"if",
"the",
"given",
"input",
"contains",
"values",
"for",
"all",
"parameters",
"used",
"by",
"this",
"template"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/policy_template_processor/template.py#L64-L76 | [
"def",
"missing_parameter_values",
"(",
"self",
",",
"parameter_values",
")",
":",
"if",
"not",
"self",
".",
"_is_valid_parameter_values",
"(",
"parameter_values",
")",
":",
"raise",
"InvalidParameterValues",
"(",
"\"Parameter values are required to process a policy template\... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Template.from_dict | Parses the input and returns an instance of this class.
:param string template_name: Name of the template
:param dict template_values_dict: Dictionary containing the value of the template. This dict must have passed
the JSON Schema validation.
:return Template: Instance of this clas... | samtranslator/policy_template_processor/template.py | def from_dict(template_name, template_values_dict):
"""
Parses the input and returns an instance of this class.
:param string template_name: Name of the template
:param dict template_values_dict: Dictionary containing the value of the template. This dict must have passed
the... | def from_dict(template_name, template_values_dict):
"""
Parses the input and returns an instance of this class.
:param string template_name: Name of the template
:param dict template_values_dict: Dictionary containing the value of the template. This dict must have passed
the... | [
"Parses",
"the",
"input",
"and",
"returns",
"an",
"instance",
"of",
"this",
"class",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/policy_template_processor/template.py#L102-L115 | [
"def",
"from_dict",
"(",
"template_name",
",",
"template_values_dict",
")",
":",
"parameters",
"=",
"template_values_dict",
".",
"get",
"(",
"\"Parameters\"",
",",
"{",
"}",
")",
"definition",
"=",
"template_values_dict",
".",
"get",
"(",
"\"Definition\"",
",",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SamPlugins.register | Register a plugin. New plugins are added to the end of the plugins list.
:param samtranslator.plugins.BasePlugin plugin: Instance/subclass of BasePlugin class that implements hooks
:raises ValueError: If plugin is not an instance of samtranslator.plugins.BasePlugin or if it is already
regis... | samtranslator/plugins/__init__.py | def register(self, plugin):
"""
Register a plugin. New plugins are added to the end of the plugins list.
:param samtranslator.plugins.BasePlugin plugin: Instance/subclass of BasePlugin class that implements hooks
:raises ValueError: If plugin is not an instance of samtranslator.plugins.... | def register(self, plugin):
"""
Register a plugin. New plugins are added to the end of the plugins list.
:param samtranslator.plugins.BasePlugin plugin: Instance/subclass of BasePlugin class that implements hooks
:raises ValueError: If plugin is not an instance of samtranslator.plugins.... | [
"Register",
"a",
"plugin",
".",
"New",
"plugins",
"are",
"added",
"to",
"the",
"end",
"of",
"the",
"plugins",
"list",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/__init__.py#L64-L80 | [
"def",
"register",
"(",
"self",
",",
"plugin",
")",
":",
"if",
"not",
"plugin",
"or",
"not",
"isinstance",
"(",
"plugin",
",",
"BasePlugin",
")",
":",
"raise",
"ValueError",
"(",
"\"Plugin must be implemented as a subclass of BasePlugin class\"",
")",
"if",
"self"... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SamPlugins._get | Retrieves the plugin with given name
:param plugin_name: Name of the plugin to retrieve
:return samtranslator.plugins.BasePlugin: Returns the plugin object if found. None, otherwise | samtranslator/plugins/__init__.py | def _get(self, plugin_name):
"""
Retrieves the plugin with given name
:param plugin_name: Name of the plugin to retrieve
:return samtranslator.plugins.BasePlugin: Returns the plugin object if found. None, otherwise
"""
for p in self._plugins:
if p.name == pl... | def _get(self, plugin_name):
"""
Retrieves the plugin with given name
:param plugin_name: Name of the plugin to retrieve
:return samtranslator.plugins.BasePlugin: Returns the plugin object if found. None, otherwise
"""
for p in self._plugins:
if p.name == pl... | [
"Retrieves",
"the",
"plugin",
"with",
"given",
"name"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/__init__.py#L92-L104 | [
"def",
"_get",
"(",
"self",
",",
"plugin_name",
")",
":",
"for",
"p",
"in",
"self",
".",
"_plugins",
":",
"if",
"p",
".",
"name",
"==",
"plugin_name",
":",
"return",
"p",
"return",
"None"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SamPlugins.act | Act on the specific life cycle event. The action here is to invoke the hook function on all registered plugins.
*args and **kwargs will be passed directly to the plugin's hook functions
:param samtranslator.plugins.LifeCycleEvents event: Event to act upon
:return: Nothing
:raises ValueE... | samtranslator/plugins/__init__.py | def act(self, event, *args, **kwargs):
"""
Act on the specific life cycle event. The action here is to invoke the hook function on all registered plugins.
*args and **kwargs will be passed directly to the plugin's hook functions
:param samtranslator.plugins.LifeCycleEvents event: Event ... | def act(self, event, *args, **kwargs):
"""
Act on the specific life cycle event. The action here is to invoke the hook function on all registered plugins.
*args and **kwargs will be passed directly to the plugin's hook functions
:param samtranslator.plugins.LifeCycleEvents event: Event ... | [
"Act",
"on",
"the",
"specific",
"life",
"cycle",
"event",
".",
"The",
"action",
"here",
"is",
"to",
"invoke",
"the",
"hook",
"function",
"on",
"all",
"registered",
"plugins",
".",
"*",
"args",
"and",
"**",
"kwargs",
"will",
"be",
"passed",
"directly",
"t... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/__init__.py#L106-L136 | [
"def",
"act",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"event",
",",
"LifeCycleEvents",
")",
":",
"raise",
"ValueError",
"(",
"\"'event' must be an instance of LifeCycleEvents class\"",
")"... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | DeploymentPreference.from_dict | :param logical_id: the logical_id of the resource that owns this deployment preference
:param deployment_preference_dict: the dict object taken from the SAM template
:return: | samtranslator/model/preferences/deployment_preference.py | def from_dict(cls, logical_id, deployment_preference_dict):
"""
:param logical_id: the logical_id of the resource that owns this deployment preference
:param deployment_preference_dict: the dict object taken from the SAM template
:return:
"""
enabled = deployment_preferen... | def from_dict(cls, logical_id, deployment_preference_dict):
"""
:param logical_id: the logical_id of the resource that owns this deployment preference
:param deployment_preference_dict: the dict object taken from the SAM template
:return:
"""
enabled = deployment_preferen... | [
":",
"param",
"logical_id",
":",
"the",
"logical_id",
"of",
"the",
"resource",
"that",
"owns",
"this",
"deployment",
"preference",
":",
"param",
"deployment_preference_dict",
":",
"the",
"dict",
"object",
"taken",
"from",
"the",
"SAM",
"template",
":",
"return",... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/preferences/deployment_preference.py#L37-L60 | [
"def",
"from_dict",
"(",
"cls",
",",
"logical_id",
",",
"deployment_preference_dict",
")",
":",
"enabled",
"=",
"deployment_preference_dict",
".",
"get",
"(",
"'Enabled'",
",",
"True",
")",
"if",
"not",
"enabled",
":",
"return",
"DeploymentPreference",
"(",
"Non... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | decrypt | decrypt leverages KMS decrypt and base64-encode decrypted blob
More info on KMS decrypt API:
https://docs.aws.amazon.com/kms/latest/APIReference/API_decrypt.html | examples/2016-10-31/encryption_proxy/src/decryption.py | def decrypt(message):
'''decrypt leverages KMS decrypt and base64-encode decrypted blob
More info on KMS decrypt API:
https://docs.aws.amazon.com/kms/latest/APIReference/API_decrypt.html
'''
try:
ret = kms.decrypt(
CiphertextBlob=base64.decodestring(message))
dec... | def decrypt(message):
'''decrypt leverages KMS decrypt and base64-encode decrypted blob
More info on KMS decrypt API:
https://docs.aws.amazon.com/kms/latest/APIReference/API_decrypt.html
'''
try:
ret = kms.decrypt(
CiphertextBlob=base64.decodestring(message))
dec... | [
"decrypt",
"leverages",
"KMS",
"decrypt",
"and",
"base64",
"-",
"encode",
"decrypted",
"blob"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/2016-10-31/encryption_proxy/src/decryption.py#L15-L29 | [
"def",
"decrypt",
"(",
"message",
")",
":",
"try",
":",
"ret",
"=",
"kms",
".",
"decrypt",
"(",
"CiphertextBlob",
"=",
"base64",
".",
"decodestring",
"(",
"message",
")",
")",
"decrypted_data",
"=",
"ret",
".",
"get",
"(",
"'Plaintext'",
")",
"except",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | lambda_handler | Demonstrates S3 trigger that uses
Rekognition APIs to detect faces, labels and index faces in S3 Object. | examples/apps/rekognition-python/lambda_function.py | def lambda_handler(event, context):
'''Demonstrates S3 trigger that uses
Rekognition APIs to detect faces, labels and index faces in S3 Object.
'''
#print("Received event: " + json.dumps(event, indent=2))
# Get the object from the event
bucket = event['Records'][0]['s3']['bucket']['name']
k... | def lambda_handler(event, context):
'''Demonstrates S3 trigger that uses
Rekognition APIs to detect faces, labels and index faces in S3 Object.
'''
#print("Received event: " + json.dumps(event, indent=2))
# Get the object from the event
bucket = event['Records'][0]['s3']['bucket']['name']
k... | [
"Demonstrates",
"S3",
"trigger",
"that",
"uses",
"Rekognition",
"APIs",
"to",
"detect",
"faces",
"labels",
"and",
"index",
"faces",
"in",
"S3",
"Object",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/rekognition-python/lambda_function.py#L42-L69 | [
"def",
"lambda_handler",
"(",
"event",
",",
"context",
")",
":",
"#print(\"Received event: \" + json.dumps(event, indent=2))",
"# Get the object from the event",
"bucket",
"=",
"event",
"[",
"'Records'",
"]",
"[",
"0",
"]",
"[",
"'s3'",
"]",
"[",
"'bucket'",
"]",
"[... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | prepend | Prepends the first argument (i.e., the exception message) of the a BaseException with the provided message.
Useful for reraising exceptions with additional information.
:param BaseException exception: the exception to prepend
:param str message: the message to prepend
:param str end: the separator to a... | samtranslator/model/exceptions.py | def prepend(exception, message, end=': '):
"""Prepends the first argument (i.e., the exception message) of the a BaseException with the provided message.
Useful for reraising exceptions with additional information.
:param BaseException exception: the exception to prepend
:param str message: the message... | def prepend(exception, message, end=': '):
"""Prepends the first argument (i.e., the exception message) of the a BaseException with the provided message.
Useful for reraising exceptions with additional information.
:param BaseException exception: the exception to prepend
:param str message: the message... | [
"Prepends",
"the",
"first",
"argument",
"(",
"i",
".",
"e",
".",
"the",
"exception",
"message",
")",
"of",
"the",
"a",
"BaseException",
"with",
"the",
"provided",
"message",
".",
"Useful",
"for",
"reraising",
"exceptions",
"with",
"additional",
"information",
... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/exceptions.py#L87-L98 | [
"def",
"prepend",
"(",
"exception",
",",
"message",
",",
"end",
"=",
"': '",
")",
":",
"exception",
".",
"args",
"=",
"exception",
".",
"args",
"or",
"(",
"''",
",",
")",
"exception",
".",
"args",
"=",
"(",
"message",
"+",
"end",
"+",
"exception",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | lambda_handler | Validate the incoming token and produce the principal user identifier
associated with the token. This can be accomplished in a number of ways:
1. Call out to the OAuth provider
2. Decode a JWT token inline
3. Lookup in a self-managed DB | examples/apps/api-gateway-authorizer-python/lambda_function.py | def lambda_handler(event, context):
# incoming token value
token = event['authorizationToken']
print("Method ARN: " + event['methodArn'])
'''
Validate the incoming token and produce the principal user identifier
associated with the token. This can be accomplished in a number of ways:
1. Ca... | def lambda_handler(event, context):
# incoming token value
token = event['authorizationToken']
print("Method ARN: " + event['methodArn'])
'''
Validate the incoming token and produce the principal user identifier
associated with the token. This can be accomplished in a number of ways:
1. Ca... | [
"Validate",
"the",
"incoming",
"token",
"and",
"produce",
"the",
"principal",
"user",
"identifier",
"associated",
"with",
"the",
"token",
".",
"This",
"can",
"be",
"accomplished",
"in",
"a",
"number",
"of",
"ways",
":"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/api-gateway-authorizer-python/lambda_function.py#L6-L68 | [
"def",
"lambda_handler",
"(",
"event",
",",
"context",
")",
":",
"# incoming token value",
"token",
"=",
"event",
"[",
"'authorizationToken'",
"]",
"print",
"(",
"\"Method ARN: \"",
"+",
"event",
"[",
"'methodArn'",
"]",
")",
"principalId",
"=",
"'user|a1b2c3d4'",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | AuthPolicy._getStatementForEffect | This function loops over an array of objects containing a resourceArn and
conditions statement and generates the array of statements for the policy. | examples/apps/api-gateway-authorizer-python/lambda_function.py | def _getStatementForEffect(self, effect, methods):
'''This function loops over an array of objects containing a resourceArn and
conditions statement and generates the array of statements for the policy.'''
statements = []
if len(methods) > 0:
statement = self._getEmptyStatem... | def _getStatementForEffect(self, effect, methods):
'''This function loops over an array of objects containing a resourceArn and
conditions statement and generates the array of statements for the policy.'''
statements = []
if len(methods) > 0:
statement = self._getEmptyStatem... | [
"This",
"function",
"loops",
"over",
"an",
"array",
"of",
"objects",
"containing",
"a",
"resourceArn",
"and",
"conditions",
"statement",
"and",
"generates",
"the",
"array",
"of",
"statements",
"for",
"the",
"policy",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/api-gateway-authorizer-python/lambda_function.py#L151-L171 | [
"def",
"_getStatementForEffect",
"(",
"self",
",",
"effect",
",",
"methods",
")",
":",
"statements",
"=",
"[",
"]",
"if",
"len",
"(",
"methods",
")",
">",
"0",
":",
"statement",
"=",
"self",
".",
"_getEmptyStatement",
"(",
"effect",
")",
"for",
"curMetho... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | PolicyTemplatesForFunctionPlugin.on_before_transform_resource | Hook method that gets called before "each" SAM resource gets processed
:param string logical_id: Logical ID of the resource being processed
:param string resource_type: Type of the resource being processed
:param dict resource_properties: Properties of the resource
:return: Nothing | samtranslator/plugins/policies/policy_templates_plugin.py | def on_before_transform_resource(self, logical_id, resource_type, resource_properties):
"""
Hook method that gets called before "each" SAM resource gets processed
:param string logical_id: Logical ID of the resource being processed
:param string resource_type: Type of the resource being... | def on_before_transform_resource(self, logical_id, resource_type, resource_properties):
"""
Hook method that gets called before "each" SAM resource gets processed
:param string logical_id: Logical ID of the resource being processed
:param string resource_type: Type of the resource being... | [
"Hook",
"method",
"that",
"gets",
"called",
"before",
"each",
"SAM",
"resource",
"gets",
"processed"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/policies/policy_templates_plugin.py#L31-L78 | [
"def",
"on_before_transform_resource",
"(",
"self",
",",
"logical_id",
",",
"resource_type",
",",
"resource_properties",
")",
":",
"if",
"not",
"self",
".",
"_is_supported",
"(",
"resource_type",
")",
":",
"return",
"function_policies",
"=",
"FunctionPolicies",
"(",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | lambda_handler | A Python AWS Lambda function to process aggregated records sent to KinesisAnalytics. | examples/apps/kinesis-analytics-process-kpl-record/lambda_function.py | def lambda_handler(event, context):
'''A Python AWS Lambda function to process aggregated records sent to KinesisAnalytics.'''
raw_kpl_records = event['records']
output = [process_kpl_record(kpl_record) for kpl_record in raw_kpl_records]
# Print number of successful and failed records.
success_coun... | def lambda_handler(event, context):
'''A Python AWS Lambda function to process aggregated records sent to KinesisAnalytics.'''
raw_kpl_records = event['records']
output = [process_kpl_record(kpl_record) for kpl_record in raw_kpl_records]
# Print number of successful and failed records.
success_coun... | [
"A",
"Python",
"AWS",
"Lambda",
"function",
"to",
"process",
"aggregated",
"records",
"sent",
"to",
"KinesisAnalytics",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/kinesis-analytics-process-kpl-record/lambda_function.py#L25-L35 | [
"def",
"lambda_handler",
"(",
"event",
",",
"context",
")",
":",
"raw_kpl_records",
"=",
"event",
"[",
"'records'",
"]",
"output",
"=",
"[",
"process_kpl_record",
"(",
"kpl_record",
")",
"for",
"kpl_record",
"in",
"raw_kpl_records",
"]",
"# Print number of success... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | transform | Translates the SAM manifest provided in the and returns the translation to CloudFormation.
:param dict input_fragment: the SAM template to transform
:param dict parameter_values: Parameter values provided by the user
:returns: the transformed CloudFormation template
:rtype: dict | samtranslator/translator/transform.py | def transform(input_fragment, parameter_values, managed_policy_loader):
"""Translates the SAM manifest provided in the and returns the translation to CloudFormation.
:param dict input_fragment: the SAM template to transform
:param dict parameter_values: Parameter values provided by the user
:returns: t... | def transform(input_fragment, parameter_values, managed_policy_loader):
"""Translates the SAM manifest provided in the and returns the translation to CloudFormation.
:param dict input_fragment: the SAM template to transform
:param dict parameter_values: Parameter values provided by the user
:returns: t... | [
"Translates",
"the",
"SAM",
"manifest",
"provided",
"in",
"the",
"and",
"returns",
"the",
"translation",
"to",
"CloudFormation",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/transform.py#L5-L16 | [
"def",
"transform",
"(",
"input_fragment",
",",
"parameter_values",
",",
"managed_policy_loader",
")",
":",
"sam_parser",
"=",
"Parser",
"(",
")",
"translator",
"=",
"Translator",
"(",
"managed_policy_loader",
".",
"load",
"(",
")",
",",
"sam_parser",
")",
"retu... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | UpdatePolicy.to_dict | :return: a dict that can be used as part of a cloudformation template | samtranslator/model/update_policy.py | def to_dict(self):
"""
:return: a dict that can be used as part of a cloudformation template
"""
dict_with_nones = self._asdict()
codedeploy_lambda_alias_update_dict = dict((k, v) for k, v in dict_with_nones.items()
if v != ref(N... | def to_dict(self):
"""
:return: a dict that can be used as part of a cloudformation template
"""
dict_with_nones = self._asdict()
codedeploy_lambda_alias_update_dict = dict((k, v) for k, v in dict_with_nones.items()
if v != ref(N... | [
":",
"return",
":",
"a",
"dict",
"that",
"can",
"be",
"used",
"as",
"part",
"of",
"a",
"cloudformation",
"template"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/update_policy.py#L23-L30 | [
"def",
"to_dict",
"(",
"self",
")",
":",
"dict_with_nones",
"=",
"self",
".",
"_asdict",
"(",
")",
"codedeploy_lambda_alias_update_dict",
"=",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"dict_with_nones",
".",
"items",
"(",
")",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ImplicitApiPlugin.on_before_transform_template | Hook method that gets called before the SAM template is processed.
The template has pass the validation and is guaranteed to contain a non-empty "Resources" section.
:param dict template_dict: Dictionary of the SAM template
:return: Nothing | samtranslator/plugins/api/implicit_api_plugin.py | def on_before_transform_template(self, template_dict):
"""
Hook method that gets called before the SAM template is processed.
The template has pass the validation and is guaranteed to contain a non-empty "Resources" section.
:param dict template_dict: Dictionary of the SAM template
... | def on_before_transform_template(self, template_dict):
"""
Hook method that gets called before the SAM template is processed.
The template has pass the validation and is guaranteed to contain a non-empty "Resources" section.
:param dict template_dict: Dictionary of the SAM template
... | [
"Hook",
"method",
"that",
"gets",
"called",
"before",
"the",
"SAM",
"template",
"is",
"processed",
".",
"The",
"template",
"has",
"pass",
"the",
"validation",
"and",
"is",
"guaranteed",
"to",
"contain",
"a",
"non",
"-",
"empty",
"Resources",
"section",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L48-L89 | [
"def",
"on_before_transform_template",
"(",
"self",
",",
"template_dict",
")",
":",
"template",
"=",
"SamTemplate",
"(",
"template_dict",
")",
"# Temporarily add Serverless::Api resource corresponding to Implicit API to the template.",
"# This will allow the processing code to work the... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ImplicitApiPlugin._get_api_events | Method to return a dictionary of API Events on the function
:param SamResource function: Function Resource object
:return dict: Dictionary of API events along with any other configuration passed to it.
Example: {
FooEvent: {Path: "/foo", Method: "post", RestApiId: blah, Meth... | samtranslator/plugins/api/implicit_api_plugin.py | def _get_api_events(self, function):
"""
Method to return a dictionary of API Events on the function
:param SamResource function: Function Resource object
:return dict: Dictionary of API events along with any other configuration passed to it.
Example: {
FooEv... | def _get_api_events(self, function):
"""
Method to return a dictionary of API Events on the function
:param SamResource function: Function Resource object
:return dict: Dictionary of API events along with any other configuration passed to it.
Example: {
FooEv... | [
"Method",
"to",
"return",
"a",
"dictionary",
"of",
"API",
"Events",
"on",
"the",
"function"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L91-L118 | [
"def",
"_get_api_events",
"(",
"self",
",",
"function",
")",
":",
"if",
"not",
"(",
"function",
".",
"valid",
"(",
")",
"and",
"isinstance",
"(",
"function",
".",
"properties",
",",
"dict",
")",
"and",
"isinstance",
"(",
"function",
".",
"properties",
".... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ImplicitApiPlugin._process_api_events | Actually process given API events. Iteratively adds the APIs to Swagger JSON in the respective Serverless::Api
resource from the template
:param SamResource function: SAM Function containing the API events to be processed
:param dict api_events: API Events extracted from the function. These eve... | samtranslator/plugins/api/implicit_api_plugin.py | def _process_api_events(self, function, api_events, template, condition=None):
"""
Actually process given API events. Iteratively adds the APIs to Swagger JSON in the respective Serverless::Api
resource from the template
:param SamResource function: SAM Function containing the API event... | def _process_api_events(self, function, api_events, template, condition=None):
"""
Actually process given API events. Iteratively adds the APIs to Swagger JSON in the respective Serverless::Api
resource from the template
:param SamResource function: SAM Function containing the API event... | [
"Actually",
"process",
"given",
"API",
"events",
".",
"Iteratively",
"adds",
"the",
"APIs",
"to",
"Swagger",
"JSON",
"in",
"the",
"respective",
"Serverless",
"::",
"Api",
"resource",
"from",
"the",
"template"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L120-L162 | [
"def",
"_process_api_events",
"(",
"self",
",",
"function",
",",
"api_events",
",",
"template",
",",
"condition",
"=",
"None",
")",
":",
"for",
"logicalId",
",",
"event",
"in",
"api_events",
".",
"items",
"(",
")",
":",
"event_properties",
"=",
"event",
".... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ImplicitApiPlugin._add_api_to_swagger | Adds the API path/method from the given event to the Swagger JSON of Serverless::Api resource this event
refers to.
:param string event_id: LogicalId of the event
:param dict event_properties: Properties of the event
:param SamTemplate template: SAM Template to search for Serverless::Ap... | samtranslator/plugins/api/implicit_api_plugin.py | def _add_api_to_swagger(self, event_id, event_properties, template):
"""
Adds the API path/method from the given event to the Swagger JSON of Serverless::Api resource this event
refers to.
:param string event_id: LogicalId of the event
:param dict event_properties: Properties of... | def _add_api_to_swagger(self, event_id, event_properties, template):
"""
Adds the API path/method from the given event to the Swagger JSON of Serverless::Api resource this event
refers to.
:param string event_id: LogicalId of the event
:param dict event_properties: Properties of... | [
"Adds",
"the",
"API",
"path",
"/",
"method",
"from",
"the",
"given",
"event",
"to",
"the",
"Swagger",
"JSON",
"of",
"Serverless",
"::",
"Api",
"resource",
"this",
"event",
"refers",
"to",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L175-L221 | [
"def",
"_add_api_to_swagger",
"(",
"self",
",",
"event_id",
",",
"event_properties",
",",
"template",
")",
":",
"# Need to grab the AWS::Serverless::Api resource for this API event and update its Swagger definition",
"api_id",
"=",
"self",
".",
"_get_api_id",
"(",
"event_proper... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ImplicitApiPlugin._get_api_id | Get API logical id from API event properties.
Handles case where API id is not specified or is a reference to a logical id. | samtranslator/plugins/api/implicit_api_plugin.py | def _get_api_id(self, event_properties):
"""
Get API logical id from API event properties.
Handles case where API id is not specified or is a reference to a logical id.
"""
api_id = event_properties.get("RestApiId")
if isinstance(api_id, dict) and "Ref" in api_id:
... | def _get_api_id(self, event_properties):
"""
Get API logical id from API event properties.
Handles case where API id is not specified or is a reference to a logical id.
"""
api_id = event_properties.get("RestApiId")
if isinstance(api_id, dict) and "Ref" in api_id:
... | [
"Get",
"API",
"logical",
"id",
"from",
"API",
"event",
"properties",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L223-L232 | [
"def",
"_get_api_id",
"(",
"self",
",",
"event_properties",
")",
":",
"api_id",
"=",
"event_properties",
".",
"get",
"(",
"\"RestApiId\"",
")",
"if",
"isinstance",
"(",
"api_id",
",",
"dict",
")",
"and",
"\"Ref\"",
"in",
"api_id",
":",
"api_id",
"=",
"api_... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ImplicitApiPlugin._maybe_add_condition_to_implicit_api | Decides whether to add a condition to the implicit api resource.
:param dict template_dict: SAM template dictionary | samtranslator/plugins/api/implicit_api_plugin.py | def _maybe_add_condition_to_implicit_api(self, template_dict):
"""
Decides whether to add a condition to the implicit api resource.
:param dict template_dict: SAM template dictionary
"""
# Short-circuit if template doesn't have any functions with implicit API events
if no... | def _maybe_add_condition_to_implicit_api(self, template_dict):
"""
Decides whether to add a condition to the implicit api resource.
:param dict template_dict: SAM template dictionary
"""
# Short-circuit if template doesn't have any functions with implicit API events
if no... | [
"Decides",
"whether",
"to",
"add",
"a",
"condition",
"to",
"the",
"implicit",
"api",
"resource",
".",
":",
"param",
"dict",
"template_dict",
":",
"SAM",
"template",
"dictionary"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L234-L262 | [
"def",
"_maybe_add_condition_to_implicit_api",
"(",
"self",
",",
"template_dict",
")",
":",
"# Short-circuit if template doesn't have any functions with implicit API events",
"if",
"not",
"self",
".",
"api_conditions",
".",
"get",
"(",
"self",
".",
"implicit_api_logical_id",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ImplicitApiPlugin._add_combined_condition_to_template | Add top-level template condition that combines the given list of conditions.
:param dict template_dict: SAM template dictionary
:param string condition_name: Name of top-level template condition
:param list conditions_to_combine: List of conditions that should be combined (via OR operator) to f... | samtranslator/plugins/api/implicit_api_plugin.py | def _add_combined_condition_to_template(self, template_dict, condition_name, conditions_to_combine):
"""
Add top-level template condition that combines the given list of conditions.
:param dict template_dict: SAM template dictionary
:param string condition_name: Name of top-level templa... | def _add_combined_condition_to_template(self, template_dict, condition_name, conditions_to_combine):
"""
Add top-level template condition that combines the given list of conditions.
:param dict template_dict: SAM template dictionary
:param string condition_name: Name of top-level templa... | [
"Add",
"top",
"-",
"level",
"template",
"condition",
"that",
"combines",
"the",
"given",
"list",
"of",
"conditions",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L264-L280 | [
"def",
"_add_combined_condition_to_template",
"(",
"self",
",",
"template_dict",
",",
"condition_name",
",",
"conditions_to_combine",
")",
":",
"# defensive precondition check",
"if",
"not",
"conditions_to_combine",
"or",
"len",
"(",
"conditions_to_combine",
")",
"<",
"2"... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ImplicitApiPlugin._maybe_add_conditions_to_implicit_api_paths | Add conditions to implicit API paths if necessary.
Implicit API resource methods are constructed from API events on individual serverless functions within the SAM
template. Since serverless functions can have conditions on them, it's possible to have a case where all methods
under a resource pa... | samtranslator/plugins/api/implicit_api_plugin.py | def _maybe_add_conditions_to_implicit_api_paths(self, template):
"""
Add conditions to implicit API paths if necessary.
Implicit API resource methods are constructed from API events on individual serverless functions within the SAM
template. Since serverless functions can have condition... | def _maybe_add_conditions_to_implicit_api_paths(self, template):
"""
Add conditions to implicit API paths if necessary.
Implicit API resource methods are constructed from API events on individual serverless functions within the SAM
template. Since serverless functions can have condition... | [
"Add",
"conditions",
"to",
"implicit",
"API",
"paths",
"if",
"necessary",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L282-L317 | [
"def",
"_maybe_add_conditions_to_implicit_api_paths",
"(",
"self",
",",
"template",
")",
":",
"for",
"api_id",
",",
"api",
"in",
"template",
".",
"iterate",
"(",
"SamResourceType",
".",
"Api",
".",
"value",
")",
":",
"if",
"not",
"api",
".",
"properties",
".... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ImplicitApiPlugin._path_condition_name | Generate valid condition logical id from the given API logical id and swagger resource path. | samtranslator/plugins/api/implicit_api_plugin.py | def _path_condition_name(self, api_id, path):
"""
Generate valid condition logical id from the given API logical id and swagger resource path.
"""
# only valid characters for CloudFormation logical id are [A-Za-z0-9], but swagger paths can contain
# slashes and curly braces for t... | def _path_condition_name(self, api_id, path):
"""
Generate valid condition logical id from the given API logical id and swagger resource path.
"""
# only valid characters for CloudFormation logical id are [A-Za-z0-9], but swagger paths can contain
# slashes and curly braces for t... | [
"Generate",
"valid",
"condition",
"logical",
"id",
"from",
"the",
"given",
"API",
"logical",
"id",
"and",
"swagger",
"resource",
"path",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L319-L327 | [
"def",
"_path_condition_name",
"(",
"self",
",",
"api_id",
",",
"path",
")",
":",
"# only valid characters for CloudFormation logical id are [A-Za-z0-9], but swagger paths can contain",
"# slashes and curly braces for templated params, e.g., /foo/{customerId}. So we'll replace",
"# non-alpha... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ImplicitApiPlugin._maybe_remove_implicit_api | Implicit API resource are tentatively added to the template for uniform handling of both Implicit & Explicit
APIs. They need to removed from the template, if there are *no* API events attached to this resource.
This method removes the Implicit API if it does not contain any Swagger paths (added in respo... | samtranslator/plugins/api/implicit_api_plugin.py | def _maybe_remove_implicit_api(self, template):
"""
Implicit API resource are tentatively added to the template for uniform handling of both Implicit & Explicit
APIs. They need to removed from the template, if there are *no* API events attached to this resource.
This method removes the I... | def _maybe_remove_implicit_api(self, template):
"""
Implicit API resource are tentatively added to the template for uniform handling of both Implicit & Explicit
APIs. They need to removed from the template, if there are *no* API events attached to this resource.
This method removes the I... | [
"Implicit",
"API",
"resource",
"are",
"tentatively",
"added",
"to",
"the",
"template",
"for",
"uniform",
"handling",
"of",
"both",
"Implicit",
"&",
"Explicit",
"APIs",
".",
"They",
"need",
"to",
"removed",
"from",
"the",
"template",
"if",
"there",
"are",
"*"... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L329-L347 | [
"def",
"_maybe_remove_implicit_api",
"(",
"self",
",",
"template",
")",
":",
"# Remove Implicit API resource if no paths got added",
"implicit_api_resource",
"=",
"template",
".",
"get",
"(",
"self",
".",
"implicit_api_logical_id",
")",
"if",
"implicit_api_resource",
"and",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ApiGatewayDeployment.make_auto_deployable | Sets up the resource such that it will triggers a re-deployment when Swagger changes
:param swagger: Dictionary containing the Swagger definition of the API | samtranslator/model/apigateway.py | def make_auto_deployable(self, stage, swagger=None):
"""
Sets up the resource such that it will triggers a re-deployment when Swagger changes
:param swagger: Dictionary containing the Swagger definition of the API
"""
if not swagger:
return
# CloudFormation ... | def make_auto_deployable(self, stage, swagger=None):
"""
Sets up the resource such that it will triggers a re-deployment when Swagger changes
:param swagger: Dictionary containing the Swagger definition of the API
"""
if not swagger:
return
# CloudFormation ... | [
"Sets",
"up",
"the",
"resource",
"such",
"that",
"it",
"will",
"triggers",
"a",
"re",
"-",
"deployment",
"when",
"Swagger",
"changes"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/apigateway.py#L76-L95 | [
"def",
"make_auto_deployable",
"(",
"self",
",",
"stage",
",",
"swagger",
"=",
"None",
")",
":",
"if",
"not",
"swagger",
":",
"return",
"# CloudFormation does NOT redeploy the API unless it has a new deployment resource",
"# that points to latest RestApi resource. Append a hash o... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Client._invoke_internal | This private method is seperate from the main, public invoke method so that other code within this SDK can
give this Lambda client a raw payload/client context to invoke with, rather than having it built for them.
This lets you include custom ExtensionMap_ values like subject which are needed for our in... | examples/apps/greengrass-hello-world/greengrasssdk/Lambda.py | def _invoke_internal(self, function_arn, payload, client_context, invocation_type="RequestResponse"):
"""
This private method is seperate from the main, public invoke method so that other code within this SDK can
give this Lambda client a raw payload/client context to invoke with, rather than ha... | def _invoke_internal(self, function_arn, payload, client_context, invocation_type="RequestResponse"):
"""
This private method is seperate from the main, public invoke method so that other code within this SDK can
give this Lambda client a raw payload/client context to invoke with, rather than ha... | [
"This",
"private",
"method",
"is",
"seperate",
"from",
"the",
"main",
"public",
"invoke",
"method",
"so",
"that",
"other",
"code",
"within",
"this",
"SDK",
"can",
"give",
"this",
"Lambda",
"client",
"a",
"raw",
"payload",
"/",
"client",
"context",
"to",
"i... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrasssdk/Lambda.py#L86-L114 | [
"def",
"_invoke_internal",
"(",
"self",
",",
"function_arn",
",",
"payload",
",",
"client_context",
",",
"invocation_type",
"=",
"\"RequestResponse\"",
")",
":",
"customer_logger",
".",
"info",
"(",
"'Invoking Lambda function \"{}\" with Greengrass Message \"{}\"'",
".",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | StreamingBody.read | Read at most amt bytes from the stream.
If the amt argument is omitted, read all data. | examples/apps/greengrass-hello-world/greengrasssdk/Lambda.py | def read(self, amt=None):
"""Read at most amt bytes from the stream.
If the amt argument is omitted, read all data.
"""
chunk = self._raw_stream.read(amt)
self._amount_read += len(chunk)
return chunk | def read(self, amt=None):
"""Read at most amt bytes from the stream.
If the amt argument is omitted, read all data.
"""
chunk = self._raw_stream.read(amt)
self._amount_read += len(chunk)
return chunk | [
"Read",
"at",
"most",
"amt",
"bytes",
"from",
"the",
"stream",
".",
"If",
"the",
"amt",
"argument",
"is",
"omitted",
"read",
"all",
"data",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrasssdk/Lambda.py#L126-L132 | [
"def",
"read",
"(",
"self",
",",
"amt",
"=",
"None",
")",
":",
"chunk",
"=",
"self",
".",
"_raw_stream",
".",
"read",
"(",
"amt",
")",
"self",
".",
"_amount_read",
"+=",
"len",
"(",
"chunk",
")",
"return",
"chunk"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | IPCClient.post_work | Send work item to specified :code:`function_arn`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: string
:param input_bytes: The data making up the work being posted.
:type input_bytes: bytes
:param client_contex... | examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py | def post_work(self, function_arn, input_bytes, client_context, invocation_type="RequestResponse"):
"""
Send work item to specified :code:`function_arn`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: string
:para... | def post_work(self, function_arn, input_bytes, client_context, invocation_type="RequestResponse"):
"""
Send work item to specified :code:`function_arn`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: string
:para... | [
"Send",
"work",
"item",
"to",
"specified",
":",
"code",
":",
"function_arn",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py#L81-L110 | [
"def",
"post_work",
"(",
"self",
",",
"function_arn",
",",
"input_bytes",
",",
"client_context",
",",
"invocation_type",
"=",
"\"RequestResponse\"",
")",
":",
"url",
"=",
"self",
".",
"_get_url",
"(",
"function_arn",
")",
"runtime_logger",
".",
"info",
"(",
"'... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | IPCClient.get_work | Retrieve the next work item for specified :code:`function_arn`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: string
:returns: Next work item to be processed by the function.
:type returns: WorkItem | examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py | def get_work(self, function_arn):
"""
Retrieve the next work item for specified :code:`function_arn`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: string
:returns: Next work item to be processed by the function... | def get_work(self, function_arn):
"""
Retrieve the next work item for specified :code:`function_arn`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: string
:returns: Next work item to be processed by the function... | [
"Retrieve",
"the",
"next",
"work",
"item",
"for",
"specified",
":",
"code",
":",
"function_arn",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py#L113-L138 | [
"def",
"get_work",
"(",
"self",
",",
"function_arn",
")",
":",
"url",
"=",
"self",
".",
"_get_work_url",
"(",
"function_arn",
")",
"runtime_logger",
".",
"info",
"(",
"'Getting work for function [{}] from {}'",
".",
"format",
"(",
"function_arn",
",",
"url",
")"... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | IPCClient.post_work_result | Post the result of processing work item by :code:`function_arn`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: string
:param work_item: The WorkItem holding the results of the work being posted.
:type work_item: WorkIte... | examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py | def post_work_result(self, function_arn, work_item):
"""
Post the result of processing work item by :code:`function_arn`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: string
:param work_item: The WorkItem holdi... | def post_work_result(self, function_arn, work_item):
"""
Post the result of processing work item by :code:`function_arn`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: string
:param work_item: The WorkItem holdi... | [
"Post",
"the",
"result",
"of",
"processing",
"work",
"item",
"by",
":",
"code",
":",
"function_arn",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py#L141-L163 | [
"def",
"post_work_result",
"(",
"self",
",",
"function_arn",
",",
"work_item",
")",
":",
"url",
"=",
"self",
".",
"_get_work_url",
"(",
"function_arn",
")",
"runtime_logger",
".",
"info",
"(",
"'Posting work result for invocation id [{}] to {}'",
".",
"format",
"(",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | IPCClient.post_handler_err | Post the error message from executing the function handler for :code:`function_arn`
with specifid :code:`invocation_id`
:param function_arn: Arn of the Lambda function which has the handler error message.
:type function_arn: string
:param invocation_id: Invocation ID of the work that ... | examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py | def post_handler_err(self, function_arn, invocation_id, handler_err):
"""
Post the error message from executing the function handler for :code:`function_arn`
with specifid :code:`invocation_id`
:param function_arn: Arn of the Lambda function which has the handler error message.
... | def post_handler_err(self, function_arn, invocation_id, handler_err):
"""
Post the error message from executing the function handler for :code:`function_arn`
with specifid :code:`invocation_id`
:param function_arn: Arn of the Lambda function which has the handler error message.
... | [
"Post",
"the",
"error",
"message",
"from",
"executing",
"the",
"function",
"handler",
"for",
":",
"code",
":",
"function_arn",
"with",
"specifid",
":",
"code",
":",
"invocation_id"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py#L166-L196 | [
"def",
"post_handler_err",
"(",
"self",
",",
"function_arn",
",",
"invocation_id",
",",
"handler_err",
")",
":",
"url",
"=",
"self",
".",
"_get_work_url",
"(",
"function_arn",
")",
"runtime_logger",
".",
"info",
"(",
"'Posting handler error for invocation id [{}] to {... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | IPCClient.get_work_result | Retrieve the result of the work processed by :code:`function_arn`
with specified :code:`invocation_id`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: string
:param invocation_id: Invocation ID of the work that is being ... | examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py | def get_work_result(self, function_arn, invocation_id):
"""
Retrieve the result of the work processed by :code:`function_arn`
with specified :code:`invocation_id`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: st... | def get_work_result(self, function_arn, invocation_id):
"""
Retrieve the result of the work processed by :code:`function_arn`
with specified :code:`invocation_id`.
:param function_arn: Arn of the Lambda function intended to receive the work for processing.
:type function_arn: st... | [
"Retrieve",
"the",
"result",
"of",
"the",
"work",
"processed",
"by",
":",
"code",
":",
"function_arn",
"with",
"specified",
":",
"code",
":",
"invocation_id",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py#L199-L230 | [
"def",
"get_work_result",
"(",
"self",
",",
"function_arn",
",",
"invocation_id",
")",
":",
"url",
"=",
"self",
".",
"_get_url",
"(",
"function_arn",
")",
"runtime_logger",
".",
"info",
"(",
"'Getting work result for invocation id [{}] from {}'",
".",
"format",
"(",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ServerlessAppPlugin.on_before_transform_template | Hook method that gets called before the SAM template is processed.
The template has passed the validation and is guaranteed to contain a non-empty "Resources" section.
This plugin needs to run as soon as possible to allow some time for templates to become available.
This verifies that the user ... | samtranslator/plugins/application/serverless_app_plugin.py | def on_before_transform_template(self, template_dict):
"""
Hook method that gets called before the SAM template is processed.
The template has passed the validation and is guaranteed to contain a non-empty "Resources" section.
This plugin needs to run as soon as possible to allow some t... | def on_before_transform_template(self, template_dict):
"""
Hook method that gets called before the SAM template is processed.
The template has passed the validation and is guaranteed to contain a non-empty "Resources" section.
This plugin needs to run as soon as possible to allow some t... | [
"Hook",
"method",
"that",
"gets",
"called",
"before",
"the",
"SAM",
"template",
"is",
"processed",
".",
"The",
"template",
"has",
"passed",
"the",
"validation",
"and",
"is",
"guaranteed",
"to",
"contain",
"a",
"non",
"-",
"empty",
"Resources",
"section",
"."... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L64-L109 | [
"def",
"on_before_transform_template",
"(",
"self",
",",
"template_dict",
")",
":",
"template",
"=",
"SamTemplate",
"(",
"template_dict",
")",
"intrinsic_resolvers",
"=",
"self",
".",
"_get_intrinsic_resolvers",
"(",
"template_dict",
".",
"get",
"(",
"'Mappings'",
"... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ServerlessAppPlugin._can_process_application | Determines whether or not the on_before_transform_template event can process this application
:param dict app: the application and its properties | samtranslator/plugins/application/serverless_app_plugin.py | def _can_process_application(self, app):
"""
Determines whether or not the on_before_transform_template event can process this application
:param dict app: the application and its properties
"""
return (self.LOCATION_KEY in app.properties and
isinstance(app.prope... | def _can_process_application(self, app):
"""
Determines whether or not the on_before_transform_template event can process this application
:param dict app: the application and its properties
"""
return (self.LOCATION_KEY in app.properties and
isinstance(app.prope... | [
"Determines",
"whether",
"or",
"not",
"the",
"on_before_transform_template",
"event",
"can",
"process",
"this",
"application"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L126-L135 | [
"def",
"_can_process_application",
"(",
"self",
",",
"app",
")",
":",
"return",
"(",
"self",
".",
"LOCATION_KEY",
"in",
"app",
".",
"properties",
"and",
"isinstance",
"(",
"app",
".",
"properties",
"[",
"self",
".",
"LOCATION_KEY",
"]",
",",
"dict",
")",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ServerlessAppPlugin._handle_get_application_request | Method that handles the get_application API call to the serverless application repo
This method puts something in the `_applications` dictionary because the plugin expects
something there in a later event.
:param string app_id: ApplicationId
:param string semver: SemanticVersion
... | samtranslator/plugins/application/serverless_app_plugin.py | def _handle_get_application_request(self, app_id, semver, key, logical_id):
"""
Method that handles the get_application API call to the serverless application repo
This method puts something in the `_applications` dictionary because the plugin expects
something there in a later event.
... | def _handle_get_application_request(self, app_id, semver, key, logical_id):
"""
Method that handles the get_application API call to the serverless application repo
This method puts something in the `_applications` dictionary because the plugin expects
something there in a later event.
... | [
"Method",
"that",
"handles",
"the",
"get_application",
"API",
"call",
"to",
"the",
"serverless",
"application",
"repo"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L137-L159 | [
"def",
"_handle_get_application_request",
"(",
"self",
",",
"app_id",
",",
"semver",
",",
"key",
",",
"logical_id",
")",
":",
"get_application",
"=",
"(",
"lambda",
"app_id",
",",
"semver",
":",
"self",
".",
"_sar_client",
".",
"get_application",
"(",
"Applica... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ServerlessAppPlugin._handle_create_cfn_template_request | Method that handles the create_cloud_formation_template API call to the serverless application repo
:param string app_id: ApplicationId
:param string semver: SemanticVersion
:param string key: The dictionary key consisting of (ApplicationId, SemanticVersion)
:param string logical_id: th... | samtranslator/plugins/application/serverless_app_plugin.py | def _handle_create_cfn_template_request(self, app_id, semver, key, logical_id):
"""
Method that handles the create_cloud_formation_template API call to the serverless application repo
:param string app_id: ApplicationId
:param string semver: SemanticVersion
:param string key: Th... | def _handle_create_cfn_template_request(self, app_id, semver, key, logical_id):
"""
Method that handles the create_cloud_formation_template API call to the serverless application repo
:param string app_id: ApplicationId
:param string semver: SemanticVersion
:param string key: Th... | [
"Method",
"that",
"handles",
"the",
"create_cloud_formation_template",
"API",
"call",
"to",
"the",
"serverless",
"application",
"repo"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L161-L177 | [
"def",
"_handle_create_cfn_template_request",
"(",
"self",
",",
"app_id",
",",
"semver",
",",
"key",
",",
"logical_id",
")",
":",
"create_cfn_template",
"=",
"(",
"lambda",
"app_id",
",",
"semver",
":",
"self",
".",
"_sar_client",
".",
"create_cloud_formation_temp... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ServerlessAppPlugin.on_before_transform_resource | Hook method that gets called before "each" SAM resource gets processed
Replaces the ApplicationId and Semantic Version pairs with a TemplateUrl.
:param string logical_id: Logical ID of the resource being processed
:param string resource_type: Type of the resource being processed
:param... | samtranslator/plugins/application/serverless_app_plugin.py | def on_before_transform_resource(self, logical_id, resource_type, resource_properties):
"""
Hook method that gets called before "each" SAM resource gets processed
Replaces the ApplicationId and Semantic Version pairs with a TemplateUrl.
:param string logical_id: Logical ID of the resou... | def on_before_transform_resource(self, logical_id, resource_type, resource_properties):
"""
Hook method that gets called before "each" SAM resource gets processed
Replaces the ApplicationId and Semantic Version pairs with a TemplateUrl.
:param string logical_id: Logical ID of the resou... | [
"Hook",
"method",
"that",
"gets",
"called",
"before",
"each",
"SAM",
"resource",
"gets",
"processed"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L194-L247 | [
"def",
"on_before_transform_resource",
"(",
"self",
",",
"logical_id",
",",
"resource_type",
",",
"resource_properties",
")",
":",
"if",
"not",
"self",
".",
"_resource_is_supported",
"(",
"resource_type",
")",
":",
"return",
"# Sanitize properties",
"self",
".",
"_c... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ServerlessAppPlugin._check_for_dictionary_key | Checks a dictionary to make sure it has a specific key. If it does not, an
InvalidResourceException is thrown.
:param string logical_id: logical id of this resource
:param dict dictionary: the dictionary to check
:param list keys: list of keys that should exist in the dictionary | samtranslator/plugins/application/serverless_app_plugin.py | def _check_for_dictionary_key(self, logical_id, dictionary, keys):
"""
Checks a dictionary to make sure it has a specific key. If it does not, an
InvalidResourceException is thrown.
:param string logical_id: logical id of this resource
:param dict dictionary: the dictionary to c... | def _check_for_dictionary_key(self, logical_id, dictionary, keys):
"""
Checks a dictionary to make sure it has a specific key. If it does not, an
InvalidResourceException is thrown.
:param string logical_id: logical id of this resource
:param dict dictionary: the dictionary to c... | [
"Checks",
"a",
"dictionary",
"to",
"make",
"sure",
"it",
"has",
"a",
"specific",
"key",
".",
"If",
"it",
"does",
"not",
"an",
"InvalidResourceException",
"is",
"thrown",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L249-L261 | [
"def",
"_check_for_dictionary_key",
"(",
"self",
",",
"logical_id",
",",
"dictionary",
",",
"keys",
")",
":",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"not",
"in",
"dictionary",
":",
"raise",
"InvalidResourceException",
"(",
"logical_id",
",",
"'Resource ... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ServerlessAppPlugin.on_after_transform_template | Hook method that gets called after the template is processed
Go through all the stored applications and make sure they're all ACTIVE.
:param dict template: Dictionary of the SAM template
:return: Nothing | samtranslator/plugins/application/serverless_app_plugin.py | def on_after_transform_template(self, template):
"""
Hook method that gets called after the template is processed
Go through all the stored applications and make sure they're all ACTIVE.
:param dict template: Dictionary of the SAM template
:return: Nothing
"""
i... | def on_after_transform_template(self, template):
"""
Hook method that gets called after the template is processed
Go through all the stored applications and make sure they're all ACTIVE.
:param dict template: Dictionary of the SAM template
:return: Nothing
"""
i... | [
"Hook",
"method",
"that",
"gets",
"called",
"after",
"the",
"template",
"is",
"processed"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L263-L298 | [
"def",
"on_after_transform_template",
"(",
"self",
",",
"template",
")",
":",
"if",
"self",
".",
"_wait_for_template_active_status",
"and",
"not",
"self",
".",
"_validate_only",
":",
"start_time",
"=",
"time",
"(",
")",
"while",
"(",
"time",
"(",
")",
"-",
"... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ServerlessAppPlugin._handle_get_cfn_template_response | Handles the response from the SAR service call
:param dict response: the response dictionary from the app repo
:param string application_id: the ApplicationId
:param string template_id: the unique TemplateId for this application | samtranslator/plugins/application/serverless_app_plugin.py | def _handle_get_cfn_template_response(self, response, application_id, template_id):
"""
Handles the response from the SAR service call
:param dict response: the response dictionary from the app repo
:param string application_id: the ApplicationId
:param string template_id: the u... | def _handle_get_cfn_template_response(self, response, application_id, template_id):
"""
Handles the response from the SAR service call
:param dict response: the response dictionary from the app repo
:param string application_id: the ApplicationId
:param string template_id: the u... | [
"Handles",
"the",
"response",
"from",
"the",
"SAR",
"service",
"call"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L300-L315 | [
"def",
"_handle_get_cfn_template_response",
"(",
"self",
",",
"response",
",",
"application_id",
",",
"template_id",
")",
":",
"status",
"=",
"response",
"[",
"'Status'",
"]",
"if",
"status",
"!=",
"\"ACTIVE\"",
":",
"# Other options are PREPARING and EXPIRED.",
"if",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ServerlessAppPlugin._sar_service_call | Handles service calls and exception management for service calls
to the Serverless Application Repository.
:param lambda service_call_lambda: lambda function that contains the service call
:param string logical_id: Logical ID of the resource being processed
:param list *args: arguments ... | samtranslator/plugins/application/serverless_app_plugin.py | def _sar_service_call(self, service_call_lambda, logical_id, *args):
"""
Handles service calls and exception management for service calls
to the Serverless Application Repository.
:param lambda service_call_lambda: lambda function that contains the service call
:param string log... | def _sar_service_call(self, service_call_lambda, logical_id, *args):
"""
Handles service calls and exception management for service calls
to the Serverless Application Repository.
:param lambda service_call_lambda: lambda function that contains the service call
:param string log... | [
"Handles",
"service",
"calls",
"and",
"exception",
"management",
"for",
"service",
"calls",
"to",
"the",
"Serverless",
"Application",
"Repository",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L317-L337 | [
"def",
"_sar_service_call",
"(",
"self",
",",
"service_call_lambda",
",",
"logical_id",
",",
"*",
"args",
")",
":",
"try",
":",
"response",
"=",
"service_call_lambda",
"(",
"*",
"args",
")",
"logging",
".",
"info",
"(",
"response",
")",
"return",
"response",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Parser._validate | Validates the template and parameter values and raises exceptions if there's an issue
:param dict sam_template: SAM template
:param dict parameter_values: Dictionary of parameter values provided by the user | samtranslator/parser/parser.py | def _validate(self, sam_template, parameter_values):
""" Validates the template and parameter values and raises exceptions if there's an issue
:param dict sam_template: SAM template
:param dict parameter_values: Dictionary of parameter values provided by the user
"""
if paramete... | def _validate(self, sam_template, parameter_values):
""" Validates the template and parameter values and raises exceptions if there's an issue
:param dict sam_template: SAM template
:param dict parameter_values: Dictionary of parameter values provided by the user
"""
if paramete... | [
"Validates",
"the",
"template",
"and",
"parameter",
"values",
"and",
"raises",
"exceptions",
"if",
"there",
"s",
"an",
"issue"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/parser/parser.py#L16-L50 | [
"def",
"_validate",
"(",
"self",
",",
"sam_template",
",",
"parameter_values",
")",
":",
"if",
"parameter_values",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"`parameter_values` argument is required\"",
")",
"if",
"(",
"\"Resources\"",
"not",
"in",
"sam_templa... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SamTemplate.iterate | Iterate over all resources within the SAM template, optionally filtering by type
:param string resource_type: Optional type to filter the resources by
:yields (string, SamResource): Tuple containing LogicalId and the resource | samtranslator/sdk/template.py | def iterate(self, resource_type=None):
"""
Iterate over all resources within the SAM template, optionally filtering by type
:param string resource_type: Optional type to filter the resources by
:yields (string, SamResource): Tuple containing LogicalId and the resource
"""
... | def iterate(self, resource_type=None):
"""
Iterate over all resources within the SAM template, optionally filtering by type
:param string resource_type: Optional type to filter the resources by
:yields (string, SamResource): Tuple containing LogicalId and the resource
"""
... | [
"Iterate",
"over",
"all",
"resources",
"within",
"the",
"SAM",
"template",
"optionally",
"filtering",
"by",
"type"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/sdk/template.py#L22-L38 | [
"def",
"iterate",
"(",
"self",
",",
"resource_type",
"=",
"None",
")",
":",
"for",
"logicalId",
",",
"resource_dict",
"in",
"self",
".",
"resources",
".",
"items",
"(",
")",
":",
"resource",
"=",
"SamResource",
"(",
"resource_dict",
")",
"needs_filter",
"=... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SamTemplate.set | Adds the resource to dictionary with given logical Id. It will overwrite, if the logicalId is already used.
:param string logicalId: Logical Id to set to
:param SamResource or dict resource: The actual resource data | samtranslator/sdk/template.py | def set(self, logicalId, resource):
"""
Adds the resource to dictionary with given logical Id. It will overwrite, if the logicalId is already used.
:param string logicalId: Logical Id to set to
:param SamResource or dict resource: The actual resource data
"""
resource_d... | def set(self, logicalId, resource):
"""
Adds the resource to dictionary with given logical Id. It will overwrite, if the logicalId is already used.
:param string logicalId: Logical Id to set to
:param SamResource or dict resource: The actual resource data
"""
resource_d... | [
"Adds",
"the",
"resource",
"to",
"dictionary",
"with",
"given",
"logical",
"Id",
".",
"It",
"will",
"overwrite",
"if",
"the",
"logicalId",
"is",
"already",
"used",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/sdk/template.py#L40-L52 | [
"def",
"set",
"(",
"self",
",",
"logicalId",
",",
"resource",
")",
":",
"resource_dict",
"=",
"resource",
"if",
"isinstance",
"(",
"resource",
",",
"SamResource",
")",
":",
"resource_dict",
"=",
"resource",
".",
"to_dict",
"(",
")",
"self",
".",
"resources... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SamTemplate.get | Gets the resource at the given logicalId if present
:param string logicalId: Id of the resource
:return SamResource: Resource, if available at the Id. None, otherwise | samtranslator/sdk/template.py | def get(self, logicalId):
"""
Gets the resource at the given logicalId if present
:param string logicalId: Id of the resource
:return SamResource: Resource, if available at the Id. None, otherwise
"""
if logicalId not in self.resources:
return None
r... | def get(self, logicalId):
"""
Gets the resource at the given logicalId if present
:param string logicalId: Id of the resource
:return SamResource: Resource, if available at the Id. None, otherwise
"""
if logicalId not in self.resources:
return None
r... | [
"Gets",
"the",
"resource",
"at",
"the",
"given",
"logicalId",
"if",
"present"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/sdk/template.py#L54-L64 | [
"def",
"get",
"(",
"self",
",",
"logicalId",
")",
":",
"if",
"logicalId",
"not",
"in",
"self",
".",
"resources",
":",
"return",
"None",
"return",
"SamResource",
"(",
"self",
".",
"resources",
".",
"get",
"(",
"logicalId",
")",
")"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | prepare_plugins | Creates & returns a plugins object with the given list of plugins installed. In addition to the given plugins,
we will also install a few "required" plugins that are necessary to provide complete support for SAM template spec.
:param plugins: list of samtranslator.plugins.BasePlugin plugins: List of plugins to... | samtranslator/translator/translator.py | def prepare_plugins(plugins, parameters={}):
"""
Creates & returns a plugins object with the given list of plugins installed. In addition to the given plugins,
we will also install a few "required" plugins that are necessary to provide complete support for SAM template spec.
:param plugins: list of sam... | def prepare_plugins(plugins, parameters={}):
"""
Creates & returns a plugins object with the given list of plugins installed. In addition to the given plugins,
we will also install a few "required" plugins that are necessary to provide complete support for SAM template spec.
:param plugins: list of sam... | [
"Creates",
"&",
"returns",
"a",
"plugins",
"object",
"with",
"the",
"given",
"list",
"of",
"plugins",
"installed",
".",
"In",
"addition",
"to",
"the",
"given",
"plugins",
"we",
"will",
"also",
"install",
"a",
"few",
"required",
"plugins",
"that",
"are",
"n... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/translator.py#L163-L188 | [
"def",
"prepare_plugins",
"(",
"plugins",
",",
"parameters",
"=",
"{",
"}",
")",
":",
"required_plugins",
"=",
"[",
"DefaultDefinitionBodyPlugin",
"(",
")",
",",
"make_implicit_api_plugin",
"(",
")",
",",
"GlobalsPlugin",
"(",
")",
",",
"make_policy_template_for_f... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Translator.translate | Loads the SAM resources from the given SAM manifest, replaces them with their corresponding
CloudFormation resources, and returns the resulting CloudFormation template.
:param dict sam_template: the SAM manifest, as loaded by json.load() or yaml.load(), or as provided by \
CloudFormatio... | samtranslator/translator/translator.py | def translate(self, sam_template, parameter_values):
"""Loads the SAM resources from the given SAM manifest, replaces them with their corresponding
CloudFormation resources, and returns the resulting CloudFormation template.
:param dict sam_template: the SAM manifest, as loaded by json.load() o... | def translate(self, sam_template, parameter_values):
"""Loads the SAM resources from the given SAM manifest, replaces them with their corresponding
CloudFormation resources, and returns the resulting CloudFormation template.
:param dict sam_template: the SAM manifest, as loaded by json.load() o... | [
"Loads",
"the",
"SAM",
"resources",
"from",
"the",
"given",
"SAM",
"manifest",
"replaces",
"them",
"with",
"their",
"corresponding",
"CloudFormation",
"resources",
"and",
"returns",
"the",
"resulting",
"CloudFormation",
"template",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/translator.py#L34-L122 | [
"def",
"translate",
"(",
"self",
",",
"sam_template",
",",
"parameter_values",
")",
":",
"sam_parameter_values",
"=",
"SamParameterValues",
"(",
"parameter_values",
")",
"sam_parameter_values",
".",
"add_default_parameter_values",
"(",
"sam_template",
")",
"sam_parameter_... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Translator._get_resources_to_iterate | Returns a list of resources to iterate, order them based on the following order:
1. AWS::Serverless::Function - because API Events need to modify the corresponding Serverless::Api resource.
2. AWS::Serverless::Api
3. Anything else
This is necessary because a Function resour... | samtranslator/translator/translator.py | def _get_resources_to_iterate(self, sam_template, macro_resolver):
"""
Returns a list of resources to iterate, order them based on the following order:
1. AWS::Serverless::Function - because API Events need to modify the corresponding Serverless::Api resource.
2. AWS::Serverless... | def _get_resources_to_iterate(self, sam_template, macro_resolver):
"""
Returns a list of resources to iterate, order them based on the following order:
1. AWS::Serverless::Function - because API Events need to modify the corresponding Serverless::Api resource.
2. AWS::Serverless... | [
"Returns",
"a",
"list",
"of",
"resources",
"to",
"iterate",
"order",
"them",
"based",
"on",
"the",
"following",
"order",
":"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/translator.py#L125-L160 | [
"def",
"_get_resources_to_iterate",
"(",
"self",
",",
"sam_template",
",",
"macro_resolver",
")",
":",
"functions",
"=",
"[",
"]",
"apis",
"=",
"[",
"]",
"others",
"=",
"[",
"]",
"resources",
"=",
"sam_template",
"[",
"\"Resources\"",
"]",
"for",
"logicalId"... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Resource.from_dict | Constructs a Resource object with the given logical id, based on the given resource dict. The resource dict
is the value associated with the logical id in a CloudFormation template's Resources section, and takes the
following format. ::
{
"Type": "<resource type>",
... | samtranslator/model/__init__.py | def from_dict(cls, logical_id, resource_dict, relative_id=None, sam_plugins=None):
"""Constructs a Resource object with the given logical id, based on the given resource dict. The resource dict
is the value associated with the logical id in a CloudFormation template's Resources section, and takes the
... | def from_dict(cls, logical_id, resource_dict, relative_id=None, sam_plugins=None):
"""Constructs a Resource object with the given logical id, based on the given resource dict. The resource dict
is the value associated with the logical id in a CloudFormation template's Resources section, and takes the
... | [
"Constructs",
"a",
"Resource",
"object",
"with",
"the",
"given",
"logical",
"id",
"based",
"on",
"the",
"given",
"resource",
"dict",
".",
"The",
"resource",
"dict",
"is",
"the",
"value",
"associated",
"with",
"the",
"logical",
"id",
"in",
"a",
"CloudFormatio... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L78-L126 | [
"def",
"from_dict",
"(",
"cls",
",",
"logical_id",
",",
"resource_dict",
",",
"relative_id",
"=",
"None",
",",
"sam_plugins",
"=",
"None",
")",
":",
"resource",
"=",
"cls",
"(",
"logical_id",
",",
"relative_id",
"=",
"relative_id",
")",
"resource",
".",
"_... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Resource._validate_logical_id | Validates that the provided logical id is an alphanumeric string.
:param str logical_id: the logical id to validate
:returns: True if the logical id is valid
:rtype: bool
:raises TypeError: if the logical id is invalid | samtranslator/model/__init__.py | def _validate_logical_id(cls, logical_id):
"""Validates that the provided logical id is an alphanumeric string.
:param str logical_id: the logical id to validate
:returns: True if the logical id is valid
:rtype: bool
:raises TypeError: if the logical id is invalid
"""
... | def _validate_logical_id(cls, logical_id):
"""Validates that the provided logical id is an alphanumeric string.
:param str logical_id: the logical id to validate
:returns: True if the logical id is valid
:rtype: bool
:raises TypeError: if the logical id is invalid
"""
... | [
"Validates",
"that",
"the",
"provided",
"logical",
"id",
"is",
"an",
"alphanumeric",
"string",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L129-L140 | [
"def",
"_validate_logical_id",
"(",
"cls",
",",
"logical_id",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r'^[A-Za-z0-9]+$'",
")",
"if",
"logical_id",
"is",
"not",
"None",
"and",
"pattern",
".",
"match",
"(",
"logical_id",
")",
":",
"return",
"Tr... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Resource._validate_resource_dict | Validates that the provided resource dict contains the correct Type string, and the required Properties dict.
:param dict resource_dict: the resource dict to validate
:returns: True if the resource dict has the expected format
:rtype: bool
:raises InvalidResourceException: if the resour... | samtranslator/model/__init__.py | def _validate_resource_dict(cls, logical_id, resource_dict):
"""Validates that the provided resource dict contains the correct Type string, and the required Properties dict.
:param dict resource_dict: the resource dict to validate
:returns: True if the resource dict has the expected format
... | def _validate_resource_dict(cls, logical_id, resource_dict):
"""Validates that the provided resource dict contains the correct Type string, and the required Properties dict.
:param dict resource_dict: the resource dict to validate
:returns: True if the resource dict has the expected format
... | [
"Validates",
"that",
"the",
"provided",
"resource",
"dict",
"contains",
"the",
"correct",
"Type",
"string",
"and",
"the",
"required",
"Properties",
"dict",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L143-L160 | [
"def",
"_validate_resource_dict",
"(",
"cls",
",",
"logical_id",
",",
"resource_dict",
")",
":",
"if",
"'Type'",
"not",
"in",
"resource_dict",
":",
"raise",
"InvalidResourceException",
"(",
"logical_id",
",",
"\"Resource dict missing key 'Type'.\"",
")",
"if",
"resour... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Resource.to_dict | Validates that the required properties for this Resource have been provided, then returns a dict
corresponding to the given Resource object. This dict will take the format of a single entry in the Resources
section of a CloudFormation template, and will take the following format. ::
{
... | samtranslator/model/__init__.py | def to_dict(self):
"""Validates that the required properties for this Resource have been provided, then returns a dict
corresponding to the given Resource object. This dict will take the format of a single entry in the Resources
section of a CloudFormation template, and will take the following f... | def to_dict(self):
"""Validates that the required properties for this Resource have been provided, then returns a dict
corresponding to the given Resource object. This dict will take the format of a single entry in the Resources
section of a CloudFormation template, and will take the following f... | [
"Validates",
"that",
"the",
"required",
"properties",
"for",
"this",
"Resource",
"have",
"been",
"provided",
"then",
"returns",
"a",
"dict",
"corresponding",
"to",
"the",
"given",
"Resource",
"object",
".",
"This",
"dict",
"will",
"take",
"the",
"format",
"of"... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L162-L187 | [
"def",
"to_dict",
"(",
"self",
")",
":",
"self",
".",
"validate_properties",
"(",
")",
"resource_dict",
"=",
"self",
".",
"_generate_resource_dict",
"(",
")",
"return",
"{",
"self",
".",
"logical_id",
":",
"resource_dict",
"}"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Resource._generate_resource_dict | Generates the resource dict for this Resource, the value associated with the logical id in a CloudFormation
template's Resources section.
:returns: the resource dict for this Resource
:rtype: dict | samtranslator/model/__init__.py | def _generate_resource_dict(self):
"""Generates the resource dict for this Resource, the value associated with the logical id in a CloudFormation
template's Resources section.
:returns: the resource dict for this Resource
:rtype: dict
"""
resource_dict = {}
reso... | def _generate_resource_dict(self):
"""Generates the resource dict for this Resource, the value associated with the logical id in a CloudFormation
template's Resources section.
:returns: the resource dict for this Resource
:rtype: dict
"""
resource_dict = {}
reso... | [
"Generates",
"the",
"resource",
"dict",
"for",
"this",
"Resource",
"the",
"value",
"associated",
"with",
"the",
"logical",
"id",
"in",
"a",
"CloudFormation",
"template",
"s",
"Resources",
"section",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L189-L213 | [
"def",
"_generate_resource_dict",
"(",
"self",
")",
":",
"resource_dict",
"=",
"{",
"}",
"resource_dict",
"[",
"'Type'",
"]",
"=",
"self",
".",
"resource_type",
"if",
"self",
".",
"depends_on",
":",
"resource_dict",
"[",
"'DependsOn'",
"]",
"=",
"self",
".",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Resource.validate_properties | Validates that the required properties for this Resource have been populated, and that all properties have
valid values.
:returns: True if all properties are valid
:rtype: bool
:raises TypeError: if any properties are invalid | samtranslator/model/__init__.py | def validate_properties(self):
"""Validates that the required properties for this Resource have been populated, and that all properties have
valid values.
:returns: True if all properties are valid
:rtype: bool
:raises TypeError: if any properties are invalid
"""
... | def validate_properties(self):
"""Validates that the required properties for this Resource have been populated, and that all properties have
valid values.
:returns: True if all properties are valid
:rtype: bool
:raises TypeError: if any properties are invalid
"""
... | [
"Validates",
"that",
"the",
"required",
"properties",
"for",
"this",
"Resource",
"have",
"been",
"populated",
"and",
"that",
"all",
"properties",
"have",
"valid",
"values",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L230-L255 | [
"def",
"validate_properties",
"(",
"self",
")",
":",
"for",
"name",
",",
"property_type",
"in",
"self",
".",
"property_types",
".",
"items",
"(",
")",
":",
"value",
"=",
"getattr",
"(",
"self",
",",
"name",
")",
"# If the property value is an intrinsic function,... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Resource.set_resource_attribute | Sets attributes on resource. Resource attributes are top-level entries of a CloudFormation resource
that exist outside of the Properties dictionary
:param attr: Attribute name
:param value: Attribute value
:return: None
:raises KeyError if `attr` is not in the supported attribut... | samtranslator/model/__init__.py | def set_resource_attribute(self, attr, value):
"""Sets attributes on resource. Resource attributes are top-level entries of a CloudFormation resource
that exist outside of the Properties dictionary
:param attr: Attribute name
:param value: Attribute value
:return: None
:... | def set_resource_attribute(self, attr, value):
"""Sets attributes on resource. Resource attributes are top-level entries of a CloudFormation resource
that exist outside of the Properties dictionary
:param attr: Attribute name
:param value: Attribute value
:return: None
:... | [
"Sets",
"attributes",
"on",
"resource",
".",
"Resource",
"attributes",
"are",
"top",
"-",
"level",
"entries",
"of",
"a",
"CloudFormation",
"resource",
"that",
"exist",
"outside",
"of",
"the",
"Properties",
"dictionary"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L257-L270 | [
"def",
"set_resource_attribute",
"(",
"self",
",",
"attr",
",",
"value",
")",
":",
"if",
"attr",
"not",
"in",
"self",
".",
"_supported_resource_attributes",
":",
"raise",
"KeyError",
"(",
"\"Unsupported resource attribute specified: %s\"",
"%",
"attr",
")",
"self",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Resource.get_resource_attribute | Gets the resource attribute if available
:param attr: Name of the attribute
:return: Value of the attribute, if set in the resource. None otherwise | samtranslator/model/__init__.py | def get_resource_attribute(self, attr):
"""Gets the resource attribute if available
:param attr: Name of the attribute
:return: Value of the attribute, if set in the resource. None otherwise
"""
if attr not in self.resource_attributes:
raise KeyError("%s is not in re... | def get_resource_attribute(self, attr):
"""Gets the resource attribute if available
:param attr: Name of the attribute
:return: Value of the attribute, if set in the resource. None otherwise
"""
if attr not in self.resource_attributes:
raise KeyError("%s is not in re... | [
"Gets",
"the",
"resource",
"attribute",
"if",
"available"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L272-L281 | [
"def",
"get_resource_attribute",
"(",
"self",
",",
"attr",
")",
":",
"if",
"attr",
"not",
"in",
"self",
".",
"resource_attributes",
":",
"raise",
"KeyError",
"(",
"\"%s is not in resource attributes\"",
"%",
"attr",
")",
"return",
"self",
".",
"resource_attributes... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Resource.get_runtime_attr | Returns a CloudFormation construct that provides value for this attribute. If the resource does not provide
this attribute, then this method raises an exception
:return: Dictionary that will resolve to value of the attribute when CloudFormation stack update is executed | samtranslator/model/__init__.py | def get_runtime_attr(self, attr_name):
"""
Returns a CloudFormation construct that provides value for this attribute. If the resource does not provide
this attribute, then this method raises an exception
:return: Dictionary that will resolve to value of the attribute when CloudFormation... | def get_runtime_attr(self, attr_name):
"""
Returns a CloudFormation construct that provides value for this attribute. If the resource does not provide
this attribute, then this method raises an exception
:return: Dictionary that will resolve to value of the attribute when CloudFormation... | [
"Returns",
"a",
"CloudFormation",
"construct",
"that",
"provides",
"value",
"for",
"this",
"attribute",
".",
"If",
"the",
"resource",
"does",
"not",
"provide",
"this",
"attribute",
"then",
"this",
"method",
"raises",
"an",
"exception"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L295-L306 | [
"def",
"get_runtime_attr",
"(",
"self",
",",
"attr_name",
")",
":",
"if",
"attr_name",
"in",
"self",
".",
"runtime_attrs",
":",
"return",
"self",
".",
"runtime_attrs",
"[",
"attr_name",
"]",
"(",
"self",
")",
"else",
":",
"raise",
"NotImplementedError",
"(",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SamResourceMacro.get_resource_references | Constructs the list of supported resource references by going through the list of CFN resources generated
by to_cloudformation() on this SAM resource. Each SAM resource must provide a map of properties that it
supports and the type of CFN resource this property resolves to.
:param list of Resou... | samtranslator/model/__init__.py | def get_resource_references(self, generated_cfn_resources, supported_resource_refs):
"""
Constructs the list of supported resource references by going through the list of CFN resources generated
by to_cloudformation() on this SAM resource. Each SAM resource must provide a map of properties that ... | def get_resource_references(self, generated_cfn_resources, supported_resource_refs):
"""
Constructs the list of supported resource references by going through the list of CFN resources generated
by to_cloudformation() on this SAM resource. Each SAM resource must provide a map of properties that ... | [
"Constructs",
"the",
"list",
"of",
"supported",
"resource",
"references",
"by",
"going",
"through",
"the",
"list",
"of",
"CFN",
"resources",
"generated",
"by",
"to_cloudformation",
"()",
"on",
"this",
"SAM",
"resource",
".",
"Each",
"SAM",
"resource",
"must",
... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L383-L406 | [
"def",
"get_resource_references",
"(",
"self",
",",
"generated_cfn_resources",
",",
"supported_resource_refs",
")",
":",
"if",
"supported_resource_refs",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"`supported_resource_refs` object is required\"",
")",
"# Create a map of... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ResourceTypeResolver.resolve_resource_type | Returns the Resource class corresponding to the 'Type' key in the given resource dict.
:param dict resource_dict: the resource dict to resolve
:returns: the resolved Resource class
:rtype: class | samtranslator/model/__init__.py | def resolve_resource_type(self, resource_dict):
"""Returns the Resource class corresponding to the 'Type' key in the given resource dict.
:param dict resource_dict: the resource dict to resolve
:returns: the resolved Resource class
:rtype: class
"""
if not self.can_resol... | def resolve_resource_type(self, resource_dict):
"""Returns the Resource class corresponding to the 'Type' key in the given resource dict.
:param dict resource_dict: the resource dict to resolve
:returns: the resolved Resource class
:rtype: class
"""
if not self.can_resol... | [
"Returns",
"the",
"Resource",
"class",
"corresponding",
"to",
"the",
"Type",
"key",
"in",
"the",
"given",
"resource",
"dict",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L469-L481 | [
"def",
"resolve_resource_type",
"(",
"self",
",",
"resource_dict",
")",
":",
"if",
"not",
"self",
".",
"can_resolve",
"(",
"resource_dict",
")",
":",
"raise",
"TypeError",
"(",
"\"Resource dict has missing or invalid value for key Type. Event Type is: {}.\"",
".",
"format... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | build_response_card | Build a responseCard with a title, subtitle, and an optional set of options which should be displayed as buttons. | examples/apps/lex-make-appointment-python/lambda_function.py | def build_response_card(title, subtitle, options):
"""
Build a responseCard with a title, subtitle, and an optional set of options which should be displayed as buttons.
"""
buttons = None
if options is not None:
buttons = []
for i in range(min(5, len(options))):
buttons.a... | def build_response_card(title, subtitle, options):
"""
Build a responseCard with a title, subtitle, and an optional set of options which should be displayed as buttons.
"""
buttons = None
if options is not None:
buttons = []
for i in range(min(5, len(options))):
buttons.a... | [
"Build",
"a",
"responseCard",
"with",
"a",
"title",
"subtitle",
"and",
"an",
"optional",
"set",
"of",
"options",
"which",
"should",
"be",
"displayed",
"as",
"buttons",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L75-L93 | [
"def",
"build_response_card",
"(",
"title",
",",
"subtitle",
",",
"options",
")",
":",
"buttons",
"=",
"None",
"if",
"options",
"is",
"not",
"None",
":",
"buttons",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"min",
"(",
"5",
",",
"len",
"(",
"o... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | get_random_int | Returns a random integer between min (included) and max (excluded) | examples/apps/lex-make-appointment-python/lambda_function.py | def get_random_int(minimum, maximum):
"""
Returns a random integer between min (included) and max (excluded)
"""
min_int = math.ceil(minimum)
max_int = math.floor(maximum)
return random.randint(min_int, max_int - 1) | def get_random_int(minimum, maximum):
"""
Returns a random integer between min (included) and max (excluded)
"""
min_int = math.ceil(minimum)
max_int = math.floor(maximum)
return random.randint(min_int, max_int - 1) | [
"Returns",
"a",
"random",
"integer",
"between",
"min",
"(",
"included",
")",
"and",
"max",
"(",
"excluded",
")"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L125-L132 | [
"def",
"get_random_int",
"(",
"minimum",
",",
"maximum",
")",
":",
"min_int",
"=",
"math",
".",
"ceil",
"(",
"minimum",
")",
"max_int",
"=",
"math",
".",
"floor",
"(",
"maximum",
")",
"return",
"random",
".",
"randint",
"(",
"min_int",
",",
"max_int",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | get_availabilities | Helper function which in a full implementation would feed into a backend API to provide query schedule availability.
The output of this function is an array of 30 minute periods of availability, expressed in ISO-8601 time format.
In order to enable quick demonstration of all possible conversation paths suppor... | examples/apps/lex-make-appointment-python/lambda_function.py | def get_availabilities(date):
"""
Helper function which in a full implementation would feed into a backend API to provide query schedule availability.
The output of this function is an array of 30 minute periods of availability, expressed in ISO-8601 time format.
In order to enable quick demonstration... | def get_availabilities(date):
"""
Helper function which in a full implementation would feed into a backend API to provide query schedule availability.
The output of this function is an array of 30 minute periods of availability, expressed in ISO-8601 time format.
In order to enable quick demonstration... | [
"Helper",
"function",
"which",
"in",
"a",
"full",
"implementation",
"would",
"feed",
"into",
"a",
"backend",
"API",
"to",
"provide",
"query",
"schedule",
"availability",
".",
"The",
"output",
"of",
"this",
"function",
"is",
"an",
"array",
"of",
"30",
"minute... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L135-L169 | [
"def",
"get_availabilities",
"(",
"date",
")",
":",
"day_of_week",
"=",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"date",
")",
".",
"weekday",
"(",
")",
"availabilities",
"=",
"[",
"]",
"available_probability",
"=",
"0.3",
"if",
"day_of_week",
"==",
"0... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | is_available | Helper function to check if the given time and duration fits within a known set of availability windows.
Duration is assumed to be one of 30, 60 (meaning minutes). Availabilities is expected to contain entries of the format HH:MM. | examples/apps/lex-make-appointment-python/lambda_function.py | def is_available(time, duration, availabilities):
"""
Helper function to check if the given time and duration fits within a known set of availability windows.
Duration is assumed to be one of 30, 60 (meaning minutes). Availabilities is expected to contain entries of the format HH:MM.
"""
if duratio... | def is_available(time, duration, availabilities):
"""
Helper function to check if the given time and duration fits within a known set of availability windows.
Duration is assumed to be one of 30, 60 (meaning minutes). Availabilities is expected to contain entries of the format HH:MM.
"""
if duratio... | [
"Helper",
"function",
"to",
"check",
"if",
"the",
"given",
"time",
"and",
"duration",
"fits",
"within",
"a",
"known",
"set",
"of",
"availability",
"windows",
".",
"Duration",
"is",
"assumed",
"to",
"be",
"one",
"of",
"30",
"60",
"(",
"meaning",
"minutes",
... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L172-L184 | [
"def",
"is_available",
"(",
"time",
",",
"duration",
",",
"availabilities",
")",
":",
"if",
"duration",
"==",
"30",
":",
"return",
"time",
"in",
"availabilities",
"elif",
"duration",
"==",
"60",
":",
"second_half_hour_time",
"=",
"increment_time_by_thirty_mins",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | get_availabilities_for_duration | Helper function to return the windows of availability of the given duration, when provided a set of 30 minute windows. | examples/apps/lex-make-appointment-python/lambda_function.py | def get_availabilities_for_duration(duration, availabilities):
"""
Helper function to return the windows of availability of the given duration, when provided a set of 30 minute windows.
"""
duration_availabilities = []
start_time = '10:00'
while start_time != '17:00':
if start_time in av... | def get_availabilities_for_duration(duration, availabilities):
"""
Helper function to return the windows of availability of the given duration, when provided a set of 30 minute windows.
"""
duration_availabilities = []
start_time = '10:00'
while start_time != '17:00':
if start_time in av... | [
"Helper",
"function",
"to",
"return",
"the",
"windows",
"of",
"availability",
"of",
"the",
"given",
"duration",
"when",
"provided",
"a",
"set",
"of",
"30",
"minute",
"windows",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L192-L207 | [
"def",
"get_availabilities_for_duration",
"(",
"duration",
",",
"availabilities",
")",
":",
"duration_availabilities",
"=",
"[",
"]",
"start_time",
"=",
"'10:00'",
"while",
"start_time",
"!=",
"'17:00'",
":",
"if",
"start_time",
"in",
"availabilities",
":",
"if",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | build_available_time_string | Build a string eliciting for a possible time slot among at least two availabilities. | examples/apps/lex-make-appointment-python/lambda_function.py | def build_available_time_string(availabilities):
"""
Build a string eliciting for a possible time slot among at least two availabilities.
"""
prefix = 'We have availabilities at '
if len(availabilities) > 3:
prefix = 'We have plenty of availability, including '
prefix += build_time_outp... | def build_available_time_string(availabilities):
"""
Build a string eliciting for a possible time slot among at least two availabilities.
"""
prefix = 'We have availabilities at '
if len(availabilities) > 3:
prefix = 'We have plenty of availability, including '
prefix += build_time_outp... | [
"Build",
"a",
"string",
"eliciting",
"for",
"a",
"possible",
"time",
"slot",
"among",
"at",
"least",
"two",
"availabilities",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L261-L273 | [
"def",
"build_available_time_string",
"(",
"availabilities",
")",
":",
"prefix",
"=",
"'We have availabilities at '",
"if",
"len",
"(",
"availabilities",
")",
">",
"3",
":",
"prefix",
"=",
"'We have plenty of availability, including '",
"prefix",
"+=",
"build_time_output_... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | build_options | Build a list of potential options for a given slot, to be used in responseCard generation. | examples/apps/lex-make-appointment-python/lambda_function.py | def build_options(slot, appointment_type, date, booking_map):
"""
Build a list of potential options for a given slot, to be used in responseCard generation.
"""
day_strings = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
if slot == 'AppointmentType':
return [
{'text': 'cleani... | def build_options(slot, appointment_type, date, booking_map):
"""
Build a list of potential options for a given slot, to be used in responseCard generation.
"""
day_strings = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
if slot == 'AppointmentType':
return [
{'text': 'cleani... | [
"Build",
"a",
"list",
"of",
"potential",
"options",
"for",
"a",
"given",
"slot",
"to",
"be",
"used",
"in",
"responseCard",
"generation",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L276-L314 | [
"def",
"build_options",
"(",
"slot",
",",
"appointment_type",
",",
"date",
",",
"booking_map",
")",
":",
"day_strings",
"=",
"[",
"'Mon'",
",",
"'Tue'",
",",
"'Wed'",
",",
"'Thu'",
",",
"'Fri'",
",",
"'Sat'",
",",
"'Sun'",
"]",
"if",
"slot",
"==",
"'Ap... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | make_appointment | Performs dialog management and fulfillment for booking a dentists appointment.
Beyond fulfillment, the implementation for this intent demonstrates the following:
1) Use of elicitSlot in slot validation and re-prompting
2) Use of confirmIntent to support the confirmation of inferred slot values, when confir... | examples/apps/lex-make-appointment-python/lambda_function.py | def make_appointment(intent_request):
"""
Performs dialog management and fulfillment for booking a dentists appointment.
Beyond fulfillment, the implementation for this intent demonstrates the following:
1) Use of elicitSlot in slot validation and re-prompting
2) Use of confirmIntent to support the... | def make_appointment(intent_request):
"""
Performs dialog management and fulfillment for booking a dentists appointment.
Beyond fulfillment, the implementation for this intent demonstrates the following:
1) Use of elicitSlot in slot validation and re-prompting
2) Use of confirmIntent to support the... | [
"Performs",
"dialog",
"management",
"and",
"fulfillment",
"for",
"booking",
"a",
"dentists",
"appointment",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L320-L476 | [
"def",
"make_appointment",
"(",
"intent_request",
")",
":",
"appointment_type",
"=",
"intent_request",
"[",
"'currentIntent'",
"]",
"[",
"'slots'",
"]",
"[",
"'AppointmentType'",
"]",
"date",
"=",
"intent_request",
"[",
"'currentIntent'",
"]",
"[",
"'slots'",
"]",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | dispatch | Called when the user specifies an intent for this bot. | examples/apps/lex-make-appointment-python/lambda_function.py | def dispatch(intent_request):
"""
Called when the user specifies an intent for this bot.
"""
logger.debug('dispatch userId={}, intentName={}'.format(intent_request['userId'], intent_request['currentIntent']['name']))
intent_name = intent_request['currentIntent']['name']
# Dispatch to your bot... | def dispatch(intent_request):
"""
Called when the user specifies an intent for this bot.
"""
logger.debug('dispatch userId={}, intentName={}'.format(intent_request['userId'], intent_request['currentIntent']['name']))
intent_name = intent_request['currentIntent']['name']
# Dispatch to your bot... | [
"Called",
"when",
"the",
"user",
"specifies",
"an",
"intent",
"for",
"this",
"bot",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L482-L494 | [
"def",
"dispatch",
"(",
"intent_request",
")",
":",
"logger",
".",
"debug",
"(",
"'dispatch userId={}, intentName={}'",
".",
"format",
"(",
"intent_request",
"[",
"'userId'",
"]",
",",
"intent_request",
"[",
"'currentIntent'",
"]",
"[",
"'name'",
"]",
")",
")",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | lambda_handler | Demonstrates a simple HTTP endpoint using API Gateway. You have full
access to the request and response payload, including headers and
status code.
TableName provided by template.yaml.
To scan a DynamoDB table, make a GET request with optional query string parameter.
To put, update, or delete an item, m... | examples/apps/microservice-http-endpoint-python3/lambda_function.py | def lambda_handler(event, context):
'''Demonstrates a simple HTTP endpoint using API Gateway. You have full
access to the request and response payload, including headers and
status code.
TableName provided by template.yaml.
To scan a DynamoDB table, make a GET request with optional query string param... | def lambda_handler(event, context):
'''Demonstrates a simple HTTP endpoint using API Gateway. You have full
access to the request and response payload, including headers and
status code.
TableName provided by template.yaml.
To scan a DynamoDB table, make a GET request with optional query string param... | [
"Demonstrates",
"a",
"simple",
"HTTP",
"endpoint",
"using",
"API",
"Gateway",
".",
"You",
"have",
"full",
"access",
"to",
"the",
"request",
"and",
"response",
"payload",
"including",
"headers",
"and",
"status",
"code",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/microservice-http-endpoint-python3/lambda_function.py#L21-L46 | [
"def",
"lambda_handler",
"(",
"event",
",",
"context",
")",
":",
"print",
"(",
"\"Received event: \"",
"+",
"json",
".",
"dumps",
"(",
"event",
",",
"indent",
"=",
"2",
")",
")",
"operations",
"=",
"{",
"'DELETE'",
":",
"lambda",
"dynamo",
",",
"x",
":... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | lambda_handler | Demonstrates a simple HTTP endpoint using API Gateway. You have full
access to the request and response payload, including headers and
status code.
To scan a DynamoDB table, make a GET request with the TableName as a
query string parameter. To put, update, or delete an item, make a POST,
PUT, or DE... | examples/apps/microservice-http-endpoint-python/lambda_function.py | def lambda_handler(event, context):
'''Demonstrates a simple HTTP endpoint using API Gateway. You have full
access to the request and response payload, including headers and
status code.
To scan a DynamoDB table, make a GET request with the TableName as a
query string parameter. To put, update, or ... | def lambda_handler(event, context):
'''Demonstrates a simple HTTP endpoint using API Gateway. You have full
access to the request and response payload, including headers and
status code.
To scan a DynamoDB table, make a GET request with the TableName as a
query string parameter. To put, update, or ... | [
"Demonstrates",
"a",
"simple",
"HTTP",
"endpoint",
"using",
"API",
"Gateway",
".",
"You",
"have",
"full",
"access",
"to",
"the",
"request",
"and",
"response",
"payload",
"including",
"headers",
"and",
"status",
"code",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/microservice-http-endpoint-python/lambda_function.py#L20-L44 | [
"def",
"lambda_handler",
"(",
"event",
",",
"context",
")",
":",
"#print(\"Received event: \" + json.dumps(event, indent=2))",
"operations",
"=",
"{",
"'DELETE'",
":",
"lambda",
"dynamo",
",",
"x",
":",
"dynamo",
".",
"delete_item",
"(",
"*",
"*",
"x",
")",
",",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | make_combined_condition | Makes a combined condition using Fn::Or. Since Fn::Or only accepts up to 10 conditions,
this method optionally creates multiple conditions. These conditions are named based on
the condition_name parameter that is passed into the method.
:param list conditions_list: list of conditions
:param string cond... | samtranslator/model/intrinsics.py | def make_combined_condition(conditions_list, condition_name):
"""
Makes a combined condition using Fn::Or. Since Fn::Or only accepts up to 10 conditions,
this method optionally creates multiple conditions. These conditions are named based on
the condition_name parameter that is passed into the method.
... | def make_combined_condition(conditions_list, condition_name):
"""
Makes a combined condition using Fn::Or. Since Fn::Or only accepts up to 10 conditions,
this method optionally creates multiple conditions. These conditions are named based on
the condition_name parameter that is passed into the method.
... | [
"Makes",
"a",
"combined",
"condition",
"using",
"Fn",
"::",
"Or",
".",
"Since",
"Fn",
"::",
"Or",
"only",
"accepts",
"up",
"to",
"10",
"conditions",
"this",
"method",
"optionally",
"creates",
"multiple",
"conditions",
".",
"These",
"conditions",
"are",
"name... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/intrinsics.py#L66-L99 | [
"def",
"make_combined_condition",
"(",
"conditions_list",
",",
"condition_name",
")",
":",
"if",
"len",
"(",
"conditions_list",
")",
"<",
"2",
":",
"# Can't make a condition if <2 conditions provided.",
"return",
"None",
"# Total number of conditions allows in an Fn::Or stateme... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | is_instrinsic | Checks if the given input is an intrinsic function dictionary. Intrinsic function is a dictionary with single
key that is the name of the intrinsics.
:param input: Input value to check if it is an intrinsic
:return: True, if yes | samtranslator/model/intrinsics.py | def is_instrinsic(input):
"""
Checks if the given input is an intrinsic function dictionary. Intrinsic function is a dictionary with single
key that is the name of the intrinsics.
:param input: Input value to check if it is an intrinsic
:return: True, if yes
"""
if input is not None \
... | def is_instrinsic(input):
"""
Checks if the given input is an intrinsic function dictionary. Intrinsic function is a dictionary with single
key that is the name of the intrinsics.
:param input: Input value to check if it is an intrinsic
:return: True, if yes
"""
if input is not None \
... | [
"Checks",
"if",
"the",
"given",
"input",
"is",
"an",
"intrinsic",
"function",
"dictionary",
".",
"Intrinsic",
"function",
"is",
"a",
"dictionary",
"with",
"single",
"key",
"that",
"is",
"the",
"name",
"of",
"the",
"intrinsics",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/intrinsics.py#L124-L140 | [
"def",
"is_instrinsic",
"(",
"input",
")",
":",
"if",
"input",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"input",
",",
"dict",
")",
"and",
"len",
"(",
"input",
")",
"==",
"1",
":",
"key",
"=",
"list",
"(",
"input",
".",
"keys",
"(",
")",
")"... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Action.can_handle | Validates that the input dictionary contains only one key and is of the given intrinsic_name
:param input_dict: Input dictionary representing the intrinsic function
:return: True if it matches expected structure, False otherwise | samtranslator/intrinsics/actions.py | def can_handle(self, input_dict):
"""
Validates that the input dictionary contains only one key and is of the given intrinsic_name
:param input_dict: Input dictionary representing the intrinsic function
:return: True if it matches expected structure, False otherwise
"""
... | def can_handle(self, input_dict):
"""
Validates that the input dictionary contains only one key and is of the given intrinsic_name
:param input_dict: Input dictionary representing the intrinsic function
:return: True if it matches expected structure, False otherwise
"""
... | [
"Validates",
"that",
"the",
"input",
"dictionary",
"contains",
"only",
"one",
"key",
"and",
"is",
"of",
"the",
"given",
"intrinsic_name"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L41-L52 | [
"def",
"can_handle",
"(",
"self",
",",
"input_dict",
")",
":",
"return",
"input_dict",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"input_dict",
",",
"dict",
")",
"and",
"len",
"(",
"input_dict",
")",
"==",
"1",
"and",
"self",
".",
"intrinsic_name",
"... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | Action._parse_resource_reference | Splits a resource reference of structure "LogicalId.Property" and returns the "LogicalId" and "Property"
separately.
:param string ref_value: Input reference value which *may* contain the structure "LogicalId.Property"
:return string, string: Returns two values - logical_id, property. If the in... | samtranslator/intrinsics/actions.py | def _parse_resource_reference(cls, ref_value):
"""
Splits a resource reference of structure "LogicalId.Property" and returns the "LogicalId" and "Property"
separately.
:param string ref_value: Input reference value which *may* contain the structure "LogicalId.Property"
:return s... | def _parse_resource_reference(cls, ref_value):
"""
Splits a resource reference of structure "LogicalId.Property" and returns the "LogicalId" and "Property"
separately.
:param string ref_value: Input reference value which *may* contain the structure "LogicalId.Property"
:return s... | [
"Splits",
"a",
"resource",
"reference",
"of",
"structure",
"LogicalId",
".",
"Property",
"and",
"returns",
"the",
"LogicalId",
"and",
"Property",
"separately",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L55-L76 | [
"def",
"_parse_resource_reference",
"(",
"cls",
",",
"ref_value",
")",
":",
"no_result",
"=",
"(",
"None",
",",
"None",
")",
"if",
"not",
"isinstance",
"(",
"ref_value",
",",
"string_types",
")",
":",
"return",
"no_result",
"splits",
"=",
"ref_value",
".",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | RefAction.resolve_parameter_refs | Resolves references that are present in the parameters and returns the value. If it is not in parameters,
this method simply returns the input unchanged.
:param input_dict: Dictionary representing the Ref function. Must contain only one key and it should be "Ref".
Ex: {Ref: "foo"}
... | samtranslator/intrinsics/actions.py | def resolve_parameter_refs(self, input_dict, parameters):
"""
Resolves references that are present in the parameters and returns the value. If it is not in parameters,
this method simply returns the input unchanged.
:param input_dict: Dictionary representing the Ref function. Must conta... | def resolve_parameter_refs(self, input_dict, parameters):
"""
Resolves references that are present in the parameters and returns the value. If it is not in parameters,
this method simply returns the input unchanged.
:param input_dict: Dictionary representing the Ref function. Must conta... | [
"Resolves",
"references",
"that",
"are",
"present",
"in",
"the",
"parameters",
"and",
"returns",
"the",
"value",
".",
"If",
"it",
"is",
"not",
"in",
"parameters",
"this",
"method",
"simply",
"returns",
"the",
"input",
"unchanged",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L82-L104 | [
"def",
"resolve_parameter_refs",
"(",
"self",
",",
"input_dict",
",",
"parameters",
")",
":",
"if",
"not",
"self",
".",
"can_handle",
"(",
"input_dict",
")",
":",
"return",
"input_dict",
"param_name",
"=",
"input_dict",
"[",
"self",
".",
"intrinsic_name",
"]",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | RefAction.resolve_resource_refs | Resolves references to some property of a resource. These are runtime properties which can't be converted
to a value here. Instead we output another reference that will more actually resolve to the value when
executed via CloudFormation
Example:
{"Ref": "LogicalId.Property"} => {"Re... | samtranslator/intrinsics/actions.py | def resolve_resource_refs(self, input_dict, supported_resource_refs):
"""
Resolves references to some property of a resource. These are runtime properties which can't be converted
to a value here. Instead we output another reference that will more actually resolve to the value when
execu... | def resolve_resource_refs(self, input_dict, supported_resource_refs):
"""
Resolves references to some property of a resource. These are runtime properties which can't be converted
to a value here. Instead we output another reference that will more actually resolve to the value when
execu... | [
"Resolves",
"references",
"to",
"some",
"property",
"of",
"a",
"resource",
".",
"These",
"are",
"runtime",
"properties",
"which",
"can",
"t",
"be",
"converted",
"to",
"a",
"value",
"here",
".",
"Instead",
"we",
"output",
"another",
"reference",
"that",
"will... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L106-L137 | [
"def",
"resolve_resource_refs",
"(",
"self",
",",
"input_dict",
",",
"supported_resource_refs",
")",
":",
"if",
"not",
"self",
".",
"can_handle",
"(",
"input_dict",
")",
":",
"return",
"input_dict",
"ref_value",
"=",
"input_dict",
"[",
"self",
".",
"intrinsic_na... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | RefAction.resolve_resource_id_refs | Updates references to the old logical id of a resource to the new (generated) logical id.
Example:
{"Ref": "MyLayer"} => {"Ref": "MyLayerABC123"}
:param dict input_dict: Dictionary representing the Ref function to be resolved.
:param dict supported_resource_id_refs: Dictionary that... | samtranslator/intrinsics/actions.py | def resolve_resource_id_refs(self, input_dict, supported_resource_id_refs):
"""
Updates references to the old logical id of a resource to the new (generated) logical id.
Example:
{"Ref": "MyLayer"} => {"Ref": "MyLayerABC123"}
:param dict input_dict: Dictionary representing ... | def resolve_resource_id_refs(self, input_dict, supported_resource_id_refs):
"""
Updates references to the old logical id of a resource to the new (generated) logical id.
Example:
{"Ref": "MyLayer"} => {"Ref": "MyLayerABC123"}
:param dict input_dict: Dictionary representing ... | [
"Updates",
"references",
"to",
"the",
"old",
"logical",
"id",
"of",
"a",
"resource",
"to",
"the",
"new",
"(",
"generated",
")",
"logical",
"id",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L139-L166 | [
"def",
"resolve_resource_id_refs",
"(",
"self",
",",
"input_dict",
",",
"supported_resource_id_refs",
")",
":",
"if",
"not",
"self",
".",
"can_handle",
"(",
"input_dict",
")",
":",
"return",
"input_dict",
"ref_value",
"=",
"input_dict",
"[",
"self",
".",
"intrin... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SubAction.resolve_parameter_refs | Substitute references found within the string of `Fn::Sub` intrinsic function
:param input_dict: Dictionary representing the Fn::Sub function. Must contain only one key and it should be
`Fn::Sub`. Ex: {"Fn::Sub": ...}
:param parameters: Dictionary of parameter values for substitution
... | samtranslator/intrinsics/actions.py | def resolve_parameter_refs(self, input_dict, parameters):
"""
Substitute references found within the string of `Fn::Sub` intrinsic function
:param input_dict: Dictionary representing the Fn::Sub function. Must contain only one key and it should be
`Fn::Sub`. Ex: {"Fn::Sub": ...}
... | def resolve_parameter_refs(self, input_dict, parameters):
"""
Substitute references found within the string of `Fn::Sub` intrinsic function
:param input_dict: Dictionary representing the Fn::Sub function. Must contain only one key and it should be
`Fn::Sub`. Ex: {"Fn::Sub": ...}
... | [
"Substitute",
"references",
"found",
"within",
"the",
"string",
"of",
"Fn",
"::",
"Sub",
"intrinsic",
"function"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L172-L194 | [
"def",
"resolve_parameter_refs",
"(",
"self",
",",
"input_dict",
",",
"parameters",
")",
":",
"def",
"do_replacement",
"(",
"full_ref",
",",
"prop_name",
")",
":",
"\"\"\"\n Replace parameter references with actual value. Return value of this method is directly replace... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SubAction.resolve_resource_refs | Resolves reference to some property of a resource. Inside string to be substituted, there could be either a
"Ref" or a "GetAtt" usage of this property. They have to be handled differently.
Ref usages are directly converted to a Ref on the resolved value. GetAtt usages are split under the assumption
... | samtranslator/intrinsics/actions.py | def resolve_resource_refs(self, input_dict, supported_resource_refs):
"""
Resolves reference to some property of a resource. Inside string to be substituted, there could be either a
"Ref" or a "GetAtt" usage of this property. They have to be handled differently.
Ref usages are directly ... | def resolve_resource_refs(self, input_dict, supported_resource_refs):
"""
Resolves reference to some property of a resource. Inside string to be substituted, there could be either a
"Ref" or a "GetAtt" usage of this property. They have to be handled differently.
Ref usages are directly ... | [
"Resolves",
"reference",
"to",
"some",
"property",
"of",
"a",
"resource",
".",
"Inside",
"string",
"to",
"be",
"substituted",
"there",
"could",
"be",
"either",
"a",
"Ref",
"or",
"a",
"GetAtt",
"usage",
"of",
"this",
"property",
".",
"They",
"have",
"to",
... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L196-L253 | [
"def",
"resolve_resource_refs",
"(",
"self",
",",
"input_dict",
",",
"supported_resource_refs",
")",
":",
"def",
"do_replacement",
"(",
"full_ref",
",",
"ref_value",
")",
":",
"\"\"\"\n Perform the appropriate replacement to handle ${LogicalId.Property} type references... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SubAction.resolve_resource_id_refs | Resolves reference to some property of a resource. Inside string to be substituted, there could be either a
"Ref" or a "GetAtt" usage of this property. They have to be handled differently.
Ref usages are directly converted to a Ref on the resolved value. GetAtt usages are split under the assumption
... | samtranslator/intrinsics/actions.py | def resolve_resource_id_refs(self, input_dict, supported_resource_id_refs):
"""
Resolves reference to some property of a resource. Inside string to be substituted, there could be either a
"Ref" or a "GetAtt" usage of this property. They have to be handled differently.
Ref usages are dir... | def resolve_resource_id_refs(self, input_dict, supported_resource_id_refs):
"""
Resolves reference to some property of a resource. Inside string to be substituted, there could be either a
"Ref" or a "GetAtt" usage of this property. They have to be handled differently.
Ref usages are dir... | [
"Resolves",
"reference",
"to",
"some",
"property",
"of",
"a",
"resource",
".",
"Inside",
"string",
"to",
"be",
"substituted",
"there",
"could",
"be",
"either",
"a",
"Ref",
"or",
"a",
"GetAtt",
"usage",
"of",
"this",
"property",
".",
"They",
"have",
"to",
... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L255-L309 | [
"def",
"resolve_resource_id_refs",
"(",
"self",
",",
"input_dict",
",",
"supported_resource_id_refs",
")",
":",
"def",
"do_replacement",
"(",
"full_ref",
",",
"ref_value",
")",
":",
"\"\"\"\n Perform the appropriate replacement to handle ${LogicalId} type references in... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SubAction._handle_sub_action | Handles resolving replacements in the Sub action based on the handler that is passed as an input.
:param input_dict: Dictionary to be resolved
:param supported_values: One of several different objects that contain the supported values that
need to be changed. See each method above for speci... | samtranslator/intrinsics/actions.py | def _handle_sub_action(self, input_dict, handler):
"""
Handles resolving replacements in the Sub action based on the handler that is passed as an input.
:param input_dict: Dictionary to be resolved
:param supported_values: One of several different objects that contain the supported valu... | def _handle_sub_action(self, input_dict, handler):
"""
Handles resolving replacements in the Sub action based on the handler that is passed as an input.
:param input_dict: Dictionary to be resolved
:param supported_values: One of several different objects that contain the supported valu... | [
"Handles",
"resolving",
"replacements",
"in",
"the",
"Sub",
"action",
"based",
"on",
"the",
"handler",
"that",
"is",
"passed",
"as",
"an",
"input",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L311-L329 | [
"def",
"_handle_sub_action",
"(",
"self",
",",
"input_dict",
",",
"handler",
")",
":",
"if",
"not",
"self",
".",
"can_handle",
"(",
"input_dict",
")",
":",
"return",
"input_dict",
"key",
"=",
"self",
".",
"intrinsic_name",
"sub_value",
"=",
"input_dict",
"["... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SubAction._handle_sub_value | Generic method to handle value to Fn::Sub key. We are interested in parsing the ${} syntaxes inside
the string portion of the value.
:param sub_value: Value of the Sub function
:param handler_method: Method to be called on every occurrence of `${LogicalId}` structure within the string.
... | samtranslator/intrinsics/actions.py | def _handle_sub_value(self, sub_value, handler_method):
"""
Generic method to handle value to Fn::Sub key. We are interested in parsing the ${} syntaxes inside
the string portion of the value.
:param sub_value: Value of the Sub function
:param handler_method: Method to be called... | def _handle_sub_value(self, sub_value, handler_method):
"""
Generic method to handle value to Fn::Sub key. We are interested in parsing the ${} syntaxes inside
the string portion of the value.
:param sub_value: Value of the Sub function
:param handler_method: Method to be called... | [
"Generic",
"method",
"to",
"handle",
"value",
"to",
"Fn",
"::",
"Sub",
"key",
".",
"We",
"are",
"interested",
"in",
"parsing",
"the",
"$",
"{}",
"syntaxes",
"inside",
"the",
"string",
"portion",
"of",
"the",
"value",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L331-L352 | [
"def",
"_handle_sub_value",
"(",
"self",
",",
"sub_value",
",",
"handler_method",
")",
":",
"# Just handle known references within the string to be substituted and return the whole dictionary",
"# because that's the best we can do here.",
"if",
"isinstance",
"(",
"sub_value",
",",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | SubAction._sub_all_refs | Substitute references within a string that is using ${key} syntax by calling the `handler_method` on every
occurrence of this structure. The value returned by this method directly replaces the reference structure.
Ex:
text = "${key1}-hello-${key2}
def handler_method(full_ref, re... | samtranslator/intrinsics/actions.py | def _sub_all_refs(self, text, handler_method):
"""
Substitute references within a string that is using ${key} syntax by calling the `handler_method` on every
occurrence of this structure. The value returned by this method directly replaces the reference structure.
Ex:
text =... | def _sub_all_refs(self, text, handler_method):
"""
Substitute references within a string that is using ${key} syntax by calling the `handler_method` on every
occurrence of this structure. The value returned by this method directly replaces the reference structure.
Ex:
text =... | [
"Substitute",
"references",
"within",
"a",
"string",
"that",
"is",
"using",
"$",
"{",
"key",
"}",
"syntax",
"by",
"calling",
"the",
"handler_method",
"on",
"every",
"occurrence",
"of",
"this",
"structure",
".",
"The",
"value",
"returned",
"by",
"this",
"meth... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L354-L384 | [
"def",
"_sub_all_refs",
"(",
"self",
",",
"text",
",",
"handler_method",
")",
":",
"# RegExp to find pattern \"${logicalId.property}\" and return the word inside bracket",
"logical_id_regex",
"=",
"'[A-Za-z0-9\\.]+|AWS::[A-Z][A-Za-z]*'",
"ref_pattern",
"=",
"re",
".",
"compile",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | GetAttAction.resolve_resource_refs | Resolve resource references within a GetAtt dict.
Example:
{ "Fn::GetAtt": ["LogicalId.Property", "Arn"] } => {"Fn::GetAtt": ["ResolvedLogicalId", "Arn"]}
Theoretically, only the first element of the array can contain reference to SAM resources. The second element
is name of an... | samtranslator/intrinsics/actions.py | def resolve_resource_refs(self, input_dict, supported_resource_refs):
"""
Resolve resource references within a GetAtt dict.
Example:
{ "Fn::GetAtt": ["LogicalId.Property", "Arn"] } => {"Fn::GetAtt": ["ResolvedLogicalId", "Arn"]}
Theoretically, only the first element of ... | def resolve_resource_refs(self, input_dict, supported_resource_refs):
"""
Resolve resource references within a GetAtt dict.
Example:
{ "Fn::GetAtt": ["LogicalId.Property", "Arn"] } => {"Fn::GetAtt": ["ResolvedLogicalId", "Arn"]}
Theoretically, only the first element of ... | [
"Resolve",
"resource",
"references",
"within",
"a",
"GetAtt",
"dict",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L394-L452 | [
"def",
"resolve_resource_refs",
"(",
"self",
",",
"input_dict",
",",
"supported_resource_refs",
")",
":",
"if",
"not",
"self",
".",
"can_handle",
"(",
"input_dict",
")",
":",
"return",
"input_dict",
"key",
"=",
"self",
".",
"intrinsic_name",
"value",
"=",
"inp... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | GetAttAction.resolve_resource_id_refs | Resolve resource references within a GetAtt dict.
Example:
{ "Fn::GetAtt": ["LogicalId", "Arn"] } => {"Fn::GetAtt": ["ResolvedLogicalId", "Arn"]}
Theoretically, only the first element of the array can contain reference to SAM resources. The second element
is name of an attribut... | samtranslator/intrinsics/actions.py | def resolve_resource_id_refs(self, input_dict, supported_resource_id_refs):
"""
Resolve resource references within a GetAtt dict.
Example:
{ "Fn::GetAtt": ["LogicalId", "Arn"] } => {"Fn::GetAtt": ["ResolvedLogicalId", "Arn"]}
Theoretically, only the first element of the... | def resolve_resource_id_refs(self, input_dict, supported_resource_id_refs):
"""
Resolve resource references within a GetAtt dict.
Example:
{ "Fn::GetAtt": ["LogicalId", "Arn"] } => {"Fn::GetAtt": ["ResolvedLogicalId", "Arn"]}
Theoretically, only the first element of the... | [
"Resolve",
"resource",
"references",
"within",
"a",
"GetAtt",
"dict",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L454-L495 | [
"def",
"resolve_resource_id_refs",
"(",
"self",
",",
"input_dict",
",",
"supported_resource_id_refs",
")",
":",
"if",
"not",
"self",
".",
"can_handle",
"(",
"input_dict",
")",
":",
"return",
"input_dict",
"key",
"=",
"self",
".",
"intrinsic_name",
"value",
"=",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | GetAttAction._get_resolved_dictionary | Resolves the function and returns the updated dictionary
:param input_dict: Dictionary to be resolved
:param key: Name of this intrinsic.
:param resolved_value: Resolved or updated value for this action.
:param remaining: Remaining sections for the GetAtt action. | samtranslator/intrinsics/actions.py | def _get_resolved_dictionary(self, input_dict, key, resolved_value, remaining):
"""
Resolves the function and returns the updated dictionary
:param input_dict: Dictionary to be resolved
:param key: Name of this intrinsic.
:param resolved_value: Resolved or updated value for this... | def _get_resolved_dictionary(self, input_dict, key, resolved_value, remaining):
"""
Resolves the function and returns the updated dictionary
:param input_dict: Dictionary to be resolved
:param key: Name of this intrinsic.
:param resolved_value: Resolved or updated value for this... | [
"Resolves",
"the",
"function",
"and",
"returns",
"the",
"updated",
"dictionary"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L497-L511 | [
"def",
"_get_resolved_dictionary",
"(",
"self",
",",
"input_dict",
",",
"key",
",",
"resolved_value",
",",
"remaining",
")",
":",
"if",
"resolved_value",
":",
"# We resolved to a new resource logicalId. Use this as the first element and keep remaining elements intact",
"# This is... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | FindInMapAction.resolve_parameter_refs | Recursively resolves "Fn::FindInMap"references that are present in the mappings and returns the value.
If it is not in mappings, this method simply returns the input unchanged.
:param input_dict: Dictionary representing the FindInMap function. Must contain only one key and it
... | samtranslator/intrinsics/actions.py | def resolve_parameter_refs(self, input_dict, parameters):
"""
Recursively resolves "Fn::FindInMap"references that are present in the mappings and returns the value.
If it is not in mappings, this method simply returns the input unchanged.
:param input_dict: Dictionary representing the F... | def resolve_parameter_refs(self, input_dict, parameters):
"""
Recursively resolves "Fn::FindInMap"references that are present in the mappings and returns the value.
If it is not in mappings, this method simply returns the input unchanged.
:param input_dict: Dictionary representing the F... | [
"Recursively",
"resolves",
"Fn",
"::",
"FindInMap",
"references",
"that",
"are",
"present",
"in",
"the",
"mappings",
"and",
"returns",
"the",
"value",
".",
"If",
"it",
"is",
"not",
"in",
"mappings",
"this",
"method",
"simply",
"returns",
"the",
"input",
"unc... | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L520-L555 | [
"def",
"resolve_parameter_refs",
"(",
"self",
",",
"input_dict",
",",
"parameters",
")",
":",
"if",
"not",
"self",
".",
"can_handle",
"(",
"input_dict",
")",
":",
"return",
"input_dict",
"value",
"=",
"input_dict",
"[",
"self",
".",
"intrinsic_name",
"]",
"#... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | lambda_handler | Process a RDS enhenced monitoring DATA_MESSAGE,
coming from CLOUDWATCH LOGS | examples/apps/datadog-process-rds-metrics/lambda_function.py | def lambda_handler(event, context):
''' Process a RDS enhenced monitoring DATA_MESSAGE,
coming from CLOUDWATCH LOGS
'''
# event is a dict containing a base64 string gzipped
event = json.loads(gzip.GzipFile(fileobj=StringIO(event['awslogs']['data'].decode('base64'))).read())
account = event[... | def lambda_handler(event, context):
''' Process a RDS enhenced monitoring DATA_MESSAGE,
coming from CLOUDWATCH LOGS
'''
# event is a dict containing a base64 string gzipped
event = json.loads(gzip.GzipFile(fileobj=StringIO(event['awslogs']['data'].decode('base64'))).read())
account = event[... | [
"Process",
"a",
"RDS",
"enhenced",
"monitoring",
"DATA_MESSAGE",
"coming",
"from",
"CLOUDWATCH",
"LOGS"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/datadog-process-rds-metrics/lambda_function.py#L104-L122 | [
"def",
"lambda_handler",
"(",
"event",
",",
"context",
")",
":",
"# event is a dict containing a base64 string gzipped",
"event",
"=",
"json",
".",
"loads",
"(",
"gzip",
".",
"GzipFile",
"(",
"fileobj",
"=",
"StringIO",
"(",
"event",
"[",
"'awslogs'",
"]",
"[",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ApiGenerator._construct_rest_api | Constructs and returns the ApiGateway RestApi.
:returns: the RestApi to which this SAM Api corresponds
:rtype: model.apigateway.ApiGatewayRestApi | samtranslator/model/api/api_generator.py | def _construct_rest_api(self):
"""Constructs and returns the ApiGateway RestApi.
:returns: the RestApi to which this SAM Api corresponds
:rtype: model.apigateway.ApiGatewayRestApi
"""
rest_api = ApiGatewayRestApi(self.logical_id, depends_on=self.depends_on, attributes=self.resou... | def _construct_rest_api(self):
"""Constructs and returns the ApiGateway RestApi.
:returns: the RestApi to which this SAM Api corresponds
:rtype: model.apigateway.ApiGatewayRestApi
"""
rest_api = ApiGatewayRestApi(self.logical_id, depends_on=self.depends_on, attributes=self.resou... | [
"Constructs",
"and",
"returns",
"the",
"ApiGateway",
"RestApi",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/api/api_generator.py#L74-L108 | [
"def",
"_construct_rest_api",
"(",
"self",
")",
":",
"rest_api",
"=",
"ApiGatewayRestApi",
"(",
"self",
".",
"logical_id",
",",
"depends_on",
"=",
"self",
".",
"depends_on",
",",
"attributes",
"=",
"self",
".",
"resource_attributes",
")",
"rest_api",
".",
"Bin... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ApiGenerator._construct_body_s3_dict | Constructs the RestApi's `BodyS3Location property`_, from the SAM Api's DefinitionUri property.
:returns: a BodyS3Location dict, containing the S3 Bucket, Key, and Version of the Swagger definition
:rtype: dict | samtranslator/model/api/api_generator.py | def _construct_body_s3_dict(self):
"""Constructs the RestApi's `BodyS3Location property`_, from the SAM Api's DefinitionUri property.
:returns: a BodyS3Location dict, containing the S3 Bucket, Key, and Version of the Swagger definition
:rtype: dict
"""
if isinstance(self.definit... | def _construct_body_s3_dict(self):
"""Constructs the RestApi's `BodyS3Location property`_, from the SAM Api's DefinitionUri property.
:returns: a BodyS3Location dict, containing the S3 Bucket, Key, and Version of the Swagger definition
:rtype: dict
"""
if isinstance(self.definit... | [
"Constructs",
"the",
"RestApi",
"s",
"BodyS3Location",
"property",
"_",
"from",
"the",
"SAM",
"Api",
"s",
"DefinitionUri",
"property",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/api/api_generator.py#L110-L138 | [
"def",
"_construct_body_s3_dict",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"definition_uri",
",",
"dict",
")",
":",
"if",
"not",
"self",
".",
"definition_uri",
".",
"get",
"(",
"\"Bucket\"",
",",
"None",
")",
"or",
"not",
"self",
".",... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ApiGenerator._construct_deployment | Constructs and returns the ApiGateway Deployment.
:param model.apigateway.ApiGatewayRestApi rest_api: the RestApi for this Deployment
:returns: the Deployment to which this SAM Api corresponds
:rtype: model.apigateway.ApiGatewayDeployment | samtranslator/model/api/api_generator.py | def _construct_deployment(self, rest_api):
"""Constructs and returns the ApiGateway Deployment.
:param model.apigateway.ApiGatewayRestApi rest_api: the RestApi for this Deployment
:returns: the Deployment to which this SAM Api corresponds
:rtype: model.apigateway.ApiGatewayDeployment
... | def _construct_deployment(self, rest_api):
"""Constructs and returns the ApiGateway Deployment.
:param model.apigateway.ApiGatewayRestApi rest_api: the RestApi for this Deployment
:returns: the Deployment to which this SAM Api corresponds
:rtype: model.apigateway.ApiGatewayDeployment
... | [
"Constructs",
"and",
"returns",
"the",
"ApiGateway",
"Deployment",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/api/api_generator.py#L140-L152 | [
"def",
"_construct_deployment",
"(",
"self",
",",
"rest_api",
")",
":",
"deployment",
"=",
"ApiGatewayDeployment",
"(",
"self",
".",
"logical_id",
"+",
"'Deployment'",
",",
"attributes",
"=",
"self",
".",
"passthrough_resource_attributes",
")",
"deployment",
".",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ApiGenerator._construct_stage | Constructs and returns the ApiGateway Stage.
:param model.apigateway.ApiGatewayDeployment deployment: the Deployment for this Stage
:returns: the Stage to which this SAM Api corresponds
:rtype: model.apigateway.ApiGatewayStage | samtranslator/model/api/api_generator.py | def _construct_stage(self, deployment, swagger):
"""Constructs and returns the ApiGateway Stage.
:param model.apigateway.ApiGatewayDeployment deployment: the Deployment for this Stage
:returns: the Stage to which this SAM Api corresponds
:rtype: model.apigateway.ApiGatewayStage
... | def _construct_stage(self, deployment, swagger):
"""Constructs and returns the ApiGateway Stage.
:param model.apigateway.ApiGatewayDeployment deployment: the Deployment for this Stage
:returns: the Stage to which this SAM Api corresponds
:rtype: model.apigateway.ApiGatewayStage
... | [
"Constructs",
"and",
"returns",
"the",
"ApiGateway",
"Stage",
"."
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/api/api_generator.py#L154-L182 | [
"def",
"_construct_stage",
"(",
"self",
",",
"deployment",
",",
"swagger",
")",
":",
"# If StageName is some intrinsic function, then don't prefix the Stage's logical ID",
"# This will NOT create duplicates because we allow only ONE stage per API resource",
"stage_name_prefix",
"=",
"sel... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ApiGenerator.to_cloudformation | Generates CloudFormation resources from a SAM API resource
:returns: a tuple containing the RestApi, Deployment, and Stage for an empty Api.
:rtype: tuple | samtranslator/model/api/api_generator.py | def to_cloudformation(self):
"""Generates CloudFormation resources from a SAM API resource
:returns: a tuple containing the RestApi, Deployment, and Stage for an empty Api.
:rtype: tuple
"""
rest_api = self._construct_rest_api()
deployment = self._construct_deployment(r... | def to_cloudformation(self):
"""Generates CloudFormation resources from a SAM API resource
:returns: a tuple containing the RestApi, Deployment, and Stage for an empty Api.
:rtype: tuple
"""
rest_api = self._construct_rest_api()
deployment = self._construct_deployment(r... | [
"Generates",
"CloudFormation",
"resources",
"from",
"a",
"SAM",
"API",
"resource"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/api/api_generator.py#L184-L203 | [
"def",
"to_cloudformation",
"(",
"self",
")",
":",
"rest_api",
"=",
"self",
".",
"_construct_rest_api",
"(",
")",
"deployment",
"=",
"self",
".",
"_construct_deployment",
"(",
"rest_api",
")",
"swagger",
"=",
"None",
"if",
"rest_api",
".",
"Body",
"is",
"not... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
train | ApiGenerator._add_cors | Add CORS configuration to the Swagger file, if necessary | samtranslator/model/api/api_generator.py | def _add_cors(self):
"""
Add CORS configuration to the Swagger file, if necessary
"""
INVALID_ERROR = "Invalid value for 'Cors' property"
if not self.cors:
return
if self.cors and not self.definition_body:
raise InvalidResourceException(self.log... | def _add_cors(self):
"""
Add CORS configuration to the Swagger file, if necessary
"""
INVALID_ERROR = "Invalid value for 'Cors' property"
if not self.cors:
return
if self.cors and not self.definition_body:
raise InvalidResourceException(self.log... | [
"Add",
"CORS",
"configuration",
"to",
"the",
"Swagger",
"file",
"if",
"necessary"
] | awslabs/serverless-application-model | python | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/api/api_generator.py#L205-L249 | [
"def",
"_add_cors",
"(",
"self",
")",
":",
"INVALID_ERROR",
"=",
"\"Invalid value for 'Cors' property\"",
"if",
"not",
"self",
".",
"cors",
":",
"return",
"if",
"self",
".",
"cors",
"and",
"not",
"self",
".",
"definition_body",
":",
"raise",
"InvalidResourceExce... | cccb0c96b5c91e53355ebc07e542467303a5eedd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.