syntax = "proto3";

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/httpbody.proto";
import "google/protobuf/empty.proto";

package animeshon.hub.v1alpha1;

option go_package = "github.com/animeapis/go-genproto/hub/v1alpha1;hub";
option java_package = "com.animeshon.hub.v1alpha1";
option java_multiple_files = true;
option ruby_package = "Animeshon::Hub::v1Alpha1";

service Git {
  option (google.api.default_host) = "hub.animeapis.com";

  rpc AdvertiseReferences(AdvertiseReferencesRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      get: "/v1alpha1/{name=*/*}/info/refs"
    };
  }

  rpc ReceivePack(ReceivePackRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      post: "/v1alpha1/{name=*/*}/git-receive-pack"
      body: "body"
    };
  }

  rpc UploadPack(UploadPackRequest) returns (google.api.HttpBody) {
    option (google.api.http) = {
      post: "/v1alpha1/{name=*/*}/git-upload-pack"
      body: "body"
    };
  }
}

service Hub {
  option (google.api.default_host) = "hub.animeapis.com";

  rpc CreateRepository(CreateRepositoryRequest) returns (Repository) {
    option (google.api.http) = {
      post: "/v1alpha1/{name=namespaces/*/repositories/*}"
      body: "*"
    };
  }

  rpc DeleteRepository(DeleteRepositoryRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1alpha1/{name=namespaces/*/repositories/*}"
    };
  }

  rpc ListRepositories(ListRepositoriesRequest) returns (ListRepositoriesResponse) {
    option (google.api.http) = {
      get: "/v1alpha1/{parent=namespaces/*}/repositories"
    };
  }
}

message Repository {
  // The repository resource name.
  string name = 1;
}

message AdvertiseReferencesRequest {
  // The resource name of the repository.
  string name = 1;

  // The git service according to the git protocol.
  string service = 2;
}

message ReceivePackRequest {
  // The resource name of the repository.
  string name = 1;

  // The request content, represented as an HttpBody.
  google.api.HttpBody body = 2;
}

message UploadPackRequest {
  // The resource name of the repository.
  string name = 1;

  // The request content, represented as an HttpBody.
  google.api.HttpBody body = 2;
}

message CreateRepositoryRequest {
  // The resource name of the repository to be created.
  string name = 1;
}

message DeleteRepositoryRequest {
  // The resource name of the repository to be deleted.
  string name = 1;
}

message ListRepositoriesRequest {
  // The parent, which owns this collection of repositories.
  string parent = 1 [(google.api.field_behavior) = REQUIRED];

  // If unspecified, server will pick an appropriate default.
  int32 page_size = 2;

  // The value returned from the previous call.
  string page_token = 3;
}

message ListRepositoriesResponse {
  // The list of repositories.
  repeated Repository repositories = 1;

  // A token to retrieve next page of results.
  string next_page_token = 2;
}
