id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
23,200
allenai/allennlp
allennlp/semparse/contexts/table_question_knowledge_graph.py
TableQuestionKnowledgeGraph.get_linked_agenda_items
def get_linked_agenda_items(self) -> List[str]: """ Returns entities that can be linked to spans in the question, that should be in the agenda, for training a coverage based semantic parser. This method essentially does a heuristic entity linking, to provide weak supervision for a learni...
python
def get_linked_agenda_items(self) -> List[str]: """ Returns entities that can be linked to spans in the question, that should be in the agenda, for training a coverage based semantic parser. This method essentially does a heuristic entity linking, to provide weak supervision for a learni...
[ "def", "get_linked_agenda_items", "(", "self", ")", "->", "List", "[", "str", "]", ":", "agenda_items", ":", "List", "[", "str", "]", "=", "[", "]", "for", "entity", "in", "self", ".", "_get_longest_span_matching_entities", "(", ")", ":", "agenda_items", "...
Returns entities that can be linked to spans in the question, that should be in the agenda, for training a coverage based semantic parser. This method essentially does a heuristic entity linking, to provide weak supervision for a learning to search parser.
[ "Returns", "entities", "that", "can", "be", "linked", "to", "spans", "in", "the", "question", "that", "should", "be", "in", "the", "agenda", "for", "training", "a", "coverage", "based", "semantic", "parser", ".", "This", "method", "essentially", "does", "a",...
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/contexts/table_question_knowledge_graph.py#L345-L358
23,201
allenai/allennlp
scripts/convert_openie_to_conll.py
split_predicate
def split_predicate(ex: Extraction) -> Extraction: """ Ensure single word predicate by adding "before-predicate" and "after-predicate" arguments. """ rel_toks = ex.toks[char_to_word_index(ex.rel.span[0], ex.sent) \ : char_to_word_index(ex.rel.span[1], ex.sent) + 1] if ...
python
def split_predicate(ex: Extraction) -> Extraction: """ Ensure single word predicate by adding "before-predicate" and "after-predicate" arguments. """ rel_toks = ex.toks[char_to_word_index(ex.rel.span[0], ex.sent) \ : char_to_word_index(ex.rel.span[1], ex.sent) + 1] if ...
[ "def", "split_predicate", "(", "ex", ":", "Extraction", ")", "->", "Extraction", ":", "rel_toks", "=", "ex", ".", "toks", "[", "char_to_word_index", "(", "ex", ".", "rel", ".", "span", "[", "0", "]", ",", "ex", ".", "sent", ")", ":", "char_to_word_inde...
Ensure single word predicate by adding "before-predicate" and "after-predicate" arguments.
[ "Ensure", "single", "word", "predicate", "by", "adding", "before", "-", "predicate", "and", "after", "-", "predicate", "arguments", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/convert_openie_to_conll.py#L79-L109
23,202
allenai/allennlp
scripts/convert_openie_to_conll.py
extraction_to_conll
def extraction_to_conll(ex: Extraction) -> List[str]: """ Return a conll representation of a given input Extraction. """ ex = split_predicate(ex) toks = ex.sent.split(' ') ret = ['*'] * len(toks) args = [ex.arg1] + ex.args2 rels_and_args = [("ARG{}".format(arg_ind), arg) ...
python
def extraction_to_conll(ex: Extraction) -> List[str]: """ Return a conll representation of a given input Extraction. """ ex = split_predicate(ex) toks = ex.sent.split(' ') ret = ['*'] * len(toks) args = [ex.arg1] + ex.args2 rels_and_args = [("ARG{}".format(arg_ind), arg) ...
[ "def", "extraction_to_conll", "(", "ex", ":", "Extraction", ")", "->", "List", "[", "str", "]", ":", "ex", "=", "split_predicate", "(", "ex", ")", "toks", "=", "ex", ".", "sent", ".", "split", "(", "' '", ")", "ret", "=", "[", "'*'", "]", "*", "l...
Return a conll representation of a given input Extraction.
[ "Return", "a", "conll", "representation", "of", "a", "given", "input", "Extraction", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/convert_openie_to_conll.py#L111-L133
23,203
allenai/allennlp
scripts/convert_openie_to_conll.py
interpret_element
def interpret_element(element_type: str, text: str, span: str) -> Element: """ Construct an Element instance from regexp groups. """ return Element(element_type, interpret_span(span), text)
python
def interpret_element(element_type: str, text: str, span: str) -> Element: """ Construct an Element instance from regexp groups. """ return Element(element_type, interpret_span(span), text)
[ "def", "interpret_element", "(", "element_type", ":", "str", ",", "text", ":", "str", ",", "span", ":", "str", ")", "->", "Element", ":", "return", "Element", "(", "element_type", ",", "interpret_span", "(", "span", ")", ",", "text", ")" ]
Construct an Element instance from regexp groups.
[ "Construct", "an", "Element", "instance", "from", "regexp", "groups", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/convert_openie_to_conll.py#L177-L184
23,204
allenai/allennlp
scripts/convert_openie_to_conll.py
convert_sent_to_conll
def convert_sent_to_conll(sent_ls: List[Extraction]): """ Given a list of extractions for a single sentence - convert it to conll representation. """ # Sanity check - make sure all extractions are on the same sentence assert(len(set([ex.sent for ex in sent_ls])) == 1) toks = sent_ls[0].sent....
python
def convert_sent_to_conll(sent_ls: List[Extraction]): """ Given a list of extractions for a single sentence - convert it to conll representation. """ # Sanity check - make sure all extractions are on the same sentence assert(len(set([ex.sent for ex in sent_ls])) == 1) toks = sent_ls[0].sent....
[ "def", "convert_sent_to_conll", "(", "sent_ls", ":", "List", "[", "Extraction", "]", ")", ":", "# Sanity check - make sure all extractions are on the same sentence", "assert", "(", "len", "(", "set", "(", "[", "ex", ".", "sent", "for", "ex", "in", "sent_ls", "]", ...
Given a list of extractions for a single sentence - convert it to conll representation.
[ "Given", "a", "list", "of", "extractions", "for", "a", "single", "sentence", "-", "convert", "it", "to", "conll", "representation", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/convert_openie_to_conll.py#L237-L249
23,205
allenai/allennlp
scripts/convert_openie_to_conll.py
pad_line_to_ontonotes
def pad_line_to_ontonotes(line, domain) -> List[str]: """ Pad line to conform to ontonotes representation. """ word_ind, word = line[ : 2] pos = 'XX' oie_tags = line[2 : ] line_num = 0 parse = "-" lemma = "-" return [domain, line_num, word_ind, word, pos, parse, lemma, '-',\ ...
python
def pad_line_to_ontonotes(line, domain) -> List[str]: """ Pad line to conform to ontonotes representation. """ word_ind, word = line[ : 2] pos = 'XX' oie_tags = line[2 : ] line_num = 0 parse = "-" lemma = "-" return [domain, line_num, word_ind, word, pos, parse, lemma, '-',\ ...
[ "def", "pad_line_to_ontonotes", "(", "line", ",", "domain", ")", "->", "List", "[", "str", "]", ":", "word_ind", ",", "word", "=", "line", "[", ":", "2", "]", "pos", "=", "'XX'", "oie_tags", "=", "line", "[", "2", ":", "]", "line_num", "=", "0", ...
Pad line to conform to ontonotes representation.
[ "Pad", "line", "to", "conform", "to", "ontonotes", "representation", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/convert_openie_to_conll.py#L252-L263
23,206
allenai/allennlp
scripts/convert_openie_to_conll.py
convert_sent_dict_to_conll
def convert_sent_dict_to_conll(sent_dic, domain) -> str: """ Given a dictionary from sentence -> extractions, return a corresponding CoNLL representation. """ return '\n\n'.join(['\n'.join(['\t'.join(map(str, pad_line_to_ontonotes(line, domain))) for line in conver...
python
def convert_sent_dict_to_conll(sent_dic, domain) -> str: """ Given a dictionary from sentence -> extractions, return a corresponding CoNLL representation. """ return '\n\n'.join(['\n'.join(['\t'.join(map(str, pad_line_to_ontonotes(line, domain))) for line in conver...
[ "def", "convert_sent_dict_to_conll", "(", "sent_dic", ",", "domain", ")", "->", "str", ":", "return", "'\\n\\n'", ".", "join", "(", "[", "'\\n'", ".", "join", "(", "[", "'\\t'", ".", "join", "(", "map", "(", "str", ",", "pad_line_to_ontonotes", "(", "lin...
Given a dictionary from sentence -> extractions, return a corresponding CoNLL representation.
[ "Given", "a", "dictionary", "from", "sentence", "-", ">", "extractions", "return", "a", "corresponding", "CoNLL", "representation", "." ]
648a36f77db7e45784c047176074f98534c76636
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/scripts/convert_openie_to_conll.py#L265-L273
23,207
awslabs/serverless-application-model
samtranslator/model/s3_utils/uri_parser.py
parse_s3_uri
def parse_s3_uri(uri): """Parses a S3 Uri into a dictionary of the Bucket, Key, and VersionId :return: a BodyS3Location dict or None if not an S3 Uri :rtype: dict """ if not isinstance(uri, string_types): return None url = urlparse(uri) query = parse_qs(url.query) if url.schem...
python
def parse_s3_uri(uri): """Parses a S3 Uri into a dictionary of the Bucket, Key, and VersionId :return: a BodyS3Location dict or None if not an S3 Uri :rtype: dict """ if not isinstance(uri, string_types): return None url = urlparse(uri) query = parse_qs(url.query) if url.schem...
[ "def", "parse_s3_uri", "(", "uri", ")", ":", "if", "not", "isinstance", "(", "uri", ",", "string_types", ")", ":", "return", "None", "url", "=", "urlparse", "(", "uri", ")", "query", "=", "parse_qs", "(", "url", ".", "query", ")", "if", "url", ".", ...
Parses a S3 Uri into a dictionary of the Bucket, Key, and VersionId :return: a BodyS3Location dict or None if not an S3 Uri :rtype: dict
[ "Parses", "a", "S3", "Uri", "into", "a", "dictionary", "of", "the", "Bucket", "Key", "and", "VersionId" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/s3_utils/uri_parser.py#L6-L27
23,208
awslabs/serverless-application-model
samtranslator/model/s3_utils/uri_parser.py
to_s3_uri
def to_s3_uri(code_dict): """Constructs a S3 URI string from given code dictionary :param dict code_dict: Dictionary containing Lambda function Code S3 location of the form {S3Bucket, S3Key, S3ObjectVersion} :return: S3 URI of form s3://bucket/key?versionId=version :rtype stri...
python
def to_s3_uri(code_dict): """Constructs a S3 URI string from given code dictionary :param dict code_dict: Dictionary containing Lambda function Code S3 location of the form {S3Bucket, S3Key, S3ObjectVersion} :return: S3 URI of form s3://bucket/key?versionId=version :rtype stri...
[ "def", "to_s3_uri", "(", "code_dict", ")", ":", "try", ":", "uri", "=", "\"s3://{bucket}/{key}\"", ".", "format", "(", "bucket", "=", "code_dict", "[", "\"S3Bucket\"", "]", ",", "key", "=", "code_dict", "[", "\"S3Key\"", "]", ")", "version", "=", "code_dic...
Constructs a S3 URI string from given code dictionary :param dict code_dict: Dictionary containing Lambda function Code S3 location of the form {S3Bucket, S3Key, S3ObjectVersion} :return: S3 URI of form s3://bucket/key?versionId=version :rtype string
[ "Constructs", "a", "S3", "URI", "string", "from", "given", "code", "dictionary" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/s3_utils/uri_parser.py#L30-L48
23,209
awslabs/serverless-application-model
samtranslator/model/s3_utils/uri_parser.py
construct_s3_location_object
def construct_s3_location_object(location_uri, logical_id, property_name): """Constructs a Lambda `Code` or `Content` property, from the SAM `CodeUri` or `ContentUri` property. This follows the current scheme for Lambda Functions and LayerVersions. :param dict or string location_uri: s3 location dict or st...
python
def construct_s3_location_object(location_uri, logical_id, property_name): """Constructs a Lambda `Code` or `Content` property, from the SAM `CodeUri` or `ContentUri` property. This follows the current scheme for Lambda Functions and LayerVersions. :param dict or string location_uri: s3 location dict or st...
[ "def", "construct_s3_location_object", "(", "location_uri", ",", "logical_id", ",", "property_name", ")", ":", "if", "isinstance", "(", "location_uri", ",", "dict", ")", ":", "if", "not", "location_uri", ".", "get", "(", "\"Bucket\"", ")", "or", "not", "locati...
Constructs a Lambda `Code` or `Content` property, from the SAM `CodeUri` or `ContentUri` property. This follows the current scheme for Lambda Functions and LayerVersions. :param dict or string location_uri: s3 location dict or string :param string logical_id: logical_id of the resource calling this functio...
[ "Constructs", "a", "Lambda", "Code", "or", "Content", "property", "from", "the", "SAM", "CodeUri", "or", "ContentUri", "property", ".", "This", "follows", "the", "current", "scheme", "for", "Lambda", "Functions", "and", "LayerVersions", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/s3_utils/uri_parser.py#L51-L86
23,210
awslabs/serverless-application-model
samtranslator/model/function_policies.py
FunctionPolicies._get_policies
def _get_policies(self, resource_properties): """ Returns a list of policies from the resource properties. This method knows how to interpret and handle polymorphic nature of the policies property. Policies can be one of the following: * Managed policy name: string ...
python
def _get_policies(self, resource_properties): """ Returns a list of policies from the resource properties. This method knows how to interpret and handle polymorphic nature of the policies property. Policies can be one of the following: * Managed policy name: string ...
[ "def", "_get_policies", "(", "self", ",", "resource_properties", ")", ":", "policies", "=", "None", "if", "self", ".", "_contains_policies", "(", "resource_properties", ")", ":", "policies", "=", "resource_properties", "[", "self", ".", "POLICIES_PROPERTY_NAME", "...
Returns a list of policies from the resource properties. This method knows how to interpret and handle polymorphic nature of the policies property. Policies can be one of the following: * Managed policy name: string * List of managed policy names: list of strings * ...
[ "Returns", "a", "list", "of", "policies", "from", "the", "resource", "properties", ".", "This", "method", "knows", "how", "to", "interpret", "and", "handle", "polymorphic", "nature", "of", "the", "policies", "property", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/function_policies.py#L55-L94
23,211
awslabs/serverless-application-model
samtranslator/model/function_policies.py
FunctionPolicies._contains_policies
def _contains_policies(self, resource_properties): """ Is there policies data in this resource? :param dict resource_properties: Properties of the resource :return: True if we can process this resource. False, otherwise """ return resource_properties is not None \ ...
python
def _contains_policies(self, resource_properties): """ Is there policies data in this resource? :param dict resource_properties: Properties of the resource :return: True if we can process this resource. False, otherwise """ return resource_properties is not None \ ...
[ "def", "_contains_policies", "(", "self", ",", "resource_properties", ")", ":", "return", "resource_properties", "is", "not", "None", "and", "isinstance", "(", "resource_properties", ",", "dict", ")", "and", "self", ".", "POLICIES_PROPERTY_NAME", "in", "resource_pro...
Is there policies data in this resource? :param dict resource_properties: Properties of the resource :return: True if we can process this resource. False, otherwise
[ "Is", "there", "policies", "data", "in", "this", "resource?" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/function_policies.py#L96-L105
23,212
awslabs/serverless-application-model
samtranslator/model/function_policies.py
FunctionPolicies._get_type
def _get_type(self, policy): """ Returns the type of the given policy :param string or dict policy: Policy data :return PolicyTypes: Type of the given policy. None, if type could not be inferred """ # Must handle intrinsic functions. Policy could be a primitive type or ...
python
def _get_type(self, policy): """ Returns the type of the given policy :param string or dict policy: Policy data :return PolicyTypes: Type of the given policy. None, if type could not be inferred """ # Must handle intrinsic functions. Policy could be a primitive type or ...
[ "def", "_get_type", "(", "self", ",", "policy", ")", ":", "# Must handle intrinsic functions. Policy could be a primitive type or an intrinsic function", "# Managed policies are either string or an intrinsic function that resolves to a string", "if", "isinstance", "(", "policy", ",", "...
Returns the type of the given policy :param string or dict policy: Policy data :return PolicyTypes: Type of the given policy. None, if type could not be inferred
[ "Returns", "the", "type", "of", "the", "given", "policy" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/function_policies.py#L107-L130
23,213
awslabs/serverless-application-model
samtranslator/model/function_policies.py
FunctionPolicies._is_policy_template
def _is_policy_template(self, policy): """ Is the given policy data a policy template? Policy templates is a dictionary with one key which is the name of the template. :param dict policy: Policy data :return: True, if this is a policy template. False if it is not """ ...
python
def _is_policy_template(self, policy): """ Is the given policy data a policy template? Policy templates is a dictionary with one key which is the name of the template. :param dict policy: Policy data :return: True, if this is a policy template. False if it is not """ ...
[ "def", "_is_policy_template", "(", "self", ",", "policy", ")", ":", "return", "self", ".", "_policy_template_processor", "is", "not", "None", "and", "isinstance", "(", "policy", ",", "dict", ")", "and", "len", "(", "policy", ")", "==", "1", "and", "self", ...
Is the given policy data a policy template? Policy templates is a dictionary with one key which is the name of the template. :param dict policy: Policy data :return: True, if this is a policy template. False if it is not
[ "Is", "the", "given", "policy", "data", "a", "policy", "template?", "Policy", "templates", "is", "a", "dictionary", "with", "one", "key", "which", "is", "the", "name", "of", "the", "template", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/function_policies.py#L132-L144
23,214
awslabs/serverless-application-model
examples/apps/greengrass-hello-world/greengrasssdk/IoTDataPlane.py
Client.get_thing_shadow
def get_thing_shadow(self, **kwargs): r""" Call shadow lambda to obtain current shadow state. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The name of the thing. :returns: (``dict``) -- The output from the GetThingShadow o...
python
def get_thing_shadow(self, **kwargs): r""" Call shadow lambda to obtain current shadow state. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The name of the thing. :returns: (``dict``) -- The output from the GetThingShadow o...
[ "def", "get_thing_shadow", "(", "self", ",", "*", "*", "kwargs", ")", ":", "thing_name", "=", "self", ".", "_get_required_parameter", "(", "'thingName'", ",", "*", "*", "kwargs", ")", "payload", "=", "b''", "return", "self", ".", "_shadow_op", "(", "'get'"...
r""" Call shadow lambda to obtain current shadow state. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The name of the thing. :returns: (``dict``) -- The output from the GetThingShadow operation * *payload* (``bytes``) -...
[ "r", "Call", "shadow", "lambda", "to", "obtain", "current", "shadow", "state", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrasssdk/IoTDataPlane.py#L28-L45
23,215
awslabs/serverless-application-model
examples/apps/greengrass-hello-world/greengrasssdk/IoTDataPlane.py
Client.update_thing_shadow
def update_thing_shadow(self, **kwargs): r""" Updates the thing shadow for the specified thing. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The name of the thing. * *payload* (``bytes or seekable file-like object``) -- ...
python
def update_thing_shadow(self, **kwargs): r""" Updates the thing shadow for the specified thing. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The name of the thing. * *payload* (``bytes or seekable file-like object``) -- ...
[ "def", "update_thing_shadow", "(", "self", ",", "*", "*", "kwargs", ")", ":", "thing_name", "=", "self", ".", "_get_required_parameter", "(", "'thingName'", ",", "*", "*", "kwargs", ")", "payload", "=", "self", ".", "_get_required_parameter", "(", "'payload'",...
r""" Updates the thing shadow for the specified thing. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The name of the thing. * *payload* (``bytes or seekable file-like object``) -- [REQUIRED] The state informa...
[ "r", "Updates", "the", "thing", "shadow", "for", "the", "specified", "thing", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrasssdk/IoTDataPlane.py#L47-L67
23,216
awslabs/serverless-application-model
examples/apps/greengrass-hello-world/greengrasssdk/IoTDataPlane.py
Client.delete_thing_shadow
def delete_thing_shadow(self, **kwargs): r""" Deletes the thing shadow for the specified thing. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The name of the thing. :returns: (``dict``) -- The output from the DeleteThingSha...
python
def delete_thing_shadow(self, **kwargs): r""" Deletes the thing shadow for the specified thing. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The name of the thing. :returns: (``dict``) -- The output from the DeleteThingSha...
[ "def", "delete_thing_shadow", "(", "self", ",", "*", "*", "kwargs", ")", ":", "thing_name", "=", "self", ".", "_get_required_parameter", "(", "'thingName'", ",", "*", "*", "kwargs", ")", "payload", "=", "b''", "return", "self", ".", "_shadow_op", "(", "'de...
r""" Deletes the thing shadow for the specified thing. :Keyword Arguments: * *thingName* (``string``) -- [REQUIRED] The name of the thing. :returns: (``dict``) -- The output from the DeleteThingShadow operation * *payload* (``bytes``)...
[ "r", "Deletes", "the", "thing", "shadow", "for", "the", "specified", "thing", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrasssdk/IoTDataPlane.py#L69-L86
23,217
awslabs/serverless-application-model
examples/apps/greengrass-hello-world/greengrasssdk/IoTDataPlane.py
Client.publish
def publish(self, **kwargs): r""" Publishes state information. :Keyword Arguments: * *topic* (``string``) -- [REQUIRED] The name of the MQTT topic. * *payload* (``bytes or seekable file-like object``) -- The state information, in...
python
def publish(self, **kwargs): r""" Publishes state information. :Keyword Arguments: * *topic* (``string``) -- [REQUIRED] The name of the MQTT topic. * *payload* (``bytes or seekable file-like object``) -- The state information, in...
[ "def", "publish", "(", "self", ",", "*", "*", "kwargs", ")", ":", "topic", "=", "self", ".", "_get_required_parameter", "(", "'topic'", ",", "*", "*", "kwargs", ")", "# payload is an optional parameter", "payload", "=", "kwargs", ".", "get", "(", "'payload'"...
r""" Publishes state information. :Keyword Arguments: * *topic* (``string``) -- [REQUIRED] The name of the MQTT topic. * *payload* (``bytes or seekable file-like object``) -- The state information, in JSON format. :returns: None
[ "r", "Publishes", "state", "information", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/greengrass-hello-world/greengrasssdk/IoTDataPlane.py#L88-L120
23,218
awslabs/serverless-application-model
samtranslator/plugins/globals/globals.py
Globals.merge
def merge(self, resource_type, resource_properties): """ Adds global properties to the resource, if necessary. This method is a no-op if there are no global properties for this resource type :param string resource_type: Type of the resource (Ex: AWS::Serverless::Function) :param...
python
def merge(self, resource_type, resource_properties): """ Adds global properties to the resource, if necessary. This method is a no-op if there are no global properties for this resource type :param string resource_type: Type of the resource (Ex: AWS::Serverless::Function) :param...
[ "def", "merge", "(", "self", ",", "resource_type", ",", "resource_properties", ")", ":", "if", "resource_type", "not", "in", "self", ".", "template_globals", ":", "# Nothing to do. Return the template unmodified", "return", "resource_properties", "global_props", "=", "s...
Adds global properties to the resource, if necessary. This method is a no-op if there are no global properties for this resource type :param string resource_type: Type of the resource (Ex: AWS::Serverless::Function) :param dict resource_properties: Properties of the resource that need to be mer...
[ "Adds", "global", "properties", "to", "the", "resource", "if", "necessary", ".", "This", "method", "is", "a", "no", "-", "op", "if", "there", "are", "no", "global", "properties", "for", "this", "resource", "type" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/globals/globals.py#L80-L96
23,219
awslabs/serverless-application-model
samtranslator/plugins/globals/globals.py
Globals._parse
def _parse(self, globals_dict): """ Takes a SAM template as input and parses the Globals section :param globals_dict: Dictionary representation of the Globals section :return: Processed globals dictionary which can be used to quickly identify properties to merge :raises: Invalid...
python
def _parse(self, globals_dict): """ Takes a SAM template as input and parses the Globals section :param globals_dict: Dictionary representation of the Globals section :return: Processed globals dictionary which can be used to quickly identify properties to merge :raises: Invalid...
[ "def", "_parse", "(", "self", ",", "globals_dict", ")", ":", "globals", "=", "{", "}", "if", "not", "isinstance", "(", "globals_dict", ",", "dict", ")", ":", "raise", "InvalidGlobalsSectionException", "(", "self", ".", "_KEYWORD", ",", "\"It must be a non-empt...
Takes a SAM template as input and parses the Globals section :param globals_dict: Dictionary representation of the Globals section :return: Processed globals dictionary which can be used to quickly identify properties to merge :raises: InvalidResourceException if the input contains properties t...
[ "Takes", "a", "SAM", "template", "as", "input", "and", "parses", "the", "Globals", "section" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/globals/globals.py#L110-L149
23,220
awslabs/serverless-application-model
samtranslator/plugins/globals/globals.py
GlobalProperties._do_merge
def _do_merge(self, global_value, local_value): """ Actually perform the merge operation for the given inputs. This method is used as part of the recursion. Therefore input values can be of any type. So is the output. :param global_value: Global value to be merged :param local_v...
python
def _do_merge(self, global_value, local_value): """ Actually perform the merge operation for the given inputs. This method is used as part of the recursion. Therefore input values can be of any type. So is the output. :param global_value: Global value to be merged :param local_v...
[ "def", "_do_merge", "(", "self", ",", "global_value", ",", "local_value", ")", ":", "token_global", "=", "self", ".", "_token_of", "(", "global_value", ")", "token_local", "=", "self", ".", "_token_of", "(", "local_value", ")", "# The following statements codify t...
Actually perform the merge operation for the given inputs. This method is used as part of the recursion. Therefore input values can be of any type. So is the output. :param global_value: Global value to be merged :param local_value: Local value to be merged :return: Merged result
[ "Actually", "perform", "the", "merge", "operation", "for", "the", "given", "inputs", ".", "This", "method", "is", "used", "as", "part", "of", "the", "recursion", ".", "Therefore", "input", "values", "can", "be", "of", "any", "type", ".", "So", "is", "the...
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/globals/globals.py#L286-L314
23,221
awslabs/serverless-application-model
samtranslator/plugins/globals/globals.py
GlobalProperties._merge_dict
def _merge_dict(self, global_dict, local_dict): """ Merges the two dictionaries together :param global_dict: Global dictionary to be merged :param local_dict: Local dictionary to be merged :return: New merged dictionary with values shallow copied """ # Local has...
python
def _merge_dict(self, global_dict, local_dict): """ Merges the two dictionaries together :param global_dict: Global dictionary to be merged :param local_dict: Local dictionary to be merged :return: New merged dictionary with values shallow copied """ # Local has...
[ "def", "_merge_dict", "(", "self", ",", "global_dict", ",", "local_dict", ")", ":", "# Local has higher priority than global. So iterate over local dict and merge into global if keys are overridden", "global_dict", "=", "global_dict", ".", "copy", "(", ")", "for", "key", "in"...
Merges the two dictionaries together :param global_dict: Global dictionary to be merged :param local_dict: Local dictionary to be merged :return: New merged dictionary with values shallow copied
[ "Merges", "the", "two", "dictionaries", "together" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/globals/globals.py#L327-L349
23,222
awslabs/serverless-application-model
samtranslator/plugins/globals/globals.py
GlobalProperties._token_of
def _token_of(self, input): """ Returns the token type of the input. :param input: Input whose type is to be determined :return TOKENS: Token type of the input """ if isinstance(input, dict): # Intrinsic functions are always dicts if is_intrinsi...
python
def _token_of(self, input): """ Returns the token type of the input. :param input: Input whose type is to be determined :return TOKENS: Token type of the input """ if isinstance(input, dict): # Intrinsic functions are always dicts if is_intrinsi...
[ "def", "_token_of", "(", "self", ",", "input", ")", ":", "if", "isinstance", "(", "input", ",", "dict", ")", ":", "# Intrinsic functions are always dicts", "if", "is_intrinsics", "(", "input", ")", ":", "# Intrinsic functions are handled *exactly* like a primitive type ...
Returns the token type of the input. :param input: Input whose type is to be determined :return TOKENS: Token type of the input
[ "Returns", "the", "token", "type", "of", "the", "input", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/globals/globals.py#L362-L384
23,223
awslabs/serverless-application-model
samtranslator/validator/validator.py
SamTemplateValidator.validate
def validate(template_dict, schema=None): """ Is this a valid SAM template dictionary :param dict template_dict: Data to be validated :param dict schema: Optional, dictionary containing JSON Schema representing SAM template :return: Empty string if there are no validation errors...
python
def validate(template_dict, schema=None): """ Is this a valid SAM template dictionary :param dict template_dict: Data to be validated :param dict schema: Optional, dictionary containing JSON Schema representing SAM template :return: Empty string if there are no validation errors...
[ "def", "validate", "(", "template_dict", ",", "schema", "=", "None", ")", ":", "if", "not", "schema", ":", "schema", "=", "SamTemplateValidator", ".", "_read_schema", "(", ")", "validation_errors", "=", "\"\"", "try", ":", "jsonschema", ".", "validate", "(",...
Is this a valid SAM template dictionary :param dict template_dict: Data to be validated :param dict schema: Optional, dictionary containing JSON Schema representing SAM template :return: Empty string if there are no validation errors in template
[ "Is", "this", "a", "valid", "SAM", "template", "dictionary" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/validator/validator.py#L12-L35
23,224
awslabs/serverless-application-model
examples/apps/lex-book-trip-python/lambda_function.py
generate_car_price
def generate_car_price(location, days, age, car_type): """ Generates a number within a reasonable range that might be expected for a flight. The price is fixed for a given pair of locations. """ car_types = ['economy', 'standard', 'midsize', 'full size', 'minivan', 'luxury'] base_location_cost ...
python
def generate_car_price(location, days, age, car_type): """ Generates a number within a reasonable range that might be expected for a flight. The price is fixed for a given pair of locations. """ car_types = ['economy', 'standard', 'midsize', 'full size', 'minivan', 'luxury'] base_location_cost ...
[ "def", "generate_car_price", "(", "location", ",", "days", ",", "age", ",", "car_type", ")", ":", "car_types", "=", "[", "'economy'", ",", "'standard'", ",", "'midsize'", ",", "'full size'", ",", "'minivan'", ",", "'luxury'", "]", "base_location_cost", "=", ...
Generates a number within a reasonable range that might be expected for a flight. The price is fixed for a given pair of locations.
[ "Generates", "a", "number", "within", "a", "reasonable", "range", "that", "might", "be", "expected", "for", "a", "flight", ".", "The", "price", "is", "fixed", "for", "a", "given", "pair", "of", "locations", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-book-trip-python/lambda_function.py#L97-L113
23,225
awslabs/serverless-application-model
examples/apps/lex-book-trip-python/lambda_function.py
generate_hotel_price
def generate_hotel_price(location, nights, room_type): """ Generates a number within a reasonable range that might be expected for a hotel. The price is fixed for a pair of location and roomType. """ room_types = ['queen', 'king', 'deluxe'] cost_of_living = 0 for i in range(len(location)): ...
python
def generate_hotel_price(location, nights, room_type): """ Generates a number within a reasonable range that might be expected for a hotel. The price is fixed for a pair of location and roomType. """ room_types = ['queen', 'king', 'deluxe'] cost_of_living = 0 for i in range(len(location)): ...
[ "def", "generate_hotel_price", "(", "location", ",", "nights", ",", "room_type", ")", ":", "room_types", "=", "[", "'queen'", ",", "'king'", ",", "'deluxe'", "]", "cost_of_living", "=", "0", "for", "i", "in", "range", "(", "len", "(", "location", ")", ")...
Generates a number within a reasonable range that might be expected for a hotel. The price is fixed for a pair of location and roomType.
[ "Generates", "a", "number", "within", "a", "reasonable", "range", "that", "might", "be", "expected", "for", "a", "hotel", ".", "The", "price", "is", "fixed", "for", "a", "pair", "of", "location", "and", "roomType", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-book-trip-python/lambda_function.py#L116-L127
23,226
awslabs/serverless-application-model
examples/apps/lex-book-trip-python/lambda_function.py
book_hotel
def book_hotel(intent_request): """ Performs dialog management and fulfillment for booking a hotel. Beyond fulfillment, the implementation for this intent demonstrates the following: 1) Use of elicitSlot in slot validation and re-prompting 2) Use of sessionAttributes to pass information that can be...
python
def book_hotel(intent_request): """ Performs dialog management and fulfillment for booking a hotel. Beyond fulfillment, the implementation for this intent demonstrates the following: 1) Use of elicitSlot in slot validation and re-prompting 2) Use of sessionAttributes to pass information that can be...
[ "def", "book_hotel", "(", "intent_request", ")", ":", "location", "=", "try_ex", "(", "lambda", ":", "intent_request", "[", "'currentIntent'", "]", "[", "'slots'", "]", "[", "'Location'", "]", ")", "checkin_date", "=", "try_ex", "(", "lambda", ":", "intent_r...
Performs dialog management and fulfillment for booking a hotel. Beyond fulfillment, the implementation for this intent demonstrates the following: 1) Use of elicitSlot in slot validation and re-prompting 2) Use of sessionAttributes to pass information that can be used to guide conversation
[ "Performs", "dialog", "management", "and", "fulfillment", "for", "booking", "a", "hotel", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/lex-book-trip-python/lambda_function.py#L261-L330
23,227
awslabs/serverless-application-model
samtranslator/model/eventsources/pull.py
PullEventSource.to_cloudformation
def to_cloudformation(self, **kwargs): """Returns the Lambda EventSourceMapping to which this pull event corresponds. Adds the appropriate managed policy to the function's execution role, if such a role is provided. :param dict kwargs: a dict containing the execution role generated for the func...
python
def to_cloudformation(self, **kwargs): """Returns the Lambda EventSourceMapping to which this pull event corresponds. Adds the appropriate managed policy to the function's execution role, if such a role is provided. :param dict kwargs: a dict containing the execution role generated for the func...
[ "def", "to_cloudformation", "(", "self", ",", "*", "*", "kwargs", ")", ":", "function", "=", "kwargs", ".", "get", "(", "'function'", ")", "if", "not", "function", ":", "raise", "TypeError", "(", "\"Missing required keyword argument: function\"", ")", "resources...
Returns the Lambda EventSourceMapping to which this pull event corresponds. Adds the appropriate managed policy to the function's execution role, if such a role is provided. :param dict kwargs: a dict containing the execution role generated for the function :returns: a list of vanilla CloudForm...
[ "Returns", "the", "Lambda", "EventSourceMapping", "to", "which", "this", "pull", "event", "corresponds", ".", "Adds", "the", "appropriate", "managed", "policy", "to", "the", "function", "s", "execution", "role", "if", "such", "a", "role", "is", "provided", "."...
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/eventsources/pull.py#L30-L73
23,228
awslabs/serverless-application-model
samtranslator/model/eventsources/pull.py
PullEventSource._link_policy
def _link_policy(self, role): """If this source triggers a Lambda function whose execution role is auto-generated by SAM, add the appropriate managed policy to this Role. :param model.iam.IAMROle role: the execution role generated for the function """ policy_arn = self.get_polic...
python
def _link_policy(self, role): """If this source triggers a Lambda function whose execution role is auto-generated by SAM, add the appropriate managed policy to this Role. :param model.iam.IAMROle role: the execution role generated for the function """ policy_arn = self.get_polic...
[ "def", "_link_policy", "(", "self", ",", "role", ")", ":", "policy_arn", "=", "self", ".", "get_policy_arn", "(", ")", "if", "role", "is", "not", "None", "and", "policy_arn", "not", "in", "role", ".", "ManagedPolicyArns", ":", "role", ".", "ManagedPolicyAr...
If this source triggers a Lambda function whose execution role is auto-generated by SAM, add the appropriate managed policy to this Role. :param model.iam.IAMROle role: the execution role generated for the function
[ "If", "this", "source", "triggers", "a", "Lambda", "function", "whose", "execution", "role", "is", "auto", "-", "generated", "by", "SAM", "add", "the", "appropriate", "managed", "policy", "to", "this", "Role", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/eventsources/pull.py#L75-L83
23,229
awslabs/serverless-application-model
samtranslator/sdk/parameter.py
SamParameterValues.add_default_parameter_values
def add_default_parameter_values(self, sam_template): """ Method to read default values for template parameters and merge with user supplied values. Example: If the template contains the following parameters defined Parameters: Param1: Type: String ...
python
def add_default_parameter_values(self, sam_template): """ Method to read default values for template parameters and merge with user supplied values. Example: If the template contains the following parameters defined Parameters: Param1: Type: String ...
[ "def", "add_default_parameter_values", "(", "self", ",", "sam_template", ")", ":", "parameter_definition", "=", "sam_template", ".", "get", "(", "\"Parameters\"", ",", "None", ")", "if", "not", "parameter_definition", "or", "not", "isinstance", "(", "parameter_defin...
Method to read default values for template parameters and merge with user supplied values. Example: If the template contains the following parameters defined Parameters: Param1: Type: String Default: default_value Param2: ...
[ "Method", "to", "read", "default", "values", "for", "template", "parameters", "and", "merge", "with", "user", "supplied", "values", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/sdk/parameter.py#L19-L59
23,230
awslabs/serverless-application-model
samtranslator/model/preferences/deployment_preference_collection.py
DeploymentPreferenceCollection.add
def add(self, logical_id, deployment_preference_dict): """ Add this deployment preference to the collection :raise ValueError if an existing logical id already exists in the _resource_preferences :param logical_id: logical id of the resource where this deployment preference applies ...
python
def add(self, logical_id, deployment_preference_dict): """ Add this deployment preference to the collection :raise ValueError if an existing logical id already exists in the _resource_preferences :param logical_id: logical id of the resource where this deployment preference applies ...
[ "def", "add", "(", "self", ",", "logical_id", ",", "deployment_preference_dict", ")", ":", "if", "logical_id", "in", "self", ".", "_resource_preferences", ":", "raise", "ValueError", "(", "\"logical_id {logical_id} previously added to this deployment_preference_collection\"",...
Add this deployment preference to the collection :raise ValueError if an existing logical id already exists in the _resource_preferences :param logical_id: logical id of the resource where this deployment preference applies :param deployment_preference_dict: the input SAM template deployment pr...
[ "Add", "this", "deployment", "preference", "to", "the", "collection" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/preferences/deployment_preference_collection.py#L32-L44
23,231
awslabs/serverless-application-model
examples/apps/alexa-skills-kit-color-expert-python/lambda_function.py
get_welcome_response
def get_welcome_response(): """ If we wanted to initialize the session to have some attributes we could add those here """ session_attributes = {} card_title = "Welcome" speech_output = "Welcome to the Alexa Skills Kit sample. " \ "Please tell me your favorite color by sayin...
python
def get_welcome_response(): """ If we wanted to initialize the session to have some attributes we could add those here """ session_attributes = {} card_title = "Welcome" speech_output = "Welcome to the Alexa Skills Kit sample. " \ "Please tell me your favorite color by sayin...
[ "def", "get_welcome_response", "(", ")", ":", "session_attributes", "=", "{", "}", "card_title", "=", "\"Welcome\"", "speech_output", "=", "\"Welcome to the Alexa Skills Kit sample. \"", "\"Please tell me your favorite color by saying, \"", "\"my favorite color is red\"", "# If the...
If we wanted to initialize the session to have some attributes we could add those here
[ "If", "we", "wanted", "to", "initialize", "the", "session", "to", "have", "some", "attributes", "we", "could", "add", "those", "here" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/alexa-skills-kit-color-expert-python/lambda_function.py#L46-L62
23,232
awslabs/serverless-application-model
examples/apps/alexa-skills-kit-color-expert-python/lambda_function.py
set_color_in_session
def set_color_in_session(intent, session): """ Sets the color in the session and prepares the speech to reply to the user. """ card_title = intent['name'] session_attributes = {} should_end_session = False if 'Color' in intent['slots']: favorite_color = intent['slots']['Color']['va...
python
def set_color_in_session(intent, session): """ Sets the color in the session and prepares the speech to reply to the user. """ card_title = intent['name'] session_attributes = {} should_end_session = False if 'Color' in intent['slots']: favorite_color = intent['slots']['Color']['va...
[ "def", "set_color_in_session", "(", "intent", ",", "session", ")", ":", "card_title", "=", "intent", "[", "'name'", "]", "session_attributes", "=", "{", "}", "should_end_session", "=", "False", "if", "'Color'", "in", "intent", "[", "'slots'", "]", ":", "favo...
Sets the color in the session and prepares the speech to reply to the user.
[ "Sets", "the", "color", "in", "the", "session", "and", "prepares", "the", "speech", "to", "reply", "to", "the", "user", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/alexa-skills-kit-color-expert-python/lambda_function.py#L79-L104
23,233
awslabs/serverless-application-model
examples/apps/alexa-skills-kit-color-expert-python/lambda_function.py
on_intent
def on_intent(intent_request, session): """ Called when the user specifies an intent for this skill """ print("on_intent requestId=" + intent_request['requestId'] + ", sessionId=" + session['sessionId']) intent = intent_request['intent'] intent_name = intent_request['intent']['name'] # ...
python
def on_intent(intent_request, session): """ Called when the user specifies an intent for this skill """ print("on_intent requestId=" + intent_request['requestId'] + ", sessionId=" + session['sessionId']) intent = intent_request['intent'] intent_name = intent_request['intent']['name'] # ...
[ "def", "on_intent", "(", "intent_request", ",", "session", ")", ":", "print", "(", "\"on_intent requestId=\"", "+", "intent_request", "[", "'requestId'", "]", "+", "\", sessionId=\"", "+", "session", "[", "'sessionId'", "]", ")", "intent", "=", "intent_request", ...
Called when the user specifies an intent for this skill
[ "Called", "when", "the", "user", "specifies", "an", "intent", "for", "this", "skill" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/examples/apps/alexa-skills-kit-color-expert-python/lambda_function.py#L148-L167
23,234
awslabs/serverless-application-model
samtranslator/translator/logical_id_generator.py
LogicalIdGenerator.get_hash
def get_hash(self, length=HASH_LENGTH): """ Generate and return a hash of data that can be used as suffix of logicalId :return: Hash of data if it was present :rtype string """ data_hash = "" if not self.data_str: return data_hash encoded_da...
python
def get_hash(self, length=HASH_LENGTH): """ Generate and return a hash of data that can be used as suffix of logicalId :return: Hash of data if it was present :rtype string """ data_hash = "" if not self.data_str: return data_hash encoded_da...
[ "def", "get_hash", "(", "self", ",", "length", "=", "HASH_LENGTH", ")", ":", "data_hash", "=", "\"\"", "if", "not", "self", ".", "data_str", ":", "return", "data_hash", "encoded_data_str", "=", "self", ".", "data_str", "if", "sys", ".", "version_info", "."...
Generate and return a hash of data that can be used as suffix of logicalId :return: Hash of data if it was present :rtype string
[ "Generate", "and", "return", "a", "hash", "of", "data", "that", "can", "be", "used", "as", "suffix", "of", "logicalId" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/logical_id_generator.py#L49-L72
23,235
awslabs/serverless-application-model
samtranslator/translator/logical_id_generator.py
LogicalIdGenerator._stringify
def _stringify(self, data): """ Stable, platform & language-independent stringification of a data with basic Python type. We use JSON to dump a string instead of `str()` method in order to be language independent. :param data: Data to be stringified. If this is one of JSON native types...
python
def _stringify(self, data): """ Stable, platform & language-independent stringification of a data with basic Python type. We use JSON to dump a string instead of `str()` method in order to be language independent. :param data: Data to be stringified. If this is one of JSON native types...
[ "def", "_stringify", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "string_types", ")", ":", "return", "data", "# Get the most compact dictionary (separators) and sort the keys recursively to get a stable output", "return", "json", ".", "dumps"...
Stable, platform & language-independent stringification of a data with basic Python type. We use JSON to dump a string instead of `str()` method in order to be language independent. :param data: Data to be stringified. If this is one of JSON native types like string, dict, array etc, it will ...
[ "Stable", "platform", "&", "language", "-", "independent", "stringification", "of", "a", "data", "with", "basic", "Python", "type", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/translator/logical_id_generator.py#L74-L90
23,236
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
23,237
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
23,238
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
23,239
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
23,240
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
23,241
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
23,242
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
23,243
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
23,244
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
23,245
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
23,246
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
23,247
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
23,248
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
23,249
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
23,250
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
23,251
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
23,252
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
23,253
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
23,254
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
23,255
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
23,256
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
23,257
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
23,258
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
23,259
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
23,260
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
23,261
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
23,262
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
23,263
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
23,264
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
23,265
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
23,266
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
23,267
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
23,268
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
23,269
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
23,270
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
23,271
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
23,272
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
23,273
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
23,274
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
23,275
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
23,276
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
23,277
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
23,278
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
23,279
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
23,280
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
23,281
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
23,282
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
23,283
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
23,284
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
23,285
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
23,286
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
23,287
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
23,288
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
23,289
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
23,290
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
23,291
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
23,292
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
23,293
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
23,294
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
23,295
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
23,296
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
23,297
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
23,298
awslabs/serverless-application-model
samtranslator/model/intrinsics.py
is_instrinsic
def is_instrinsic(input): """ Checks if the given input is an intrinsic function dictionary. Intrinsic function is a dictionary with single key that is the name of the intrinsics. :param input: Input value to check if it is an intrinsic :return: True, if yes """ if input is not None \ ...
python
def is_instrinsic(input): """ Checks if the given input is an intrinsic function dictionary. Intrinsic function is a dictionary with single key that is the name of the intrinsics. :param input: Input value to check if it is an intrinsic :return: True, if yes """ if input is not None \ ...
[ "def", "is_instrinsic", "(", "input", ")", ":", "if", "input", "is", "not", "None", "and", "isinstance", "(", "input", ",", "dict", ")", "and", "len", "(", "input", ")", "==", "1", ":", "key", "=", "list", "(", "input", ".", "keys", "(", ")", ")"...
Checks if the given input is an intrinsic function dictionary. Intrinsic function is a dictionary with single key that is the name of the intrinsics. :param input: Input value to check if it is an intrinsic :return: True, if yes
[ "Checks", "if", "the", "given", "input", "is", "an", "intrinsic", "function", "dictionary", ".", "Intrinsic", "function", "is", "a", "dictionary", "with", "single", "key", "that", "is", "the", "name", "of", "the", "intrinsics", "." ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/model/intrinsics.py#L124-L140
23,299
awslabs/serverless-application-model
samtranslator/intrinsics/actions.py
Action.can_handle
def can_handle(self, input_dict): """ Validates that the input dictionary contains only one key and is of the given intrinsic_name :param input_dict: Input dictionary representing the intrinsic function :return: True if it matches expected structure, False otherwise """ ...
python
def can_handle(self, input_dict): """ Validates that the input dictionary contains only one key and is of the given intrinsic_name :param input_dict: Input dictionary representing the intrinsic function :return: True if it matches expected structure, False otherwise """ ...
[ "def", "can_handle", "(", "self", ",", "input_dict", ")", ":", "return", "input_dict", "is", "not", "None", "and", "isinstance", "(", "input_dict", ",", "dict", ")", "and", "len", "(", "input_dict", ")", "==", "1", "and", "self", ".", "intrinsic_name", "...
Validates that the input dictionary contains only one key and is of the given intrinsic_name :param input_dict: Input dictionary representing the intrinsic function :return: True if it matches expected structure, False otherwise
[ "Validates", "that", "the", "input", "dictionary", "contains", "only", "one", "key", "and", "is", "of", "the", "given", "intrinsic_name" ]
cccb0c96b5c91e53355ebc07e542467303a5eedd
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/intrinsics/actions.py#L41-L52