// Copyright 2025 The Sigstore Authors
//
// 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 dev.sigstore.rekor.v2;

import "google/api/field_behavior.proto";

import "rekor/v2/dsse.proto";
import "rekor/v2/hashedrekord.proto";

option go_package = "github.com/sigstore/protobuf-specs/gen/pb-go/rekor/v2";

option java_package = "dev.sigstore.proto.rekor.v2";
option java_multiple_files = true;
option java_outer_classname = "RekorV2Entry";
option ruby_package = "Sigstore::Rekor::V2";

// Entry is the message that is canonicalized and uploaded to the log.
// This format is meant to be compliant with Rekor v1 entries in that
// the `apiVersion` and `kind` can be parsed before parsing the spec.
// Clients are expected to understand and handle the differences in the
// contents of `spec` between Rekor v1 (a polymorphic OpenAPI defintion)
// and Rekor v2 (a typed proto defintion).
message Entry {
    string kind = 1 [(google.api.field_behavior) = REQUIRED];
    string api_version = 2 [(google.api.field_behavior) = REQUIRED];
    Spec spec = 3 [(google.api.field_behavior) = REQUIRED];
}

// Spec contains one of the Rekor entry types.
message Spec {
    oneof spec {
        HashedRekordLogEntryV002 hashed_rekord_v002 = 1 [(google.api.field_behavior) = REQUIRED];
        DSSELogEntryV002 dsse_v002  = 2 [(google.api.field_behavior) = REQUIRED];
    }
}

// Create a new HashedRekord or DSSE
message CreateEntryRequest {
    oneof spec {
        HashedRekordRequestV002 hashed_rekord_request_v002 = 1 [(google.api.field_behavior) = REQUIRED];
        DSSERequestV002 dsse_request_v002 = 2 [(google.api.field_behavior) = REQUIRED];
    }
}
