swagger: '2.0'
info:
  title: Model Management API
  version: '3.2.0'
  x-visibility: external
  description: >-
    Model Management is the component responsible for the storage and
    management of analytical models and solutions. Models, algorithms or other
    scripts can be uploaded using this component to be further used by users
    from the same tenant.

    Users can upload new versions to the model in later requests. In case a user updates
    his model, a new version is created. All this versions can be retrieved
    using the model identifier. Also a user can update the metadata of the model by
    creating a new version.

    When being used by other services, as in, when data needs to be completely private from any user or services, in order to prevent data to be accessed by an interractive user under the same tenant that is being impersonated with a technical user, always use a technical user that is not related to a tenant.

    ## Generic Errors

    The following generic error codes might occur at any of the specified operations. Generic errors are prefixed with 'mdsp.core.generic'.

    - 401: unauthorized

    - 403: forbidden

    - 429: tooManyRequests

    - 500: internalServerError

schemes:
  - https
basePath: /api/modelmanagement/v3
securityDefinitions:
  amm:
    type: oauth2
    flow: accessCode
    authorizationUrl: 'https://oauth.simple.api/authorization'
    tokenUrl: 'https://oauth.simple.api/token'
    scopes:
      plr.amm.c: upload a model or an algorithm and the corresponding metadata
      plr.amm.u: update a model or an algorithm or the metadata
      plr.amm.r: get information regarding models and metadata
      plr.amm.d: delete a model or an algorithm and the corresponding metadata
