// Copyright 2020-2025 Buf Technologies, 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";

package buf.alpha.registry.v1alpha1;

import "buf/alpha/image/v1/image.proto";

// The supported formats for the serialized message conversion.
enum ConvertFormat {
  CONVERT_FORMAT_UNSPECIFIED = 0;
  CONVERT_FORMAT_BIN = 1;
  CONVERT_FORMAT_JSON = 2;
}

// ConvertService coverts serialized messages
service ConvertService {
  // Convert converts a serialized message according to
  // the provided type name using an image.
  rpc Convert(ConvertRequest) returns (ConvertResponse);
}

message ConvertRequest {
  // type_name is the full type name of the serialized message (like acme.weather.v1.Units).
  string type_name = 1;
  // image is the image source that defines the serialized message.
  buf.alpha.image.v1.Image image = 2;
  // payload is the serialized Protobuf message.
  bytes payload = 3;
  // request_format is the format of the payload.
  ConvertFormat request_format = 4;
  // response_format is the desired format of the output result.
  ConvertFormat response_format = 5;
}

message ConvertResponse {
  // payload is the converted serialized message in one of the supported formats.
  bytes payload = 1;
}
