// Copyright 2025 Envoy Project 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 envoy.type.http.v3;

import "google/protobuf/duration.proto";

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.type.http.v3";
option java_outer_classname = "CookieProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/type/http/v3;httpv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: HTTP cookie API]

// Cookie defines an API for obtaining or generating HTTP cookie.
message Cookie {
  // The name that will be used to obtain cookie value from downstream HTTP request or generate
  // new cookie for downstream.
  string name = 1 [(validate.rules).string = {min_len: 1}];

  // Duration of cookie. This will be used to set the expiry time of a new cookie when it is
  // generated. Set this to 0s to use a session cookie and disable cookie expiration.
  google.protobuf.Duration ttl = 2 [(validate.rules).duration = {gte {}}];

  // Path of cookie. This will be used to set the path of a new cookie when it is generated.
  // If no path is specified here, no path will be set for the cookie.
  string path = 3;

  // Additional attributes for the cookie. They will be used when generating a new cookie.
  repeated CookieAttribute attributes = 4;
}

// CookieAttribute defines an API for adding additional attributes for a HTTP cookie.
message CookieAttribute {
  // The name of the cookie attribute.
  string name = 1
      [(validate.rules).string =
           {min_len: 1 max_bytes: 16384 well_known_regex: HTTP_HEADER_NAME strict: false}];

  // The optional value of the cookie attribute.
  string value = 2 [
    (validate.rules).string = {max_bytes: 16384 well_known_regex: HTTP_HEADER_VALUE strict: false}
  ];
}
