Example #1
0
 def tag_instance_profile(self):
     profile_name = self._get_param('InstanceProfileName')
     tags = self._get_multi_param('Tags.member')
     tags = {tag['Key']: tag['Value'] for tag in tags or []}
     profile = moto_iam_backend.get_instance_profile(profile_name)
     profile.tags.update(tags)
     return ''
Example #2
0
 def tag_instance_profile(self):
     profile_name = self._get_param("InstanceProfileName")
     tags = self._get_multi_param("Tags.member")
     tags = {tag["Key"]: tag["Value"] for tag in tags or []}
     profile = moto_iam_backend.get_instance_profile(profile_name)
     profile.tags.update(tags)
     return ""
Example #3
0
 def untag_instance_profile(self):
     profile_name = self._get_param("InstanceProfileName")
     tag_keys = self._get_multi_param("TagKeys.member")
     profile = moto_iam_backend.get_instance_profile(profile_name)
     profile.tags = {
         k: v
         for k, v in profile.tags.items() if k not in tag_keys
     }
     return ""
Example #4
0
 def untag_instance_profile(
     self,
     context: RequestContext,
     instance_profile_name: instanceProfileNameType,
     tag_keys: tagKeyListType,
 ) -> None:
     profile = moto_iam_backend.get_instance_profile(instance_profile_name)
     for tag in tag_keys:
         profile.tags.pop(tag, None)
Example #5
0
 def tag_instance_profile(
     self,
     context: RequestContext,
     instance_profile_name: instanceProfileNameType,
     tags: tagListType,
 ) -> None:
     profile = moto_iam_backend.get_instance_profile(instance_profile_name)
     value_by_key = {tag["Key"]: tag["Value"] for tag in tags}
     profile.tags.update(value_by_key)
Example #6
0
 def list_instance_profile_tags(self):
     profile_name = self._get_param("InstanceProfileName")
     profile = moto_iam_backend.get_instance_profile(profile_name)
     result = {
         "ListInstanceProfileTagsResponse": {
             "@xmlns": XMLNS_IAM,
             "ListInstanceProfileTagsResult": {"Tags": profile.tags},
         }
     }
     return xmltodict.unparse(result)
Example #7
0
 def list_instance_profile_tags(self):
     profile_name = self._get_param('InstanceProfileName')
     profile = moto_iam_backend.get_instance_profile(profile_name)
     result = {
         'ListInstanceProfileTagsResponse': {
             '@xmlns': XMLNS_IAM,
             'ListInstanceProfileTagsResult': {'Tags': profile.tags}
         }
     }
     return xmltodict.unparse(result)
Example #8
0
 def list_instance_profile_tags(
     self,
     context: RequestContext,
     instance_profile_name: instanceProfileNameType,
     marker: markerType = None,
     max_items: maxItemsType = None,
 ) -> ListInstanceProfileTagsResponse:
     profile = moto_iam_backend.get_instance_profile(instance_profile_name)
     response = ListInstanceProfileTagsResponse()
     response["Tags"] = [
         Tag(Key=k, Value=v) for k, v in profile.tags.items()
     ]
     return response