def testFromResourcePath(self): from_resource_path = instances_util.Instance.FromResourcePath expected = instances_util.Instance('a', 'b', 'c') self.assertEqual(from_resource_path('a/b/c'), expected) self.assertEqual(from_resource_path('b/c', service='a'), expected) self.assertEqual(from_resource_path('c', service='a', version='b'), expected)
def testFromResourcePath_OverSpecified(self): from_resource_path = instances_util.Instance.FromResourcePath expected = instances_util.Instance('b', 'c', 'd') self.assertEqual(from_resource_path('b/c/d', service='b'), expected) self.assertEqual(from_resource_path('b/c/d', service='b', version='c'), expected) self.assertEqual(from_resource_path('c/d', service='b', version='c'), expected)
def Run(self, args): client = appengine_api_client.GetApiClient() instance = instances_util.Instance(args.service, args.version, args.instance) log.status.Print('Deleting the instance [{0}].'.format(instance)) console_io.PromptContinue(cancel_on_no=True) res = resources.REGISTRY.Parse(args.instance, params={'servicesId': args.service, 'versionsId': args.version, 'instancesId': args.instance}, collection='appengine.apps.services.' 'versions.instances') client.DeleteInstance(res)
def Run(self, args): client = appengine_api_client.GetApiClientForTrack(self.ReleaseTrack()) instance = instances_util.Instance(args.service, args.version, args.instance) log.status.Print('Deleting the instance [{0}].'.format(instance)) console_io.PromptContinue(cancel_on_no=True) res = resources.REGISTRY.Parse( args.instance, params={ 'appsId': properties.VALUES.core.project.GetOrFail, 'servicesId': args.service, 'versionsId': args.version, 'instancesId': args.instance, }, collection='appengine.apps.services.versions.instances') client.DeleteInstance(res)
def _MakeUtilInstance(self, service, version, instance): """Make an instances_util.Instance object, populated with API message.""" vm_name = self._GetVMName(instance) instance_msg = self._MakeInstance(service, version, instance, vm_name) return instances_util.Instance(service, version, instance, instance_msg)
def testFromResourcePath_EmptyComponent(self): self.assertEqual(instances_util.Instance.FromResourcePath('a//c'), instances_util.Instance('a', '', 'c'))
def testFromResourcePath_UnderSpecified(self): self.assertEqual(instances_util.Instance.FromResourcePath('b/c'), instances_util.Instance(None, 'b', 'c')) self.assertEqual( instances_util.Instance.FromResourcePath('c', service='a'), instances_util.Instance('a', None, 'c'))