{
  "info": {
    "title": "data-credentials",
    "version": ""
  },
  "paths": {
    "/api/v1/data-credentials/{qID}": {
      "get": {
        "tags": [
          "data-credentials"
        ],
        "summary": "Gets a credential by ID (or by name when bycredentialname=true is set in query)",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Credential"
                }
              }
            },
            "description": "Credential retrieved"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "Empty value not permitted for dataName"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "Credential not found"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/qCredID"
          },
          {
            "$ref": "#/components/parameters/bycredentialname"
          }
        ],
        "x-qlik-visibility": "public",
        "x-qlik-stability": "stable",
        "x-qlik-deprecated": false,
        "x-qlik-tier": {
          "tier": "1",
          "limit": 1000
        }
      },
      "patch": {
        "tags": [
          "data-credentials"
        ],
        "summary": "Patches a credential specified by ID (or by name when bycredentialname=true is set in query)",
        "responses": {
          "204": {
            "description": "Credential updated successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "Connection ID changed"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "Credential not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "Credential already exists (when updated name conflicts with existing record)"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/qCredID"
          },
          {
            "$ref": "#/components/parameters/bycredentialname"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchRequest"
              }
            }
          },
          "required": true
        },
        "x-qlik-visibility": "public",
        "x-qlik-stability": "stable",
        "x-qlik-deprecated": false,
        "x-qlik-tier": {
          "tier": "2",
          "limit": 100
        }
      },
      "put": {
        "tags": [
          "data-credentials"
        ],
        "summary": "Updates a credential specified by ID (or by name when bycredentialname=true is set in query)",
        "responses": {
          "204": {
            "description": "Credential updated successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "Connection ID changed"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "Credential not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "Credential already exists (when updated name conflicts with existing record)"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/qCredID"
          },
          {
            "$ref": "#/components/parameters/bycredentialname"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CredentialCreate"
              }
            }
          },
          "required": true
        },
        "x-qlik-visibility": "public",
        "x-qlik-stability": "stable",
        "x-qlik-deprecated": false,
        "x-qlik-tier": {
          "tier": "2",
          "limit": 100
        }
      },
      "delete": {
        "tags": [
          "data-credentials"
        ],
        "summary": "Deletes the specified credential by ID (or by name when type=credentialname is set in query)",
        "responses": {
          "204": {
            "description": "Credential deleted successfully"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "Credential not found"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/qCredID"
          },
          {
            "$ref": "#/components/parameters/bycredentialname"
          }
        ],
        "x-qlik-visibility": "public",
        "x-qlik-stability": "stable",
        "x-qlik-deprecated": false,
        "x-qlik-tier": {
          "tier": "2",
          "limit": 100
        }
      }
    },
    "/api/v1/data-credentials/actions/filter-orphan": {
      "post": {
        "tags": [
          "data-credentials"
        ],
        "summary": "Gets list of orphan data credentials (i.e. credentials that are not associated to any data connection) filtering on properties defined in request body",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionFilterOrphanResponse"
                }
              }
            },
            "description": "Orphan credentials returned"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "Bad request (Missing required field in request body)"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseErrors"
                }
              }
            },
            "description": "User has no access to credentials"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionFilterOrphanRequest"
              }
            }
          },
          "required": true
        },
        "x-qlik-visibility": "public",
        "x-qlik-stability": "stable",
        "x-qlik-deprecated": false,
        "x-qlik-tier": {
          "tier": "2",
          "limit": 100
        }
      }
    }
  },
  "openapi": "3.0.0",
  "components": {
    "parameters": {
      "bycredentialname": {
        "in": "query",
        "name": "byCredentialName",
        "schema": {
          "type": "boolean"
        },
        "example": false,
        "required": false,
        "description": "If set to true, credentialId in the query will be interpreted as credential's name"
      },
      "qCredID": {
        "in": "path",
        "name": "qID",
        "schema": {
          "type": "string"
        },
        "example": "027d2703-e745-43ec-8876-a2e6ac341700",
        "required": true,
        "description": "Credential ID"
      }
    },
    "schemas": {
      "ActionFilterOrphanRequest": {
        "type": "object",
        "properties": {
          "qType": {
            "type": "string",
            "example": "QvOdbcConnectorPackage.exe",
            "description": "Filtering on type of credentials"
          },
          "qSeparated": {
            "enum": [
              0,
              1
            ],
            "type": "integer",
            "example": 0,
            "description": "Filtering on separate status of credentials: * 0 - embedded credential * 1 - separated credential\n"
          },
          "datasourceID": {
            "type": "string",
            "example": "snowflake",
            "description": "Filtering on datasource ID of credentials"
          }
        }
      },
      "ActionFilterOrphanResponse": {
        "type": "object",
        "required": [
          "data",
          "count"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrphanCredentialResItem"
            }
          },
          "count": {
            "type": "integer",
            "example": 1,
            "description": "Number of orphan credentials found"
          }
        }
      },
      "Credential": {
        "type": "object",
        "required": [
          "qID",
          "qName",
          "qType",
          "qConnCount"
        ],
        "properties": {
          "qID": {
            "type": "string",
            "example": "065f977e-6eca-408c-b78b-ecded823712c",
            "description": "UUID of the credential"
          },
          "links": {
            "$ref": "#/components/schemas/Link"
          },
          "qName": {
            "type": "string",
            "example": "MyCredential for REST datasource",
            "description": "Name of the credential",
            "x-qlik-filterable": true
          },
          "qType": {
            "type": "string",
            "example": "QvWebStorageProviderConnectorPackage.exe",
            "description": "Type of credential",
            "x-qlik-filterable": true
          },
          "created": {
            "type": "string",
            "example": "2022-04-08T10:00:28.287Z",
            "description": "Datetime when the credential was created",
            "x-qlik-filterable": true
          },
          "updated": {
            "type": "string",
            "example": "2022-04-09T10:00:28.287Z",
            "description": "Datetime when the credential was last updated",
            "x-qlik-filterable": true
          },
          "qConnCount": {
            "type": "integer",
            "example": 1,
            "description": "Number of linked connections"
          },
          "datasourceID": {
            "type": "string",
            "example": "rest",
            "description": "ID datasource that the credential is created for",
            "x-qlik-filterable": true
          },
          "qReferenceKey": {
            "type": "string",
            "example": "credential:key",
            "description": "Reference key of credential in redis"
          }
        }
      },
      "CredentialCreate": {
        "required": [
          "qName",
          "qType",
          "qUsername",
          "qPassword"
        ],
        "properties": {
          "qID": {
            "type": "string",
            "example": "c2dd20e3-1842-42d0-81fe-1ecf08e6abde",
            "description": "UUID of the credential"
          },
          "qName": {
            "type": "string",
            "example": "MyCredential for REST datasource",
            "description": "Name of the credential"
          },
          "qType": {
            "type": "string",
            "example": "QvWebStorageProviderConnectorPackage.exe",
            "description": "Type of credential (i.e. connector provider of the corresponding connection)"
          },
          "qPassword": {
            "type": "string",
            "example": "MyPassword",
            "description": "Password"
          },
          "qUsername": {
            "type": "string",
            "example": "MyUsername",
            "description": "User name"
          },
          "connectionId": {
            "type": "string",
            "example": "2eb98dea-5e3b-4f50-9967-841cec04b72f",
            "description": "ID of connection that will be associated with the credential"
          },
          "datasourceID": {
            "type": "string",
            "example": "rest",
            "description": "ID datasource that the credential is created for"
          }
        },
        "description": "Credential"
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "DCERROR-0010",
            "description": "Unique internal error code"
          },
          "title": {
            "type": "string",
            "example": "Bad or invalid request",
            "description": "A summary in english explaining what went wrong"
          },
          "detail": {
            "type": "string",
            "example": "Field xxx is missing in the request",
            "description": "More concrete details"
          },
          "status": {
            "type": "integer",
            "example": 400,
            "description": "HTTP status code"
          }
        }
      },
      "Errors": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/Error"
        }
      },
      "Link": {
        "type": "object",
        "required": [
          "self"
        ],
        "properties": {
          "self": {
            "type": "object",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "type": "string",
                "example": "https://mytenant.us.qlikcloud.com/...",
                "description": "URL pointing to the resource"
              }
            },
            "description": "Link to current query"
          }
        }
      },
      "OrphanCredentialResItem": {
        "required": [
          "qID",
          "qName",
          "qType",
          "userId",
          "tenantId",
          "created",
          "updated"
        ],
        "properties": {
          "qID": {
            "type": "string",
            "example": "c2dd20e3-1842-42d0-81fe-1ecf08e6abde",
            "description": "UUID of the credential"
          },
          "user": {
            "type": "string",
            "example": "rFdHeUOiVYgPX5iTbvL0x0Cs6F62QI",
            "description": "User ID of the credential's owner"
          },
          "qName": {
            "type": "string",
            "example": "MyCredential for REST datasource",
            "description": "Name of the credential"
          },
          "qType": {
            "type": "string",
            "example": "QvWebStorageProviderConnectorPackage.exe",
            "description": "Type of credential (i.e. connector provider of the corresponding connection)"
          },
          "tenant": {
            "type": "string",
            "example": "xqFQ0k34vSR0d9G7J-vZtHZQkiYrCqc8",
            "description": "Tenant ID of the credential's owner"
          },
          "created": {
            "type": "string",
            "example": "2022-04-08T10:00:28.287Z",
            "description": "Datetime when the credential was created"
          },
          "updated": {
            "type": "string",
            "example": "2022-04-09T10:00:28.287Z",
            "description": "Datetime when the credential was last updated"
          },
          "datasourceID": {
            "type": "string",
            "example": "rest",
            "description": "ID datasource that the credential is created for"
          }
        },
        "description": "Orphan credential"
      },
      "PatchRequest": {
        "type": "array",
        "items": {
          "type": "object",
          "required": [
            "op",
            "path"
          ],
          "properties": {
            "op": {
              "enum": [
                "add",
                "replace",
                "remove"
              ],
              "type": "string",
              "example": "add",
              "description": "Operation type"
            },
            "path": {
              "type": "string",
              "example": "/qName",
              "description": "Path to the target field to be patched"
            },
            "value": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "boolean"
                },
                {
                  "type": "integer"
                },
                {
                  "type": "array"
                }
              ],
              "example": "New value",
              "description": "Value used for the patch. Required only for `add` or `replace` operations. The value type should match the type of the target field."
            }
          }
        }
      },
      "ResponseErrors": {
        "type": "object",
        "properties": {
          "errors": {
            "$ref": "#/components/schemas/Errors"
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "https://{tenant}.{region}.qlikcloud.com",
      "variables": {
        "region": {
          "default": "us",
          "description": "The region the tenant is hosted in"
        },
        "tenant": {
          "default": "your-tenant",
          "description": "Name of the tenant that will be called"
        }
      }
    }
  ]
}