// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you 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 cso.v1;

option csharp_namespace = "Cso.V1";
option go_package = "github.com/elastic/harp/api/gen/go/cso/v1;csov1";
option java_multiple_files = true;
option java_outer_classname = "SecretProto";
option java_package = "com.github.elastic.cloudsec.cso.v1";
option objc_class_prefix = "CXX";
option php_namespace = "Cso\\V1";

// -----------------------------------------------------------------------------

// RingLevel enumerates all cso ring level values.
enum RingLevel {
  // Default value when no enumeration is specified.
  RING_LEVEL_INVALID = 0;
  // Explicitly Unknown object value.
  RING_LEVEL_UNKNOWN = 1;
  // Defines secret used by secrets.
  RING_LEVEL_META = 2;
  // Defines infrastructure level secrets.
  RING_LEVEL_INFRASTRUCTURE = 3;
  // Defines platform level secrets.
  RING_LEVEL_PLATFORM = 4;
  // Defines product level secrets.
  RING_LEVEL_PRODUCT = 5;
  // Defines application level secrets.
  RING_LEVEL_APPLICATION = 6;
  // Defines artifact level secrets.
  RING_LEVEL_ARTIFACT = 7;
}

// Secret represents secret value and metadata.
message Secret {
  RingLevel ring_level = 1;
  Value value = 2;
  oneof path {
    Meta meta = 10;
    Infrastructure infrastructure = 11;
    Platform platform = 12;
    Product product = 13;
    Application application = 14;
    Artifact artifact = 15;
  }
}

// Value represents an encoded secret value.
message Value {
  string type = 1;
  bytes body = 2;
}

// -----------------------------------------------------------------------------

// Meta describes secrets of secrets path components.
message Meta {
  string key = 1;
}

// -----------------------------------------------------------------------------

// Infrastructure describes infrastructure secret path components.
message Infrastructure {
  // Cloud provider name
  string cloud_provider = 1;
  // Cloud provider account identifier or alias
  string account_id = 2;
  // Cloud provider region
  string region = 3;
  // Service name used
  string service_name = 4;
  // Key is the free part of the namming specification.
  string key = 5;
}

// -----------------------------------------------------------------------------

// QualityLevel enumerates entity quality level values.
enum QualityLevel {
  // Default value when no enumeration is specified.
  QUALITY_LEVEL_INVALID = 0;
  // Explicitly Unknown object value.
  QUALITY_LEVEL_UNKNOWN = 1;
  // Production grade
  QUALITY_LEVEL_PRODUCTION = 2;
  // Staging grade
  QUALITY_LEVEL_STAGING = 3;
  // QA Grade
  QUALITY_LEVEL_QA = 4;
  // Dev grade
  QUALITY_LEVEL_DEV = 5;
}

// Platform describes platform secret path components.
message Platform {
  // Quality level
  QualityLevel stage = 1;
  // Paltform name
  string name = 2;
  // Platform region
  string region = 3;
  // Platform service name
  string service_name = 4;
  // Key is the free part of the namming specification.
  string key = 5;
}

// -----------------------------------------------------------------------------

// Product describes product secret path components.
message Product {
  // Product name
  string name = 1;
  // Product version
  string version = 2;
  // Product component name
  string component_name = 3;
  // Key is the free part of the namming specification.
  string key = 4;
}

// -----------------------------------------------------------------------------

// Application describes application secret path components.
message Application {
  // Quality level
  QualityLevel stage = 1;
  // Platform name
  string platform_name = 2;
  // Product name
  string product_name = 3;
  // Product version
  string product_version = 4;
  // Product component name
  string component_name = 5;
  // Key is the free part of the namming specification.
  string key = 6;
}

// -----------------------------------------------------------------------------

// Artifact describes artifact secret path components.
message Artifact {
  // Artifact type
  string type = 1;
  // Artifact id
  string id = 2;
  // Key is the free part of the namming specification.
  string key = 3;
}
