Updated on 2022-09-15 GMT+08:00

Updating an API

Description

This API is used to update an API.

URI

  • URI format

    PUT /v1/{project_id}/service/apis/{api_id}

  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID. For details about how to obtain the project ID, see Project ID and Account ID.

    api_id

    Yes

    String

    API ID

    api

    Yes

    Dictionary

    API

    • api parameter description

      Parameter

      Mandatory

      Type

      Description

      catalog_id

      Yes

      String

      Catalog ID. The ID of the root catalog is 0.

      name

      Yes

      String

      API name, which can contain 3 to 64 characters, starting with a letter. Only letters, digits, and underscores (_) are allowed.

      description

      Yes

      String

      API description, which contains no more than 255 characters

      log_flag

      Yes

      Boolean

      Whether to enable the log function. Value true means to enable the function, and false means the opposite.

      api_type

      Yes

      String

      API type. Available values include:

      API_TYPE_CREATE: API for creation

      API_TYPE_REGISTER: API for registration

      auth_type

      Yes

      String

      Authentication mode. Available values include:

      The value can be APP (app authentication), IAM (IAM authentication), or NONE (no authentication).

      publish_type

      Yes

      String

      API publish type. Available values include:

      PUBLISH_TYPE_PUBLIC: The API is available to all tenants.

      PUBLISH_TYPE_PRIVATE: The API is private and available only to tenants in the same project.

      manager

      Yes

      String

      API reviewer name

      path

      Yes

      String

      API path

      The request path can contain request parameters enclosed in braces ({}), for example, /getUserInfo/{userId}, and special characters *%+-_. are not allowed.

      protocol

      Yes

      String

      API access protocol. Available values include:

      PROTOCOL_TYPE_HTTP: HTTP

      PROTOCOL_TYPE_HTTPS: HTTPS

      request_type

      Yes

      String

      API request type. Available values include:

      REQUEST_TYPE_POST: POST type

      REQUEST_TYPE_GET: GET type

      request_paras

      No

      Dictionary

      API request parameters

      datasource_config

      No

      Dictionary

      API data source configuration (required for API creation, but not for API registration)

      data_mask_switch

      No

      Boolean

      Whether to enable data masking

      This parameter is available only in DLM Exclusive.

      data_mask_paras

      No

      Dictionary

      Data masking parameters

    • request_paras parameter description

      Parameter

      Mandatory

      Type

      Description

      name

      Yes

      String

      Parameter name

      The value can contain 1 to 32 characters, including letters, digits, periods (.), hyphens (-), and underscores (_), and must start with a letter. If the parameter is in the header, the parameter name cannot contain underscores (_). The parameter name is case-insensitive and cannot start with x-apig- or x-sdk-. It cannot be x-stage, x-api-id, x-app-id, or x-request-id. If the parameter is in the header, the parameter name cannot be Authorization or X-Auth-Token.

      position

      Yes

      String

      Parameter position. Available values include:

      The value can be REQUEST_PARAMETER_POSITION_PATH, REQUEST_PARAMETER_POSITION_HEADER, or REQUEST_PARAMETER_POSITION_QUERY.

      type

      Yes

      String

      Parameter type.

      The value can be REQUEST_PARAMETER_TYPE_NUMBER or REQUEST_PARAMETER_TYPE_STRING.

      description

      Yes

      String

      Parameter description, which contains no more than 255 characters

      necessary

      Yes

      Boolean

      Mandatory

      example_value

      No

      String

      Example value

      support_null

      No

      Boolean

      Whether null is allowed

      default_value

      No

      String

      Default value

    • datasource_config parameter description

      Parameter

      Mandatory

      Type

      Description

      type

      Yes

      String

      Data source type

      The value can be DWS, MYSQL, or DLI.

      connection_id

      Yes

      String

      Data connection ID

      connection_name

      Yes

      String

      Data connection name

      database

      Yes

      String

      Database name

      queue

      No

      String

      Data queue (If the data source is DLI, you need to select a data connection.)

      access_mode

      Yes

      String

      Mode of obtaining data

      SQL: Data is obtained using SQL statements. The public cloud only supports this mode.

      ROW_KEY: Data is obtained through the row key. This mode applies only to the HBase data source.

      PREFIX_FILTER: Data is obtained through the prefix filter. This mode applies only to the HBase data source.

      pagination

      Yes

      String

      Pagination mode

      The value can be DEFAULT or CUSTOM.

      sql

      Yes

      String

      SQL statement (Base64 encoded)

      total_size_switch

      No

      Boolean

      Whether to return the total number of records

      total_size_sql

      No

      Boolean

      SQL script for calculating the total number of records in the dataset in the script mode

      This parameter is mandatory if the API uses a script to obtain data and return of the total number of records is enabled.

      backend_paras

      Yes

      Dictionary

      Request parameters

      response_paras

      Yes

      Dictionary

      Response parameters

      order_paras

      Yes

      Dictionary

      Sorting parameters

    • data_mask_paras parameter description

      Parameter

      Mandatory

      Type

      Description

      column_name

      Yes

      String

      Field name (subject to the field name in the returned result)

      algorithm_name

      Yes

      String

      Algorithm name. For details, see Data Security APIs.

      algorithm_type

      Yes

      String

      Algorithm type. For details, see Data Security APIs.

      en_name

      Yes

      String

      Algorithm name in English. For details, see Data Security APIs.

      algorithm_parameters

      Yes

      String

      Algorithm parameters. For details, see Data Security APIs.

      failure_policy

      Yes

      String

      Failure policy to be applied when an exception occurs during data masking. Available values include:

      1. INTERRUPT_AND_EXCEPTION

      2. DEFAULT_VALUE

      3. SKIP

      4. SET_NULL

      default_value

      No

      String

      Default value to be obtained when a failure occurs. This parameter is required only when failure_policy is DEFAULT_VALUE.

    • backend_paras parameter description

      Parameter

      Mandatory

      Type

      Description

      name

      Yes

      String

      Request parameter name

      The name must be one that has been defined in requestParas.

      mapping

      No

      String

      Binding field. This parameter is required by APIs that obtain data through configuration, and not required by APIs that obtain data using a script.

      condition

      No

      String

      Operator. Available values include:

      CONDITION_TYPE_EQ: equal to

      CONDITION_TYPE_NE: not equal to

      CONDITION_TYPE_GT: greater than

      CONDITION_TYPE_GE: greater than or equal to

      CONDITION_TYPE_LT: less than

      CONDITION_TYPE_LE: less than or equal to

      CONDITION_TYPE_LIKE: %parameter%

      CONDITION_TYPE_LIKE_L: %parameter

      CONDITION_TYPE_LIKE_R: parameter%

    • response_paras parameter description

      Parameter

      Mandatory

      Type

      Description

      name

      Yes

      String

      Request parameter name

      The name must be one that has been defined in requestParas.

      field

      Yes

      String

      Binding field. This parameter is required by APIs that obtain data through configuration, and not required by APIs that obtain data using a script.

      type

      Yes

      String

      Parameter type.

      The value can be REQUEST_PARAMETER_TYPE_NUMBER or REQUEST_PARAMETER_TYPE_STRING.

      description

      No

      String

      Parameter description

      example_value

      No

      String

      Example value

    • order_paras parameter description

      Parameter

      Mandatory

      Type

      Description

      name

      Yes

      String

      Sorting parameter name

      field

      Yes

      String

      Sorting field (field in the database table)

      descriptioin

      Yes

      String

      Parameter description, which contains no more than 255 characters

      optional

      Yes

      Boolean

      Mandatory or optional

      sort

      Yes

      String

      Sorting order. The value can be ASC (ascending order), DESC (descending order), or CUSTOM (user-defined order).

      order

      Yes

      Integer

      Sequence of sorting parameters

