[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for Trino](../index.md) > [Step-by-step guides](index.md) > Catalogs > Updating a catalog

# Updating a Trino catalog

{% list tabs group=instructions %}

- Management console {#console}

    1. Go to the [resource folder](https://console.yandex.cloud) page.
    1. Navigate to **Managed Service for&nbsp;Trino**.
    1. Click the cluster name.
    1. In the left-hand panel, select ![image](../../_assets/console-icons/folder-tree.svg) **Catalogs**.
    1. Next to the Trino catalog, click ![image](../../_assets/console-icons/ellipsis.svg) and select **Edit**.
    1. Update your Trino catalog parameters and click **Update**.

- CLI {#cli}

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    1. View the description of the CLI command for updating a Trino catalog:

        ```bash
        yc managed-trino catalog update --help
        ```

    1. View the description of the CLI command for updating a Trino catalog with a specific connector:

        ```bash
        yc managed-trino catalog update <connector_type> --help
        ```

    1. To update the catalog, run this command:

        ```bash
        yc managed-trino catalog update <connector_type> <Trino_catalog_name> \
            --new-name <new_Trino_catalog_name>
        ```

        You can get the Trino catalog name together with the [list of Trino catalogs in the cluster](catalog-list.md#list-catalogs.md).

        In the command, you can also provide the settings for your Trino catalog depending on the connector type. [Learn more about settings for various connector types](catalog-create.md#catalog-settings).

- Terraform {#tf}

    1. Open the current Terraform configuration file with the infrastructure plan.

        To learn how to create this file, refer to [Creating a cluster](cluster-create.md).

    1. Edit the Trino catalog settings in the `yandex_trino_catalog` section:

        ```hcl
        resource "yandex_trino_catalog" "<Trino_catalog_name>" {
          ...
          <connector_type> = {
            <Trino_catalog_settings>
          }
        }
        ```

        [Learn more about the Trino catalog settings](catalog-create.md#catalog-settings) for various connector types.

    1. Make sure the settings are correct.

        1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
        1. Run this command:
        
           ```bash
           terraform validate
           ```
        
           Terraform will show any errors found in your configuration files.

    1. Confirm updating the resources.

        1. Run this command to view the planned changes:
        
           ```bash
           terraform plan
           ```
        
           If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
        
        1. If everything looks correct, apply the changes:
           1. Run this command:
        
              ```bash
              terraform apply
              ```
        
           1. Confirm updating the resources.
           1. Wait for the operation to complete.

- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Use the [Catalog.Update](../api-ref/Catalog/update.md) method and send the following request, e.g., via [cURL](https://curl.se/):

        {% note warning %}
        
        The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
        
        {% endnote %}

        ```bash
        curl \
            --request PATCH \
            --header "Authorization: Bearer $IAM_TOKEN" \
            --header "Content-Type: application/json" \
            --url 'https://trino.api.cloud.yandex.net/managed-trino/v1/clusters/<cluster_ID>/catalogs/<Trino_catalog_ID>' \
            --data '{
                      "updateMask": "catalog.name,catalog.connector.<connector_type>.<path_to_setting>.<setting_1>,catalog.connector.<connector_type>.<path_to_setting>.<setting_2>,...,catalog.connector.<connector_type>.<path_to_setting>.<setting_N>",
                      "catalog": {
                        "name": "<new_Trino_catalog_name>",
                        "connector": {
                          "<connector_type>": {
                            <Trino_catalog_settings_to_update>
                          }
                        }
                      }
                    }'
        ```

        Where `updateMask` is a comma-separated string of parameters to update.

        [Learn more about the Trino](#catalog-settings) catalog settings for various connector types.

        You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters) and the folder ID with the [list of Trino catalogs in the cluster](catalog-list.md).

    1. Check the [server response](../api-ref/Catalog/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. Call the [CatalogService.Update](../api-ref/grpc/Catalog/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        {% note warning %}
        
        The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `update_mask` parameter as an array of `paths[]` strings.
        
        {% cut "Format for listing settings" %}
        
        ```yaml
        "update_mask": {
            "paths": [
                "<setting_1>",
                "<setting_2>",
                ...
                "<setting_N>"
            ]
        }
        ```
        
        {% endcut %}
        
        {% endnote %}

        ```bash
        grpcurl \
            -format json \
            -import-path ~/cloudapi/ \
            -import-path ~/cloudapi/third_party/googleapis/ \
            -proto ~/cloudapi/yandex/cloud/trino/v1/catalog_service.proto \
            -rpc-header "Authorization: Bearer $IAM_TOKEN" \
            -d '{
                  "cluster_id": "<cluster_ID>",
                  "catalog_id": "<Trino_catalog_ID>",
                  "update_mask": {
                    "paths": [
                      "catalog.name",
                      "catalog.connector.<connector_type>.<path_to_setting>.<setting_1>",
                      "catalog.connector.<connector_type>.<path_to_setting>.<setting_2>",
                      ...
                      "catalog.connector.<connector_type>.<path_to_setting>.<setting_N>"
                    ]
                  },
                  "catalog": {
                    "name": "<new_Trino_catalog_name>",
                    "connector": {
                      "<connector_type>": {
                        <Trino_catalog_settings_to_update>
                      }
                    }
                  }
                }' \
            trino.api.cloud.yandex.net:443 \
            yandex.cloud.trino.v1.CatalogService.Update
        ```

        Where `update_mask` is the list of parameters to update as an array of strings (`paths[]`).

        [Learn more about the Trino](#catalog-settings) catalog settings for various connector types.

        You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters), and the folder ID, with the [list of Trino catalogs in the cluster](catalog-list.md).

    1. Check the [server response](../api-ref/grpc/Catalog/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}