{
  "swagger": "2.0",
  "info":
  {
    "description": "Vector API Specifications",
    "version": "1.0.0",
    "title": "OWS Assets",
    "termsOfService": "https://ows-assets.theorchard.io",
    "contact":
    {
      "name": "pravin.battula@sts.in"
    }
  },
  "tags": ["example","assets","track","image"],
  "schemes":["http"],
  "paths":
  {
      "/hello":
      {
        "get":
        {
          "description" : "Hello World with an optional GET param name ",
          "tags": ["example"],
          "responses":
          {
                  "200":
                  {
                    "description": "200 OK.",
                    "example" : "Hello Bill!"
                  }
          }
        }
      },
      "/upload-token/":
      {
        "get":
        {
          "description": "Generate credentials for raw assets upload.",
          "tags": ["assets"],
          "responses":
          {
            "200":
            {
              "description": "200 OK.",
              "example" :
              {
                "credentials": {
                    "token": "AQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/L",
                    "aws_secret_access_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY",
                    "aws_access_key_id": "AKIAIOSFODNN7EXAMPLE",
                    "expiration": "2016-01-25T19:55:29.611Z"
                },
                "bucket": "TEST-orcd-raw-assets",
                "filename": "hjhj45_rfwri_424524"
              }
              }
          }
        }
      },
      "/assets/status":
      {
        "get":{
          "description":"Returns the current status of the asset",
          "tags": ["assets"],
          "parameters" :
          [
            {
              "name": "Correlation-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": True,
              "example" : "aae353fa-0319-11e7-bc4b-080027043700",
            },
            {
              "name": "Orchard-User-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": True,
              "example" : "alw:12345",
            },
            {
              "name": "filename",
              "in": "path",
              "description":"Name of uploaded file with or without extension",
              "type":"string",
              "required": True,
              "example" : "bdc36b07_d1ed_4eae_a143_c3d50ab77d36.mp3",
            },
          ],
          "responses":
          {
            "200":
            {
              "description": "200 OK.",
              "example" :
              {
                "status": "finished",
                "message": "success"
              }
            },
            "400":
            {
              "description": "404 File Not Found",
              "example" :
              {
                "message": "Asset not found",
                "code": "non_found_error"
              }
            },
            "500":
            {
              "description": "500 Internal server error",
              "example":
              {
                "message": "Could not connect to MySQL",
                "code": "server_error"
              }
            }
          }
        }
      },
      "/asset":
      {
        "post":
        {
          "description":"Saves into about newly uploaded asset",
           "tags":["assets"],
          "parameters":
          [
            {
              "name": "Correlation-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "aae353fa-0319-11e7-bc4b-080027043700",
            },
            {
              "name": "Orchard-User-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "alw:12345",
            },
            {
              "name": "Grass-Account-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "112345",
            },
            {
              "name": "Grass-Account-Type",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "vendor",
            },
            {
              "name": "body",
              "in": "body",
              "description":"",
              "type":"string",
              "required": True,
              "consumes" : ["application/json"]
            },
          ],
          "responses":
          {
            "200":
            {
              "description" : "200 OK",
              "exmaple":
              {
                "status": "ok"
              }
            },
            "404":
            {
              "description" : "404 File not found",
              "example":
              {
                "message": "ilename.tif not found in bucket TEST-BUCKET!",
                "code": "non_found_error"
              }
            },
            "500":
            {
              "description" : "500 Internal server",
              "example":
              {
                "message": "Could not connect to MySQL",
                "code": "server_error"
              }
            }
          }
        }
      },
      "/stream/track/{track_id}":
      {
        "get":
        {
          "description" : "Returns the current status of the asset",
          "tags":["assets"],
          "parameters":
          [
            {
              "name": "Correlation-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": True,
              "example" : "aae353fa-0319-11e7-bc4b-080027043700",
            },
            {
              "name": "Orchard-User-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "alw:12345",
            },
            {
              "name": "track_id",
              "in": "path",
              "description":"Track ID",
              "type":"integer",
              "required": True,
            },
          ],
          "responses":
          {
            "200":
            {
              "description" : " 200 OK",
              "example":
              {
                "track_unique_id": 999,
                "stream_url": "rtmp://...",
                "duration":  160
              }
            },
            "404":
            {
              "description" : "404 File not found",
              "example":
              {
                "message": "Track not found",
                "code": "non_found_error"
              }
            },
            "500":
            {
              "description" : "500 Internal server",
              "example":
              {
                "message": "Could not connect to MySQL",
                "code": "server_error"
              }
            }
          }
        }
      },
      "/asset/product/{product_id}":
      {
        "get":
        {
          "description" : "Returns a set of general information for all assets (across all asset types) for a particular release, which can be used for tracking assets status or/and assets streaming.",
          "tags":["assets"],
          "parameters":
          [
            {
              "name": "Correlation-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": True,
              "example" : "aae353fa-0319-11e7-bc4b-080027043700",
            },
            {
              "name": "Orchard-User-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "alw:12345",
            },
            {
              "name": "product_id",
              "in": "path",
              "description":"Product ID",
              "type":"integer",
              "required": True,
            },
          ],
          "responses":
          {
            "200":
            {
              "description" : " 200 OK",
              "example":
              {
                "product_id": 999,
                "upc": "the upc",
                "assets": [

                {
                        "filename": "hjhj45_rfwri_424524.wav",
                        "asset_type": "audio",
                        "track_unique_id": 5,
                        "status": "finished",
                        "url": "rtmp://...",
                        "duration": 162
                    }, {
                        "filename": "aaerd_r4524_qe34a.jpg",
                        "asset_type": "image",
                        "status": "finished",
                        "url": "http://...",
                        "duration": null,
                        "track_unique_id": null
                    },
                    {
                        "filename": "a9892_qwe44_asd45.mp3",
                        "asset_type": "audio",
                        "track_unique_id": 11,
                        "status": "finished",
                        "duration": null
                    }]
              }
            },
            "404":
            {
              "description" : "404 File not found",
              "example":
              {
                "message": "Product not found",
                "code": "non_found_error"
              }
            },
            "500":
            {
              "description" : "500 Internal server",
              "example":
              {
                "message": "Could not connect to MySQL",
                "code": "server_error"
              }
            }
          }
        }
      },
      "/track/{from_tuid}/copy/{to_tuid}":
      {
        "post":
        {
          "description": "Creates a copy of the track assets (copy assets from track with unique id <from_tuid> to track with unique id <to_tuid>).",
          "tags":["track"],
          "parameters":
          [
            {
              "name": "Correlation-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "aae353fa-0319-11e7-bc4b-080027043700",
            },
            {
              "name": "Orchard-User-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "alw:12345",
            },
            {
              "name": "Grass-Account-Id",
              "in": "header",
              "description":"non-required, must be owner of source and destination products",
              "type":"string",
              "required": False,
              "example" : "112345",
            },
            {
              "name": "Grass-Account-Type",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "default" : "vendor",
              "enum": ["vendor", "subaccount"]
            },
            {
              "name": "from_tuid",
              "in": "path",
              "description":"From track unique id",
              "type":"string",
              "required": True,
            },
            {
              "name": "to_tuid",
              "in": "path",
              "description":"To track unique id",
              "type":"string",
              "required": True,
            },
          ],
          "responses":
          {
            "200":
            {
              "description" : "200 OK",
              "exmaple":
              {
                "status": "ok"
              }
            },
            "404":
            {
              "description" : "404 File not found",
              "example":
              {
                "message": "Product not found",
                "code": "non_found_error"
              }
            },
            "500":
            {
              "description" : "500 Internal server",
              "example":
              {
                "message": "Could not connect to MySQL",
                "code": "server_error"
              }
            }
          }
        }
      },
      "/image/{product_id}":
      {
          "delete":
          {
            "description":"Removes image assets for product with id <product_id>.Product should NOT have “in_content” status.",
            "tags":["image"],
          "parameters":
          [
            {
              "name": "Correlation-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "aae353fa-0319-11e7-bc4b-080027043700",
            },
            {
              "name": "Orchard-User-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "alw:12345",
            },
            {
              "name": "Grass-Account-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "112345",
            },
            {
              "name": "Grass-Account-Type",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "default" : "vendor",
              "enum": ["vendor","subaccount"]
            },
            {
              "name": "product_id",
              "in": "path",
              "description":"Product ID",
              "type":"integer",
              "required": True,
            }
          ],
          "responses":
          {
            "200":
            {
              "description":"200 OK",
              "example":
              {
                "status": "ok"
              }
            },
            "404":
            {
              "description": "404 Product not found",
              "example":
              {
                "message": "Product not found",
                "code": "non_found_error"
              }
            },
            "500":
            {
              "description": "500 Internal Server Error",
              "example":
              {
                "message": "Could not connect to MySQL",
                "code": "server_error"
              }
            }
          }
          }
      },
      "/track/{track_id}":
      {
          "delete":
          {
          "description":"Removes assets for track with unique id <track_id>. Product of this track should NOT have “in_content” status",
          "tags":["track"],
          "parameters":
          [
            {
              "name": "Correlation-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "aae353fa-0319-11e7-bc4b-080027043700",
            },
            {
              "name": "Orchard-User-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "alw:12345",
            },
            {
              "name": "Grass-Account-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "112345",
            },
            {
              "name": "Grass-Account-Type",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "default" : "vendor",
              "enum": ["vendor", "subaccount"]
            },
            {
              "name": "track_id",
              "in": "path",
              "description":"Track ID",
              "type":"integer",
              "required": True,
            }
          ],
          "responses":
          {
            "200":
            {
              "description":"200 OK",
              "example":
              {
                "status": "ok"
              }
            },
            "404":
            {
              "description": "404 Product not found",
              "example":
              {
                "message": "Track not found",
                "code": "non_found_error"
              }
            },
            "500":
            {
              "description": "500 Internal Server Error",
              "example":
              {
                "message": "Could not connect to MySQL",
                "code": "server_error"
              }
            }
          }
          }
      },
      "/product/{from_pid}/copy/{to_pid}":
      {
        "post":
        {
          "description": "Creates a copy of the product assets (copy assets from product with unique id <from_pid> to product with unique id <to_pid>).",
          "tags":["assets"],
          "parameters":
          [
            {
              "name": "Correlation-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "aae353fa-0319-11e7-bc4b-080027043700",
            },
            {
              "name": "Orchard-User-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "alw:12345",
            },
            {
              "name": "Grass-Account-Id",
              "in": "header",
              "description":"non-required, must be owner of source and destination products",
              "type":"string",
              "required": False,
              "example" : "112345",
            },
            {
              "name": "Grass-Account-Type",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "default" : "vendor",
              "enum": ["vendor", "subaccount"]
            },
            {
              "name": "from_pid",
              "in": "path",
              "description":"From product unique id",
              "type":"string",
              "required": True,
            },
            {
              "name": "to_pid",
              "in": "path",
              "description":"To product unique id",
              "type":"string",
              "required": True,
            },
          ],
          "responses":
          {
            "200":
            {
              "description" : "200 OK",
              "exmaple":
              {
                "status": "ok"
              }
            },
            "403":
            {
              "description": "403 Product not owned",
              "example":
              {
                "message": "Product not owned by account",
                "code": "not_owned"
              }
            },
            "404":
            {
              "description" : "404 File not found",
              "example":
              {
                "message": "Product not found for provided product id.",
                "code": "non_found_error"
              }
            },
            "500":
            {
              "description" : "500 Internal server",
              "example":
              {
                "message": "Could not connect to MySQL",
                "code": "server_error"
              }
            }
          }
        }
      },
      "/correction/images/approval/{product_id}":
      {
        "post":
        {
          "description": "Renames image correction assets to replace the originals in S3",
          "tags":["assets"],
          "parameters":
          [
            {
              "name": "Correlation-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "aae353fa-0319-11e7-bc4b-080027043700",
            },
            {
              "name": "Orchard-User-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "alw:12345",
            },
            {
              "name": "product_id",
              "in": "path",
              "description":"Product ID",
              "type":"string",
              "required": True,
            },
          ],
          "responses":
          {
            "200":
            {
              "description" : "200 OK",
            },
            "403":
            {
              "description": "Forbidden",
            },
            "404":
            {
              "description" : "404 File not found",
              "example":
              {
                "code": "not_found_error",
                "message":
                {
                  "cover": {
                    "code": "not_found_error",
                    "message": null
                  }
                }
              }
            },
            "500":
            {
              "description" : "500 Internal server",
              "example":
              {
                  "code": "server_error",
                  "message": {
                    "cover": {
                      "code": "server_error",
                      "message": "Could not connect to S3 or something"
                    }
                  }
              }
            }
          }
        }
      },
      "/v2/asset/status/{filename}":
      {
        "get":
        {
          "description" : "Returns the current status of the asset",
          "tags":["assets"],
          "parameters":
          [
            {
              "name": "Correlation-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "aae353fa-0319-11e7-bc4b-080027043700",
            },
            {
              "name": "Orchard-User-Id",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "example" : "alw:12345",
            },
            {
              "name": "Grass-Account-Id",
              "in": "header",
              "description":"non-required, must be owner of source and destination products",
              "type":"string",
              "required": False,
              "example" : "112345",
            },
            {
              "name": "Grass-Account-Type",
              "in": "header",
              "description":"",
              "type":"string",
              "required": False,
              "default" : "vendor",
              "enum": ["vendor", "subaccount"]
            },
            {
              "name": "filename",
              "in": "path",
              "description":"Asset filename",
              "type":"string",
              "required": True,
            },
          ],
          "responses":
          {
            "200":
            {
              "description" : "200 OK",
              "exmaple":
              {
                "id": 1,
                "asset_upload_id": 2,
                "status": "complete",
                "description": "Description",
                "message": "{}",
                "status_time" : "2016-01-25T19:55:29.611Z"
              }
            },
            "403":
            {
              "description": "Forbidden",
            },
            "404":
            {
              "description" : "404 Asset not found",
              "example":
              {
                "code": "not_found_error",
                "message": {
                  "cover": {
                    "code": "not_found_error",
                    "message": null
                  }
                }
              }
            },
            "500":
            {
              "description" : "500 Internal server",
              "example":
              {
                "code": "server_error",
                "message": {
                  "cover": {
                    "code": "server_error",
                    "message": "Could not connect to database or something"
                  }
                }
              }
            }
          }
        }
      }
  }
}