// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.example.endpointsapis.v1;

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";

option java_multiple_files = true;
option java_package = "com.google.example.endpointsapis.v1";
option java_outer_classname = "WorkspaceProto";

// Manages workspaces.
service Workspaces {
  // List workspaces.
  rpc ListWorkspaces(ListWorkspacesRequest) returns (ListWorkspacesResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/workspaces"
    };
  }

  // Get information about a Workspace.
  rpc GetWorkspace(GetWorkspaceRequest) returns (Workspace) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/workspaces/*}"
    };
  }

  // Create a Workspace.
  rpc CreateWorkspace(CreateWorkspaceRequest) returns (Workspace) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/workspaces"
      body: "workspace"
    };
  }

  // Updates a Workspace.
  rpc UpdateWorkspace(UpdateWorkspaceRequest) returns (Workspace) {
    option (google.api.http) = {
      patch: "/v1/{name=projects/*/locations/*/Workspaces/*}"
      body: "workspace"
    };
  }

  // Deletes a Workspace.
  rpc DeleteWorkspace(DeleteWorkspaceRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/workspaces/*}"
    };
  }
}

// Presents a workspace
message Workspace {
  // The Workspace name in the format of "projects/*/locations/*/workspaces/*".
  string name = 1;
}

// Request message for listing Workspaces.
message ListWorkspacesRequest {
  // The parent used for listing. It should have the format of
  // `projects/{number}/locations/{location}`.
  string parent = 1;
  // The page size for list pagination.
  int32 page_size = 2;
  // The page token for list pagination.
  string page_token = 3;
}

// A list of workspaces.
message ListWorkspacesResponse {
  // The list of workspaces.
  repeated Workspace items = 1;
  // The next page token for list pagination.
  string next_page_token = 2;
}

// Request message for retrieving a Workspace.
message GetWorkspaceRequest {
  // The name of the Workspace to retrieve.
  string name = 1;
}

// Request message for creating a Workspace.
message CreateWorkspaceRequest {
  // The namespace in which the Workspace should be created.
  string parent = 1;

  // The Workspace instance to create.
  Workspace workspace = 2;
}

// Request message for replacing a Workspace.
message UpdateWorkspaceRequest {
  // The name of the Workspace being replaced.
  string name = 1;

  // The Workspace object being replaced.
  Workspace workspace = 2;
}

// Request message for deleting a Workspace.
message DeleteWorkspaceRequest {
  // The name of the Workspace to delete.
  string name = 1;
}
