3 O4Â\³ ã@s ddlmZGdd„deƒZdS)é)Ú SamResourcec@sBeZdZdZdd„Zddd„Zdd„Zd d „Zd d „Zd d„Z dS)Ú SamTemplatez- Class representing the SAM template cCs||_|d|_dS)z• Initialize with a template dictionary, that contains "Resources" dictionary :param dict template_dict: Template Dictionary Z ResourcesN)Ú template_dictÚ resources)Úselfr©rú‚/Users/sshvans/Documents/Work/Quickstart/python-virtual-environments/env/lib/python3.6/site-packages/samtranslator/sdk/template.pyÚ__init__ szSamTemplate.__init__NccsLxF|jjƒD]8\}}t|ƒ}|jƒ}|r6|o4|j|k}|r ||fVq WdS)a 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 N)rÚitemsrZvalidÚtype)rZ resource_typeÚ logicalIdÚ resource_dictÚresourceZ needs_filterrrrÚiterateszSamTemplate.iteratecCs$|}t|tƒr|jƒ}||j|<dS)zú 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 N)Ú isinstancerÚto_dictr)rr rr rrrÚset(s zSamTemplate.setcCs||jkrdSt|jj|ƒƒS)zÉ 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 N)rrÚget)rr rrrr6s zSamTemplate.getcCs||jkr|j|=dS)zi Deletes a resource at the given ID :param string logicalId: Resource to delete N)r)rr rrrÚdeleteBs zSamTemplate.deletecCs|j|jd<|jS)zj Returns the template as a dictionary :return dict: SAM template as a dictionary ZResource)rr)rrrrrLs zSamTemplate.to_dict)N) Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrrrrrrrrrs   rN)Zsamtranslator.sdk.resourcerÚobjectrrrrrÚs