def env_vars_create(env_var_name, env_var_value, secret, deployment_name, version_name, yaml_file, format_): """ Create an environment variable. \b - When deployment_name and version_name are provided: the environment variable will be created on deployment version level. - When a deployment name is provided, but not a version name: the environment variable will be created on deployment level. - When no deployment_name nor a version name is provided: the environment variable will be created on project level. \b It is possible to create multiple environment variables at ones by passing a yaml file. The structure of this file is assumed to look like: ``` environment_variables: - name: env_var_1 value: value_1 - name: env_var_2 value: value_2 secret: true - name: env_var_3 value: value_3 secret: true ``` The 'secret' parameter is optional, and is `false` by default. """ project_name = get_current_project(error=True) if not yaml_file and not env_var_name: raise Exception( "Please, specify the environment variable in either a yaml file or as a command argument" ) if yaml_file and (env_var_name or env_var_value or secret): raise Exception( "Please, use either a yaml file or command options, not both") if version_name and not deployment_name: raise Exception("Missing option <deployment_name>") if yaml_file: yaml_content = read_yaml(yaml_file, required_fields=['environment_variables']) check_required_fields(input_dict=yaml_content, list_name='environment_variables', required_fields=['name', 'value']) items = [] for env_var in yaml_content['environment_variables']: secret = env_var['secret'] if 'secret' in env_var else False item = create_env_var(project_name, deployment_name, version_name, env_var['name'], env_var['value'], secret) items.append(item) print_list(items, LIST_ITEMS, fmt=format_) else: item = create_env_var(project_name, deployment_name, version_name, env_var_name, env_var_value, secret) print_item(item, LIST_ITEMS, fmt=format_)
def pipelines_create(pipeline_name, yaml_file, format_): """ Create a new pipeline. \b Define the pipeline parameters using a yaml file. For example: ``` pipeline_name: my-pipeline-name pipeline_description: Pipeline created via command line. pipeline_labels: my-key-1: my-label-1 my-key-2: my-label-2 input_type: structured input_fields: - name: my-pipeline-param1 data_type: int output_type: structured output_fields: - name: my-pipeline-output1 data_type: int ``` Possible input/output types: [structured, plain]. Possible data_types: [blob, int, string, double, bool, array_string, array_int, array_double]. """ client = init_client() project_name = get_current_project(error=True) yaml_content = read_yaml(yaml_file, required_fields=PIPELINE_REQUIRED_FIELDS) assert 'pipeline_name' in yaml_content or pipeline_name, \ 'Please, specify the pipeline name in either the yaml file or as a command argument' pipeline_fields, input_fields, output_fields = define_pipeline( yaml_content, pipeline_name) pipeline_data = api.PipelineCreate(**pipeline_fields, **input_fields, **output_fields) pipeline_response = client.pipelines_create(project_name=project_name, data=pipeline_data) client.api_client.close() print_item(pipeline_response, row_attrs=LIST_ITEMS, required_front=['name', 'description', 'input_type'], optional=[ 'input_fields name', 'input_fields data_type', 'output_type', 'output_fields name', 'output_fields data_type', 'creation_date', 'last_updated' ], rename={ 'name': 'pipeline_name', 'description': 'pipeline_description' }, fmt=format_)
def deployments_update(deployment_name, new_name, default_version, yaml_file, quiet): """ Update a deployment. If you only want to update the name of the deployment or the default deployment version, use the options `<new_name>` and `<default_version>`. If you want to update the deployment input/output fields, description or labels, please use a yaml file to define the new deployment. \b For example: ``` deployment_description: Deployment created via command line. deployment_labels: my-key-1: my-label-1 my-key-2: my-label-2 input_fields: - name: param1 data_type: int - name: param2 data_type: string output_fields: - name: param1 data_type: int - name: param2 data_type: string ``` """ project_name = get_current_project(error=True) yaml_content = read_yaml(yaml_file) deployment = api.DeploymentUpdate(name=new_name, default_version=default_version) if 'deployment_description' in yaml_content: deployment.description = yaml_content['deployment_description'] if 'deployment_labels' in yaml_content: deployment.labels = yaml_content['deployment_labels'] if 'input_fields' in yaml_content and isinstance(yaml_content['input_fields'], list): deployment.input_fields = [ api.DeploymentInputFieldCreate(name=item['name'], data_type=item['data_type']) for item in yaml_content['input_fields'] ] if 'output_fields' in yaml_content and isinstance(yaml_content['output_fields'], list): deployment.output_fields = [ api.DeploymentInputFieldCreate(name=item['name'], data_type=item['data_type']) for item in yaml_content['output_fields'] ] client = init_client() client.deployments_update(project_name=project_name, deployment_name=deployment_name, data=deployment) client.api_client.close() if not quiet: click.echo("Deployment was successfully updated")
def pipeline_versions_update(pipeline_name, version_name, yaml_file, new_name, quiet, **kwargs): """ Update a version of a pipeline. \b It is possible to define the parameters using a yaml file. For example: ``` version_description: Version created via command line. version_labels: my-key-1: my-label-1 my-key-2: my-label-2 request_retention_mode: none request_retention_time: 604800 objects: - name: object1 reference_name: my-deployment-name reference_version: my-deployment-version attachments: - destination_name: object1 sources: - source_name: pipeline_start mapping: - source_field_name: my-pipeline-param1 destination_field_name: my-deployment-param1 ``` You can update version parameters by either providing the options in a yaml file and passing the file path as `<yaml_file>`, or passing the options as command options. If both a `<yaml_file>` is set and options are given, the options defined by `<yaml_file>` will be overwritten by the specified command options. """ project_name = get_current_project(error=True) client = init_client() yaml_content = read_yaml(yaml_file, required_fields=[]) existing_version = client.pipeline_versions_get( project_name=project_name, pipeline_name=pipeline_name, version=version_name) # Define the pipeline version kwargs = set_pipeline_version_defaults(kwargs, yaml_content, existing_version) # Rename objects reference version kwargs = rename_pipeline_object_reference_version(content=kwargs) version_data = api.PipelineVersionUpdate(**{ 'version': new_name, **{k: kwargs[k] for k in PIPELINE_VERSION_FIELDS} }) client.pipeline_versions_update(project_name=project_name, pipeline_name=pipeline_name, version=version_name, data=version_data) client.api_client.close() if not quiet: click.echo("Pipeline version was successfully updated")
def pipeline_versions_create(pipeline_name, version_name, yaml_file, format_, **kwargs): """ Create a version of a pipeline. \b It is possible to define the parameters using a yaml file. For example: ``` pipeline_name: my-pipeline-name version_name: my-pipeline-version version_description: Version created via command line. version_labels: my-key-1: my-label-1 my-key-2: my-label-2 request_retention_mode: none request_retention_time: 604800 objects: - name: object1 reference_name: my-deployment-name reference_version: my-deployment-version attachments: - destination_name: object1 sources: - source_name: pipeline_start mapping: - source_field_name: my-pipeline-param1 destination_field_name: my-deployment-param1 ``` Those parameters can also be provided as command options. If both a `<yaml_file>` is set and options are given, the options defined by `<yaml_file>` will be overwritten by the specified command options. The version name can either be passed as command argument or specified inside the yaml file using `<version_name>`. """ project_name = get_current_project(error=True) yaml_content = read_yaml(yaml_file, required_fields=[]) client = init_client() assert 'pipeline_name' in yaml_content or pipeline_name, \ 'Please, specify the pipeline name in either the yaml file or as a command argument' assert 'version_name' in yaml_content or version_name, \ 'Please, specify the version name in either the yaml file or as a command argument' pipeline_name = set_dict_default(pipeline_name, yaml_content, 'pipeline_name') version_name = set_dict_default(version_name, yaml_content, 'version_name') # Define the pipeline version kwargs = set_pipeline_version_defaults(kwargs, yaml_content, None) # Rename objects reference version kwargs = rename_pipeline_object_reference_version(content=kwargs) version = api.PipelineVersionCreate( version=version_name, **{k: kwargs[k] for k in PIPELINE_VERSION_FIELDS}) response = client.pipeline_versions_create(project_name=project_name, pipeline_name=pipeline_name, data=version) client.api_client.close() print_item(item=response, row_attrs=LIST_ITEMS, rename={ 'pipeline': 'pipeline_name', 'version': 'version_name', **PIPELINE_VERSION_FIELDS_RENAMED }, fmt=format_)
def deployments_create(deployment_name, yaml_file, format_): """ Create a new deployment. \b Define the deployment parameters using a yaml file. For example: ``` deployment_name: my-deployment-name deployment_description: Deployment created via command line. deployment_labels: my-key-1: my-label-1 my-key-2: my-label-2 input_type: structured input_fields: - name: param1 data_type: int - name: param2 data_type: string output_type: plain ``` The deployment name can either be passed as argument or specified inside the yaml file. If it is both passed as argument and specified inside the yaml file, the value passed as argument is used. Possible input/output types: [structured, plain]. Possible data_types: [blob, int, string, double, bool, array_string, array_int, array_double]. """ project_name = get_current_project(error=True) yaml_content = read_yaml(yaml_file, required_fields=DEPLOYMENT_REQUIRED_FIELDS) client = init_client() assert 'deployment_name' in yaml_content or deployment_name, 'Please, specify the deployment name in either the ' \ 'yaml file or as a command argument' deployment_name = set_dict_default(deployment_name, yaml_content, 'deployment_name') description = set_dict_default(None, yaml_content, 'deployment_description') if 'input_fields' in yaml_content and isinstance(yaml_content['input_fields'], list): input_fields = [api.DeploymentInputFieldCreate(name=item['name'], data_type=item['data_type']) for item in yaml_content['input_fields']] else: input_fields = None if 'output_fields' in yaml_content and isinstance(yaml_content['output_fields'], list): output_fields = [api.DeploymentInputFieldCreate(name=item['name'], data_type=item['data_type']) for item in yaml_content['output_fields']] else: output_fields = None if 'deployment_labels' in yaml_content: labels = yaml_content['deployment_labels'] else: labels = {} deployment = api.DeploymentCreate( name=deployment_name, description=description, input_type=yaml_content['input_type'], output_type=yaml_content['output_type'], input_fields=input_fields, output_fields=output_fields, labels=labels ) response = client.deployments_create(project_name=project_name, data=deployment) client.api_client.close() print_item( item=response, row_attrs=LIST_ITEMS, required_front=['id', 'name', 'project', 'description', 'labels', 'input_type', 'output_type'], optional=['input_fields name', 'input_fields data_type', 'output_fields name', 'output_fields data_type'], required_end=['creation_date', 'last_updated'], rename={'name': 'deployment_name', 'description': 'deployment_description', 'labels': 'deployment_labels'}, fmt=format_ )
def deployments_deploy(deployment_name, version_name, directory, output_path, yaml_file, overwrite, assume_yes, quiet, **kwargs): """ Deploy a new version of a deployment. Please, specify the code `<directory>` that should be deployed. The files in this directory will be zipped and uploaded. Subdirectories and files that shouldn't be contained in the ZIP can be specified in an ignore file, which is by default '.ubiops-ignore'. The structure of this file is assumed to be equal to the wellknown '.gitignore' file. If you want to store a local copy of the uploaded zip file, please use the `<output_path>` option. The `<output_path>` option will be used as output location of the zip file. If the `<output_path>` is a directory, the zip will be saved in `[deployment_name]_[deployment_version]_[datetime.now()].zip`. Use the `<assume_yes>` option to overwrite without confirmation if file specified in `<output_path>` already exists. Provide either deployment mode 'express' or 'batch', default is 'express'. \b It is possible to define the parameters using a yaml file. For example: ``` deployment_name: my-deployment-name version_name: my-deployment-version version_description: Version created via command line. version_labels: my-key-1: my-label-1 my-key-2: my-label-2 language: python3.7 instance_type: 2048mb minimum_instances: 0 maximum_instances: 1 maximum_idle_time: 300 request_retention_mode: none request_retention_time: 604800 deployment_mode: express ``` Those parameters can also be provided as command options. If both a `<yaml_file>` is set and options are given, the options defined by `<yaml_file>` will be overwritten by the specified command options. The deployment name can either be passed as command argument or specified inside the yaml file using `<deployment_name>`. It's not possible to update the programming language and deployment mode of an existing deployment version. """ if output_path is None: store_zip = False output_path = '' else: store_zip = True project_name = get_current_project(error=True) client = init_client() yaml_content = read_yaml(yaml_file, required_fields=[]) assert 'deployment_name' in yaml_content or deployment_name, 'Please, specify the deployment name in either the ' \ 'yaml file or as a command argument' assert 'version_name' in yaml_content or version_name, 'Please, specify the version name in either the yaml ' \ 'file or as a command option' deployment_name = set_dict_default(deployment_name, yaml_content, 'deployment_name') version_name = set_dict_default(version_name, yaml_content, 'version_name') existing_version = None if overwrite: try: existing_version = client.deployment_versions_get( project_name=project_name, deployment_name=deployment_name, version=version_name ) except api.exceptions.ApiException: # Do nothing if version doesn't exist pass kwargs = define_deployment_version( kwargs, yaml_content, extra_yaml_fields=['deployment_file', 'ignore_file'] ) kwargs['ignore_file'] = DEFAULT_IGNORE_FILE if kwargs['ignore_file'] is None else kwargs['ignore_file'] if not quiet and kwargs['memory_allocation'] and not kwargs['instance_type']: click.secho( "Deprecation warning: parameter 'memory_allocation' is deprecated, use 'instance_type' instead", fg='red' ) zip_path = zip_dir( directory=directory, output_path=output_path, ignore_filename=kwargs['ignore_file'], deployment_name=deployment_name, version_name=version_name, force=assume_yes ) try: has_uploaded_zips = False has_changed_fields = False if not (overwrite and existing_version): version = api.DeploymentVersionCreate( version=version_name, **{k: kwargs[k] for k in DEPLOYMENT_VERSION_FIELDS} ) client.deployment_versions_create(project_name=project_name, deployment_name=deployment_name, data=version) else: revisions = client.revisions_list( project_name=project_name, deployment_name=deployment_name, version=version_name ) has_uploaded_zips = len(revisions) > 0 if overwrite and existing_version: has_changed_fields = update_existing_deployment_version( client, project_name, deployment_name, version_name, existing_version, kwargs ) has_changed_env_vars = update_deployment_file( client, project_name, deployment_name, version_name, kwargs['deployment_file'] ) if has_uploaded_zips and (has_changed_fields or has_changed_env_vars): # Wait for changes being applied click.echo("Waiting for changes to take effect... This takes %d seconds." % UPDATE_TIME) sleep(UPDATE_TIME) client.revisions_file_upload( project_name=project_name, deployment_name=deployment_name, version=version_name, file=zip_path ) client.api_client.close() except Exception as e: if os.path.isfile(zip_path) and not store_zip: os.remove(zip_path) client.api_client.close() raise e if os.path.isfile(zip_path): if store_zip: if not quiet: click.echo("Created zip: %s" % zip_path) else: os.remove(zip_path) if not quiet: click.echo("Deployment was successfully deployed")
def exports_create(yaml_file, format_): """ Create a new export. \b Define the export objects parameters using a yaml file. For example: ``` deployments: deployment-1: versions: v1: environment_variables: deployment_version_env_var_1: include_value: True deployment_version_env_var_2: include_value: False v2: {} environment_variables: deployment_env_var: include_value: False pipelines: pipeline-1: versions: v1: {} v2: {} environment_variables: project_env_var: include_value: False ``` """ project_name = get_current_project(error=True) yaml_content = read_yaml(yaml_file) client = init_client() if 'deployments' in yaml_content: if not isinstance(yaml_content['deployments'], dict): raise Exception( "Deployments field should be a dictionary with deployment names as key and versions as value" ) deployments = yaml_content['deployments'] else: deployments = {} if 'pipelines' in yaml_content: if not isinstance(yaml_content['pipelines'], dict): raise Exception( "Pipelines field should be a dictionary with pipeline names as key and versions as value" ) pipelines = yaml_content['pipelines'] else: pipelines = {} if 'environment_variables' in yaml_content: if not isinstance(yaml_content['environment_variables'], dict): raise Exception( "Environment_variables field should be a dictionary with environment variable name as key and details " "of whether to include the variable value as value" ) environment_variables = yaml_content['environment_variables'] else: environment_variables = {} export = api.ExportCreate( deployments=deployments, pipelines=pipelines, environment_variables=environment_variables ) response = client.exports_create(project_name=project_name, data=export) client.api_client.close() print_item(item=response, row_attrs=LIST_ITEMS, fmt=format_)
def imports_confirm(import_id, yaml_file, format_): """ Confirm (and update) an import by selecting the objects in the import. \b Define the import object selection using a yaml file. For example: ``` deployments: deployment-1: description: My deployment labels: my-key-1: my-label-1 my-key-2: my-label-2 input_type: structured output_type: structured input_fields: - name: input data_type: int output_fields: - name: output data_type: int default_version: v1 versions: v1: zip: "deployments/deployment_deployment-1/versions/deployment_deployment-1_version_v1.zip" description: language: python3.8 deployment_mode: express maximum_idle_time: 300 minimum_instances: 0 maximum_instances: 5 memory_allocation: 512 request_retention_mode: full request_retention_time: 604800 environment_variables: deployment_version_env_var_1: value: env_var_value_1 secret: True deployment_version_env_var_2: value: env_var_value_2 secret: False v2: {} pipelines: pipeline-1: description: My pipeline labels: my-key-1: my-label-1 my-key-2: my-label-2 input_type: structured output_type: structured input_fields: - name: input data_type: int output_fields: - name: output data_type: int default_version: v1 versions: v1: description: labels: request_retention_mode: full request_retention_time: 604800 objects: - name: obj-1 reference_name: deployment-1 reference_version: v1 attachments: - sources: - mapping: - source_field_name: input destination_field_name: input source_name: pipeline_start destination_name: obj-1 - sources: - mapping: - source_field_name: input destination_field_name: output source_name: obj-1 destination_name: pipeline_end v2: {} ``` """ project_name = get_current_project(error=True) yaml_content = read_yaml(yaml_file) client = init_client() if 'deployments' in yaml_content: if not isinstance(yaml_content['deployments'], dict): raise Exception( "Deployments field should be a dictionary with deployment names as key and deployment and version " "details as value") deployments = yaml_content['deployments'] else: deployments = {} if 'pipelines' in yaml_content: if not isinstance(yaml_content['pipelines'], dict): raise Exception( "Pipelines field should be a dictionary with pipelines names as key and pipeline and version " "details as value") pipelines = yaml_content['pipelines'] else: pipelines = {} if 'environment_variables' in yaml_content: if not isinstance(yaml_content['environment_variables'], dict): raise Exception( "Environment_variables field should be a dictionary with environment variable name as key and variable " "details as value") environment_variables = yaml_content['environment_variables'] else: environment_variables = {} import_update_data = api.ImportUpdate( deployments=deployments, pipelines=pipelines, environment_variables=environment_variables) response = client.imports_update(project_name=project_name, import_id=import_id, data=import_update_data) client.api_client.close() print_item(item=response, row_attrs=GET_ITEMS, fmt=format_)
def versions_update(deployment_name, version_name, yaml_file, new_name, quiet, **kwargs): """Update a version of a deployment. \b It is possible to define the parameters using a yaml file. For example: ``` version_description: Version created via command line. version_labels: my-key-1: my-label-1 my-key-2: my-label-2 instance_type: 2048mb minimum_instances: 0 maximum_instances: 1 maximum_idle_time: 300 request_retention_mode: none request_retention_time: 604800 ``` You may want to change some deployment options, like, `<maximum_instances>` and `<memory_allocation>`. You can do this by either providing the options in a yaml file and passing the file path as `<yaml_file>`, or passing the options as command options. If both a `<yaml_file>` is set and options are given, the options defined by `<yaml_file>` will be overwritten by the specified command options. It's not possible to update the programming language of an existing deployment version. """ project_name = get_current_project(error=True) client = init_client() yaml_content = read_yaml(yaml_file, required_fields=[]) kwargs['version_name'] = new_name kwargs = define_deployment_version(kwargs, yaml_content, extra_yaml_fields=['deployment_file']) if not quiet and kwargs[ 'memory_allocation'] and not kwargs['instance_type']: click.secho( "Deprecation warning: parameter 'memory_allocation' is deprecated, use 'instance_type' instead", fg='red') version = api.DeploymentVersionUpdate( **{ k: kwargs[k] for k in DEPLOYMENT_VERSION_FIELDS_UPDATE if kwargs[k] is not None }) client.deployment_versions_update(project_name=project_name, deployment_name=deployment_name, version=version_name, data=version) update_deployment_file(client, project_name, deployment_name, version_name, kwargs['deployment_file']) client.api_client.close() if not quiet: click.echo("Deployment version was successfully updated")
def versions_create(deployment_name, version_name, yaml_file, format_, **kwargs): """Create a version of a deployment. \b It is possible to define the parameters using a yaml file. For example: ``` deployment_name: my-deployment-name version_name: my-deployment-version version_description: Version created via command line. version_labels: my-key-1: my-label-1 my-key-2: my-label-2 language: python3.7 instance_type: 2048mb minimum_instances: 0 maximum_instances: 1 maximum_idle_time: 300 request_retention_mode: none request_retention_time: 604800 deployment_mode: express ``` Provide either deployment mode 'express' or 'batch', default is 'express'. Those parameters can also be provided as command options. If both a `<yaml_file>` is set and options are given, the options defined by `<yaml_file>` will be overwritten by the specified command options. The version name can either be passed as command argument or specified inside the yaml file using `<version_name>`. """ project_name = get_current_project(error=True) yaml_content = read_yaml(yaml_file, required_fields=[]) client = init_client() assert 'deployment_name' in yaml_content or deployment_name, 'Please, specify the deployment name in either ' \ 'the yaml file or as a command argument' assert 'version_name' in yaml_content or version_name, 'Please, specify the version name in either ' \ 'the yaml file or as a command argument' kwargs = define_deployment_version(kwargs, yaml_content, extra_yaml_fields=['deployment_file']) if format_ != 'json' and kwargs[ 'memory_allocation'] and not kwargs['instance_type']: click.secho( "Deprecation warning: parameter 'memory_allocation' is deprecated, use 'instance_type' instead", fg='red') deployment_name = set_dict_default(deployment_name, yaml_content, 'deployment_name') version_name = set_dict_default(version_name, yaml_content, 'version_name') version = api.DeploymentVersionCreate( version=version_name, **{k: kwargs[k] for k in DEPLOYMENT_VERSION_FIELDS}) response = client.deployment_versions_create( project_name=project_name, deployment_name=deployment_name, data=version) update_deployment_file(client, project_name, deployment_name, version_name, kwargs['deployment_file']) client.api_client.close() print_item(item=response, row_attrs=LIST_ITEMS, rename={ 'deployment': 'deployment_name', 'version': 'version_name', **DEPLOYMENT_VERSION_FIELDS_RENAMED }, fmt=format_)
def pipelines_update(pipeline_name, new_name, yaml_file, default_version, quiet): """ Update a pipeline. If you only want to update the name of the pipeline or the default pipeline version, use the options `<new_name>` and `<default_version>`. If you want to update the pipeline input/output type and fields, please use a yaml file to define the new pipeline. Please note that it's only possible to update the input of a pipeline for pipelines that have no pipeline versions with a connected pipeline start, that it's only possible to update the output of a pipeline for pipelines that have no pipeline versions with a connected pipeline end. """ client = init_client() project_name = get_current_project(error=True) # Check if pipeline exists existing_pipeline = client.pipelines_get(project_name=project_name, pipeline_name=pipeline_name) if yaml_file: # Update pipeline according to yaml (and default version update if given) yaml_content = read_yaml(yaml_file, required_fields=PIPELINE_REQUIRED_FIELDS) pipeline_fields, input_fields, output_fields = define_pipeline( yaml_content, pipeline_name, current_pipeline_name=pipeline_name) changed_input_data = get_changed_pipeline_structure( existing_pipeline, input_fields) changed_output_data = get_changed_pipeline_structure(existing_pipeline, output_fields, is_input=False) pipeline = api.PipelineUpdate(**pipeline_fields, **changed_input_data, **changed_output_data, default_version=default_version) if pipeline.name != pipeline_name: # Pipeline will be renamed try: client.pipelines_get(project_name=project_name, pipeline_name=pipeline.name) raise Exception( f"Trying to rename pipeline '{pipeline_name}' to '{pipeline.name}', but a pipeline with the new " f"name already exists") except api.exceptions.ApiException: pass client.pipelines_update(project_name=project_name, pipeline_name=pipeline_name, data=pipeline) if not quiet: click.echo("Pipeline was successfully updated") elif new_name and new_name != pipeline_name: # Pipeline will be renamed (and default version update if given) try: client.pipelines_get(project_name=project_name, pipeline_name=new_name) raise Exception( f"Trying to rename pipeline '{pipeline_name}' to '{new_name}', but a pipeline with the new " f"name already exists") except api.exceptions.ApiException: pass pipeline = api.PipelineUpdate(name=new_name, default_version=default_version) client.pipelines_update(project_name=project_name, pipeline_name=pipeline_name, data=pipeline) if not quiet: click.echo("Pipeline was successfully updated") elif default_version is not None: # Pipeline default version will be changed pipeline = api.PipelineUpdate(default_version=default_version) client.pipelines_update(project_name=project_name, pipeline_name=pipeline_name, data=pipeline) if not quiet: click.echo("Pipeline default version was successfully updated") else: if not quiet: click.echo("Nothing to update") client.api_client.close()