repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
awslabs/serverless-application-model | samtranslator/intrinsics/resource_refs.py | SupportedResourceReferences.add | def add(self, logical_id, property, value):
"""
Add the information that resource with given `logical_id` supports the given `property`, and that a reference
to `logical_id.property` resolves to given `value.
Example:
"MyApi.Deployment" -> "MyApiDeployment1234567890"
... | python | def add(self, logical_id, property, value):
"""
Add the information that resource with given `logical_id` supports the given `property`, and that a reference
to `logical_id.property` resolves to given `value.
Example:
"MyApi.Deployment" -> "MyApiDeployment1234567890"
... | [
"def",
"add",
"(",
"self",
",",
"logical_id",
",",
"property",
",",
"value",
")",
":",
"if",
"not",
"logical_id",
"or",
"not",
"property",
":",
"raise",
"ValueError",
"(",
"\"LogicalId and property must be a non-empty string\"",
")",
"if",
"not",
"value",
"or",
... | Add the information that resource with given `logical_id` supports the given `property`, and that a reference
to `logical_id.property` resolves to given `value.
Example:
"MyApi.Deployment" -> "MyApiDeployment1234567890"
:param logical_id: Logical ID of the resource (Ex: MyLambdaF... | [
"Add",
"the",
"information",
"that",
"resource",
"with",
"given",
"logical_id",
"supports",
"the",
"given",
"property",
"and",
"that",
"a",
"reference",
"to",
"logical_id",
".",
"property",
"resolves",
"to",
"given",
"value",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/resource_refs.py#L17-L44 | train |
awslabs/serverless-application-model | samtranslator/intrinsics/resource_refs.py | SupportedResourceReferences.get | def get(self, logical_id, property):
"""
Returns the value of the reference for given logical_id at given property. Ex: MyFunction.Alias
:param logical_id: Logical Id of the resource
:param property: Property of the resource you want to resolve. None if you want to get value of all prop... | python | def get(self, logical_id, property):
"""
Returns the value of the reference for given logical_id at given property. Ex: MyFunction.Alias
:param logical_id: Logical Id of the resource
:param property: Property of the resource you want to resolve. None if you want to get value of all prop... | [
"def",
"get",
"(",
"self",
",",
"logical_id",
",",
"property",
")",
":",
"# By defaulting to empty dictionary, we can handle the case where logical_id is not in map without if statements",
"prop_values",
"=",
"self",
".",
"get_all",
"(",
"logical_id",
")",
"if",
"prop_values"... | Returns the value of the reference for given logical_id at given property. Ex: MyFunction.Alias
:param logical_id: Logical Id of the resource
:param property: Property of the resource you want to resolve. None if you want to get value of all properties
:return: Value of this property if present... | [
"Returns",
"the",
"value",
"of",
"the",
"reference",
"for",
"given",
"logical_id",
"at",
"given",
"property",
".",
"Ex",
":",
"MyFunction",
".",
"Alias"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/resource_refs.py#L46-L60 | train |
awslabs/serverless-application-model | examples/2016-10-31/encryption_proxy/src/encryption.py | encrypt | def encrypt(key, message):
'''encrypt leverages KMS encrypt and base64-encode encrypted blob
More info on KMS encrypt API:
https://docs.aws.amazon.com/kms/latest/APIReference/API_encrypt.html
'''
try:
ret = kms.encrypt(KeyId=key, Plaintext=message)
encrypted_data = base64.en... | python | def encrypt(key, message):
'''encrypt leverages KMS encrypt and base64-encode encrypted blob
More info on KMS encrypt API:
https://docs.aws.amazon.com/kms/latest/APIReference/API_encrypt.html
'''
try:
ret = kms.encrypt(KeyId=key, Plaintext=message)
encrypted_data = base64.en... | [
"def",
"encrypt",
"(",
"key",
",",
"message",
")",
":",
"try",
":",
"ret",
"=",
"kms",
".",
"encrypt",
"(",
"KeyId",
"=",
"key",
",",
"Plaintext",
"=",
"message",
")",
"encrypted_data",
"=",
"base64",
".",
"encodestring",
"(",
"ret",
".",
"get",
"(",... | encrypt leverages KMS encrypt and base64-encode encrypted blob
More info on KMS encrypt API:
https://docs.aws.amazon.com/kms/latest/APIReference/API_encrypt.html | [
"encrypt",
"leverages",
"KMS",
"encrypt",
"and",
"base64",
"-",
"encode",
"encrypted",
"blob"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/2016-10-31/encryption_proxy/src/encryption.py#L16-L29 | train |
awslabs/serverless-application-model | samtranslator/model/tags/resource_tagging.py | get_tag_list | def get_tag_list(resource_tag_dict):
"""
Transforms the SAM defined Tags into the form CloudFormation is expecting.
SAM Example:
```
...
Tags:
TagKey: TagValue
```
CloudFormation equivalent:
- Key: TagKey
Value: TagValue
```
... | python | def get_tag_list(resource_tag_dict):
"""
Transforms the SAM defined Tags into the form CloudFormation is expecting.
SAM Example:
```
...
Tags:
TagKey: TagValue
```
CloudFormation equivalent:
- Key: TagKey
Value: TagValue
```
... | [
"def",
"get_tag_list",
"(",
"resource_tag_dict",
")",
":",
"tag_list",
"=",
"[",
"]",
"if",
"resource_tag_dict",
"is",
"None",
":",
"return",
"tag_list",
"for",
"tag_key",
",",
"tag_value",
"in",
"resource_tag_dict",
".",
"items",
"(",
")",
":",
"tag",
"=",
... | Transforms the SAM defined Tags into the form CloudFormation is expecting.
SAM Example:
```
...
Tags:
TagKey: TagValue
```
CloudFormation equivalent:
- Key: TagKey
Value: TagValue
```
:param resource_tag_dict: Customer defined dicti... | [
"Transforms",
"the",
"SAM",
"defined",
"Tags",
"into",
"the",
"form",
"CloudFormation",
"is",
"expecting",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/tags/resource_tagging.py#L7-L36 | train |
awslabs/serverless-application-model | samtranslator/translator/arn_generator.py | ArnGenerator.get_partition_name | def get_partition_name(cls, region=None):
"""
Gets the name of the partition given the region name. If region name is not provided, this method will
use Boto3 to get name of the region where this code is running.
This implementation is borrowed from AWS CLI
https://github.com/aw... | python | def get_partition_name(cls, region=None):
"""
Gets the name of the partition given the region name. If region name is not provided, this method will
use Boto3 to get name of the region where this code is running.
This implementation is borrowed from AWS CLI
https://github.com/aw... | [
"def",
"get_partition_name",
"(",
"cls",
",",
"region",
"=",
"None",
")",
":",
"if",
"region",
"is",
"None",
":",
"# Use Boto3 to get the region where code is running. This uses Boto's regular region resolution",
"# mechanism, starting from AWS_DEFAULT_REGION environment variable.",
... | Gets the name of the partition given the region name. If region name is not provided, this method will
use Boto3 to get name of the region where this code is running.
This implementation is borrowed from AWS CLI
https://github.com/aws/aws-cli/blob/1.11.139/awscli/customizations/emr/createdefaul... | [
"Gets",
"the",
"name",
"of",
"the",
"partition",
"given",
"the",
"region",
"name",
".",
"If",
"region",
"name",
"is",
"not",
"provided",
"this",
"method",
"will",
"use",
"Boto3",
"to",
"get",
"name",
"of",
"the",
"region",
"where",
"this",
"code",
"is",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/arn_generator.py#L33-L56 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/default_definition_body_plugin.py | DefaultDefinitionBodyPlugin.on_before_transform_template | 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.
:param dict template_dict: Dictionary of the SAM template
... | python | 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.
:param dict template_dict: Dictionary of the SAM template
... | [
"def",
"on_before_transform_template",
"(",
"self",
",",
"template_dict",
")",
":",
"template",
"=",
"SamTemplate",
"(",
"template_dict",
")",
"for",
"logicalId",
",",
"api",
"in",
"template",
".",
"iterate",
"(",
"SamResourceType",
".",
"Api",
".",
"value",
"... | 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.
:param dict template_dict: Dictionary of the SAM template
:return: Nothing | [
"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",
"."... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/default_definition_body_plugin.py#L22-L37 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.has_path | def has_path(self, path, method=None):
"""
Returns True if this Swagger has the given path and optional method
:param string path: Path name
:param string method: HTTP method
:return: True, if this path/method is present in the document
"""
method = self._normali... | python | def has_path(self, path, method=None):
"""
Returns True if this Swagger has the given path and optional method
:param string path: Path name
:param string method: HTTP method
:return: True, if this path/method is present in the document
"""
method = self._normali... | [
"def",
"has_path",
"(",
"self",
",",
"path",
",",
"method",
"=",
"None",
")",
":",
"method",
"=",
"self",
".",
"_normalize_method_name",
"(",
"method",
")",
"path_dict",
"=",
"self",
".",
"get_path",
"(",
"path",
")",
"path_dict_exists",
"=",
"path_dict",
... | Returns True if this Swagger has the given path and optional method
:param string path: Path name
:param string method: HTTP method
:return: True, if this path/method is present in the document | [
"Returns",
"True",
"if",
"this",
"Swagger",
"has",
"the",
"given",
"path",
"and",
"optional",
"method"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L46-L60 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.method_has_integration | def method_has_integration(self, method):
"""
Returns true if the given method contains a valid method definition.
This uses the get_method_contents function to handle conditionals.
:param dict method: method dictionary
:return: true if method has one or multiple integrations
... | python | def method_has_integration(self, method):
"""
Returns true if the given method contains a valid method definition.
This uses the get_method_contents function to handle conditionals.
:param dict method: method dictionary
:return: true if method has one or multiple integrations
... | [
"def",
"method_has_integration",
"(",
"self",
",",
"method",
")",
":",
"for",
"method_definition",
"in",
"self",
".",
"get_method_contents",
"(",
"method",
")",
":",
"if",
"self",
".",
"method_definition_has_integration",
"(",
"method_definition",
")",
":",
"retur... | Returns true if the given method contains a valid method definition.
This uses the get_method_contents function to handle conditionals.
:param dict method: method dictionary
:return: true if method has one or multiple integrations | [
"Returns",
"true",
"if",
"the",
"given",
"method",
"contains",
"a",
"valid",
"method",
"definition",
".",
"This",
"uses",
"the",
"get_method_contents",
"function",
"to",
"handle",
"conditionals",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L62-L73 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.get_method_contents | def get_method_contents(self, method):
"""
Returns the swagger contents of the given method. This checks to see if a conditional block
has been used inside of the method, and, if so, returns the method contents that are
inside of the conditional.
:param dict method: method dicti... | python | def get_method_contents(self, method):
"""
Returns the swagger contents of the given method. This checks to see if a conditional block
has been used inside of the method, and, if so, returns the method contents that are
inside of the conditional.
:param dict method: method dicti... | [
"def",
"get_method_contents",
"(",
"self",
",",
"method",
")",
":",
"if",
"self",
".",
"_CONDITIONAL_IF",
"in",
"method",
":",
"return",
"method",
"[",
"self",
".",
"_CONDITIONAL_IF",
"]",
"[",
"1",
":",
"]",
"return",
"[",
"method",
"]"
] | Returns the swagger contents of the given method. This checks to see if a conditional block
has been used inside of the method, and, if so, returns the method contents that are
inside of the conditional.
:param dict method: method dictionary
:return: list of swagger component dictionari... | [
"Returns",
"the",
"swagger",
"contents",
"of",
"the",
"given",
"method",
".",
"This",
"checks",
"to",
"see",
"if",
"a",
"conditional",
"block",
"has",
"been",
"used",
"inside",
"of",
"the",
"method",
"and",
"if",
"so",
"returns",
"the",
"method",
"contents... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L86-L97 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.has_integration | def has_integration(self, path, method):
"""
Checks if an API Gateway integration is already present at the given path/method
:param string path: Path name
:param string method: HTTP method
:return: True, if an API Gateway integration is already present
"""
metho... | python | def has_integration(self, path, method):
"""
Checks if an API Gateway integration is already present at the given path/method
:param string path: Path name
:param string method: HTTP method
:return: True, if an API Gateway integration is already present
"""
metho... | [
"def",
"has_integration",
"(",
"self",
",",
"path",
",",
"method",
")",
":",
"method",
"=",
"self",
".",
"_normalize_method_name",
"(",
"method",
")",
"path_dict",
"=",
"self",
".",
"get_path",
"(",
"path",
")",
"return",
"self",
".",
"has_path",
"(",
"p... | Checks if an API Gateway integration is already present at the given path/method
:param string path: Path name
:param string method: HTTP method
:return: True, if an API Gateway integration is already present | [
"Checks",
"if",
"an",
"API",
"Gateway",
"integration",
"is",
"already",
"present",
"at",
"the",
"given",
"path",
"/",
"method"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L99-L112 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.add_path | def add_path(self, path, method=None):
"""
Adds the path/method combination to the Swagger, if not already present
:param string path: Path name
:param string method: HTTP method
:raises ValueError: If the value of `path` in Swagger is not a dictionary
"""
method... | python | def add_path(self, path, method=None):
"""
Adds the path/method combination to the Swagger, if not already present
:param string path: Path name
:param string method: HTTP method
:raises ValueError: If the value of `path` in Swagger is not a dictionary
"""
method... | [
"def",
"add_path",
"(",
"self",
",",
"path",
",",
"method",
"=",
"None",
")",
":",
"method",
"=",
"self",
".",
"_normalize_method_name",
"(",
"method",
")",
"path_dict",
"=",
"self",
".",
"paths",
".",
"setdefault",
"(",
"path",
",",
"{",
"}",
")",
"... | Adds the path/method combination to the Swagger, if not already present
:param string path: Path name
:param string method: HTTP method
:raises ValueError: If the value of `path` in Swagger is not a dictionary | [
"Adds",
"the",
"path",
"/",
"method",
"combination",
"to",
"the",
"Swagger",
"if",
"not",
"already",
"present"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L114-L135 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.add_lambda_integration | def add_lambda_integration(self, path, method, integration_uri,
method_auth_config=None, api_auth_config=None, condition=None):
"""
Adds aws_proxy APIGW integration to the given path+method.
:param string path: Path name
:param string method: HTTP Method
... | python | def add_lambda_integration(self, path, method, integration_uri,
method_auth_config=None, api_auth_config=None, condition=None):
"""
Adds aws_proxy APIGW integration to the given path+method.
:param string path: Path name
:param string method: HTTP Method
... | [
"def",
"add_lambda_integration",
"(",
"self",
",",
"path",
",",
"method",
",",
"integration_uri",
",",
"method_auth_config",
"=",
"None",
",",
"api_auth_config",
"=",
"None",
",",
"condition",
"=",
"None",
")",
":",
"method",
"=",
"self",
".",
"_normalize_meth... | Adds aws_proxy APIGW integration to the given path+method.
:param string path: Path name
:param string method: HTTP Method
:param string integration_uri: URI for the integration. | [
"Adds",
"aws_proxy",
"APIGW",
"integration",
"to",
"the",
"given",
"path",
"+",
"method",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L137-L179 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.make_path_conditional | def make_path_conditional(self, path, condition):
"""
Wrap entire API path definition in a CloudFormation if condition.
"""
self.paths[path] = make_conditional(condition, self.paths[path]) | python | def make_path_conditional(self, path, condition):
"""
Wrap entire API path definition in a CloudFormation if condition.
"""
self.paths[path] = make_conditional(condition, self.paths[path]) | [
"def",
"make_path_conditional",
"(",
"self",
",",
"path",
",",
"condition",
")",
":",
"self",
".",
"paths",
"[",
"path",
"]",
"=",
"make_conditional",
"(",
"condition",
",",
"self",
".",
"paths",
"[",
"path",
"]",
")"
] | Wrap entire API path definition in a CloudFormation if condition. | [
"Wrap",
"entire",
"API",
"path",
"definition",
"in",
"a",
"CloudFormation",
"if",
"condition",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L181-L185 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.add_cors | def add_cors(self, path, allowed_origins, allowed_headers=None, allowed_methods=None, max_age=None,
allow_credentials=None):
"""
Add CORS configuration to this path. Specifically, we will add a OPTIONS response config to the Swagger that
will return headers required for CORS. Si... | python | def add_cors(self, path, allowed_origins, allowed_headers=None, allowed_methods=None, max_age=None,
allow_credentials=None):
"""
Add CORS configuration to this path. Specifically, we will add a OPTIONS response config to the Swagger that
will return headers required for CORS. Si... | [
"def",
"add_cors",
"(",
"self",
",",
"path",
",",
"allowed_origins",
",",
"allowed_headers",
"=",
"None",
",",
"allowed_methods",
"=",
"None",
",",
"max_age",
"=",
"None",
",",
"allow_credentials",
"=",
"None",
")",
":",
"# Skip if Options is already present",
"... | Add CORS configuration to this path. Specifically, we will add a OPTIONS response config to the Swagger that
will return headers required for CORS. Since SAM uses aws_proxy integration, we cannot inject the headers
into the actual response returned from Lambda function. This is something customers have ... | [
"Add",
"CORS",
"configuration",
"to",
"this",
"path",
".",
"Specifically",
"we",
"will",
"add",
"a",
"OPTIONS",
"response",
"config",
"to",
"the",
"Swagger",
"that",
"will",
"return",
"headers",
"required",
"for",
"CORS",
".",
"Since",
"SAM",
"uses",
"aws_pr... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L205-L254 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor._options_method_response_for_cors | def _options_method_response_for_cors(self, allowed_origins, allowed_headers=None, allowed_methods=None,
max_age=None, allow_credentials=None):
"""
Returns a Swagger snippet containing configuration for OPTIONS HTTP Method to configure CORS.
This snippe... | python | def _options_method_response_for_cors(self, allowed_origins, allowed_headers=None, allowed_methods=None,
max_age=None, allow_credentials=None):
"""
Returns a Swagger snippet containing configuration for OPTIONS HTTP Method to configure CORS.
This snippe... | [
"def",
"_options_method_response_for_cors",
"(",
"self",
",",
"allowed_origins",
",",
"allowed_headers",
"=",
"None",
",",
"allowed_methods",
"=",
"None",
",",
"max_age",
"=",
"None",
",",
"allow_credentials",
"=",
"None",
")",
":",
"ALLOW_ORIGIN",
"=",
"\"Access-... | Returns a Swagger snippet containing configuration for OPTIONS HTTP Method to configure CORS.
This snippet is taken from public documentation:
https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html#enable-cors-for-resource-using-swagger-importer-tool
:param string/dict a... | [
"Returns",
"a",
"Swagger",
"snippet",
"containing",
"configuration",
"for",
"OPTIONS",
"HTTP",
"Method",
"to",
"configure",
"CORS",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L256-L343 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor._make_cors_allowed_methods_for_path | def _make_cors_allowed_methods_for_path(self, path):
"""
Creates the value for Access-Control-Allow-Methods header for given path. All HTTP methods defined for this
path will be included in the result. If the path contains "ANY" method, then *all available* HTTP methods will
be returned ... | python | def _make_cors_allowed_methods_for_path(self, path):
"""
Creates the value for Access-Control-Allow-Methods header for given path. All HTTP methods defined for this
path will be included in the result. If the path contains "ANY" method, then *all available* HTTP methods will
be returned ... | [
"def",
"_make_cors_allowed_methods_for_path",
"(",
"self",
",",
"path",
")",
":",
"# https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html",
"all_http_methods",
"=",
"[",
"\"OPTIONS\"",
",",
"\"GET\"",
",",
"\"HEAD\"",
",",
"\"POST\"",
",",
"\"PUT\"",
",",
"\"DELETE\"",
... | Creates the value for Access-Control-Allow-Methods header for given path. All HTTP methods defined for this
path will be included in the result. If the path contains "ANY" method, then *all available* HTTP methods will
be returned as result.
:param string path: Path to generate AllowMethods val... | [
"Creates",
"the",
"value",
"for",
"Access",
"-",
"Control",
"-",
"Allow",
"-",
"Methods",
"header",
"for",
"given",
"path",
".",
"All",
"HTTP",
"methods",
"defined",
"for",
"this",
"path",
"will",
"be",
"included",
"in",
"the",
"result",
".",
"If",
"the"... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L345-L384 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.add_authorizers | def add_authorizers(self, authorizers):
"""
Add Authorizer definitions to the securityDefinitions part of Swagger.
:param list authorizers: List of Authorizer configurations which get translated to securityDefinitions.
"""
self.security_definitions = self.security_definitions or... | python | def add_authorizers(self, authorizers):
"""
Add Authorizer definitions to the securityDefinitions part of Swagger.
:param list authorizers: List of Authorizer configurations which get translated to securityDefinitions.
"""
self.security_definitions = self.security_definitions or... | [
"def",
"add_authorizers",
"(",
"self",
",",
"authorizers",
")",
":",
"self",
".",
"security_definitions",
"=",
"self",
".",
"security_definitions",
"or",
"{",
"}",
"for",
"authorizer_name",
",",
"authorizer",
"in",
"authorizers",
".",
"items",
"(",
")",
":",
... | Add Authorizer definitions to the securityDefinitions part of Swagger.
:param list authorizers: List of Authorizer configurations which get translated to securityDefinitions. | [
"Add",
"Authorizer",
"definitions",
"to",
"the",
"securityDefinitions",
"part",
"of",
"Swagger",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L386-L395 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.set_path_default_authorizer | def set_path_default_authorizer(self, path, default_authorizer, authorizers):
"""
Sets the DefaultAuthorizer for each method on this path. The DefaultAuthorizer won't be set if an Authorizer
was defined at the Function/Path/Method level
:param string path: Path name
:param strin... | python | def set_path_default_authorizer(self, path, default_authorizer, authorizers):
"""
Sets the DefaultAuthorizer for each method on this path. The DefaultAuthorizer won't be set if an Authorizer
was defined at the Function/Path/Method level
:param string path: Path name
:param strin... | [
"def",
"set_path_default_authorizer",
"(",
"self",
",",
"path",
",",
"default_authorizer",
",",
"authorizers",
")",
":",
"for",
"method_name",
",",
"method",
"in",
"self",
".",
"get_path",
"(",
"path",
")",
".",
"items",
"(",
")",
":",
"self",
".",
"set_me... | Sets the DefaultAuthorizer for each method on this path. The DefaultAuthorizer won't be set if an Authorizer
was defined at the Function/Path/Method level
:param string path: Path name
:param string default_authorizer: Name of the authorizer to use as the default. Must be a key in the
... | [
"Sets",
"the",
"DefaultAuthorizer",
"for",
"each",
"method",
"on",
"this",
"path",
".",
"The",
"DefaultAuthorizer",
"won",
"t",
"be",
"set",
"if",
"an",
"Authorizer",
"was",
"defined",
"at",
"the",
"Function",
"/",
"Path",
"/",
"Method",
"level"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L397-L409 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.add_auth_to_method | def add_auth_to_method(self, path, method_name, auth, api):
"""
Adds auth settings for this path/method. Auth settings currently consist solely of Authorizers
but this method will eventually include setting other auth settings such as API Key,
Resource Policy, etc.
:param string... | python | def add_auth_to_method(self, path, method_name, auth, api):
"""
Adds auth settings for this path/method. Auth settings currently consist solely of Authorizers
but this method will eventually include setting other auth settings such as API Key,
Resource Policy, etc.
:param string... | [
"def",
"add_auth_to_method",
"(",
"self",
",",
"path",
",",
"method_name",
",",
"auth",
",",
"api",
")",
":",
"method_authorizer",
"=",
"auth",
"and",
"auth",
".",
"get",
"(",
"'Authorizer'",
")",
"if",
"method_authorizer",
":",
"api_auth",
"=",
"api",
"."... | Adds auth settings for this path/method. Auth settings currently consist solely of Authorizers
but this method will eventually include setting other auth settings such as API Key,
Resource Policy, etc.
:param string path: Path name
:param string method_name: Method name
:param d... | [
"Adds",
"auth",
"settings",
"for",
"this",
"path",
"/",
"method",
".",
"Auth",
"settings",
"currently",
"consist",
"solely",
"of",
"Authorizers",
"but",
"this",
"method",
"will",
"eventually",
"include",
"setting",
"other",
"auth",
"settings",
"such",
"as",
"A... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L411-L429 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.add_gateway_responses | def add_gateway_responses(self, gateway_responses):
"""
Add Gateway Response definitions to Swagger.
:param dict gateway_responses: Dictionary of GatewayResponse configuration which gets translated.
"""
self.gateway_responses = self.gateway_responses or {}
for response_... | python | def add_gateway_responses(self, gateway_responses):
"""
Add Gateway Response definitions to Swagger.
:param dict gateway_responses: Dictionary of GatewayResponse configuration which gets translated.
"""
self.gateway_responses = self.gateway_responses or {}
for response_... | [
"def",
"add_gateway_responses",
"(",
"self",
",",
"gateway_responses",
")",
":",
"self",
".",
"gateway_responses",
"=",
"self",
".",
"gateway_responses",
"or",
"{",
"}",
"for",
"response_type",
",",
"response",
"in",
"gateway_responses",
".",
"items",
"(",
")",
... | Add Gateway Response definitions to Swagger.
:param dict gateway_responses: Dictionary of GatewayResponse configuration which gets translated. | [
"Add",
"Gateway",
"Response",
"definitions",
"to",
"Swagger",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L516-L525 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.swagger | def swagger(self):
"""
Returns a **copy** of the Swagger document as a dictionary.
:return dict: Dictionary containing the Swagger document
"""
# Make sure any changes to the paths are reflected back in output
self._doc["paths"] = self.paths
if self.security_de... | python | def swagger(self):
"""
Returns a **copy** of the Swagger document as a dictionary.
:return dict: Dictionary containing the Swagger document
"""
# Make sure any changes to the paths are reflected back in output
self._doc["paths"] = self.paths
if self.security_de... | [
"def",
"swagger",
"(",
"self",
")",
":",
"# Make sure any changes to the paths are reflected back in output",
"self",
".",
"_doc",
"[",
"\"paths\"",
"]",
"=",
"self",
".",
"paths",
"if",
"self",
".",
"security_definitions",
":",
"self",
".",
"_doc",
"[",
"\"securi... | Returns a **copy** of the Swagger document as a dictionary.
:return dict: Dictionary containing the Swagger document | [
"Returns",
"a",
"**",
"copy",
"**",
"of",
"the",
"Swagger",
"document",
"as",
"a",
"dictionary",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L528-L543 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor.is_valid | def is_valid(data):
"""
Checks if the input data is a Swagger document
:param dict data: Data to be validated
:return: True, if data is a Swagger
"""
return bool(data) and \
isinstance(data, dict) and \
bool(data.get("swagger")) and \
... | python | def is_valid(data):
"""
Checks if the input data is a Swagger document
:param dict data: Data to be validated
:return: True, if data is a Swagger
"""
return bool(data) and \
isinstance(data, dict) and \
bool(data.get("swagger")) and \
... | [
"def",
"is_valid",
"(",
"data",
")",
":",
"return",
"bool",
"(",
"data",
")",
"and",
"isinstance",
"(",
"data",
",",
"dict",
")",
"and",
"bool",
"(",
"data",
".",
"get",
"(",
"\"swagger\"",
")",
")",
"and",
"isinstance",
"(",
"data",
".",
"get",
"(... | Checks if the input data is a Swagger document
:param dict data: Data to be validated
:return: True, if data is a Swagger | [
"Checks",
"if",
"the",
"input",
"data",
"is",
"a",
"Swagger",
"document"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L546-L556 | train |
awslabs/serverless-application-model | samtranslator/swagger/swagger.py | SwaggerEditor._normalize_method_name | def _normalize_method_name(method):
"""
Returns a lower case, normalized version of HTTP Method. It also know how to handle API Gateway specific methods
like "ANY"
NOTE: Always normalize before using the `method` value passed in as input
:param string method: Name of the HTTP M... | python | def _normalize_method_name(method):
"""
Returns a lower case, normalized version of HTTP Method. It also know how to handle API Gateway specific methods
like "ANY"
NOTE: Always normalize before using the `method` value passed in as input
:param string method: Name of the HTTP M... | [
"def",
"_normalize_method_name",
"(",
"method",
")",
":",
"if",
"not",
"method",
"or",
"not",
"isinstance",
"(",
"method",
",",
"string_types",
")",
":",
"return",
"method",
"method",
"=",
"method",
".",
"lower",
"(",
")",
"if",
"method",
"==",
"'any'",
... | Returns a lower case, normalized version of HTTP Method. It also know how to handle API Gateway specific methods
like "ANY"
NOTE: Always normalize before using the `method` value passed in as input
:param string method: Name of the HTTP Method
:return string: Normalized method name | [
"Returns",
"a",
"lower",
"case",
"normalized",
"version",
"of",
"HTTP",
"Method",
".",
"It",
"also",
"know",
"how",
"to",
"handle",
"API",
"Gateway",
"specific",
"methods",
"like",
"ANY"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/swagger/swagger.py#L576-L593 | train |
awslabs/serverless-application-model | samtranslator/plugins/globals/globals_plugin.py | GlobalsPlugin.on_before_transform_template | def on_before_transform_template(self, template_dict):
"""
Hook method that runs before a template gets transformed. In this method, we parse and process Globals section
from the template (if present).
:param dict template_dict: SAM template as a dictionary
"""
try:
... | python | def on_before_transform_template(self, template_dict):
"""
Hook method that runs before a template gets transformed. In this method, we parse and process Globals section
from the template (if present).
:param dict template_dict: SAM template as a dictionary
"""
try:
... | [
"def",
"on_before_transform_template",
"(",
"self",
",",
"template_dict",
")",
":",
"try",
":",
"global_section",
"=",
"Globals",
"(",
"template_dict",
")",
"except",
"InvalidGlobalsSectionException",
"as",
"ex",
":",
"raise",
"InvalidDocumentException",
"(",
"[",
"... | Hook method that runs before a template gets transformed. In this method, we parse and process Globals section
from the template (if present).
:param dict template_dict: SAM template as a dictionary | [
"Hook",
"method",
"that",
"runs",
"before",
"a",
"template",
"gets",
"transformed",
".",
"In",
"this",
"method",
"we",
"parse",
"and",
"process",
"Globals",
"section",
"from",
"the",
"template",
"(",
"if",
"present",
")",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/globals/globals_plugin.py#L20-L40 | train |
awslabs/serverless-application-model | samtranslator/model/types.py | is_type | 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... | python | 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",
")",
":",
"def",
"validate",
"(",
"value",
",",
"should_raise",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"valid_type",
")",
":",
"if",
"should_raise",
":",
"raise",
"TypeError",
"(",
"\"Exp... | 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 | [
"Returns",
"a",
"validator",
"function",
"that",
"succeeds",
"only",
"for",
"inputs",
"of",
"the",
"provided",
"valid_type",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/types.py#L15-L29 | train |
awslabs/serverless-application-model | samtranslator/model/types.py | list_of | 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... | python | 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",
")",
":",
"def",
"validate",
"(",
"value",
",",
"should_raise",
"=",
"True",
")",
":",
"validate_type",
"=",
"is_type",
"(",
"list",
")",
"if",
"not",
"validate_type",
"(",
"value",
",",
"should_raise",
"=",
"should_... | 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,... | [
"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",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/types.py#L32-L54 | train |
awslabs/serverless-application-model | samtranslator/model/types.py | dict_of | 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... | python | 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",
")",
":",
"def",
"validate",
"(",
"value",
",",
"should_raise",
"=",
"True",
")",
":",
"validate_type",
"=",
"is_type",
"(",
"dict",
")",
"if",
"not",
"validate_type",
"(",
"value",
",",
"should_... | 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... | [
"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",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/types.py#L57-L88 | train |
awslabs/serverless-application-model | samtranslator/model/types.py | one_of | 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
... | python | 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",
")",
":",
"def",
"validate",
"(",
"value",
",",
"should_raise",
"=",
"True",
")",
":",
"if",
"any",
"(",
"validate",
"(",
"value",
",",
"should_raise",
"=",
"False",
")",
"for",
"validate",
"in",
"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
otherwise
:rtype: call... | [
"Returns",
"a",
"validator",
"function",
"that",
"succeeds",
"only",
"if",
"the",
"input",
"passes",
"at",
"least",
"one",
"of",
"the",
"provided",
"validators",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/types.py#L91-L106 | train |
awslabs/serverless-application-model | samtranslator/policy_template_processor/template.py | Template.to_statement | 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... | python | 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",
")",
":",
"missing",
"=",
"self",
".",
"missing_parameter_values",
"(",
"parameter_values",
")",
"if",
"len",
"(",
"missing",
")",
">",
"0",
":",
"# str() of elements of list to prevent any `u` prefix from b... | 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... | [
"With",
"the",
"given",
"values",
"for",
"each",
"parameter",
"this",
"method",
"will",
"return",
"a",
"policy",
"statement",
"that",
"can",
"be",
"used",
"directly",
"with",
"IAM",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/policy_template_processor/template.py#L30-L62 | train |
awslabs/serverless-application-model | samtranslator/policy_template_processor/template.py | Template.missing_parameter_values | 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... | python | 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",
")",
":",
"if",
"not",
"self",
".",
"_is_valid_parameter_values",
"(",
"parameter_values",
")",
":",
"raise",
"InvalidParameterValues",
"(",
"\"Parameter values are required to process a policy template\... | 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 ... | [
"Checks",
"if",
"the",
"given",
"input",
"contains",
"values",
"for",
"all",
"parameters",
"used",
"by",
"this",
"template"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/policy_template_processor/template.py#L64-L76 | train |
awslabs/serverless-application-model | samtranslator/policy_template_processor/template.py | Template.from_dict | 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... | python | 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",
")",
":",
"parameters",
"=",
"template_values_dict",
".",
"get",
"(",
"\"Parameters\"",
",",
"{",
"}",
")",
"definition",
"=",
"template_values_dict",
".",
"get",
"(",
"\"Definition\"",
",",
... | 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... | [
"Parses",
"the",
"input",
"and",
"returns",
"an",
"instance",
"of",
"this",
"class",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/policy_template_processor/template.py#L102-L115 | train |
awslabs/serverless-application-model | samtranslator/plugins/__init__.py | SamPlugins.register | 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.... | python | 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",
")",
":",
"if",
"not",
"plugin",
"or",
"not",
"isinstance",
"(",
"plugin",
",",
"BasePlugin",
")",
":",
"raise",
"ValueError",
"(",
"\"Plugin must be implemented as a subclass of BasePlugin class\"",
")",
"if",
"self"... | 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... | [
"Register",
"a",
"plugin",
".",
"New",
"plugins",
"are",
"added",
"to",
"the",
"end",
"of",
"the",
"plugins",
"list",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/__init__.py#L64-L80 | train |
awslabs/serverless-application-model | samtranslator/plugins/__init__.py | SamPlugins._get | 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... | python | 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",
")",
":",
"for",
"p",
"in",
"self",
".",
"_plugins",
":",
"if",
"p",
".",
"name",
"==",
"plugin_name",
":",
"return",
"p",
"return",
"None"
] | 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 | [
"Retrieves",
"the",
"plugin",
"with",
"given",
"name"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/__init__.py#L92-L104 | train |
awslabs/serverless-application-model | samtranslator/plugins/__init__.py | SamPlugins.act | 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 ... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"event",
",",
"LifeCycleEvents",
")",
":",
"raise",
"ValueError",
"(",
"\"'event' must be an instance of LifeCycleEvents class\"",
")"... | 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... | [
"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... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/__init__.py#L106-L136 | train |
awslabs/serverless-application-model | samtranslator/model/preferences/deployment_preference.py | DeploymentPreference.from_dict | 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... | python | 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",
")",
":",
"enabled",
"=",
"deployment_preference_dict",
".",
"get",
"(",
"'Enabled'",
",",
"True",
")",
"if",
"not",
"enabled",
":",
"return",
"DeploymentPreference",
"(",
"Non... | :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: | [
":",
"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",... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/preferences/deployment_preference.py#L37-L60 | train |
awslabs/serverless-application-model | examples/2016-10-31/encryption_proxy/src/decryption.py | decrypt | 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... | python | 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",
")",
":",
"try",
":",
"ret",
"=",
"kms",
".",
"decrypt",
"(",
"CiphertextBlob",
"=",
"base64",
".",
"decodestring",
"(",
"message",
")",
")",
"decrypted_data",
"=",
"ret",
".",
"get",
"(",
"'Plaintext'",
")",
"except",
... | 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 | [
"decrypt",
"leverages",
"KMS",
"decrypt",
"and",
"base64",
"-",
"encode",
"decrypted",
"blob"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/2016-10-31/encryption_proxy/src/decryption.py#L15-L29 | train |
awslabs/serverless-application-model | examples/apps/rekognition-python/lambda_function.py | lambda_handler | 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... | python | 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",
")",
":",
"#print(\"Received event: \" + json.dumps(event, indent=2))",
"# Get the object from the event",
"bucket",
"=",
"event",
"[",
"'Records'",
"]",
"[",
"0",
"]",
"[",
"'s3'",
"]",
"[",
"'bucket'",
"]",
"[... | Demonstrates S3 trigger that uses
Rekognition APIs to detect faces, labels and index faces in S3 Object. | [
"Demonstrates",
"S3",
"trigger",
"that",
"uses",
"Rekognition",
"APIs",
"to",
"detect",
"faces",
"labels",
"and",
"index",
"faces",
"in",
"S3",
"Object",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/rekognition-python/lambda_function.py#L42-L69 | train |
awslabs/serverless-application-model | samtranslator/model/exceptions.py | prepend | 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... | python | 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",
"=",
"': '",
")",
":",
"exception",
".",
"args",
"=",
"exception",
".",
"args",
"or",
"(",
"''",
",",
")",
"exception",
".",
"args",
"=",
"(",
"message",
"+",
"end",
"+",
"exception",
... | 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... | [
"Prepends",
"the",
"first",
"argument",
"(",
"i",
".",
"e",
".",
"the",
"exception",
"message",
")",
"of",
"the",
"a",
"BaseException",
"with",
"the",
"provided",
"message",
".",
"Useful",
"for",
"reraising",
"exceptions",
"with",
"additional",
"information",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/exceptions.py#L87-L98 | train |
awslabs/serverless-application-model | examples/apps/api-gateway-authorizer-python/lambda_function.py | lambda_handler | 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... | python | 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'",
"]",
")",
"principalId",
"=",
"'user|a1b2c3d4'",... | 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 | [
"Validate",
"the",
"incoming",
"token",
"and",
"produce",
"the",
"principal",
"user",
"identifier",
"associated",
"with",
"the",
"token",
".",
"This",
"can",
"be",
"accomplished",
"in",
"a",
"number",
"of",
"ways",
":"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/api-gateway-authorizer-python/lambda_function.py#L6-L68 | train |
awslabs/serverless-application-model | examples/apps/api-gateway-authorizer-python/lambda_function.py | AuthPolicy._getStatementForEffect | 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... | python | 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",
")",
":",
"statements",
"=",
"[",
"]",
"if",
"len",
"(",
"methods",
")",
">",
"0",
":",
"statement",
"=",
"self",
".",
"_getEmptyStatement",
"(",
"effect",
")",
"for",
"curMetho... | This function loops over an array of objects containing a resourceArn and
conditions statement and generates the array of statements for the policy. | [
"This",
"function",
"loops",
"over",
"an",
"array",
"of",
"objects",
"containing",
"a",
"resourceArn",
"and",
"conditions",
"statement",
"and",
"generates",
"the",
"array",
"of",
"statements",
"for",
"the",
"policy",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/api-gateway-authorizer-python/lambda_function.py#L151-L171 | train |
awslabs/serverless-application-model | samtranslator/plugins/policies/policy_templates_plugin.py | PolicyTemplatesForFunctionPlugin.on_before_transform_resource | 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... | python | 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",
")",
":",
"if",
"not",
"self",
".",
"_is_supported",
"(",
"resource_type",
")",
":",
"return",
"function_policies",
"=",
"FunctionPolicies",
"(",... | 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 | [
"Hook",
"method",
"that",
"gets",
"called",
"before",
"each",
"SAM",
"resource",
"gets",
"processed"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/policies/policy_templates_plugin.py#L31-L78 | train |
awslabs/serverless-application-model | examples/apps/kinesis-analytics-process-kpl-record/lambda_function.py | lambda_handler | 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... | python | 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",
")",
":",
"raw_kpl_records",
"=",
"event",
"[",
"'records'",
"]",
"output",
"=",
"[",
"process_kpl_record",
"(",
"kpl_record",
")",
"for",
"kpl_record",
"in",
"raw_kpl_records",
"]",
"# Print number of success... | A Python AWS Lambda function to process aggregated records sent to KinesisAnalytics. | [
"A",
"Python",
"AWS",
"Lambda",
"function",
"to",
"process",
"aggregated",
"records",
"sent",
"to",
"KinesisAnalytics",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/kinesis-analytics-process-kpl-record/lambda_function.py#L25-L35 | train |
awslabs/serverless-application-model | samtranslator/translator/transform.py | transform | 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... | python | 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",
")",
":",
"sam_parser",
"=",
"Parser",
"(",
")",
"translator",
"=",
"Translator",
"(",
"managed_policy_loader",
".",
"load",
"(",
")",
",",
"sam_parser",
")",
"retu... | 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 | [
"Translates",
"the",
"SAM",
"manifest",
"provided",
"in",
"the",
"and",
"returns",
"the",
"translation",
"to",
"CloudFormation",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/transform.py#L5-L16 | train |
awslabs/serverless-application-model | samtranslator/model/update_policy.py | UpdatePolicy.to_dict | 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... | python | 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",
")",
":",
"dict_with_nones",
"=",
"self",
".",
"_asdict",
"(",
")",
"codedeploy_lambda_alias_update_dict",
"=",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"dict_with_nones",
".",
"items",
"(",
")",
... | :return: a dict that can be used as part of a cloudformation template | [
":",
"return",
":",
"a",
"dict",
"that",
"can",
"be",
"used",
"as",
"part",
"of",
"a",
"cloudformation",
"template"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/update_policy.py#L23-L30 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/implicit_api_plugin.py | ImplicitApiPlugin.on_before_transform_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
... | python | 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",
")",
":",
"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... | 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 | [
"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",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L48-L89 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/implicit_api_plugin.py | ImplicitApiPlugin._get_api_events | 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... | python | 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",
")",
":",
"if",
"not",
"(",
"function",
".",
"valid",
"(",
")",
"and",
"isinstance",
"(",
"function",
".",
"properties",
",",
"dict",
")",
"and",
"isinstance",
"(",
"function",
".",
"properties",
".... | 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... | [
"Method",
"to",
"return",
"a",
"dictionary",
"of",
"API",
"Events",
"on",
"the",
"function"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L91-L118 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/implicit_api_plugin.py | ImplicitApiPlugin._process_api_events | 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... | python | 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",
")",
":",
"for",
"logicalId",
",",
"event",
"in",
"api_events",
".",
"items",
"(",
")",
":",
"event_properties",
"=",
"event",
".... | 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... | [
"Actually",
"process",
"given",
"API",
"events",
".",
"Iteratively",
"adds",
"the",
"APIs",
"to",
"Swagger",
"JSON",
"in",
"the",
"respective",
"Serverless",
"::",
"Api",
"resource",
"from",
"the",
"template"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L120-L162 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/implicit_api_plugin.py | ImplicitApiPlugin._add_api_to_swagger | 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... | python | 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",
")",
":",
"# 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... | 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... | [
"Adds",
"the",
"API",
"path",
"/",
"method",
"from",
"the",
"given",
"event",
"to",
"the",
"Swagger",
"JSON",
"of",
"Serverless",
"::",
"Api",
"resource",
"this",
"event",
"refers",
"to",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L175-L221 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/implicit_api_plugin.py | ImplicitApiPlugin._get_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:
... | python | 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",
")",
":",
"api_id",
"=",
"event_properties",
".",
"get",
"(",
"\"RestApiId\"",
")",
"if",
"isinstance",
"(",
"api_id",
",",
"dict",
")",
"and",
"\"Ref\"",
"in",
"api_id",
":",
"api_id",
"=",
"api_... | Get API logical id from API event properties.
Handles case where API id is not specified or is a reference to a logical id. | [
"Get",
"API",
"logical",
"id",
"from",
"API",
"event",
"properties",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L223-L232 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/implicit_api_plugin.py | ImplicitApiPlugin._maybe_add_condition_to_implicit_api | 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... | python | 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",
")",
":",
"# Short-circuit if template doesn't have any functions with implicit API events",
"if",
"not",
"self",
".",
"api_conditions",
".",
"get",
"(",
"self",
".",
"implicit_api_logical_id",
... | Decides whether to add a condition to the implicit api resource.
:param dict template_dict: SAM template dictionary | [
"Decides",
"whether",
"to",
"add",
"a",
"condition",
"to",
"the",
"implicit",
"api",
"resource",
".",
":",
"param",
"dict",
"template_dict",
":",
"SAM",
"template",
"dictionary"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L234-L262 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/implicit_api_plugin.py | ImplicitApiPlugin._add_combined_condition_to_template | 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... | python | 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",
")",
":",
"# defensive precondition check",
"if",
"not",
"conditions_to_combine",
"or",
"len",
"(",
"conditions_to_combine",
")",
"<",
"2"... | 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... | [
"Add",
"top",
"-",
"level",
"template",
"condition",
"that",
"combines",
"the",
"given",
"list",
"of",
"conditions",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L264-L280 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/implicit_api_plugin.py | ImplicitApiPlugin._maybe_add_conditions_to_implicit_api_paths | 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... | python | 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",
")",
":",
"for",
"api_id",
",",
"api",
"in",
"template",
".",
"iterate",
"(",
"SamResourceType",
".",
"Api",
".",
"value",
")",
":",
"if",
"not",
"api",
".",
"properties",
".... | 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... | [
"Add",
"conditions",
"to",
"implicit",
"API",
"paths",
"if",
"necessary",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L282-L317 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/implicit_api_plugin.py | ImplicitApiPlugin._path_condition_name | 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... | python | 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",
")",
":",
"# 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... | Generate valid condition logical id from the given API logical id and swagger resource path. | [
"Generate",
"valid",
"condition",
"logical",
"id",
"from",
"the",
"given",
"API",
"logical",
"id",
"and",
"swagger",
"resource",
"path",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L319-L327 | train |
awslabs/serverless-application-model | samtranslator/plugins/api/implicit_api_plugin.py | ImplicitApiPlugin._maybe_remove_implicit_api | 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... | python | 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",
")",
":",
"# Remove Implicit API resource if no paths got added",
"implicit_api_resource",
"=",
"template",
".",
"get",
"(",
"self",
".",
"implicit_api_logical_id",
")",
"if",
"implicit_api_resource",
"and",... | 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... | [
"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",
"*"... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/api/implicit_api_plugin.py#L329-L347 | train |
awslabs/serverless-application-model | samtranslator/model/apigateway.py | ApiGatewayDeployment.make_auto_deployable | 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 ... | python | 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",
")",
":",
"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... | 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 | [
"Sets",
"up",
"the",
"resource",
"such",
"that",
"it",
"will",
"triggers",
"a",
"re",
"-",
"deployment",
"when",
"Swagger",
"changes"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/apigateway.py#L76-L95 | train |
awslabs/serverless-application-model | examples/apps/greengrass-hello-world/greengrasssdk/Lambda.py | Client._invoke_internal | 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... | python | 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\"",
")",
":",
"customer_logger",
".",
"info",
"(",
"'Invoking Lambda function \"{}\" with Greengrass Message \"{}\"'",
".",
... | 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... | [
"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... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrasssdk/Lambda.py#L86-L114 | train |
awslabs/serverless-application-model | examples/apps/greengrass-hello-world/greengrasssdk/Lambda.py | StreamingBody.read | 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 | python | 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",
")",
":",
"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. | [
"Read",
"at",
"most",
"amt",
"bytes",
"from",
"the",
"stream",
".",
"If",
"the",
"amt",
"argument",
"is",
"omitted",
"read",
"all",
"data",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrasssdk/Lambda.py#L126-L132 | train |
awslabs/serverless-application-model | examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py | IPCClient.post_work | 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... | python | 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\"",
")",
":",
"url",
"=",
"self",
".",
"_get_url",
"(",
"function_arn",
")",
"runtime_logger",
".",
"info",
"(",
"'... | 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... | [
"Send",
"work",
"item",
"to",
"specified",
":",
"code",
":",
"function_arn",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py#L81-L110 | train |
awslabs/serverless-application-model | examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py | IPCClient.get_work | 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... | python | 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",
")",
":",
"url",
"=",
"self",
".",
"_get_work_url",
"(",
"function_arn",
")",
"runtime_logger",
".",
"info",
"(",
"'Getting work for function [{}] from {}'",
".",
"format",
"(",
"function_arn",
",",
"url",
")"... | 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 | [
"Retrieve",
"the",
"next",
"work",
"item",
"for",
"specified",
":",
"code",
":",
"function_arn",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py#L113-L138 | train |
awslabs/serverless-application-model | examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py | IPCClient.post_work_result | 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... | python | 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",
")",
":",
"url",
"=",
"self",
".",
"_get_work_url",
"(",
"function_arn",
")",
"runtime_logger",
".",
"info",
"(",
"'Posting work result for invocation id [{}] to {}'",
".",
"format",
"(",... | 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... | [
"Post",
"the",
"result",
"of",
"processing",
"work",
"item",
"by",
":",
"code",
":",
"function_arn",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py#L141-L163 | train |
awslabs/serverless-application-model | examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py | IPCClient.post_handler_err | 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.
... | python | 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",
")",
":",
"url",
"=",
"self",
".",
"_get_work_url",
"(",
"function_arn",
")",
"runtime_logger",
".",
"info",
"(",
"'Posting handler error for invocation id [{}] to {... | 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 ... | [
"Post",
"the",
"error",
"message",
"from",
"executing",
"the",
"function",
"handler",
"for",
":",
"code",
":",
"function_arn",
"with",
"specifid",
":",
"code",
":",
"invocation_id"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py#L166-L196 | train |
awslabs/serverless-application-model | examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py | IPCClient.get_work_result | 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... | python | 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",
")",
":",
"url",
"=",
"self",
".",
"_get_url",
"(",
"function_arn",
")",
"runtime_logger",
".",
"info",
"(",
"'Getting work result for invocation id [{}] from {}'",
".",
"format",
"(",... | 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 ... | [
"Retrieve",
"the",
"result",
"of",
"the",
"work",
"processed",
"by",
":",
"code",
":",
"function_arn",
"with",
"specified",
":",
"code",
":",
"invocation_id",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrass_ipc_python_sdk/ipc_client.py#L199-L230 | train |
awslabs/serverless-application-model | samtranslator/plugins/application/serverless_app_plugin.py | ServerlessAppPlugin.on_before_transform_template | 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... | python | 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",
")",
":",
"template",
"=",
"SamTemplate",
"(",
"template_dict",
")",
"intrinsic_resolvers",
"=",
"self",
".",
"_get_intrinsic_resolvers",
"(",
"template_dict",
".",
"get",
"(",
"'Mappings'",
"... | 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 ... | [
"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",
"."... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L64-L109 | train |
awslabs/serverless-application-model | samtranslator/plugins/application/serverless_app_plugin.py | ServerlessAppPlugin._can_process_application | 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... | python | 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",
")",
":",
"return",
"(",
"self",
".",
"LOCATION_KEY",
"in",
"app",
".",
"properties",
"and",
"isinstance",
"(",
"app",
".",
"properties",
"[",
"self",
".",
"LOCATION_KEY",
"]",
",",
"dict",
")",
... | Determines whether or not the on_before_transform_template event can process this application
:param dict app: the application and its properties | [
"Determines",
"whether",
"or",
"not",
"the",
"on_before_transform_template",
"event",
"can",
"process",
"this",
"application"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L126-L135 | train |
awslabs/serverless-application-model | samtranslator/plugins/application/serverless_app_plugin.py | ServerlessAppPlugin._handle_get_application_request | 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.
... | python | 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",
")",
":",
"get_application",
"=",
"(",
"lambda",
"app_id",
",",
"semver",
":",
"self",
".",
"_sar_client",
".",
"get_application",
"(",
"Applica... | 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
... | [
"Method",
"that",
"handles",
"the",
"get_application",
"API",
"call",
"to",
"the",
"serverless",
"application",
"repo"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L137-L159 | train |
awslabs/serverless-application-model | samtranslator/plugins/application/serverless_app_plugin.py | ServerlessAppPlugin._handle_create_cfn_template_request | 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... | python | 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",
")",
":",
"create_cfn_template",
"=",
"(",
"lambda",
"app_id",
",",
"semver",
":",
"self",
".",
"_sar_client",
".",
"create_cloud_formation_temp... | 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... | [
"Method",
"that",
"handles",
"the",
"create_cloud_formation_template",
"API",
"call",
"to",
"the",
"serverless",
"application",
"repo"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L161-L177 | train |
awslabs/serverless-application-model | samtranslator/plugins/application/serverless_app_plugin.py | ServerlessAppPlugin.on_before_transform_resource | 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... | python | 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",
")",
":",
"if",
"not",
"self",
".",
"_resource_is_supported",
"(",
"resource_type",
")",
":",
"return",
"# Sanitize properties",
"self",
".",
"_c... | 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... | [
"Hook",
"method",
"that",
"gets",
"called",
"before",
"each",
"SAM",
"resource",
"gets",
"processed"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L194-L247 | train |
awslabs/serverless-application-model | samtranslator/plugins/application/serverless_app_plugin.py | ServerlessAppPlugin._check_for_dictionary_key | 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... | python | 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",
")",
":",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"not",
"in",
"dictionary",
":",
"raise",
"InvalidResourceException",
"(",
"logical_id",
",",
"'Resource ... | 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 | [
"Checks",
"a",
"dictionary",
"to",
"make",
"sure",
"it",
"has",
"a",
"specific",
"key",
".",
"If",
"it",
"does",
"not",
"an",
"InvalidResourceException",
"is",
"thrown",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L249-L261 | train |
awslabs/serverless-application-model | samtranslator/plugins/application/serverless_app_plugin.py | ServerlessAppPlugin.on_after_transform_template | 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... | python | 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",
")",
":",
"if",
"self",
".",
"_wait_for_template_active_status",
"and",
"not",
"self",
".",
"_validate_only",
":",
"start_time",
"=",
"time",
"(",
")",
"while",
"(",
"time",
"(",
")",
"-",
"... | 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 | [
"Hook",
"method",
"that",
"gets",
"called",
"after",
"the",
"template",
"is",
"processed"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L263-L298 | train |
awslabs/serverless-application-model | samtranslator/plugins/application/serverless_app_plugin.py | ServerlessAppPlugin._handle_get_cfn_template_response | 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... | python | 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",
")",
":",
"status",
"=",
"response",
"[",
"'Status'",
"]",
"if",
"status",
"!=",
"\"ACTIVE\"",
":",
"# Other options are PREPARING and EXPIRED.",
"if",... | 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 | [
"Handles",
"the",
"response",
"from",
"the",
"SAR",
"service",
"call"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L300-L315 | train |
awslabs/serverless-application-model | samtranslator/plugins/application/serverless_app_plugin.py | ServerlessAppPlugin._sar_service_call | 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... | python | 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",
")",
":",
"try",
":",
"response",
"=",
"service_call_lambda",
"(",
"*",
"args",
")",
"logging",
".",
"info",
"(",
"response",
")",
"return",
"response",... | 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 ... | [
"Handles",
"service",
"calls",
"and",
"exception",
"management",
"for",
"service",
"calls",
"to",
"the",
"Serverless",
"Application",
"Repository",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L317-L337 | train |
awslabs/serverless-application-model | samtranslator/parser/parser.py | Parser._validate | 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... | python | 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",
")",
":",
"if",
"parameter_values",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"`parameter_values` argument is required\"",
")",
"if",
"(",
"\"Resources\"",
"not",
"in",
"sam_templa... | 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 | [
"Validates",
"the",
"template",
"and",
"parameter",
"values",
"and",
"raises",
"exceptions",
"if",
"there",
"s",
"an",
"issue"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/parser/parser.py#L16-L50 | train |
awslabs/serverless-application-model | samtranslator/sdk/template.py | SamTemplate.iterate | 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
"""
... | python | 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",
")",
":",
"for",
"logicalId",
",",
"resource_dict",
"in",
"self",
".",
"resources",
".",
"items",
"(",
")",
":",
"resource",
"=",
"SamResource",
"(",
"resource_dict",
")",
"needs_filter",
"=... | 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"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/sdk/template.py#L22-L38 | train |
awslabs/serverless-application-model | samtranslator/sdk/template.py | SamTemplate.set | 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... | python | 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",
")",
":",
"resource_dict",
"=",
"resource",
"if",
"isinstance",
"(",
"resource",
",",
"SamResource",
")",
":",
"resource_dict",
"=",
"resource",
".",
"to_dict",
"(",
")",
"self",
".",
"resources... | 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 | [
"Adds",
"the",
"resource",
"to",
"dictionary",
"with",
"given",
"logical",
"Id",
".",
"It",
"will",
"overwrite",
"if",
"the",
"logicalId",
"is",
"already",
"used",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/sdk/template.py#L40-L52 | train |
awslabs/serverless-application-model | samtranslator/sdk/template.py | SamTemplate.get | 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... | python | 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",
")",
":",
"if",
"logicalId",
"not",
"in",
"self",
".",
"resources",
":",
"return",
"None",
"return",
"SamResource",
"(",
"self",
".",
"resources",
".",
"get",
"(",
"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 | [
"Gets",
"the",
"resource",
"at",
"the",
"given",
"logicalId",
"if",
"present"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/sdk/template.py#L54-L64 | train |
awslabs/serverless-application-model | samtranslator/translator/translator.py | prepare_plugins | 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... | python | 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",
"=",
"{",
"}",
")",
":",
"required_plugins",
"=",
"[",
"DefaultDefinitionBodyPlugin",
"(",
")",
",",
"make_implicit_api_plugin",
"(",
")",
",",
"GlobalsPlugin",
"(",
")",
",",
"make_policy_template_for_f... | 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... | [
"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... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/translator.py#L163-L188 | train |
awslabs/serverless-application-model | samtranslator/translator/translator.py | Translator.translate | 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... | python | 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",
")",
":",
"sam_parameter_values",
"=",
"SamParameterValues",
"(",
"parameter_values",
")",
"sam_parameter_values",
".",
"add_default_parameter_values",
"(",
"sam_template",
")",
"sam_parameter_... | 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... | [
"Loads",
"the",
"SAM",
"resources",
"from",
"the",
"given",
"SAM",
"manifest",
"replaces",
"them",
"with",
"their",
"corresponding",
"CloudFormation",
"resources",
"and",
"returns",
"the",
"resulting",
"CloudFormation",
"template",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/translator.py#L34-L122 | train |
awslabs/serverless-application-model | samtranslator/translator/translator.py | Translator._get_resources_to_iterate | 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... | python | 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",
")",
":",
"functions",
"=",
"[",
"]",
"apis",
"=",
"[",
"]",
"others",
"=",
"[",
"]",
"resources",
"=",
"sam_template",
"[",
"\"Resources\"",
"]",
"for",
"logicalId"... | 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... | [
"Returns",
"a",
"list",
"of",
"resources",
"to",
"iterate",
"order",
"them",
"based",
"on",
"the",
"following",
"order",
":"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/translator.py#L125-L160 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | Resource.from_dict | 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
... | python | 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",
")",
":",
"resource",
"=",
"cls",
"(",
"logical_id",
",",
"relative_id",
"=",
"relative_id",
")",
"resource",
".",
"_... | 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>",
... | [
"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... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L78-L126 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | Resource._validate_logical_id | 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
"""
... | python | 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",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r'^[A-Za-z0-9]+$'",
")",
"if",
"logical_id",
"is",
"not",
"None",
"and",
"pattern",
".",
"match",
"(",
"logical_id",
")",
":",
"return",
"Tr... | 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",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L129-L140 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | Resource._validate_resource_dict | 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
... | python | 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",
")",
":",
"if",
"'Type'",
"not",
"in",
"resource_dict",
":",
"raise",
"InvalidResourceException",
"(",
"logical_id",
",",
"\"Resource dict missing key 'Type'.\"",
")",
"if",
"resour... | 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... | [
"Validates",
"that",
"the",
"provided",
"resource",
"dict",
"contains",
"the",
"correct",
"Type",
"string",
"and",
"the",
"required",
"Properties",
"dict",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L143-L160 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | Resource.to_dict | 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... | python | 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",
")",
":",
"self",
".",
"validate_properties",
"(",
")",
"resource_dict",
"=",
"self",
".",
"_generate_resource_dict",
"(",
")",
"return",
"{",
"self",
".",
"logical_id",
":",
"resource_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. ::
{
... | [
"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"... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L162-L187 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | Resource._generate_resource_dict | 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... | python | 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",
")",
":",
"resource_dict",
"=",
"{",
"}",
"resource_dict",
"[",
"'Type'",
"]",
"=",
"self",
".",
"resource_type",
"if",
"self",
".",
"depends_on",
":",
"resource_dict",
"[",
"'DependsOn'",
"]",
"=",
"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 | [
"Generates",
"the",
"resource",
"dict",
"for",
"this",
"Resource",
"the",
"value",
"associated",
"with",
"the",
"logical",
"id",
"in",
"a",
"CloudFormation",
"template",
"s",
"Resources",
"section",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L189-L213 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | Resource.validate_properties | 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
"""
... | python | 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",
")",
":",
"for",
"name",
",",
"property_type",
"in",
"self",
".",
"property_types",
".",
"items",
"(",
")",
":",
"value",
"=",
"getattr",
"(",
"self",
",",
"name",
")",
"# If the property value is an intrinsic function,... | 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",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L230-L255 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | Resource.set_resource_attribute | 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
:... | python | 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",
")",
":",
"if",
"attr",
"not",
"in",
"self",
".",
"_supported_resource_attributes",
":",
"raise",
"KeyError",
"(",
"\"Unsupported resource attribute specified: %s\"",
"%",
"attr",
")",
"self",
... | 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... | [
"Sets",
"attributes",
"on",
"resource",
".",
"Resource",
"attributes",
"are",
"top",
"-",
"level",
"entries",
"of",
"a",
"CloudFormation",
"resource",
"that",
"exist",
"outside",
"of",
"the",
"Properties",
"dictionary"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L257-L270 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | Resource.get_resource_attribute | 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... | python | 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",
")",
":",
"if",
"attr",
"not",
"in",
"self",
".",
"resource_attributes",
":",
"raise",
"KeyError",
"(",
"\"%s is not in resource attributes\"",
"%",
"attr",
")",
"return",
"self",
".",
"resource_attributes... | Gets the resource attribute if available
:param attr: Name of the attribute
:return: Value of the attribute, if set in the resource. None otherwise | [
"Gets",
"the",
"resource",
"attribute",
"if",
"available"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L272-L281 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | Resource.get_runtime_attr | 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... | python | 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",
")",
":",
"if",
"attr_name",
"in",
"self",
".",
"runtime_attrs",
":",
"return",
"self",
".",
"runtime_attrs",
"[",
"attr_name",
"]",
"(",
"self",
")",
"else",
":",
"raise",
"NotImplementedError",
"(",... | 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 | [
"Returns",
"a",
"CloudFormation",
"construct",
"that",
"provides",
"value",
"for",
"this",
"attribute",
".",
"If",
"the",
"resource",
"does",
"not",
"provide",
"this",
"attribute",
"then",
"this",
"method",
"raises",
"an",
"exception"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L295-L306 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | SamResourceMacro.get_resource_references | 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 ... | python | 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",
")",
":",
"if",
"supported_resource_refs",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"`supported_resource_refs` object is required\"",
")",
"# Create a map of... | 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... | [
"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",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L383-L406 | train |
awslabs/serverless-application-model | samtranslator/model/__init__.py | ResourceTypeResolver.resolve_resource_type | 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... | python | 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",
")",
":",
"if",
"not",
"self",
".",
"can_resolve",
"(",
"resource_dict",
")",
":",
"raise",
"TypeError",
"(",
"\"Resource dict has missing or invalid value for key Type. Event Type is: {}.\"",
".",
"format... | 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 | [
"Returns",
"the",
"Resource",
"class",
"corresponding",
"to",
"the",
"Type",
"key",
"in",
"the",
"given",
"resource",
"dict",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/__init__.py#L469-L481 | train |
awslabs/serverless-application-model | examples/apps/lex-make-appointment-python/lambda_function.py | build_response_card | 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... | python | 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",
")",
":",
"buttons",
"=",
"None",
"if",
"options",
"is",
"not",
"None",
":",
"buttons",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"min",
"(",
"5",
",",
"len",
"(",
"o... | Build a responseCard with a title, subtitle, and an optional set of options which should be displayed as buttons. | [
"Build",
"a",
"responseCard",
"with",
"a",
"title",
"subtitle",
"and",
"an",
"optional",
"set",
"of",
"options",
"which",
"should",
"be",
"displayed",
"as",
"buttons",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L75-L93 | train |
awslabs/serverless-application-model | examples/apps/lex-make-appointment-python/lambda_function.py | get_random_int | 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) | python | 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",
")",
":",
"min_int",
"=",
"math",
".",
"ceil",
"(",
"minimum",
")",
"max_int",
"=",
"math",
".",
"floor",
"(",
"maximum",
")",
"return",
"random",
".",
"randint",
"(",
"min_int",
",",
"max_int",
... | Returns a random integer between min (included) and max (excluded) | [
"Returns",
"a",
"random",
"integer",
"between",
"min",
"(",
"included",
")",
"and",
"max",
"(",
"excluded",
")"
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L125-L132 | train |
awslabs/serverless-application-model | examples/apps/lex-make-appointment-python/lambda_function.py | get_availabilities | 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... | python | 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",
")",
":",
"day_of_week",
"=",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"date",
")",
".",
"weekday",
"(",
")",
"availabilities",
"=",
"[",
"]",
"available_probability",
"=",
"0.3",
"if",
"day_of_week",
"==",
"0... | 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... | [
"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... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L135-L169 | train |
awslabs/serverless-application-model | examples/apps/lex-make-appointment-python/lambda_function.py | is_available | 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... | python | 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",
")",
":",
"if",
"duration",
"==",
"30",
":",
"return",
"time",
"in",
"availabilities",
"elif",
"duration",
"==",
"60",
":",
"second_half_hour_time",
"=",
"increment_time_by_thirty_mins",
... | 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. | [
"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",
... | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L172-L184 | train |
awslabs/serverless-application-model | examples/apps/lex-make-appointment-python/lambda_function.py | get_availabilities_for_duration | 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... | python | 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",
")",
":",
"duration_availabilities",
"=",
"[",
"]",
"start_time",
"=",
"'10:00'",
"while",
"start_time",
"!=",
"'17:00'",
":",
"if",
"start_time",
"in",
"availabilities",
":",
"if",
... | Helper function to return the windows of availability of the given duration, when provided a set of 30 minute windows. | [
"Helper",
"function",
"to",
"return",
"the",
"windows",
"of",
"availability",
"of",
"the",
"given",
"duration",
"when",
"provided",
"a",
"set",
"of",
"30",
"minute",
"windows",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L192-L207 | train |
awslabs/serverless-application-model | examples/apps/lex-make-appointment-python/lambda_function.py | build_available_time_string | 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... | python | 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",
")",
":",
"prefix",
"=",
"'We have availabilities at '",
"if",
"len",
"(",
"availabilities",
")",
">",
"3",
":",
"prefix",
"=",
"'We have plenty of availability, including '",
"prefix",
"+=",
"build_time_output_... | Build a string eliciting for a possible time slot among at least two availabilities. | [
"Build",
"a",
"string",
"eliciting",
"for",
"a",
"possible",
"time",
"slot",
"among",
"at",
"least",
"two",
"availabilities",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L261-L273 | train |
awslabs/serverless-application-model | examples/apps/lex-make-appointment-python/lambda_function.py | build_options | 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... | python | 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",
")",
":",
"day_strings",
"=",
"[",
"'Mon'",
",",
"'Tue'",
",",
"'Wed'",
",",
"'Thu'",
",",
"'Fri'",
",",
"'Sat'",
",",
"'Sun'",
"]",
"if",
"slot",
"==",
"'Ap... | Build a list of potential options for a given slot, to be used in responseCard generation. | [
"Build",
"a",
"list",
"of",
"potential",
"options",
"for",
"a",
"given",
"slot",
"to",
"be",
"used",
"in",
"responseCard",
"generation",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L276-L314 | train |
awslabs/serverless-application-model | examples/apps/lex-make-appointment-python/lambda_function.py | make_appointment | 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... | python | 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",
")",
":",
"appointment_type",
"=",
"intent_request",
"[",
"'currentIntent'",
"]",
"[",
"'slots'",
"]",
"[",
"'AppointmentType'",
"]",
"date",
"=",
"intent_request",
"[",
"'currentIntent'",
"]",
"[",
"'slots'",
"]",... | 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... | [
"Performs",
"dialog",
"management",
"and",
"fulfillment",
"for",
"booking",
"a",
"dentists",
"appointment",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L320-L476 | train |
awslabs/serverless-application-model | examples/apps/lex-make-appointment-python/lambda_function.py | dispatch | 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... | python | 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",
")",
":",
"logger",
".",
"debug",
"(",
"'dispatch userId={}, intentName={}'",
".",
"format",
"(",
"intent_request",
"[",
"'userId'",
"]",
",",
"intent_request",
"[",
"'currentIntent'",
"]",
"[",
"'name'",
"]",
")",
")",
... | Called when the user specifies an intent for this bot. | [
"Called",
"when",
"the",
"user",
"specifies",
"an",
"intent",
"for",
"this",
"bot",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-make-appointment-python/lambda_function.py#L482-L494 | train |
awslabs/serverless-application-model | examples/apps/microservice-http-endpoint-python3/lambda_function.py | lambda_handler | 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... | python | 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",
")",
":",
"print",
"(",
"\"Received event: \"",
"+",
"json",
".",
"dumps",
"(",
"event",
",",
"indent",
"=",
"2",
")",
")",
"operations",
"=",
"{",
"'DELETE'",
":",
"lambda",
"dynamo",
",",
"x",
":... | 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... | [
"Demonstrates",
"a",
"simple",
"HTTP",
"endpoint",
"using",
"API",
"Gateway",
".",
"You",
"have",
"full",
"access",
"to",
"the",
"request",
"and",
"response",
"payload",
"including",
"headers",
"and",
"status",
"code",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/microservice-http-endpoint-python3/lambda_function.py#L21-L46 | train |
awslabs/serverless-application-model | examples/apps/microservice-http-endpoint-python/lambda_function.py | lambda_handler | 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 ... | python | 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",
")",
":",
"#print(\"Received event: \" + json.dumps(event, indent=2))",
"operations",
"=",
"{",
"'DELETE'",
":",
"lambda",
"dynamo",
",",
"x",
":",
"dynamo",
".",
"delete_item",
"(",
"*",
"*",
"x",
")",
",",... | 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... | [
"Demonstrates",
"a",
"simple",
"HTTP",
"endpoint",
"using",
"API",
"Gateway",
".",
"You",
"have",
"full",
"access",
"to",
"the",
"request",
"and",
"response",
"payload",
"including",
"headers",
"and",
"status",
"code",
"."
] | cccb0c96b5c91e53355ebc07e542467303a5eedd | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/microservice-http-endpoint-python/lambda_function.py#L20-L44 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.