syntax = "proto3";

package com.owncloud.ocis.thumbnails.v0;

option go_package = "github.com/owncloud/ocis/thumbnails/pkg/proto/v0;proto";

import "protoc-gen-openapiv2/options/annotations.proto";

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  info: {
    title: "ownCloud Infinite Scale thumbnails";
    version: "1.0.0";
    contact: {
      name: "ownCloud GmbH";
      url: "https://github.com/owncloud/ocis";
      email: "support@owncloud.com";
    };
    license: {
      name: "Apache-2.0";
      url: "https://github.com/owncloud/ocis/blob/master/LICENSE";
    };
  };
  schemes: HTTP;
  schemes: HTTPS;
  consumes: "application/json";
  produces: "application/json";
  external_docs: {
    description: "Developer Manual";
    url: "https://owncloud.dev/extensions/thumbnails/";
  };
};

// A Service for handling thumbnail generation
service ThumbnailService {
    // Generates the thumbnail and returns it.
    rpc GetThumbnail(GetThumbnailRequest) returns (GetThumbnailResponse);
}

// A request to retrieve a thumbnail
message GetThumbnailRequest {
    // The path to the source image
    string filepath = 1;
    // The file types to which the thumbnail can get encoded to.
    enum ThumbnailType {
        PNG = 0; // Represents PNG type
        JPG = 1; // Represents JPG type
    }
    // The type to which the thumbnail should get encoded to.
    ThumbnailType thumbnail_type = 2;
    // The width of the thumbnail
    int32 width = 3;
    // The height of the thumbnail
    int32 height = 4;
    oneof source {
      WebdavSource webdav_source = 5;
      CS3Source cs3_source = 6;
    }
}

message WebdavSource {
  // REQUIRED.
  string url = 1;
  // REQUIRED.
  bool is_public_link = 2;
  // OPTIONAL.
  string webdav_authorization = 3;
  // OPTIONAL.
  string reva_authorization = 4;
  // OPTIONAL.
  string public_link_token = 5;
}

message CS3Source {
  string path = 1;
  string authorization = 2;
}

// The service response
message GetThumbnailResponse {
    // The thumbnail as a binary
    bytes thumbnail = 1;
    // The mimetype of the thumbnail
    string mimetype = 2;
}
