syntax="proto3";

package test;

option go_package="/proto;pb";

import "api/annotations.proto";
import "codec/frame.proto";
import "tag/tag.proto";
import "openapiv3/annotations.proto";

option (micro.openapiv3.openapiv3_swagger) = {
  info: {
    title: "test title";
    version: "0.0.5";
    description: "test desc";
  };
	servers: {
    url: "{proto}://{sub}.example.com/v1";
    description: "server";
		variables: {
			additional_properties: {
				name: "proto";
				value: {
				  enum: ["http", "https"];
				  default: "http";
				  description: "protocols"
				};
			};
			additional_properties: {
			  name: "sub";
				value: {
					enum: ["test", "prod"];
          default: "test";
          description: "subdomain";
				};
			};
		};
	};
	servers: {
    url: "https://other.example.com/v1";
    description: "other test server";
 	};
};

service TestService {
	rpc TestMultipart(MultipartReq) returns (MultipartRsp) {
		option (micro.api.http) = {
			post: "/users/multipart"; body: "*";
		};
		option (micro.openapiv3.openapiv3_operation) = {
			operation_id: "TestMultipart";
			request_body: {
				request_body: {
					content: {
						additional_properties: {
							name: "multipart/form-data";
							value: {
								schema: {
									reference: {
										_ref: ".MultipartReq";
									};
								};
							};
						};
					};
				};
			};
		};
	};
	rpc TestEndpoint(Request) returns (Response) {
		option (micro.api.http) = {
			get: "/users/test"
		};
		option (micro.openapiv3.openapiv3_operation) = {
			operation_id: "TestEndpoint";
			parameters: {
				parameter: {
				  name: "client_uid";
				  in: "header";
				  schema: {
						schema: {
					  	type: "string";
						};
					};
				  required: true;
			  };
		  };
			parameters: {
				parameter: {
				  name: "csrftoken";
				  in: "cookie";
				  schema: {
						schema: {
					  	type: "string";
						};
					};
				  required: true;
			  };
		  };
		};
	};
	rpc UserByID(Request) returns (Response) {
		option (micro.api.http) = {
			get: "/users/{id}"
		};
	};
	rpc UserImageByID(Request) returns (micro.codec.Frame) {
		option (micro.api.http) = {
			get: "/users/{id}/image"
		};
	};
	rpc UploadFile(RequestImage) returns (ResponseImage) {
		option (micro.api.http) = {
			post: "/users/image/upload"
		};
	}
	rpc KzAmlRs(RequestAml) returns (ResponseAml) {
		option (micro.api.http) = {
			post: "/aml"
		};
	}
};

message MultipartReq {
  string prefix = 1;
	bytes body = 2;
};

message MultipartRsp {

};

message RequestAml {
	KZAmlNewOnlineRs kzAmlNewOnlineRs = 1 [(micro.tag.tags) = "xml:\"KZAmlNewOnlineRs\"" ];
}

message KZAmlNewOnlineRs {
	string rquid = 1 [(micro.tag.tags) = "xml:\"RqUID\"" ];
	string rqtm = 2 [(micro.tag.tags) = "xml:\"RqTm\"" ];
	Status status = 3 [(micro.tag.tags) = "xml:\"Status\"" ];
	int64 terr_status = 4 [(micro.tag.tags) = "xml:\"TerrStatus\"" ];
	int64 aml_status = 5 [(micro.tag.tags) = "xml:\"AMLStatus\"" ];
}

message Status {
	int64 status_code = 1 [(micro.tag.tags) = "xml:\"StatusCode\"" ];
}

message ResponseAml {
	string resp = 1;
}

message RequestImage {
	bytes image = 1;
	string file_name = 2;
	string doc_type = 3;
}

message ResponseImage {}

message Request {
	string id = 1;
        string client_uid = 2;
}

message Response {
	string encoded_id = 1 [(micro.tag.tags) = "xml:\"encoded_id,attr\"" ];
}
