From 9cf2934a1db2e504be4d234d806f20037c27e960 Mon Sep 17 00:00:00 2001
From: Xuqian Ma <xqm@google.com>
Date: Thu, 14 Nov 2024 05:48:59 +0000
Subject: [PATCH] Add set-as-path BGP action and bgp-as-builtin-type to support
 replacing entire AS path.

---
 release/models/bgp/openconfig-bgp-errors.yang |  8 ++++++-
 release/models/bgp/openconfig-bgp-policy.yang | 21 ++++++++++++++++++-
 release/models/bgp/openconfig-bgp-types.yang  | 21 ++++++++++++++++++-
 3 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/release/models/bgp/openconfig-bgp-errors.yang b/release/models/bgp/openconfig-bgp-errors.yang
index 53372afc7..2fb0e497c 100644
--- a/release/models/bgp/openconfig-bgp-errors.yang
+++ b/release/models/bgp/openconfig-bgp-errors.yang
@@ -18,7 +18,13 @@ submodule openconfig-bgp-errors {
     "This module defines BGP NOTIFICATION message error codes
     and subcodes";
 
-  oc-ext:openconfig-version "6.1.0";
+  oc-ext:openconfig-version "6.2.0";
+
+  revision "2025-01-03" {
+    description
+      "Add new bgp-as-builtin-type to support last AS for set-as-path action";
+    reference "6.2.0";
+  }
 
   revision "2024-09-06" {
     description
diff --git a/release/models/bgp/openconfig-bgp-policy.yang b/release/models/bgp/openconfig-bgp-policy.yang
index ee5c34e01..87beeb8b6 100644
--- a/release/models/bgp/openconfig-bgp-policy.yang
+++ b/release/models/bgp/openconfig-bgp-policy.yang
@@ -28,7 +28,14 @@ module openconfig-bgp-policy {
     It augments the base routing-policy module with BGP-specific
     options for conditions and actions.";
 
-  oc-ext:openconfig-version "8.0.0";
+  oc-ext:openconfig-version "8.2.0";
+
+  revision "2025-01-03" {
+    description
+      "Add set-as-path BGP action and use-last-as leaf to
+      set-as-path-prepend to prepend last AS.";
+    reference "8.2.0";
+  }
 
   revision "2024-08-23" {
     description
@@ -1388,6 +1395,18 @@ module openconfig-bgp-policy {
         "When set-med is specified, this leaf is mandatory to set the
         appropriate action on the MED metric value.";
     }
+
+    leaf-list set-as-path {
+      type union {
+        type oc-inet:as-number;
+        type oc-bgp-types:bgp-as-builtin-type;
+      }
+      ordered-by user;
+      description
+        "set the entire AS path attribute in the route update,
+	with an ordered list of ASes that consists of AS numbers
+	or last-as.";
+    }
   }
 
   grouping bgp-actions-state {
diff --git a/release/models/bgp/openconfig-bgp-types.yang b/release/models/bgp/openconfig-bgp-types.yang
index 57b8e9b65..741b0d9d4 100644
--- a/release/models/bgp/openconfig-bgp-types.yang
+++ b/release/models/bgp/openconfig-bgp-types.yang
@@ -24,7 +24,13 @@ module openconfig-bgp-types {
     policy. It can be imported by modules that make use of BGP
     attributes";
 
-  oc-ext:openconfig-version "6.1.0";
+  oc-ext:openconfig-version "6.2.0";
+
+  revision "2025-01-03" {
+    description
+      "Add new bgp-as-builtin-type to support last AS for set-as-path action";
+    reference "6.2.0";
+  }
 
   revision "2024-09-06" {
     description
@@ -841,4 +847,17 @@ module openconfig-bgp-types {
     description
       "Defines the types of BGP AS path segments.";
   }
+
+  typedef bgp-as-builtin-type {
+    type enumeration {
+      enum LAST {
+        description
+          "The last AS in the AS path, which is also the most recent
+          AS added to the path.";
+      }
+    }
+    description
+      "Type definition for specifying the built in AS types
+      that can be used for setting AS path actions.";
+  }
 }