// Copyright Istio 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.

// THIS FILE IS AUTOMATICALLY GENERATED BY MIXGEN.

syntax = "proto3";


// The `kubernetes` template holds data that controls the production of Kubernetes-specific
// attributes.
// 
// Example config:
// 
// ```yaml
// apiVersion: "config.istio.io/v1alpha2"
// kind: kubernetes
// metadata:
//   name: attributes
//   namespace: istio-system
// spec:
//   # Pass the required attribute data to the adapter
//   source_uid: source.uid | ""
//   source_ip: source.ip | ip("0.0.0.0") # default to unspecified ip addr
//   destination_uid: destination.uid | ""
//   destination_ip: destination.ip | ip("0.0.0.0") # default to unspecified ip addr
//   attribute_bindings:
//     # Fill the new attributes from the adapter produced output.
//     # $out refers to an instance of OutputTemplate message
//     source.ip: $out.source_pod_ip
//     source.labels: $out.source_labels
//     source.namespace: $out.source_namespace
//     source.service: $out.source_service
//     source.serviceAccount: $out.source_service_account_name
//     destination.ip: $out.destination_pod_ip
//     destination.labels: $out.destination_labels
//     destination.namespace: $out.destination_mamespace
//     destination.service: $out.destination_service
//     destination.serviceAccount: $out.destination_service_account_name
// ```
//
// The `kubernetes` template represents data used to generate kubernetes-derived attributes.
// 
// The values provided controls the manner in which the kubernetesenv adapter discovers and
// generates values related to pod information.
// Next ID: 8
package adapter.template.kubernetes;


import "gogoproto/gogo.proto";
import "mixer/adapter/model/v1beta1/extensions.proto";
import "google/protobuf/any.proto";

import "policy/v1beta1/type.proto";

option (istio.mixer.adapter.model.v1beta1.template_variety) = TEMPLATE_VARIETY_ATTRIBUTE_GENERATOR;
option (istio.mixer.adapter.model.v1beta1.template_name) = "kubernetes";

option (gogoproto.goproto_getters_all) = false;
option (gogoproto.equal_all) = false;
option (gogoproto.gostring_all) = false;
option (gogoproto.stable_marshaler_all) = true;

// HandleKubernetesService is implemented by backends that wants to handle request-time 'kubernetes' instances.
service HandleKubernetesService {
    // HandleKubernetes is called by Mixer at request-time to deliver 'kubernetes' instances to the backend.
    rpc HandleKubernetes(HandleKubernetesRequest) returns (OutputMsg);
}

// Request message for HandleKubernetes method.
message HandleKubernetesRequest {

    // 'kubernetes' instance.
    InstanceMsg instance = 1;

    // Adapter specific handler configuration.
    //
    // Note: Backends can also implement [InfrastructureBackend][https://istio.io/docs/reference/config/mixer/istio.mixer.adapter.model.v1beta1.html#InfrastructureBackend]
    // service and therefore opt to receive handler configuration during session creation through [InfrastructureBackend.CreateSession][TODO: Link to this fragment]
    // call. In that case, adapter_config will have type_url as 'google.protobuf.Any.type_url' and would contain string
    // value of session_id (returned from InfrastructureBackend.CreateSession).
    google.protobuf.Any adapter_config = 2;

    // Id to dedupe identical requests from Mixer.
    string dedup_id = 3;
}



