diff --git a/dry_run/BUILD.bazel b/dry_run/BUILD.bazel new file mode 100644 index 0000000..eaea026 --- /dev/null +++ b/dry_run/BUILD.bazel @@ -0,0 +1,67 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") +load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library") +load("//:common.bzl", "use_new_compilers") + +#Copyright 2021 Google LLC +# +# 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 +# +# https://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. + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +use_new_compilers() + +proto_library( + name = "dry_run_proto", + srcs = ["dry_run.proto"], + deps = [ + "//types:types_proto", + "@com_github_openconfig_gnmi//proto/gnmi:gnmi_proto", + ], +) + +cc_proto_library( + name = "dry_run_cc_proto", + deps = [":dry_run_proto"], +) + +cc_grpc_library( + name = "dry_run_cc_grpc_proto", + srcs = [":dry_run_proto"], + grpc_only = True, + deps = [":dry_run_cc_proto"], +) + +go_proto_library( + name = "dry_run_go_proto", + compilers = [ + "go_protoc_gen_go", + "go_protoc_gen_go_grpc", + ], + importpath = "github.com/openconfig/gnoi/dry_run", + proto = ":dry_run_proto", + deps = [ + "//types", + "@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", + ], +) + +go_library( + name = "dry_run", + embed = [":dry_run_go_proto"], + importpath = "github.com/openconfig/gnoi/dry_run", +) diff --git a/dry_run/dry_run.pb.go b/dry_run/dry_run.pb.go new file mode 100644 index 0000000..50ff1d9 --- /dev/null +++ b/dry_run/dry_run.pb.go @@ -0,0 +1,379 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.21.10 +// source: dry_run/dry_run.proto + +package dry_run + +import ( + gnmi "github.com/openconfig/gnmi/proto/gnmi" + _ "github.com/openconfig/gnoi/types" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type CompareRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + In *gnmi.SetRequest `protobuf:"bytes,1,opt,name=in,proto3" json:"in,omitempty"` +} + +func (x *CompareRequest) Reset() { + *x = CompareRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_dry_run_dry_run_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CompareRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CompareRequest) ProtoMessage() {} + +func (x *CompareRequest) ProtoReflect() protoreflect.Message { + mi := &file_dry_run_dry_run_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CompareRequest.ProtoReflect.Descriptor instead. +func (*CompareRequest) Descriptor() ([]byte, []int) { + return file_dry_run_dry_run_proto_rawDescGZIP(), []int{0} +} + +func (x *CompareRequest) GetIn() *gnmi.SetRequest { + if x != nil { + return x.In + } + return nil +} + +type CompareResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Diffs []*Diff `protobuf:"bytes,1,rep,name=diffs,proto3" json:"diffs,omitempty"` +} + +func (x *CompareResponse) Reset() { + *x = CompareResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_dry_run_dry_run_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CompareResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CompareResponse) ProtoMessage() {} + +func (x *CompareResponse) ProtoReflect() protoreflect.Message { + mi := &file_dry_run_dry_run_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CompareResponse.ProtoReflect.Descriptor instead. +func (*CompareResponse) Descriptor() ([]byte, []int) { + return file_dry_run_dry_run_proto_rawDescGZIP(), []int{1} +} + +func (x *CompareResponse) GetDiffs() []*Diff { + if x != nil { + return x.Diffs + } + return nil +} + +type Diff struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Path: + // + // *Diff_Added + // *Diff_Removed + // *Diff_Modified + // *Diff_Diff + Path isDiff_Path `protobuf_oneof:"path"` + Msg string `protobuf:"bytes,100,opt,name=msg,proto3" json:"msg,omitempty"` +} + +func (x *Diff) Reset() { + *x = Diff{} + if protoimpl.UnsafeEnabled { + mi := &file_dry_run_dry_run_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Diff) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Diff) ProtoMessage() {} + +func (x *Diff) ProtoReflect() protoreflect.Message { + mi := &file_dry_run_dry_run_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Diff.ProtoReflect.Descriptor instead. +func (*Diff) Descriptor() ([]byte, []int) { + return file_dry_run_dry_run_proto_rawDescGZIP(), []int{2} +} + +func (m *Diff) GetPath() isDiff_Path { + if m != nil { + return m.Path + } + return nil +} + +func (x *Diff) GetAdded() *gnmi.Path { + if x, ok := x.GetPath().(*Diff_Added); ok { + return x.Added + } + return nil +} + +func (x *Diff) GetRemoved() *gnmi.Path { + if x, ok := x.GetPath().(*Diff_Removed); ok { + return x.Removed + } + return nil +} + +func (x *Diff) GetModified() *gnmi.Path { + if x, ok := x.GetPath().(*Diff_Modified); ok { + return x.Modified + } + return nil +} + +func (x *Diff) GetDiff() []byte { + if x, ok := x.GetPath().(*Diff_Diff); ok { + return x.Diff + } + return nil +} + +func (x *Diff) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +type isDiff_Path interface { + isDiff_Path() +} + +type Diff_Added struct { + Added *gnmi.Path `protobuf:"bytes,1,opt,name=added,proto3,oneof"` +} + +type Diff_Removed struct { + Removed *gnmi.Path `protobuf:"bytes,2,opt,name=removed,proto3,oneof"` +} + +type Diff_Modified struct { + Modified *gnmi.Path `protobuf:"bytes,3,opt,name=modified,proto3,oneof"` +} + +type Diff_Diff struct { + Diff []byte `protobuf:"bytes,4,opt,name=diff,proto3,oneof"` +} + +func (*Diff_Added) isDiff_Path() {} + +func (*Diff_Removed) isDiff_Path() {} + +func (*Diff_Modified) isDiff_Path() {} + +func (*Diff_Diff) isDiff_Path() {} + +var File_dry_run_dry_run_proto protoreflect.FileDescriptor + +var file_dry_run_dry_run_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x64, 0x72, 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x2f, 0x64, 0x72, 0x79, 0x5f, 0x72, 0x75, + 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x67, 0x6e, 0x6f, 0x69, 0x2e, 0x64, 0x72, + 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x1a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x67, 0x6e, 0x6d, + 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6e, 0x6d, 0x69, 0x2f, 0x67, 0x6e, 0x6d, + 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x67, + 0x6e, 0x6f, 0x69, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x32, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x67, 0x6e, 0x6d, 0x69, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x02, 0x69, 0x6e, 0x22, 0x3b, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, + 0x70, 0x61, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x05, + 0x64, 0x69, 0x66, 0x66, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6e, + 0x6f, 0x69, 0x2e, 0x64, 0x72, 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x52, + 0x05, 0x64, 0x69, 0x66, 0x66, 0x73, 0x22, 0xac, 0x01, 0x0a, 0x04, 0x44, 0x69, 0x66, 0x66, 0x12, + 0x22, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, + 0x2e, 0x67, 0x6e, 0x6d, 0x69, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x48, 0x00, 0x52, 0x05, 0x61, 0x64, + 0x64, 0x65, 0x64, 0x12, 0x26, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x67, 0x6e, 0x6d, 0x69, 0x2e, 0x50, 0x61, 0x74, 0x68, + 0x48, 0x00, 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x12, 0x28, 0x0a, 0x08, 0x6d, + 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, + 0x67, 0x6e, 0x6d, 0x69, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x48, 0x00, 0x52, 0x08, 0x6d, 0x6f, 0x64, + 0x69, 0x66, 0x69, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x04, 0x64, 0x69, 0x66, 0x66, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x04, 0x64, 0x69, 0x66, 0x66, 0x12, 0x10, 0x0a, 0x03, 0x6d, + 0x73, 0x67, 0x18, 0x64, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x42, 0x06, 0x0a, + 0x04, 0x70, 0x61, 0x74, 0x68, 0x32, 0x54, 0x0a, 0x06, 0x44, 0x72, 0x79, 0x52, 0x75, 0x6e, 0x12, + 0x4a, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x12, 0x1c, 0x2e, 0x67, 0x6e, 0x6f, + 0x69, 0x2e, 0x64, 0x72, 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6e, 0x6f, 0x69, 0x2e, + 0x64, 0x72, 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, 0x2c, 0xd2, 0x3e, 0x05, + 0x30, 0x2e, 0x31, 0x2e, 0x30, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x67, 0x6e, 0x6f, + 0x69, 0x2f, 0x64, 0x72, 0x79, 0x5f, 0x72, 0x75, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_dry_run_dry_run_proto_rawDescOnce sync.Once + file_dry_run_dry_run_proto_rawDescData = file_dry_run_dry_run_proto_rawDesc +) + +func file_dry_run_dry_run_proto_rawDescGZIP() []byte { + file_dry_run_dry_run_proto_rawDescOnce.Do(func() { + file_dry_run_dry_run_proto_rawDescData = protoimpl.X.CompressGZIP(file_dry_run_dry_run_proto_rawDescData) + }) + return file_dry_run_dry_run_proto_rawDescData +} + +var file_dry_run_dry_run_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_dry_run_dry_run_proto_goTypes = []interface{}{ + (*CompareRequest)(nil), // 0: gnoi.dry_run.CompareRequest + (*CompareResponse)(nil), // 1: gnoi.dry_run.CompareResponse + (*Diff)(nil), // 2: gnoi.dry_run.Diff + (*gnmi.SetRequest)(nil), // 3: gnmi.SetRequest + (*gnmi.Path)(nil), // 4: gnmi.Path +} +var file_dry_run_dry_run_proto_depIdxs = []int32{ + 3, // 0: gnoi.dry_run.CompareRequest.in:type_name -> gnmi.SetRequest + 2, // 1: gnoi.dry_run.CompareResponse.diffs:type_name -> gnoi.dry_run.Diff + 4, // 2: gnoi.dry_run.Diff.added:type_name -> gnmi.Path + 4, // 3: gnoi.dry_run.Diff.removed:type_name -> gnmi.Path + 4, // 4: gnoi.dry_run.Diff.modified:type_name -> gnmi.Path + 0, // 5: gnoi.dry_run.DryRun.Compare:input_type -> gnoi.dry_run.CompareRequest + 1, // 6: gnoi.dry_run.DryRun.Compare:output_type -> gnoi.dry_run.CompareResponse + 6, // [6:7] is the sub-list for method output_type + 5, // [5:6] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_dry_run_dry_run_proto_init() } +func file_dry_run_dry_run_proto_init() { + if File_dry_run_dry_run_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_dry_run_dry_run_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CompareRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dry_run_dry_run_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CompareResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dry_run_dry_run_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Diff); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_dry_run_dry_run_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*Diff_Added)(nil), + (*Diff_Removed)(nil), + (*Diff_Modified)(nil), + (*Diff_Diff)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_dry_run_dry_run_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_dry_run_dry_run_proto_goTypes, + DependencyIndexes: file_dry_run_dry_run_proto_depIdxs, + MessageInfos: file_dry_run_dry_run_proto_msgTypes, + }.Build() + File_dry_run_dry_run_proto = out.File + file_dry_run_dry_run_proto_rawDesc = nil + file_dry_run_dry_run_proto_goTypes = nil + file_dry_run_dry_run_proto_depIdxs = nil +} diff --git a/dry_run/dry_run.proto b/dry_run/dry_run.proto new file mode 100644 index 0000000..5a358fd --- /dev/null +++ b/dry_run/dry_run.proto @@ -0,0 +1,76 @@ +// +// Copyright 2019 Google LLC. All Rights Reserved. +// +// 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 gnoi.dry_run; + +import "github.com/openconfig/gnmi/proto/gnmi/gnmi.proto"; +import "github.com/openconfig/gnoi/types/types.proto"; + +option go_package = "github.com/openconfig/gnoi/dry_run"; +option (types.gnoi_version) = "0.1.0"; + +service DryRun { + // Compare performs a comparison of the two configurations. + // One of the configurations will be provided as a gNMI SetRequest. + // This will be compared against a configuration that is already on + // the device. The device will return differences found between the + // two configurations. The response must describe every difference + // between the two configurations regardless of the datastore in which + // they reside. If no differences are found, this indicates that sending + // the gNMI SetRequest would result in no changes to the device. + // Most importantly, this RPC must NEVER result in configuration changes + // on the device. + rpc Compare(CompareRequest) returns (stream CompareResponse) {} +} + +message CompareRequest { + // The configuration that is to be compared against a configuration + // already on the device. + gnmi.SetRequest in = 1; +} + +message CompareResponse { + // The differences found between the two configurations. + repeated Diff diffs = 1; +} + +message Diff { + // The path to the configuration that is different. This path may be an + // OpenConfig path or a vendor native path. Alternatively, the path may + // be empty if the difference cannot be mapped to a specific path. In this + // case, the message field must contain enough details to discern what + // is different. Another alternative if the diff is not reasonably able + // to be represented on a granular level is to generically provide the diff + // as bytes. For example, a path with origin CLI would use the diff field to + // return any added, removed or modified content. + + oneof path { + gnmi.Path added = 1; + gnmi.Path removed = 2; + gnmi.Path modified = 3; + bytes diff = 4; + } + + // A human readable message describing the difference in more detail + // if useful. Generally, this will be most useful when the path is empty + // or for a modified path. + // Examples: + // Empty Path: "'config foo bar' was changed to 'config foo baz'" + // Modified Path: "Value changed from bar to baz" + string msg = 100; +} diff --git a/dry_run/dry_run_grpc.pb.go b/dry_run/dry_run_grpc.pb.go new file mode 100644 index 0000000..0dce965 --- /dev/null +++ b/dry_run/dry_run_grpc.pb.go @@ -0,0 +1,132 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.10 +// source: dry_run/dry_run.proto + +package dry_run + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// DryRunClient is the client API for DryRun service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type DryRunClient interface { + Compare(ctx context.Context, in *CompareRequest, opts ...grpc.CallOption) (DryRun_CompareClient, error) +} + +type dryRunClient struct { + cc grpc.ClientConnInterface +} + +func NewDryRunClient(cc grpc.ClientConnInterface) DryRunClient { + return &dryRunClient{cc} +} + +func (c *dryRunClient) Compare(ctx context.Context, in *CompareRequest, opts ...grpc.CallOption) (DryRun_CompareClient, error) { + stream, err := c.cc.NewStream(ctx, &DryRun_ServiceDesc.Streams[0], "/gnoi.dry_run.DryRun/Compare", opts...) + if err != nil { + return nil, err + } + x := &dryRunCompareClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type DryRun_CompareClient interface { + Recv() (*CompareResponse, error) + grpc.ClientStream +} + +type dryRunCompareClient struct { + grpc.ClientStream +} + +func (x *dryRunCompareClient) Recv() (*CompareResponse, error) { + m := new(CompareResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// DryRunServer is the server API for DryRun service. +// All implementations must embed UnimplementedDryRunServer +// for forward compatibility +type DryRunServer interface { + Compare(*CompareRequest, DryRun_CompareServer) error + mustEmbedUnimplementedDryRunServer() +} + +// UnimplementedDryRunServer must be embedded to have forward compatible implementations. +type UnimplementedDryRunServer struct { +} + +func (UnimplementedDryRunServer) Compare(*CompareRequest, DryRun_CompareServer) error { + return status.Errorf(codes.Unimplemented, "method Compare not implemented") +} +func (UnimplementedDryRunServer) mustEmbedUnimplementedDryRunServer() {} + +// UnsafeDryRunServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to DryRunServer will +// result in compilation errors. +type UnsafeDryRunServer interface { + mustEmbedUnimplementedDryRunServer() +} + +func RegisterDryRunServer(s grpc.ServiceRegistrar, srv DryRunServer) { + s.RegisterService(&DryRun_ServiceDesc, srv) +} + +func _DryRun_Compare_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(CompareRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(DryRunServer).Compare(m, &dryRunCompareServer{stream}) +} + +type DryRun_CompareServer interface { + Send(*CompareResponse) error + grpc.ServerStream +} + +type dryRunCompareServer struct { + grpc.ServerStream +} + +func (x *dryRunCompareServer) Send(m *CompareResponse) error { + return x.ServerStream.SendMsg(m) +} + +// DryRun_ServiceDesc is the grpc.ServiceDesc for DryRun service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var DryRun_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "gnoi.dry_run.DryRun", + HandlerType: (*DryRunServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Compare", + Handler: _DryRun_Compare_Handler, + ServerStreams: true, + }, + }, + Metadata: "dry_run/dry_run.proto", +} diff --git a/go.mod b/go.mod index 1bddaf0..d207554 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.21 require ( github.com/golang/protobuf v1.5.4 github.com/openconfig/bootz v0.3.1 + github.com/openconfig/gnmi v0.10.0 github.com/openconfig/gnsi v1.6.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 google.golang.org/grpc v1.65.0 @@ -12,7 +13,6 @@ require ( ) require ( - github.com/openconfig/gnmi v0.10.0 // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect diff --git a/regenerate-files.sh b/regenerate-files.sh index a23fc1d..df8a4bb 100755 --- a/regenerate-files.sh +++ b/regenerate-files.sh @@ -30,6 +30,8 @@ bazel build //debug:all copy_generated "debug" bazel build //diag:all copy_generated "diag" +bazel build //dry_run:all +copy_generated "dry_run" bazel build //factory_reset:all copy_generated "factory_reset" bazel build //file:all