tags:
  - name: repositories
    description: >-
      Retrieves an access token which allows the user to publish a Docker image to the MindSphere's Docker image repository. After the image has been uploaded, the user will be able to link a model's version to the uploaded Docker Image via a POST operation on the /models endpoint. When uploading the Docker image, remember that the tag name provided in the push request (default is 'latest' if none provided) will be used as a version number in the model that will be created. This image tag needs to be unique. In order to fully create an AMM model for the uploaded image, the repository URI that holds the image needs to be linked to a specific model. If the repository name is not correct, then the model will not be created and a response mentioning that it could not find the image is returned. If the image is not linked with a model in less than 24 hours, then it will be automatically removed after 24 hours. The response obtained from this endpoint can be used using any Docker based CLI or using the cloud provider CLI tools (e.g. AWS CLI). Any cloud provider tools like SDKs or CLIs, will require to be installed and maintained by you. To use this endpoint with Docker CLI it is sufficient to extract the <code>user</code>, <code>password</code> and <code>registry</code> attributes from the <code>credentials</code> node and use them as in:<br/>

        <code>
        docker login -u AWS -p &lt;&lt;password&gt;&gt; &lt;&lt;registry&gt;&gt;
        </code>


        Once the authentication step is completed, you can push your Docker image to the provided repository. Pushing the local image requires first tagging it with the remote URI. The general format of an image tag is this: <code>[registry_host[:port]/]namespace[/]environment[/]modelmanagement[/]tenant_name[/]repository-name[:imageTag]</code>. To simplify the process of uploading a Docker image, the remote URI to be used is provided in this endpoint's response under the <code>uri</code> attribute. You should always use descriptive tags that will help you identify the image that you are using or uploading, that is, to differentiate a stable image from a development and testing one. Tagging a local image can be done using:<br/>

        <code>
        docker tag local_image_name:tag &lt;&lt;uri&gt;&gt;:&lt;&lt;imageTag&gt;&gt;
        </code>


        Please observe that the remote URI provided in the response needs to be used in tagging the local Docker image; the remote URI does not contain the tag, but we recommend always providing one. This tag that you are providing here will be copied in the <i>Version</i>'s number; when creating a new model with type Docker image, there is no need to provide the version number attribute. If no tag provided, on the upload of the image the default <i>latest</i> tag will be used. However, avoid using the <i>latest</i> tag. Pushing the image from the local repository to the AMM's repository requires:<br/>

        <code>
        docker push &lt;&lt;uri&gt;&gt;:&lt;&lt;imageTag&gt;&gt;
        </code>


        Once this image is completely uploaded to the repository then you can associate it with a model metadata to make it visible in AMM. To achieve that you can use one of the operations <code>POST /models</code> with a <code>type='Docker Image'</code> to create a new model, or <code>POST /models/{modelId}/versions</code> to add a new image layer on top of an existing model having the same Docker image type.


        To use cloud provider tools (like CLIs or SDKs) in combination with the docker image repository functions this API provides (e.g. AWS ECR), you need to establish a session with the provider using their own tools. For that, extract from the <code>providerCredentials</code> node the <code>secret</code>, <code>accessKey</code> and <code>sessionToken</code> and set them as environment variables (or in a configuration file) as needed, depending on the cloud provider requirements that is this instance hosted on. For example, to connect to AWS using the <code>providerCredentials</code> the following environment variables need to be set:<br/>

        <code>
        export AWS_ACCESS_KEY_ID=&lt;&lt;accessKey&gt;&gt;<br/>
        export AWS_SECRET_ACCESS_KEY=&lt;&lt;secret&gt;&gt;<br/>
        export AWS_SESSION_TOKEN=&lt;&lt;sessionToken&gt;&gt;
        </code>

        To extract those keys from the response you can use any scripting tools like `jq` (JSON processor) with a code like:<br/>

        <code>
        secret=$(jq -r '.credentials.secretAccessKey' <<< "${response}")
        session=$(jq -r '.credentials.sessionToken' <<< "${response}")
        accesskey=$(jq -r '.credentials.accessKeyId' <<< "${response}")
        </code>

        And then update these as environment variables to be used by the cloud provider CLI:<br/>


        <code>
        export AWS_ACCESS_KEY_ID=$(echo "${accesskey}")
        export AWS_SECRET_ACCESS_KEY=$(echo "${secret}")
        export AWS_SESSION_TOKEN=$(echo "${session}")
        </code>


        In order to use any tools from the cloud provider, in particular for the AWS hosted instance, you will require to install the AWS CLI tools first. Cloud providers offer SDKs as well as CLI tools that allow you to execute a login command. For AWS CLI the command is:<br/>

        <code>
        aws ecr get-login-password --region &lt;&lt;region&gt;&gt;
        </code>


        Here the `region` is the same as the MindSphere's region.


        Following the cloud provider login, you can then use <code>aws ecr &lt;&lt;command&gt;&gt;</code>.<br/>

        Only the docker repository functions from the cloud provider are enabled from this API endpoint. The following operations are permitted for the allowed repositories: describing images, repositories and image scan findings, uploading and downloading image layers and listing the tags under a image repository.

        Storing images and using(downloading and uploading) them can become cost intensive, in particular for heavier images but also for images that are carried over the network many times. Both storage size and number of network operations are essential for an effective cost of operating the service. We recommend carefull manipulation and regular cleanups of the repositories in order to avoid increasing costs. Always create your images with the minimal base that is needed by your project and avoid heavy and all-purpose images that contain 'everything', but use only a small subset of the OS components. In addition, we think it's a best practice to always try to use Versions and maintain changes to your Docker image model in layers, by pushing local image changes to AMM, and avoid creating a new model every time your local image has a change. This will minimize the storage and will also increase startup time on execution, when the image is downloaded. Regarding cleanup procedure, we recommend regular chekcs on the images that are not being used and remove them from AMM by deleting their respective models.
  - name: models
    description: >-
      Models are the principal entities of the Model Management API. Each Model needs to have a link to at least one Version. Models do not contain payload or URIs to repositories, but only Versions do.
  - name: versions
    description: >-
      Versions are the child entities of Models. These contain references to payloads, therefore you can upload or download payload only through a specific Version. A Version contains a single payload reference (file or repository). Each Version has a single version number; the version number has a specific format for non repository models, while for repository based models it can be any string, but not empty.