Request Message

  • Example request for updating an API
    {
      "catalog_id": "0",
      "name": "testOpenApi_create_configuration",
      "description": "configuration",
      "log_flag": false,
      "api_type": "API_SPECIFIC_TYPE_CONFIGURATION",
      "auth_type": "APP",
      "publish_type": "PUBLISH_TYPE_PRIVATE",
      "manager": "test",
      "path": "/testOpenApi_configuration/{p}",
      "protocol": "PROTOCOL_TYPE_HTTP",
      "request_type": "REQUEST_TYPE_GET",
      "request_paras": [
        {
          "name": "p",
          "position": "REQUEST_PARAMETER_POSITION_PATH",
          "type": "REQUEST_PARAMETER_TYPE_NUMBER",
          "description": "test",
          "necessary": true,
          "example_value": null,
          "support_null": false,
          "default_value": null
        },
        {
          "name": "h",
          "position": "REQUEST_PARAMETER_POSITION_HEADER",
          "type": "REQUEST_PARAMETER_TYPE_STRING",
          "description": "",
          "necessary": false,
          "example_value": "",
          "support_null": false,
          "default_value": ""
        },
        {
          "name": "q",
          "position": "REQUEST_PARAMETER_POSITION_QUERY",
          "type": "REQUEST_PARAMETER_TYPE_NUMBER",
          "description": "",
          "necessary": true,
          "example_value": null,
          "support_null": false,
          "default_value": null
        }
      ],
      "datasource_config": {
        "type": "DLI",
        "connection_id": "8a94809a70fa181e0130fd2cbb6e0007",
        "database": "default",
        "queue": "default",
        "access_type": "CONFIGURATION",
        "access_mode": "SQL",
        "pagination": "DEFAULT",
        "table_name": "testTable",
        "backend_paras": [
          {
            "name": "p",
            "mapping": "a1",
            "condition": "CONDITION_TYPE_EQ"
          },
          {
            "name": "h",
            "mapping": "a2",
            "condition": "CONDITION_TYPE_EQ"
          },
          {
            "name": "q",
            "mapping": "a3",
            "condition": "CONDITION_TYPE_EQ"
          }
        ],
        "response_paras": [
          {
            "name": "a1",
            "type": "REQUEST_PARAMETER_TYPE_STRING",
            "field": "a1",
            "description": "",
            "example_value": ""
          },
          {
            "name": "a2",
            "type": "REQUEST_PARAMETER_TYPE_STRING",
            "field": "a2",
            "description": "",
            "example_value": ""
          },
          {
            "name": "a3",
            "type": "REQUEST_PARAMETER_TYPE_NUMBER",
            "field": "a3",
            "description": "",
            "example_value": "1"
          }
        ],
        "order_paras": [
          {
            "field": "a1",
            "name": "o1",
            "description": "1",
            "optional": false,
            "sort": "ASC",
            "order": 1
          },
          {
            "field": "a2",
            "name": "o2",
            "description": "",
            "optional": true,
            "sort": "CUSTOM",
            "order": 2
          }
        ]
      },
    "data_mask_switch":true,
    "data_mask_paras":[
    {
    "column_name":"id",
    "algorithm_name":"Retain first N and last M.",
    "algorithm_type":"MASK",
    "en_name":"KeepBeforeNAfterM",
    "algorithm_parameters":"{\"m\":0,\"n\":1}",
    "failure_policy":"SKIP",
    "default_value":""
    }
    ]
    }
     

Response

  • Example response

    None

Status Code

Status Code

Description

204

The API is updated successfully.

For details about status codes, see Status Codes.