def testRemoveIamPolicyBinding(self):
        original_policy = self.msgs.GoogleIamV1Policy(bindings=[
            self.msgs.GoogleIamV1Binding(members=['user:[email protected]'],
                                         role='roles/owner')
        ],
                                                      etag=b'abcd')
        new_policy = self.msgs.GoogleIamV1Policy(bindings=[], etag=b'abcd')
        get_iam_policy = self.StartObjectPatch(self.models_client,
                                               'GetIamPolicy',
                                               return_value=original_policy,
                                               autospec=True)
        set_iam_policy = self.StartObjectPatch(self.models_client,
                                               'SetIamPolicy',
                                               return_value=new_policy,
                                               autospec=True)

        response = models_util.RemoveIamPolicyBinding(self.models_client,
                                                      'myModel',
                                                      'user:[email protected]',
                                                      'roles/owner')

        self.assertEqual(response, new_policy)
        get_iam_policy.assert_called_once_with(self.model_ref)
        set_iam_policy.assert_called_once_with(self.model_ref, new_policy,
                                               'bindings,etag')
    def Run(self, args):
        """This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      The specified function with its description and configured filter.
    """
        with endpoint_util.MlEndpointOverrides(region=args.region):
            client = models.ModelsClient()
            return models_util.RemoveIamPolicyBinding(client, args.model,
                                                      args.member, args.role)
示例#3
0
def _Run(args):
    region = region_util.GetRegion(args)
    with endpoint_util.MlEndpointOverrides(region=region):
        client = models.ModelsClient()
        return models_util.RemoveIamPolicyBinding(client, args.model,
                                                  args.member, args.role)
 def Run(self, args):
   return models_util.RemoveIamPolicyBinding(
       models.ModelsClient(), args.model, args.member, args.role)