paths:
  '/repositories/getAccessToken':
    get:
      tags:
        - repositories
      summary: Retrieves an access token which allows the user to commit/push a Docker Image to the service's docker image registry.
      description: >-
        Retrieves an access token which allows the user to publish a Docker image to the MindSphere's Docker image repository. After the image has been uploaded, the user will be able to link a model's version to the uploaded Docker Image via a POST operation on the /models endpoint.
      parameters:
        - name: type
          in: query
          description: The type of model for which the token is requested
          required: false
          default: docker
          type: string
        - name: provider
          in: query
          required: false
          description: the provider for the model type
          default: AWS
          type: string
      security:
        - amm:
            - plr.amm.c
      consumes:
        - application/json
      produces:
        - application/json
      responses:
        '200':
          description: The access token for the model type and provider requested.
          schema:
            $ref: '#/definitions/DockerImageResponse'
    post:
      tags:
        - repositories
      summary: Retrieves an access token which allows the user to commit/push a Docker Image to the service's docker image registry.
      description: >-
        Requests an access token with a specific repository name that is handled by the <code>repositoryName</code> request parameter. This will allow the user to publish a Docker image to the MindSphere's Docker image repository. After the image has been uploaded, the user will be able to link a model's version to the uploaded Docker Image via a POST operation on the /models endpoint.
      parameters:
        - name: type
          in: query
          description: The type of model for which the token is requested
          required: false
          default: docker
          type: string
        - name: provider
          in: query
          required: false
          description: the provider for the model type
          default: AWS
          type: string
        - name: repositoryName
          in: query
          required: false
          description: the repository name for which the request is made
          type: string
      security:
        - amm:
            - plr.amm.c
      consumes:
        - application/json
      produces:
        - application/json
      responses:
        '200':
          description: The access token for the model type and provider requested.
          schema:
            $ref: '#/definitions/DockerImageResponse'
  '/models':
    get:
      tags:
        - models
      summary: Retrieves a list with all models and algorithms.
      description: >-
        Retrieves all models and algorithms uploaded by the users in the same
        tenant. The response will be an array containing information regarding
        the models. Also for each of the models the details regarding the last
        version will be present in the response
      security:
        - amm:
            - plr.amm.r
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: query
          name: pageNumber
          type: integer
          required: false
          description: Specifies the requested page index
        - in: query
          name: pageSize
          type: integer
          required: false
          format: int32
          minimum: 1
          maximum: 100
          description: Specifies the number of elements in a page
        - in: query
          name: filter
          type: string
          required: false
          description: |
            Complex filter that can filter by model name, type, description, author or fields set as optional parameters. All fields are optional.  Filters can be set as plain string or as a regular expression.
            The expected format follows:<br />
            <pre>
            ?filter={
              "name":"model\*",
              "type":"type",
              "description":"modelDescription",
              "number": "v1.0-tag",
              "optionalParameters":{
                 "entityId":"64",
                 "entityName": "*"
              }
            }
            </pre>
            This filter allowes filtering by Docker tags as well.
        - in: query
          name: sort
          type: string
          required: false
          enum: [asc,desc]
          default: desc
          description: >-
            Parameter used to sort the models by the *lastModified* field ascending or descending.<br />
      responses:
        '200':
          description: The list of models is retrieved
          schema:
            $ref: '#/definitions/ModelArray'
        '400':
          $ref: '#/responses/400-wrong-param'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
    post:
      tags:
        - models
      summary: Uploads a model payload and the corresponding metadata or it ssociates the provided metadata with a specific Docker URI.
      description: >-
        Uploads a model payload and the corresponding metadata while creating the first version of that model. The model can be either provided (as binary file), or linked to a previously uploaded Docker image. If the model is to be linked to a Docker image, this has to be first uploaded using the getAccessToken endpoint.
      security:
        - amm:
          - plr.amm.c
      consumes:
        - multipart/form-data
      produces:
        - application/json
      parameters:
        - name: file
          in: formData
          type: file
          required: false
          description: The model/algorithm file
        - name: uri
          in: formData
          type: string
          required: false
          description: Docker image repository URI (either the tag alone, or the complete service repository path) which represents the model which is to be uploaded. Do not provide this value if the model is not of a Docker type
        - name: metadata
          in: formData
          required: true
          type: string
          description: |
            The details regarding what the model represents, as name, author, type, description, in JSON format (see definitions/Model and definitions/VersionDefinition)<br />
            <pre>{
              "name": "NN - Quasi Newton",
              "description": "Newton using variable matrix methods",
              "type": "Zeppelin notebook",
              "author": "user@siemens.com",
              "lastVersion": {
                "number": 3.1,
                "expirationDate": "2017-10-01T12:00:00.001Z",
                "author": "user@siemens.com",
                "creationDate": "2017-10-01T12:00:00.001Z",
                "dependencies": [
                  {
                    "name": "sklearn-theano",
                    "type": "Python",
                    "version": "1.7, 5.2.6"
                  }
                ],
                "io": {
                  "consumes": "CSV/XML/Parquet",
                  "input": [
                    {
                      "name": "t1",
                      "type": "integer",
                      "description": "temperature sensor value",
                      "value": 5
                    }
                  ],
                  "output": [
                    {
                      "name": "t1",
                      "type": "integer",
                      "description": "temperature sensor value",
                      "value": 5
                    }
                  ],
                  "optionalParameters": {
                    "freeFormParams": "for the author to use"
                  }
                },
                "producedBy": [
                  "951b3240-7857-11e8-adc0-fa7ae01bbebc"
                ],
                "kpi": [
                  {
                    "name": "error rate",
                    "value": 0.9
                  }
                ]
              }
            }</pre>
      responses:
        '201':
          description: >-
            The model and metadata were uploaded successfully. Returns the details regarding the newly created model
          schema:
            $ref: '#/definitions/Model'
        '400':
          $ref: '#/responses/400-wrong-param'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
  '/models/{modelId}':
    get:
      tags:
        - models
      summary: Retrieves the model's textual description plus its last version details.
      description: >-
        Allows retrieving model's metadata like name, description, author, including the last Version details (see Version entity definition). If the model is a docker file, the returned file will be a byte representation of a JSON object containig the Credentials and repository URI that can be used to retrieve the image. The Credentials object in this response is identical to the one obtained by calling generateAccessToken endpoint.
      security:
        - amm:
            - plr.amm.r
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - name: modelId
          in: path
          description: Model ID to get the information for it
          required: true
          type: string
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/Model'
        '400':
          $ref: '#/responses/400-wrong-param'
        '404':
          $ref: '#/responses/404-not-found'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
    patch:
      tags:
        - models
      summary: Updates the model's metadata.
      description: Allows you to update the main model details, like name, description, type
      security:
        - amm:
            - plr.amm.u
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - name: modelId
          in: path
          description: ID of the model which is to be updated
          required: true
          type: string
        - in: body
          name: model
          required: true
          schema:
            $ref: '#/definitions/ModelDefinition'
      responses:
        '200':
          description: The model file was updated. The new version is returned
          schema:
            $ref: '#/definitions/Model'
        '400':
          $ref: '#/responses/400-wrong-param'
        '404':
          $ref: '#/responses/404-not-found'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
    delete:
      tags:
        - models
      summary: Deletes a model, including all its versions
      description: Deletes a model, all the versions and the corresponding metadata and Docker image(s). Also, use this endpoint if needed to delete a model that has a single version available.
      security:
        - amm:
          - plr.amm.d
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - name: modelId
          in: path
          description: ID of the model which is to be updated
          required: true
          type: string
      responses:
        '204':
          description: The model file was deleted
        '400':
          $ref: '#/responses/400-wrong-param'
        '404':
          $ref: '#/responses/404-not-found'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
  '/models/{modelId}/versions/last':
    get:
      tags:
        - versions
      summary: Downloads the last version payload or description of a model. If the model is a docker file, the returned file will be a byte representation of a JSON object containig the Credentials and tag which can be used in order to retrieve the image, identical to the response of the generateAccessToken endpoint.
      description: >-
        Retrieves the last version of a model, including its payload, depending on the accept parameter being specified: application/json will return only the last Version definition, while application/octet-stream will return the last version payload stored. When application/octet-stream is used for a Docker model type, a JSON file will be returned containing the image details.
      security:
        - amm:
          - plr.amm.r
      consumes:
       - application/json
      produces:
        - application/json
        - application/octet-stream
      parameters:
        - name: modelId
          in: path
          description: Model ID to get the information for it
          required: true
          type: string
      responses:
        '200':
          description: >-
            Depending on the Accept type specified it can return either the last version payload data(when application/octet-stream is used) or the last Version metadata details.
          schema:
            $ref: '#/definitions/Version'
        '400':
          $ref: '#/responses/400-wrong-param'
        '404':
          $ref: '#/responses/404-not-found'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
    patch:
      tags:
        - versions
      summary: Updates the last version metadata information of a model, without allowing updates to the model payload itself
      produces:
        - application/json
      consumes:
        - application/json
      description: >-
        Updates the last version information of a model, excluding related
        payload if used. Information like creation date and author cannot be
        updated. <br />
        Information regarding the model details can be updated using another
        endpoint. The 'metadata' key in 'formData' is required.
      security:
        - amm:
          - plr.amm.u
      parameters:
        - name: modelId
          in: path
          description: The model id
          required: true
          type: string
        - in: body
          name: version
          required: true
          schema:
            $ref: '#/definitions/VersionDefinition'
      responses:
        '200':
          description: The version metadata was updated successfully. The updated version is returned.
          schema:
            $ref: '#/definitions/VersionDefinition'
        '400':
          $ref: '#/responses/400-wrong-param'
        '404':
          $ref: '#/responses/404-not-found'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
    delete:
      tags:
        - versions
      summary: Deletes the last version of a model
      description: >-
        Deletes the last version of a model and its associated payload or Docker image. If the version is the only version of the model all the information regarding the model will be deleted.
      security:
        - amm:
          - plr.amm.d
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - name: modelId
          in: path
          description: Id of the model which is to be deleted
          required: true
          type: string
      responses:
        '204':
          description: The last version was deleted
        '400':
          $ref: '#/responses/400-wrong-param'
        '404':
          $ref: '#/responses/404-not-found'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
  '/models/{modelId}/versions':
    post:
      tags:
        - versions
      summary: Creates a new version for the selected model
      description: This helps in adding a new version to an existing model. The payload can be provided (as a file), or, for Docker image model types, the new Version can be linked to a previously uploaded Docker image. To create a Version for a model of type Docker image, the image needs to be uploaded first in the AMM repository following the steps from <i>GET /repositories/getAccessToken</i> endpoint. Once the image is fully uploaded, then its repository URI will be required as a formData parameter in this request along with the Version metadata.
      security:
        - amm:
            - plr.amm.c
      consumes:
        - multipart/form-data
      produces:
        - application/json
      parameters:
        - name: modelId
          in: path
          description: Model ID to create a new verion for
          required: true
          type: string
        - name: file
          in: formData
          type: file
          required: false
          description: The model/algorithm file
        - name: uri
          in: formData
          type: string
          description: >-
            Docker image repository URI (either the tag alone, or the complete service repository path) which represents the payload that is to be linked with this Version. For Docker images, these need to be fully uploaded before using this endpoint. The <i>uri</i> can be obtained using <code>GET /repositories/getAccessToken</code> and following the steps described there to upload an image.Do not provide this value if the model is not of a Docker type
        - in: formData
          name: metadata
          required: true
          type: string
          description: |
            Version data in JSON format (See definitions/VersionDefinition)
            <pre>
            {
              "number": 3.1,
              "expirationDate": "2017-10-01T12:00:00.001Z",
              "author": "user@siemens.com",
              "creationDate": "2017-10-01T12:00:00.001Z",
              "dependencies": [
                {
                  "name": "sklearn-theano",
                  "type": "Python",
                  "version": "1.7, 5.2.6"
                }
              ],
              "io": {
                "consumes": "CSV/XML/Parquet",
                "input": [
                  {
                    "name": "t1",
                    "type": "integer",
                    "description": "temperature sensor value",
                    "value": 5
                  }
                ],
                "output": [
                  {
                    "name": "t1",
                    "type": "integer",
                    "description": "temperature sensor value",
                    "value": 5
                  }
                ],
                "optionalParameters": {
                  "freeFormParams": "for the author to use"
                }
              },
              "producedBy": [
                "951b3240-7857-11e8-adc0-fa7ae01bbebc"
              ],
              "kpi": [
                {
                  "name": "error rate",
                  "value": 0.9
                }
              ]
            }
            </pre>
            For a Docker image type, the metadata required by the version can be empty, but still required. The <i>number</i> attribute is not required since this value will be inferred from the <i>uri</i>.
      responses:
        '201':
          description: The model and metadata were uploaded successfully. Returns modelID
          schema:
            $ref: '#/definitions/VersionDefinition'
        '400':
          $ref: '#/responses/400-wrong-param'
        '404':
          $ref: '#/responses/404-not-found'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
    get:
      tags:
        - versions
      summary: Retrieves metadata of all versions of a model
      description: >-
        Retrieves all the versions of a model or an algorithm based on the model
        identifier. Whenever a new model file or a metadata JSON are uploaded as
        an update of an existing entry a new version of the entry is created.
        This endpoint will retrieved information regarding all the versions
        created by the users. For Docker image type it will return a list of
        available versions (or tags) for the specified {modelId}
      security:
        - amm:
            - plr.amm.r
      consumes:
       - application/json
      produces:
        - application/json
      parameters:
        - name: modelId
          in: path
          description: Model ID to get the information for it
          required: true
          type: string
        - in: query
          name: pageNumber
          type: integer
          required: false
          description: Specifies the requested page index
        - in: query
          name: pageSize
          type: integer
          required: false
          format: int32
          minimum: 1
          maximum: 100
          description: Specifies the number of elements in a page
      responses:
        '200':
          description: The list of version of the model is retrieved
          schema:
            $ref: '#/definitions/VersionArray'
        '400':
          $ref: '#/responses/400-wrong-param'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
        '404':
          $ref: '#/responses/404-not-found'
  '/models/{modelId}/versions/{versionId}':
    get:
      tags:
        - versions
      summary: Retrieves the version payload or the version metadata
      description: Retrieves the specified version metadata or payload of a model, depending on the accept parameter being specified - application/json will return only the last Version definition, while application/octet-stream will return the stored version payload.
      security:
        - amm:
            - plr.amm.r
      consumes:
        - application/json
        - application/octet-stream
      produces:
        - application/octet-stream
        - application/json
      parameters:
        - name: modelId
          in: path
          description: Model ID to get the information for it
          required: true
          type: string
        - name: versionId
          in: path
          description: Version ID to get the information for it
          required: true
          type: string
          format: uuid
      responses:
        '200':
          description: The version payload or version metadata is returned depending on the accept header
          schema:
            $ref: '#/definitions/Version'
        '400':
          $ref: '#/responses/400-wrong-param'
        '404':
          $ref: '#/responses/404-not-found'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
    delete:
      tags:
        - versions
      summary: Deletes the specified version of a model and the corresponding metadata
      description: >-
        Deletes a version of a model and the corresponding metadata including the Docker image, only if the version is not the single available version for the model. For Docker images, only the last version of the Docker image can be deleted.
      security:
        - amm:
            - plr.amm.d
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - name: modelId
          in: path
          description: Id of the model
          required: true
          type: string
        - name: versionId
          in: path
          description: The version id
          required: true
          type: string
      responses:
        '204':
          description: The version was deleted
        '400':
          $ref: '#/responses/400-wrong-param'
        '404':
          $ref: '#/responses/404-not-found'
        '403':
          $ref: '#/responses/403-unauth'
        '500':
          $ref: '#/responses/500-internal'