// Contains output payload for 'kubernetes' template.
message OutputMsg {
    
    // Refers to the source.uid for a pod. This is for TCP use cases where the attribute is not present.
// attribute_bindings can refer to this field using $out.source_pod_uid
    string source_pod_uid = 31;
    
    // Refers to source pod ip address. attribute_bindings can refer to this field using $out.source_pod_ip
    istio.policy.v1beta1.IPAddress source_pod_ip = 1;
    
    // Refers to source pod name. attribute_bindings can refer to this field using $out.source_pod_name
    string source_pod_name = 2;
    
    // Refers to source pod labels. attribute_bindings can refer to this field using $out.source_labels
    map<string, string> source_labels = 3;
    
    // Refers to source pod namespace. attribute_bindings can refer to this field using $out.source_namespace
    string source_namespace = 4;
    
    // Refers to source pod service account name. attribute_bindings can refer to this field using $out.source_service_account_name
    string source_service_account_name = 6;
    
    // Refers to source pod host ip address. attribute_bindings can refer to this field using $out.source_host_ip
    istio.policy.v1beta1.IPAddress source_host_ip = 7;
    
    // Refers to the Istio workload identifier for the source pod. Attribute_bindings can refer to this field using $out.source_workload_uid
    string source_workload_uid = 22;
    
    // Refers to the Istio workload name for the source pod. Attribute_bindings can refer to this field using $out.source_workload_name
    string source_workload_name = 23;
    
    // Refers to the Istio workload namespace for the source pod. Attribute_bindings can refer to this field using $out.source_workload_namespace
    string source_workload_namespace = 24;
    
    // Refers to the (controlling) owner of the source pod. Attribute_bindings can refer to this field using $out.source_owner
    string source_owner = 25;
    
    // Refers to the destination.uid for a pod. This is for TCP use cases where the attribute is not present.
// attribute_bindings can refer to this field using $out.destination_pod_uid
    string destination_pod_uid = 32;
    
    // Refers to destination pod ip address. attribute_bindings can refer to this field using $out.destination_pod_ip
    istio.policy.v1beta1.IPAddress destination_pod_ip = 8;
    
    // Refers to destination pod name. attribute_bindings can refer to this field using $out.destination_pod_name
    string destination_pod_name = 9;
    
    // Refers to destination container name. attribute_bindings can refer to this field using $out.destination_container_name
    string destination_container_name = 30;
    
    // Refers to destination pod labels. attribute_bindings can refer to this field using $out.destination_labels
    map<string, string> destination_labels = 10;
    
    // Refers to destination pod namespace. attribute_bindings can refer to this field using $out.destination_namespace
    string destination_namespace = 11;
    
    // Refers to destination pod service account name. attribute_bindings can refer to this field using $out.destination_service_account_name
    string destination_service_account_name = 13;
    
    // Refers to destination pod host ip address. attribute_bindings can refer to this field using $out.destination_host_ip
    istio.policy.v1beta1.IPAddress destination_host_ip = 14;
    
    // Refers to the (controlling) owner of the destination pod. Attribute_bindings can refer to this field using $out.destination_owner
    string destination_owner = 26;
    
    // Refers to the Istio workload identifier for the destination pod. Attribute_bindings can refer to this field using $out.destination_workload_uid
    string destination_workload_uid = 27;
    
    // Refers to the Istio workload name for the destination pod. Attribute_bindings can refer to this field using $out.destination_workload_name
    string destination_workload_name = 28;
    
    // Refers to the Istio workload name for the destination pod. Attribute_bindings can refer to this field using $out.destination_workload_namespace
    string destination_workload_namespace = 29;
    
}

// Contains instance payload for 'kubernetes' template. This is passed to infrastructure backends during request-time
// through HandleKubernetesService.HandleKubernetes.
message InstanceMsg {

    // Name of the instance as specified in configuration.
    string name = 72295727;
    
    // Source pod's uid. Must be of the form: "kubernetes://pod.namespace"
    string source_uid = 1;
    
    // Source pod's ip.
    istio.policy.v1beta1.IPAddress source_ip = 2;
    
    // Destination pod's uid. Must be of the form: "kubernetes://pod.namespace"
    string destination_uid = 3;
    
    // Destination pod's ip.
    istio.policy.v1beta1.IPAddress destination_ip = 4;
    
    // Destination container's port number.
    int64 destination_port = 7;
    
}

// Contains inferred type information about specific instance of 'kubernetes' template. This is passed to
// infrastructure backends during configuration-time through [InfrastructureBackend.CreateSession][TODO: Link to this fragment].
message Type {
    
}


// Represents instance configuration schema for 'kubernetes' template.
message InstanceParam {
    
    // Source pod's uid. Must be of the form: "kubernetes://pod.namespace"
    string source_uid = 1;
    
    // Source pod's ip.
    string source_ip = 2;
    
    // Destination pod's uid. Must be of the form: "kubernetes://pod.namespace"
    string destination_uid = 3;
    
    // Destination pod's ip.
    string destination_ip = 4;
    
    // Destination container's port number.
    string destination_port = 7;
    // Attribute names to expression mapping. These expressions can use the fields from the output object
    // returned by the attribute producing adapters using $out.<fieldName> notation. For example:
    // source.ip : $out.source_pod_ip
    // In the above example, source.ip attribute will be added to the existing attribute list and its value will be set to
    // the value of source_pod_ip field of the output returned by the adapter.
    map<string, string> attribute_bindings = 72295728;
    
}

