def Run(self, args):
   result = self.iam_client.projects_serviceAccounts_keys.Get(
       self.messages.IamProjectsServiceAccountsKeysGetRequest(
           name=iam_util.EmailAndKeyToResourceName(args.iam_account, args.key),
           publicKeyType=iam_util.PublicKeyTypeFromString(args.type)))
   self.WriteFile(args.output_file, result.publicKeyData)
   log.status.Print('written key [{0}] for [{2}] as [{1}]'.format(
       args.key, args.output_file, args.iam_account))
 def _SetUpGetPublicKeyExpectations(self, iam_account, key_id='1234'):
     self.client.projects_serviceAccounts_keys.Get.Expect(
         request=self.msgs.IamProjectsServiceAccountsKeysGetRequest(
             name=iam_util.EmailAndKeyToResourceName(iam_account, key_id),
             publicKeyType=iam_util.PublicKeyTypeFromString('pem')),
         response=self.msgs.ServiceAccountKey(
             name=('projects/test-project/serviceAccounts/%s/keys/1234' %
                   iam_account),
             publicKeyData=b'key data goes here'))
Exemple #3
0
  def Run(self, args):
    console_io.PromptContinue(
        message='You are about to delete key [{0}] for service '
        'account [{1}].'.format(args.key, args.account),
        cancel_on_no=True)
    self.iam_client.projects_serviceAccounts_keys.Delete(
        self.messages.IamProjectsServiceAccountsKeysDeleteRequest(
            name=iam_util.EmailAndKeyToResourceName(args.iam_account,
                                                    args.key)))

    log.status.Print('deleted key [{1}] for service account [{0}]'.format(
        args.iam_account, args.key))