openapi: 3.1.0
info:
  title: Stashy API
  version: 1.0.0
servers:
  - url: https://files.toffee.com
    description: Your Stashy instance
paths:
  /v1/files:
    post:
      summary: CreateFile
      description: Upload a file to storage.
      operationId: StorageService_CreateFile
      requestBody:
        content:
          '*/*':
            schema:
              type: string
              format: binary
        required: false
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stashy.v1alpha1.CreateFileResponse'
  /v1/files/{id}:
    get:
      summary: GetFile
      description: Download a file from storage.
      operationId: StorageService_GetFile
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            title: id
      responses:
        "200":
          description: File content
          content:
            '*/*':
              schema:
                type: string
                format: binary
    put:
      summary: UpdateFile
      description: Replace the content of an existing file. Only the owner can update.
      operationId: StorageService_UpdateFile
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            title: id
      requestBody:
        content:
          '*/*':
            schema:
              type: string
              format: binary
        required: false
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stashy.v1alpha1.UpdateFileResponse'
    delete:
      summary: DeleteFile
      description: Delete a file. Only the owner can delete.
      operationId: StorageService_DeleteFile
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            title: id
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stashy.v1alpha1.DeleteFileResponse'
  /v1/files/{id}/publish:
    post:
      summary: PublishFile
      description: Make a file publicly accessible.
      operationId: StorageService_PublishFile
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            title: id
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stashy.v1alpha1.PublishFileResponse'
  /v1/files/{id}/unpublish:
    post:
      summary: UnpublishFile
      description: Remove public access from a file.
      operationId: StorageService_UnpublishFile
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            title: id
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stashy.v1alpha1.UnpublishFileResponse'
components:
  schemas:
    google.api.HttpBody:
      type: object
      properties:
        content_type:
          type: string
          title: content_type
          description: The HTTP Content-Type header value specifying the content type of the body.
        data:
          type: string
          title: data
          format: byte
          description: The HTTP request/response body as raw binary.
        extensions:
          type: array
          items:
            $ref: '#/components/schemas/google.protobuf.Any'
          title: extensions
          description: |-
            Application specific response metadata. Must be set in the first response
             for streaming APIs.
      title: HttpBody
      additionalProperties: false
      description: |-
        Message that represents an arbitrary HTTP body. It should only be used for
         payload formats that can't be represented as JSON, such as raw binary or
         an HTML page.


         This message can be used both in streaming and non-streaming API methods in
         the request as well as the response.

         It can be used as a top-level request field, which is convenient if one
         wants to extract parameters from either the URL or HTTP template into the
         request fields and also want access to the raw HTTP body.

         Example:

             message GetResourceRequest {
               // A unique request id.
               string request_id = 1;

               // The raw HTTP body is bound to this field.
               google.api.HttpBody http_body = 2;

             }

             service ResourceService {
               rpc GetResource(GetResourceRequest)
                 returns (google.api.HttpBody);
               rpc UpdateResource(google.api.HttpBody)
                 returns (google.protobuf.Empty);

             }

         Example with streaming methods:

             service CaldavService {
               rpc GetCalendar(stream google.api.HttpBody)
                 returns (stream google.api.HttpBody);
               rpc UpdateCalendar(stream google.api.HttpBody)
                 returns (stream google.api.HttpBody);

             }

         Use of this type only changes how the request and response bodies are
         handled, all other features will continue to work unchanged.
    google.protobuf.Any:
      type: object
      properties:
        type:
          type: string
        value:
          type: string
          format: binary
      additionalProperties: true
      description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message.
    stashy.v1alpha1.CreateFileRequest:
      type: object
      properties:
        file:
          title: file
          $ref: '#/components/schemas/google.api.HttpBody'
      title: CreateFileRequest
      required:
        - file
      additionalProperties: false
    stashy.v1alpha1.CreateFileResponse:
      type: object
      properties:
        id:
          type: string
          title: id
        url:
          type: string
          title: url
          format: uri
      title: CreateFileResponse
      required:
        - id
        - url
      additionalProperties: false
    stashy.v1alpha1.DeleteFileRequest:
      type: object
      properties:
        id:
          type: string
          title: id
      title: DeleteFileRequest
      required:
        - id
      additionalProperties: false
    stashy.v1alpha1.DeleteFileResponse:
      type: object
      title: DeleteFileResponse
      additionalProperties: false
    stashy.v1alpha1.GetFileRequest:
      type: object
      properties:
        id:
          type: string
          title: id
      title: GetFileRequest
      required:
        - id
      additionalProperties: false
    stashy.v1alpha1.GetFileResponse:
      type: object
      properties:
        file:
          title: file
          $ref: '#/components/schemas/google.api.HttpBody'
      title: GetFileResponse
      required:
        - file
      additionalProperties: false
    stashy.v1alpha1.PublishFileRequest:
      type: object
      properties:
        id:
          type: string
          title: id
      title: PublishFileRequest
      required:
        - id
      additionalProperties: false
    stashy.v1alpha1.PublishFileResponse:
      type: object
      title: PublishFileResponse
      additionalProperties: false
    stashy.v1alpha1.UnpublishFileRequest:
      type: object
      properties:
        id:
          type: string
          title: id
      title: UnpublishFileRequest
      required:
        - id
      additionalProperties: false
    stashy.v1alpha1.UnpublishFileResponse:
      type: object
      title: UnpublishFileResponse
      additionalProperties: false
    stashy.v1alpha1.UpdateFileRequest:
      type: object
      properties:
        id:
          type: string
          title: id
        file:
          title: file
          $ref: '#/components/schemas/google.api.HttpBody'
      title: UpdateFileRequest
      required:
        - id
        - file
      additionalProperties: false
    stashy.v1alpha1.UpdateFileResponse:
      type: object
      title: UpdateFileResponse
      additionalProperties: false
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: opaque
security:
  - BearerAuth: []
