def Run(self, args): """Delete a Cloud Run Integration.""" integration_name = args.name conn_context = connection_context.GetConnectionContext( args, run_flags.Product.RUN_APPS, self.ReleaseTrack()) with run_apps_operations.Connect(conn_context) as client: with progress_tracker.StagedProgressTracker( 'Deleting Integration...', stages.IntegrationDeleteStages(), failure_message='Failed to delete integration.' ) as tracker: try: integration_type = client.DeleteIntegration( name=integration_name, tracker=tracker) except exceptions.IntegrationsOperationError as err: pretty_print.Info( messages_util.GetDeleteErrorMessage(integration_name)) raise err else: pretty_print.Info('') pretty_print.Success( messages_util.GetSuccessMessage( integration_type=integration_type, integration_name=integration_name, action='deleted'))
def Run(self, args): """Creates a Cloud Run Integration.""" integration_type = args.type service = args.service input_name = args.name parameters = flags.GetParameters(args) flags.ValidateCreateParameters(integration_type, parameters) conn_context = connection_context.GetConnectionContext( args, run_flags.Product.RUN_APPS, self.ReleaseTrack()) with run_apps_operations.Connect(conn_context) as client: self._validateServiceNameAgainstIntegrations( client, integration_type=integration_type, service=service, integration_name=input_name) with progress_tracker.StagedProgressTracker( 'Creating new Integration...', stages.IntegrationStages(create=True), failure_message='Failed to create new integration.' ) as tracker: integration_name = client.CreateIntegration( tracker=tracker, integration_type=integration_type, parameters=parameters, service=service, name=input_name) resource_config = client.GetIntegration(integration_name) resource_status = client.GetIntegrationStatus(integration_name) pretty_print.Info('') pretty_print.Success( messages_util.GetSuccessMessage( integration_type=integration_type, integration_name=integration_name, action='created')) call_to_action = messages_util.GetCallToAction( integration_type, resource_config, resource_status) if call_to_action: pretty_print.Info('') pretty_print.Info(call_to_action) pretty_print.Info( messages_util.CheckStatusMessage(self.ReleaseTrack(), integration_name))
def Run(self, args): """Describe an integration type.""" name = args.name conn_context = connection_context.GetConnectionContext( args, run_flags.Product.RUN_APPS, self.ReleaseTrack()) with run_apps_operations.Connect(conn_context) as client: resource_config = client.GetIntegration(name) resource_status = client.GetIntegrationStatus(name) resource_type = client.GetResourceTypeFromConfig(resource_config) integration_type = types_utils.GetIntegrationType(resource_type) return { 'name': name, 'region': conn_context.region, 'type': integration_type, 'config': resource_config, 'status': resource_status }
def Run(self, args): """Create or Update application from YAML.""" self._ValidateAppConfigFile(args.FILE) app_dict = dict(args.FILE) name = app_dict.pop('name') appconfig = {'config': yaml.dump(args.FILE).encode('utf-8')} conn_context = connection_context.GetConnectionContext( args, run_flags.Product.RUN_APPS, self.ReleaseTrack()) with run_apps_operations.Connect(conn_context) as client: with progress_tracker.StagedProgressTracker( 'Applying Configuration...', stages.ApplyStages(), failure_message='Failed to apply application configuration.' ) as tracker: return client.ApplyAppConfig(tracker, name, appconfig)
def Run(self, args): """Update a Cloud Run Integration.""" add_service = args.add_service remove_service = args.remove_service integration_name = args.name parameters = flags.GetParameters(args) conn_context = connection_context.GetConnectionContext( args, run_flags.Product.RUN_APPS, self.ReleaseTrack()) with run_apps_operations.Connect(conn_context) as client: with progress_tracker.StagedProgressTracker( 'Updating Integration...', stages.IntegrationStages(create=False), failure_message='Failed to update integration.' ) as tracker: client.UpdateIntegration(tracker=tracker, name=integration_name, parameters=parameters, add_service=add_service, remove_service=remove_service) resource_config = client.GetIntegration(integration_name) resource_status = client.GetIntegrationStatus(integration_name) resource_type = client.GetResourceTypeFromConfig(resource_config) integration_type = types_utils.GetIntegrationType(resource_type) pretty_print.Info('') pretty_print.Success( messages_util.GetSuccessMessage( integration_type=integration_type, integration_name=integration_name, action='updated')) call_to_action = messages_util.GetCallToAction( integration_type, resource_config, resource_status) if call_to_action: pretty_print.Info('') pretty_print.Info(call_to_action) pretty_print.Info( messages_util.CheckStatusMessage(self.ReleaseTrack(), integration_name))
def Run(self, args): """List integration types.""" conn_context = connection_context.GetConnectionContext( args, run_flags.Product.RUN_APPS, self.ReleaseTrack()) with run_apps_operations.Connect(conn_context) as client: return list(client.ListIntegrationTypes())