Import an API version

POST /apim/import_version/{import_path}

Overview

This API imports an API version from one Control plane/Org to another using a public API. Alternatively, you can also update the accounts used and add expressions to the API version while importing.

Prerequisites

  • Write permission on the target API to import the API version

Request

   POSThttps://{control_plane_path}/api/1/rest/public/apim/import_version/{import_path}?{query_parameter}

Example

https://cdn.elastic.snaplogic.com/api/1/rest/public/apim/import_version/test_org/openapi/1.0?duplicate_check=true/

Path Parameters

Key Description
import_path The path to the target API.

Format:{org_name}/apim/{api_name}/{api_version name}

Query Parameters

Key Type Description
duplicate_check boolean
  • skip or true

    This parameter first performs a check for the existence of a API version with the same name.

    • If a API version with the same name exists, additional assets are updated within the API version.

    • If the API version with the same name does not exist, it will be imported successfully with unpublished status.

    Any assets with the same name are not updated and it generates an error code 409

  • create_new or false
    • If a API version with the same name exists, API version is successfully imported with a numbered name in the formatAPI version number. Example:apiVersion1

    • This setting has no effect if the target API version does not exist.

  • overwrite

    • If an asset with the same name exists in the target API version and the asset's type is specified in overwrite_types, it is overwritten. Otherwise, it is skipped.

overwrite_types list

The types of assets that can be overwritten, if an asset with the same name already exists in the destination API version.

Valid values:

  • Account

  • File

  • Flows

  • Job (task)

  • Pipeline

  • Policy

Note: Policy is always overwritten
Note:

The parameter setting is same for import of API version between different Orgs.

Request Header

Specify Basic for authorization and multipart/form-data for content type.

 Authorization: Basic {your_encoded_security_credentials}
Content-Type: multipart/form-data

Request Body

Key Type Description
file string
  • The unmodified zip file of the source API version that was exported.
file_account string

The JSON file containing the list of accounts to modify.

  • To create this file:

    1. Extract the accounts_template.json file from the exported zip file. The JSON includes nodes for each account associated with the API version.

    2. Delete the JSON nodes for accounts that you do not want to modify.

    3. Update the values of the value keys for the accounts that you want to modify. Replace any encrypted values (such as the password) with the original plain text value. This is required, even if you are not changing the value itself, because these values are encrypted again during import.

    Note:
    • Do not modify the UUID of the account or the structure of the property_map node. The property_map structure might be different for each account and must be preserved.

    • If this file is not provided, the accounts are not modified.

file_expr string
  • A zip file containing expression files to add to the root of the project in the new location.
    • If an expression file with the same name already exists in the target location, it is overwritten.

    • If this file is not provided, no additional expression files are added to the project.

Note: If the zip file contains folders, the folder structure is flattened. If duplicate filenames exist in different folders of the zip file, only one of those files is copied to the new location.
Example: An expression library file (typically with the .expr extension) might contain:
 {
  prefix:'test';
  prefixer: x => this.prefix + x
   }
Note: The parameter setting is same for import of API version between different Orgs.

Response

Example Response Body

 {
  "response_map": {
    "successful": [
      {
        "snode_id": "...",
        "name": "..."
      },
      ...
    ],
    "failed": [
      {
        "status_code": 409,
        "reason": "...",
        "snode_id": "...",
        "name": "..."
      },
      ...
    ],
    "warnings": [
      {
        "message": "...",
        "snode_id": "...",
        "name": "..."
      },
      ...
    ]
  },
  "http_status_code": 200
}

Error Handling

HTTP Status Codes Status Description Resolution
200 successful

An array of objects that contain:

  • the node ID

  • the asset or an expression file

is successfully imported.

N/A
400 Bad Request The request was unacceptable, often due to missing a required parameter.
  • Check if all the required parameters are added accurately.

  • Check if the Body parameter is set as form-data and valid .zipfile is added.

  • Check if the Headers parameter is set with key as content-type and value as multipart/form-data

409 Conflict This response is sent when a request conflicts with the current state of the server.
  • Check if a project with the same name exists.

  • Set the duplicate_check parameter to skip or true.

  • Existing assets with the same name won't be updated, and other assets will be added.