{
  "swagger": "2.0",
  "info": {
    "title": "Blob storage service",
    "version": "0.1507.0",
    "description": "Send your API key as a bearer token: `Authorization: Bearer <api key>`."
  },
  "tags": [
    {
      "name": "BlobStorageService",
      "x-displayName": "Blob storage service",
      "description": "Service for storing and retrieving blobs in object storage with workspace-based authorization."
    }
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/blobs/v1": {
      "post": {
        "operationId": "BlobStorageService_UploadBlobStream",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/UploadBlobStreamResponse"
            },
            "x-example": {
              "fileName": "<file name>"
            }
          }
        },
        "parameters": [
          {
            "name": "body",
            "description": "(streaming inputs)",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UploadBlobStreamRequest"
            },
            "x-example": {
              "owningRid": {
                "rid": "<rid>"
              },
              "fileName": "<file name>",
              "ensureUnique": true,
              "content": "<content>"
            }
          }
        ],
        "tags": [
          "BlobStorageService"
        ],
        "summary": "Upload blob stream",
        "description": "Upload a blob using streaming. The blob will be stored with authorization checks based on the provided owningRid."
      }
    },
    "/blobs/v1/get": {
      "post": {
        "operationId": "BlobStorageService_GetSignedUrlForBlob",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetSignedUrlForBlobResponse"
            },
            "x-example": {
              "url": "<url>"
            }
          }
        },
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/GetSignedUrlForBlobRequest"
            },
            "x-example": {
              "owningRid": {
                "rid": "<rid>"
              },
              "fileName": "<file name>"
            }
          }
        ],
        "tags": [
          "BlobStorageService"
        ],
        "summary": "Get signed URL for blob",
        "description": "Retrieve a signed URL for downloading a blob. The URL is valid for 15 minutes."
      }
    }
  },
  "definitions": {
    "GetSignedUrlForBlobRequest": {
      "type": "object",
      "properties": {
        "owningRid": {
          "$ref": "#/definitions/ResourceIdentifier"
        },
        "fileName": {
          "type": "string"
        }
      },
      "required": [
        "owningRid",
        "fileName"
      ],
      "example": {
        "owningRid": {
          "rid": "<rid>"
        },
        "fileName": "<file name>"
      }
    },
    "GetSignedUrlForBlobResponse": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "title": "This is a short lived signed url that can be used by the client to retrieve the object"
        }
      }
    },
    "ResourceIdentifier": {
      "type": "object",
      "properties": {
        "rid": {
          "type": "string",
          "pattern": "^ri\\.[a-z][a-z0-9\\-]*\\.([a-z0-9][a-z0-9\\-]*)?\\.[a-z][a-z0-9\\-]*\\.[a-zA-Z0-9\\-\\._]+$",
          "x-constraints": [
            "Matches `^ri\\.[a-z][a-z0-9\\-]*\\.([a-z0-9][a-z0-9\\-]*)?\\.[a-z][a-z0-9\\-]*\\.[a-zA-Z0-9\\-\\._]+$`."
          ]
        }
      },
      "description": "This is used to identify any type of blob that will be in object storage.",
      "required": [
        "rid"
      ]
    },
    "UploadBlobStreamRequest": {
      "type": "object",
      "properties": {
        "owningRid": {
          "$ref": "#/definitions/ResourceIdentifier"
        },
        "fileName": {
          "type": "string"
        },
        "ensureUnique": {
          "type": "boolean",
          "title": "when set to true, ensure_unique will attach the current timestamp to the file name this will ensure that we do not overwrite an existing file in blob storage"
        },
        "content": {
          "type": "string",
          "format": "byte"
        }
      },
      "title": "file_name and owning_rid should be consistent across all requests for a byte stream permission on the uploaded blob is tied to associated owning_rid when making a call to upload stream request, the assumption is that the user already has auth on the owning_rid, and we will throw a permission error if this doesn't hold",
      "required": [
        "owningRid",
        "fileName",
        "ensureUnique",
        "content"
      ],
      "example": {
        "owningRid": {
          "rid": "<rid>"
        },
        "fileName": "<file name>",
        "ensureUnique": true,
        "content": "<content>"
      }
    },
    "UploadBlobStreamResponse": {
      "type": "object",
      "properties": {
        "fileName": {
          "type": "string",
          "title": "This is the key that can be used in a retrieve blob request in order to retrieve this specific blob. If ensure_unique is not set, this will match the file name provided in UploadBlobStreamRequest"
        }
      }
    }
  },
  "securityDefinitions": {
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization",
      "description": "Your API key as a bearer token: `Authorization: Bearer <api key>`."
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ]
}
