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.Create( 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: log.CreatedResource(app_profile_ref.Name(), kind='app profile') return result
def _CreateAppProfile(self, app_profile_ref, args): """Creates 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: Created app profile resource object. """ return app_profiles.Create( 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 testCreateRequiresOnlyOneRoutingPolicy(self): with self.AssertRaisesExceptionRegexp( ValueError, 'Must specify either --route-to or --route-any'): app_profiles.Create(self.app_profile_ref, description='my-description', cluster=self.cluster_id, multi_cluster=True)
def testCreateMultiCluster(self): response = self.msgs.AppProfile() app_profile_to_create = self.msgs.AppProfile( description='my-description', multiClusterRoutingUseAny={}) self.client.projects_instances_appProfiles.Create.Expect( request=self.msgs. BigtableadminProjectsInstancesAppProfilesCreateRequest( appProfile=app_profile_to_create, appProfileId=self.app_profile_id, parent=self.instance_relative_name, ignoreWarnings=False), response=response) self.assertEquals( app_profiles.Create(self.app_profile_ref, multi_cluster=True, description='my-description'), response)
def testCreate(self): response = self.msgs.AppProfile() app_profile_to_create = self.msgs.AppProfile( description='my-description', singleClusterRouting=self.msgs.SingleClusterRouting( clusterId=self.cluster_id, allowTransactionalWrites=True)) self.client.projects_instances_appProfiles.Create.Expect( request=self.msgs. BigtableadminProjectsInstancesAppProfilesCreateRequest( appProfile=app_profile_to_create, appProfileId=self.app_profile_id, parent=self.instance_relative_name, ignoreWarnings=False), response=response) self.assertEquals( app_profiles.Create(self.app_profile_ref, self.cluster_id, description='my-description', transactional_writes=True), response)
def testCreateRequiresRoutingPolicy(self): with self.AssertRaisesExceptionRegexp( ValueError, 'Must specify either --route-to or --route-any'): app_profiles.Create(self.app_profile_ref, description='my-description')