def testUpdateRequiresClusterOrMultiClusterUseAny(self):
     with self.AssertRaisesExceptionRegexp(
             ValueError, 'Cannot update both --route-to and --route-any'):
         app_profiles.Update(self.app_profile_ref,
                             description='my-description',
                             cluster=self.cluster_id,
                             multi_cluster=True)
    def _UpdateAppProfile(self, app_profile_ref, args):
        """Updates an AppProfile with the given arguments.

    Args:
      app_profile_ref: A resource reference of the new app profile.
      args: an argparse namespace. All the arguments that were provided to this
          command invocation.

    Raises:
      ConflictingArgumentsException:
          If both cluster and multi_cluster are present.
          If both multi_cluster and transactional_writes are present.
          If both cluster and restrict_to are present.
      OneOfArgumentsRequiredException: If neither cluster or multi_cluster are
          present.

    Returns:
      Long running operation.
    """
        return app_profiles.Update(
            app_profile_ref,
            cluster=args.route_to,
            description=args.description,
            multi_cluster=args.route_any,
            restrict_to=args.restrict_to,
            transactional_writes=args.transactional_writes,
            force=args.force)
 def testUpdateMultiClusterUseAny(self):
     response = self.msgs.Operation()
     app_profile_to_update = self.msgs.AppProfile(
         multiClusterRoutingUseAny={})
     update_mask = 'multiClusterRoutingUseAny'
     self.client.projects_instances_appProfiles.Patch.Expect(
         request=self.msgs.
         BigtableadminProjectsInstancesAppProfilesPatchRequest(
             name=self.app_profile_relative_name,
             appProfile=app_profile_to_update,
             updateMask=update_mask,
             ignoreWarnings=False),
         response=response)
     self.assertEquals(
         app_profiles.Update(self.app_profile_ref, multi_cluster=True),
         response)
 def testUpdate(self):
     response = self.msgs.Operation()
     app_profile_to_update = self.msgs.AppProfile(
         singleClusterRouting=self.msgs.SingleClusterRouting(
             clusterId=self.cluster_id, allowTransactionalWrites=False),
         description='new-description')
     update_mask = 'singleClusterRouting,description'
     self.client.projects_instances_appProfiles.Patch.Expect(
         request=self.msgs.
         BigtableadminProjectsInstancesAppProfilesPatchRequest(
             name=self.app_profile_relative_name,
             appProfile=app_profile_to_update,
             updateMask=update_mask,
             ignoreWarnings=False),
         response=response)
     self.assertEquals(
         app_profiles.Update(self.app_profile_ref,
                             cluster=self.cluster_id,
                             description='new-description'), response)
예제 #5
0
  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.

    Raises:
      exceptions.ConflictingArgumentsException: If the user provides
        --transactional-writes and --route-any.

    Returns:
      Created resource.
    """
    app_profile_ref = args.CONCEPTS.app_profile.Parse()
    try:
      result = app_profiles.Update(
          app_profile_ref,
          cluster=args.route_to,
          description=args.description,
          multi_cluster=args.route_any,
          transactional_writes=args.transactional_writes,
          force=args.force)
    except HttpError as e:
      util.FormatErrorMessages(e)
    else:
      operation_ref = util.GetOperationRef(result)

      if args.async:
        log.UpdatedResource(
            operation_ref,
            kind='bigtable app-profile {0}'.format(app_profile_ref.Name()),
            is_async=True)
        return result

      return util.AwaitAppProfile(
          operation_ref,
          'Updating bigtable app-profile {0}'.format(app_profile_ref.Name()))