responses:
  500-internal:
    description: Error during execution
    schema:
      $ref: '#/definitions/Errors'
  400-wrong-param:
    description: >-
      One of the required input parameters is missing or does not follow the
      input format
    schema:
      $ref: '#/definitions/Errors'
  404-not-found:
    description: The resource or index is not found
    schema:
      $ref: '#/definitions/Errors'
  403-unauth:
    description: Forbidden - The user does not have permission for this endpoint
    schema:
      $ref: '#/definitions/Errors'
definitions:
  Model:
    type: object
    properties:
      id:
        type: string
        format: uuid
        example: 951b3240-7857-11e8-adc0-fa7ae01bbebc
      name:
        type: string
        example: NN - Quasi Newton
      description:
        type: string
        example: Newton using variable metrix methods
      type:
        type: string
        example: Zeppelin notebook
      author:
        type: string
        example: user@siemens.com
      lastVersion:
        $ref: '#/definitions/Version'
  ModelArray:
    type: object
    properties:
      models:
        type: array
        items:
          $ref: '#/definitions/Model'
      page:
        $ref: '#/definitions/Page'
  Version:
    type: object
    description: >-
      Returned version information. Contains the submitted version entity, as
      well as additional information provided by the system, such as user
      information, created date.
    properties:
      id:
        type: string
        format: uuid
        example: 951b3240-7857-11e8-adc0-fa7ae01bbebc
      number:
        type: number
        format: string
        example: 3.1
      uri:
        type: string
        example: 216273414971.dkr.ecr.eu-central-1.amazonaws.com/modelmanagement/tenant/e5870f41-2ddb-46f1-8b96-3a1d743be7a0:mytag1.0
      expirationDate:
        type: string
        format: date
        example: '2017-10-01T12:00:00.001Z'
      author:
        type: string
        example: user@siemens.com
      creationDate:
        type: string
        format: date
        example: '2017-10-01T12:00:00.001Z'
      lastDownloadDate:
        type: string
        format: date
        example: '2022-10-01T12:00:00.001Z'
      sizeInBytes:
        type: string
        format: number
        example: '2096'
      dependencies:
        type: array
        items:
          $ref: '#/definitions/Dependency'
      io:
        $ref: '#/definitions/IO'
      producedBy:
        type: array
        items:
          type: string
          format: uuid
          example: 951b3240-7857-11e8-adc0-fa7ae01bbebc
      kpi:
        type: array
        items:
          $ref: '#/definitions/KPI'
  VersionArray:
    type: object
    properties:
      versions:
        type: array
        items:
          $ref: '#/definitions/Version'
      page:
        $ref: '#/definitions/Page'
  Dependency:
    type: object
    properties:
      name:
        type: string
        example: sklearn-theano
      type:
        type: string
        example: Python
      version:
        type: string
        example: '"1.7", "5.2.6"'
  KPI:
    type: object
    properties:
      name:
        type: string
        example: error rate
      value:
        type: string
        example: 0.9
  Column:
    type: object
    properties:
      name:
        type: string
        example: 't1'
      type:
        type: string
        example: integer
      description:
        type: string
        example: temperature sensor value
      value:
        type: object
        example: 5
  Credentials:
    type: object
    description: Temporary access token
    properties:
      user:
        description: the user name provided by the cloud provider
        type: string
        example: AWS
      password:
        description: the password
        type: string
        example: N7il4x3ZujoA7J0qYwVCpzqRYvGnN8Qm2M9W5TkHmYDL6FB00DlwdDMQffxyACV8
      registry:
        description: the location of the remote registry that will be accessed
        type: string
        example: >-
          700273414571.dkr.ecr.eu-central-1.amazonaws.com
  ProviderCredentials:
    type: object
    description: Temporary access token
    properties:
      secret:
        description: secret access key
        type: string
        example: AbCdEfGhIjKlMnOpQrStUvWxYz
      accessKey:
        description: access key ID
        type: string
        example: AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz
      sessionToken:
        description: session token
        type: string
        example: >-
          AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz
  DockerImageResponse:
    type: object
    properties:
      credentials:
        $ref: '#/definitions/Credentials'
      uri:
        type: string
        example: 216273414971.dkr.ecr.eu-central-1.amazonaws.com/modelmanagement/tenant/e5870f41-2ddb-46f1-8b96-3a1d743be7a0:mytag1.0
      providerCredentials:
        $ref: '#/definitions/ProviderCredentials'
      expirationTime:
        description: ExpirationTime
        type: string
        example: '2017-01-01T15:00:00.002Z'
  IO:
    type: object
    properties:
      consumes:
        type: string
        example: CSV/XML/Parquet
      input:
        type: array
        items:
          $ref: '#/definitions/Column'
      output:
        type: array
        items:
          $ref: '#/definitions/Column'
      optionalParameters:
        type: object
        description: Field which should contain any relevant metadata information which can refer to how to further process or interpret the input or output files.
  VndError:
    type: object
    properties:
      code:
        type: string
        example: mdsp.core.modelmanagement.error
        readOnly: true
      message:
        type: string
        example: Error message
        readOnly: true
      logref:
        type: string
        example: c06534d4-6f0e-11e8-adc0-fa7ae01bbebc
        readOnly: true
  Errors:
    type: object
    properties:
      errors:
        type: array
        items:
          $ref: '#/definitions/VndError'
  Page:
    type: object
    properties:
      number:
        type: integer
        description: Number of current page.
        example: 1
      size:
        type: integer
        description: Size of the page
        example: 20
      totalPages:
        type: integer
        description: Number of the total pages
        example: 2
      totalElements:
        type: integer
        description: The total number of elements
        example: 40
  VersionDefinition:
    type: object
    properties:
      expirationDate:
        type: string
        format: date
        example: '2017-10-01T12:00:00.001Z'
      dependencies:
        type: array
        items:
          $ref: '#/definitions/Dependency'
      io:
        $ref: '#/definitions/IO'
      producedBy:
        type: array
        items:
          type: string
          format: uuid
          example: 951b3240-7857-11e8-adc0-fa7ae01bbebc
      kpi:
        type: array
        items:
          $ref: '#/definitions/KPI'
  ModelDefinition:
    type: object
    required:
      - name
      - type
    properties:
      name:
        type: string
        example: NN - Quasi Newton
      description:
        type: string
        example: Newton using variable metrix methods
      type:
        type: string
        example: "Zeppelin notebook"
