syntax = "proto3";
package generated;
option go_package = "github.com/vmware-tanzu/velero/pkg/plugin/generated";

import "Shared.proto";

message PutObjectRequest {
    string plugin = 1;
    string bucket = 2;
    string key = 3;
    bytes body = 4;
}

message ObjectExistsRequest {
    string plugin = 1;
    string bucket = 2;
    string key = 3;
}

message ObjectExistsResponse {
    bool exists = 1;
}

message GetObjectRequest {
    string plugin = 1;
    string bucket = 2;
    string key = 3;
}

message Bytes {
    bytes data = 1;
}

message ListCommonPrefixesRequest {
    string plugin = 1;
    string bucket = 2;
    string delimiter = 3;
    string prefix = 4;
}

message ListCommonPrefixesResponse {
    repeated string prefixes = 1;
}

message ListObjectsRequest {
    string plugin = 1;
    string bucket = 2;
    string prefix = 3;
}

message ListObjectsResponse {
    repeated string keys = 1;
}

message DeleteObjectRequest {
    string plugin = 1;
    string bucket = 2;  
    string key = 3;
}


message CreateSignedURLRequest {
    string plugin = 1;
    string bucket = 2;
    string key = 3;
    int64 ttl = 4;
}

message CreateSignedURLResponse {
    string url = 1;
}

message ObjectStoreInitRequest {
    string plugin = 1;
    map<string, string> config = 2;
}

service ObjectStore {
    rpc Init(ObjectStoreInitRequest) returns (Empty);
    rpc PutObject(stream PutObjectRequest) returns (Empty);
    rpc ObjectExists(ObjectExistsRequest) returns (ObjectExistsResponse);
    rpc GetObject(GetObjectRequest) returns (stream Bytes);
    rpc ListCommonPrefixes(ListCommonPrefixesRequest) returns (ListCommonPrefixesResponse);
    rpc ListObjects(ListObjectsRequest) returns (ListObjectsResponse);
    rpc DeleteObject(DeleteObjectRequest) returns (Empty);
    rpc CreateSignedURL(CreateSignedURLRequest) returns (CreateSignedURLResponse);
}
