def main(self):
     if self.args.get('recursive') or self.args.get('pretend'):
         # Figure out what we have to delete
         req = GetInstanceProfile(
             config=self.config, service=self.service,
             InstanceProfileName=self.args['InstanceProfileName'],
             DelegateAccount=self.args.get('DelegateAccount'))
         response = req.main()
         roles = []
         for role in response.get('InstanceProfile', {}).get('Roles') or []:
             roles.append({'arn': role.get('Arn'),
                           'name': role.get('RoleName')})
     else:
         # Just in case
         roles = []
     if self.args.get('pretend'):
         return {'roles': roles}
     else:
         if self.args.get('recursive'):
             for role in roles:
                 req = RemoveRoleFromInstanceProfile(
                     config=self.config, service=self.service,
                     RoleName=role['name'],
                     InstanceProfileName=self.args['InstanceProfileName'],
                     DelegateAccount=self.args.get('DelegateAccount'))
                 req.main()
     return self.send()
 def main(self):
     if self.args.get('recursive') or self.args.get('pretend'):
         # Figure out what we have to delete
         req = GetInstanceProfile.from_other(
             self, InstanceProfileName=self.args['InstanceProfileName'],
             DelegateAccount=self.args.get('DelegateAccount'))
         response = req.main()
         roles = []
         for role in response.get('InstanceProfile', {}).get('Roles') or []:
             roles.append({'arn': role.get('Arn'),
                           'name': role.get('RoleName')})
     else:
         # Just in case
         roles = []
     if self.args.get('pretend'):
         return {'roles': roles}
     else:
         if self.args.get('recursive'):
             for role in roles:
                 req = RemoveRoleFromInstanceProfile.from_other(
                     self, RoleName=role['name'],
                     InstanceProfileName=self.args['InstanceProfileName'],
                     DelegateAccount=self.args.get('DelegateAccount'))
                 req.main()
     return self.send()
 def main(self):
     if self.args.get('recursive') or self.args.get('pretend'):
         # Figure out what we have to delete
         req = GetInstanceProfile.from_other(
             self,
             InstanceProfileName=self.args['InstanceProfileName'],
             DelegateAccount=self.args.get('DelegateAccount'))
         response = req.main()
         roles = []
         for role in response.get('InstanceProfile', {}).get('Roles') or []:
             roles.append({
                 'arn': role.get('Arn'),
                 'name': role.get('RoleName')
             })
     else:
         # Just in case
         roles = []
     if self.args.get('pretend'):
         return {'roles': roles}
     else:
         if self.args.get('recursive'):
             for role in roles:
                 req = RemoveRoleFromInstanceProfile.from_other(
                     self,
                     RoleName=role['name'],
                     InstanceProfileName=self.args['InstanceProfileName'],
                     DelegateAccount=self.args.get('DelegateAccount'))
                 req.main()
                 # This role could be attached to another instance
                 # profile, which means that a truly-recursive delete
                 # would need to also remove it from that instance
                 # profile, delete all of the role's policies, and
                 # so on.  The failure modes for this are rather nasty,
                 # so we don't tell DeleteRole to delete recursively;
                 # if the same role belongs to more than one instance
                 # profile then DeleteRole will simply fail harmlessly.
                 req = DeleteRole.from_other(
                     self,
                     RoleName=role['name'],
                     DelegateAccount=self.args.get('DelegateAccount'))
                 req.main()
     return self.send()
 def main(self):
     if self.args.get('recursive') or self.args.get('pretend'):
         # Figure out what we have to delete
         req = GetInstanceProfile.from_other(
             self, InstanceProfileName=self.args['InstanceProfileName'],
             DelegateAccount=self.args.get('DelegateAccount'))
         response = req.main()
         roles = []
         for role in response.get('InstanceProfile', {}).get('Roles') or []:
             roles.append({'arn': role.get('Arn'),
                           'name': role.get('RoleName')})
     else:
         # Just in case
         roles = []
     if self.args.get('pretend'):
         return {'roles': roles}
     else:
         if self.args.get('recursive'):
             for role in roles:
                 req = RemoveRoleFromInstanceProfile.from_other(
                     self, RoleName=role['name'],
                     InstanceProfileName=self.args['InstanceProfileName'],
                     DelegateAccount=self.args.get('DelegateAccount'))
                 req.main()
                 # This role could be attached to another instance
                 # profile, which means that a truly-recursive delete
                 # would need to also remove it from that instance
                 # profile, delete all of the role's policies, and
                 # so on.  The failure modes for this are rather nasty,
                 # so we don't tell DeleteRole to delete recursively;
                 # if the same role belongs to more than one instance
                 # profile then DeleteRole will simply fail harmlessly.
                 req = DeleteRole.from_other(
                     self, RoleName=role['name'],
                     DelegateAccount=self.args.get('DelegateAccount'))
                 req.main()
     return self.send()