/*
Copyright 2023 The Dapr 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 dapr.proto.components.v1;

import "dapr/proto/components/v1/common.proto";

option go_package = "github.com/dapr/dapr/pkg/proto/components/v1;components";

// Interface for secret store.
service SecretStore {
    // Initializes the secret store with the given metadata.
    rpc Init(SecretStoreInitRequest) returns (SecretStoreInitResponse) {}

    // Returns a list of implemented secret store features.
    rpc Features(FeaturesRequest) returns (FeaturesResponse) {}

    // Get an individual secret from the store.
    rpc Get(GetSecretRequest) returns (GetSecretResponse) {}

    // Get all secrets from the store.
    rpc BulkGet(BulkGetSecretRequest) returns (BulkGetSecretResponse) {}

    // Ping the pubsub. Used for liveness porpuses.
    rpc Ping(PingRequest) returns (PingResponse) {}
  }

// Request to initialize the secret store.
message SecretStoreInitRequest {
  MetadataRequest metadata = 1;
}

// Response from initialization.
message SecretStoreInitResponse {}

// GetSecretRequest is the message to get secret from secret store.
message GetSecretRequest {
  // The name of secret key.
  string key = 1;

  // The metadata which will be sent to secret store components.
  map<string, string> metadata = 2;
}

// GetSecretResponse is the response message to convey the requested secret.
message GetSecretResponse {
  // data is the secret value. Some secret store, such as kubernetes secret
  // store, can save multiple secrets for single secret key.
  map<string, string> data = 1;
}

// BulkGetSecretRequest is the message to get the secrets from secret store.
message BulkGetSecretRequest {
  // The metadata which will be sent to secret store components.
  map<string, string> metadata = 1;
}

// SecretResponse is a map of decrypted string/string values
message SecretResponse {
  map<string, string> secrets = 1;
}

// BulkGetSecretResponse is the response message to convey the requested secrets.
message BulkGetSecretResponse {
  // data hold the secret values. Some secret store, such as kubernetes secret
  // store, can save multiple secrets for single secret key.
  map<string, SecretResponse> data = 1;
}