/*
Copyright 2023 The Kubernetes 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.
*/

// To regenerate api.pb.go run `hack/update-codegen.sh protobindings`

syntax = "proto3";

package v1alpha2;
option go_package = "k8s.io/kubelet/pkg/apis/dra/v1alpha2";

import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "k8s.io/api/resource/v1alpha2/generated.proto";

option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) =  true;
option (gogoproto.goproto_getters_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.goproto_unrecognized_all) = false;

service Node {
  rpc NodePrepareResource (NodePrepareResourceRequest)
    returns (NodePrepareResourceResponse) {}

  rpc NodeUnprepareResource (NodeUnprepareResourceRequest)
    returns (NodeUnprepareResourceResponse) {}
}

message NodePrepareResourceRequest {
    // The ResourceClaim namespace (ResourceClaim.meta.Namespace).
    // This field is REQUIRED.
    string namespace = 1;
    // The UID of the Resource claim (ResourceClaim.meta.UUID).
    // This field is REQUIRED.
    string claim_uid = 2;
    // The name of the Resource claim (ResourceClaim.meta.Name)
    // This field is REQUIRED.
    string claim_name = 3;
    // Resource handle (AllocationResult.ResourceHandles[*].Data)
    // This field is REQUIRED.
    string resource_handle = 4;
    // Structured parameter resource handle (AllocationResult.ResourceHandles[*].StructuredData).
    // This field is OPTIONAL. If present, it needs to be used
    // instead of resource_handle. It will only have a single entry.
    //
    // Using "repeated" instead of "optional" is a workaround for https://github.com/gogo/protobuf/issues/713.
    repeated k8s.io.api.resource.v1alpha2.StructuredResourceHandle structured_resource_handle = 5;
}

message NodePrepareResourceResponse {
    // These are the additional devices that kubelet must
    // make available via the container runtime. A resource
    // may have zero or more devices.
    repeated string cdi_devices = 1;
}

message NodeUnprepareResourceRequest {
    // The ResourceClaim namespace (ResourceClaim.meta.Namespace).
    // This field is REQUIRED.
    string namespace = 1;
    // The UID of the Resource claim (ResourceClaim.meta.UUID).
    // This field is REQUIRED.
    string claim_uid = 2;
    // The name of the Resource claim (ResourceClaim.meta.Name)
    // This field is REQUIRED.
    string claim_name = 3;
    // Resource handle (AllocationResult.ResourceHandles[*].Data)
    // This field is REQUIRED.
    string resource_handle = 4;
    // Structured parameter resource handle (AllocationResult.ResourceHandles[*].StructuredData).
    // This field is OPTIONAL. If present, it needs to be used
    // instead of resource_handle. It will only have a single entry.
    repeated k8s.io.api.resource.v1alpha2.StructuredResourceHandle structured_resource_handle = 5;
}

message NodeUnprepareResourceResponse {
    // Intentionally empty.
}
