syntax = "proto3";

package containerd.v1.namespaces;

import "gogoproto/gogo.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";

// Namespaces provides the ability to manipulate containerd namespaces.
//
// All objects in the system are required to be a member of a namespace. If a
// namespace is deleted, all objects, including containers, images and
// snapshots, will be deleted, as well.
//
// Unless otherwise noted, operations in containerd apply only to the namespace
// supplied per request.
//
// I hope this goes without saying, but namespaces are themselves NOT
// namespaced.
service Namespaces {
	rpc Get(GetNamespaceRequest) returns (GetNamespaceResponse);
	rpc List(ListNamespacesRequest) returns (ListNamespacesResponse);
	rpc Create(CreateNamespaceRequest) returns (CreateNamespaceResponse);
	rpc Update(UpdateNamespaceRequest) returns (UpdateNamespaceResponse);
	rpc Delete(DeleteNamespaceRequest) returns (google.protobuf.Empty);
}

message Namespace {
	string namespace = 1;

	// Labels provides an area to include arbitrary data on namespaces.
	//
	// Note that to add a new value to this field, read the existing set and
	// include the entire result in the update call.
	map<string, string> labels  = 2;
}

message GetNamespaceRequest {
	string name = 1;
}

message GetNamespaceResponse {
	Namespace namespace = 1 [(gogoproto.nullable) = false];
}

message ListNamespacesRequest {
	string filter = 1; // TODO(stevvooe): Define a filtering syntax to make these queries.
}

message ListNamespacesResponse {
	repeated Namespace namespaces = 1 [(gogoproto.nullable) = false];
}

message CreateNamespaceRequest {
	Namespace namespace = 1 [(gogoproto.nullable) = false];
}

message CreateNamespaceResponse {
	Namespace namespace = 1 [(gogoproto.nullable) = false];
}

// UpdateNamespaceRequest updates the metadata for a namespace.
//
// The operation should follow semantics described in
// https://developers.google.com/protocol-buffers/docs/reference/csharp/class/google/protobuf/well-known-types/field-mask,
// unless otherwise qualified.
message UpdateNamespaceRequest {
	// Namespace provides the target value, as declared by the mask, for the update.
	//
	// The namespace field must be set.
	Namespace namespace = 1 [(gogoproto.nullable) = false];

	// UpdateMask specifies which fields to perform the update on. If empty,
	// the operation applies to all fields.
	google.protobuf.FieldMask update_mask = 2;
}

message UpdateNamespaceResponse {
	Namespace namespace = 1 [(gogoproto.nullable) = false];
}

message DeleteNamespaceRequest {
	string namespace = 1;
}
