def Run(self, args): api = GetApiAdapter(self.ReleaseTrack()) queues_client = api.queues queue_ref = parsers.ParseQueue(args.queue, args.location) location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref) queue_config = parsers.ParseCreateOrUpdateQueueArgs( args, constants.PUSH_QUEUE, api.messages, release_track=self.ReleaseTrack()) if not self.is_alpha: create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, app_engine_http_queue=queue_config.appEngineHttpQueue, stackdriver_logging_config=queue_config. stackdriverLoggingConfig) else: create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, app_engine_http_target=queue_config.appEngineHttpTarget) log.CreatedResource( parsers.GetConsolePromptString(queue_ref.RelativeName()), 'queue') return create_response
def Run(self, args): api = GetApiAdapter(self.ReleaseTrack()) queues_client = api.queues queue_ref = parsers.ParseQueue(args.queue, args.location) location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref) queue_config = parsers.ParseCreateOrUpdateQueueArgs( args, constants.PULL_QUEUE, api.messages, release_track=self.ReleaseTrack()) log.warning(constants.QUEUE_MANAGEMENT_WARNING) if self.ReleaseTrack() == base.ReleaseTrack.ALPHA: create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, pull_target=queue_config.pullTarget) else: create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, queue_type=queue_config.type) log.CreatedResource(queue_ref.Name(), 'queue') return create_response
def Run(self, args): queues_client = queues.Queues() queue_ref = parsers.ParseQueue(args.id) location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref) configs = parsers.ParseCreateOrUpdateQueueArgs( args, constants.PULL_QUEUE, queues_client.api.messages) create_response = queues_client.Create(location_ref, queue_ref, *configs) log.CreatedResource(queue_ref.Name(), 'queue') return create_response
def testExtractLocationRef(self): expected_location_ref = resources.REGISTRY.Parse( '{}/projects/my-project/locations/us-central'.format( _SELF_LINK_PREFIX), collection=constants.LOCATIONS_COLLECTION) queue_ref = resources.REGISTRY.Parse( '{}/projects/my-project/locations/us-central/queues/my-queue'. format(_SELF_LINK_PREFIX), collection=constants.QUEUES_COLLECTION) actual_location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref) self.assertEqual(actual_location_ref, expected_location_ref)
def Run(self, args): queues_client = queues.Queues() queue_ref = parsers.ParseQueue(args.queue, args.location) location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref) queue_config = parsers.ParseCreateOrUpdateQueueArgs( args, constants.PULL_QUEUE, queues_client.api.messages) log.warning(constants.QUEUE_MANAGEMENT_WARNING) create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, pull_target=queue_config.pullTarget) log.CreatedResource(queue_ref.Name(), 'queue') return create_response
def Run(self, args): queues_client = queues.Queues() queue_ref = parsers.ParseQueue(args.id) location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref) queue_config = parsers.ParseCreateOrUpdateQueueArgs( args, constants.APP_ENGINE_QUEUE, queues_client.api.messages) log.warn(constants.QUEUE_MANAGEMENT_WARNING) create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, app_engine_http_target=queue_config.appEngineHttpTarget) log.CreatedResource(queue_ref.Name(), 'queue') return create_response
def Run(self, args): api = GetApiAdapter(self.ReleaseTrack()) queues_client = api.queues queue_ref = parsers.ParseQueue(args.queue, args.location) location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref) queue_config = parsers.ParseCreateOrUpdateQueueArgs( args, constants.APP_ENGINE_QUEUE, api.messages, is_alpha=True) log.warning(constants.QUEUE_MANAGEMENT_WARNING) create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, app_engine_http_target=queue_config.appEngineHttpTarget) log.CreatedResource(queue_ref.Name(), 'queue') return create_response
def Run(self, args): if self.ReleaseTrack() == base.ReleaseTrack.BETA: queue_type = args.type else: queue_type = constants.PUSH_QUEUE api = GetApiAdapter(self.ReleaseTrack()) queues_client = api.queues queue_ref = parsers.ParseQueue(args.queue, args.location) location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref) queue_config = parsers.ParseCreateOrUpdateQueueArgs( args, queue_type, api.messages, release_track=self.ReleaseTrack()) if self.ReleaseTrack() == base.ReleaseTrack.ALPHA: create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, app_engine_http_target=queue_config.appEngineHttpTarget) elif self.ReleaseTrack() == base.ReleaseTrack.BETA: create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, app_engine_http_queue=queue_config.appEngineHttpQueue, stackdriver_logging_config=queue_config. stackdriverLoggingConfig, queue_type=queue_config.type) else: create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, app_engine_routing_override=queue_config. appEngineRoutingOverride, stackdriver_logging_config=queue_config. stackdriverLoggingConfig) log.CreatedResource( parsers.GetConsolePromptString(queue_ref.RelativeName()), 'queue') return create_response
def Run(self, args): api = GetApiAdapter(self.ReleaseTrack()) queues_client = api.queues queue_ref = parsers.ParseQueue(args.queue, args.location) location_ref = parsers.ExtractLocationRefFromQueueRef(queue_ref) queue_config = parsers.ParseCreateOrUpdateQueueArgs( args, constants.PUSH_QUEUE, api.messages, release_track=self.ReleaseTrack()) log.warning(constants.QUEUE_MANAGEMENT_WARNING) if self.ReleaseTrack() == base.ReleaseTrack.ALPHA: create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, app_engine_http_target=queue_config.appEngineHttpTarget) elif self.ReleaseTrack() == base.ReleaseTrack.BETA: create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, app_engine_http_queue=queue_config.appEngineHttpQueue, stackdriver_logging_config=queue_config. stackdriverLoggingConfig) else: create_response = queues_client.Create( location_ref, queue_ref, retry_config=queue_config.retryConfig, rate_limits=queue_config.rateLimits, app_engine_routing_override=queue_config. appEngineRoutingOverride) log.CreatedResource(queue_ref.Name(), 'queue') return create_response