// #######################################################################
// ##- @Copyright (C) Huawei Technologies., Ltd. 2019-2020. All rights reserved.
// # - iSulad licensed under the Mulan PSL v1.
// # - You can use this software according to the terms and conditions of the Mulan PSL v1.
// # - You may obtain a copy of Mulan PSL v1 at:
// # -     http://license.coscl.org.cn/MulanPSL
// # - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
// # - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
// # - PURPOSE.
// # - See the Mulan PSL v1 for more details.
// ##- @Description: generate grpc
// ##- @Author: wujing
// ##- @Create: 2020-01-16
// #######################################################################


/*
Since some of this code is derived from containerd, their copyright
is retained here....

Copyright 2013-2016 Docker, Inc.

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";
option optimize_for = CODE_SIZE;

import "google/protobuf/timestamp.proto";
import "descriptor.proto";

package images;

// Images is a service that allows one to register images with containerd.
//
// In containerd, an image is merely the mapping of a name to a content root,
// described by a descriptor. The behavior and state of image is purely
// dictated by the type of the descriptor.
//
// From the perspective of this service, these references are mostly shallow,
// in that the existence of the required content won't be validated until
// required by consuming services.
//
// As such, this can really be considered a "metadata service".
service ImagesService {
	// List returns a list of all images known to containerd.
	rpc List(ListImagesRequest) returns (ListImagesResponse);

	// Delete deletes the image by name.
	rpc Delete(DeleteImageRequest) returns (DeleteImageResponse);

	// load image from archive.
	rpc Load(LoadImageRequest) returns (LoadImageResponse);

	//inspect image
	rpc Inspect(InspectImageRequest) returns (InspectImageResponse);

	// Login to a Docker registry
	rpc Login(LoginRequest) returns (LoginResponse);

	// Logout from a Docker registry
	rpc Logout(LogoutRequest) returns (LogoutResponse);
}

message Image {
	// Name provides a unique name for the image.
	//
	// Containerd treats this as the primary identifier.
	string name = 1;

	// Labels provides free form labels for the image. These are runtime only
	// and do not get inherited into the package image in any way.
	//
	// Labels may be updated using the field mask.
	// The combined size of a key/value pair cannot exceed 4096 bytes.
	map<string, string> labels = 2;

	// Target describes the content entry point of the image.
	containerd.types.Descriptor target = 3;

	// CreatedAt is the time the image was first created.
	google.protobuf.Timestamp created_at = 7;

	// UpdatedAt is the last time the image was mutated.
	google.protobuf.Timestamp updated_at = 8;
}

message ListImagesRequest {
	// Filters contains one or more filters using the syntax defined in the
	// containerd filter package.
	//
	// The returned result will be those that match any of the provided
	// filters. Expanded, images that match the following will be
	// returned:
	//
	//   filters[0] or filters[1] or ... or filters[n-1] or filters[n]
	//
	// If filters is zero-length or nil, all items will be returned.
	map<string, string>  filters = 1;
}

message ListImagesResponse {
	repeated Image images = 1;
	uint32 cc = 2;
	string errmsg = 3;
}

message DeleteImageRequest {
	string name = 1;
	bool force = 2;
}

message DeleteImageResponse {
	string name = 1;
	uint32 cc = 2;
	string errmsg = 3;
}

message LoadImageRequest {
	string file = 1;
	string type = 2;
	string tag = 3;
}

message LoadImageResponse {
	uint32 cc = 1;
	string errmsg = 2;
}

message InspectImageRequest {
	string id = 1;
	bool bformat = 2;
	int32 timeout = 3;
}

message InspectImageResponse {
	string ImageJSON = 1;
	uint32 cc = 2;
	string errmsg = 3;
}

message LoginRequest {
	string username = 1;
	string password = 2;
	string server = 3;
	string type = 4;
}

message LoginResponse {
	uint32 cc = 1;
	string errmsg = 2;
}

message LogoutRequest {
	string server = 1;
	string type = 2;
}

message LogoutResponse {
	uint32 cc = 1;
	string errmsg = 2;
}
