From c092fa708ccb0ca72b9a548d6d31714d91ae8c27 Mon Sep 17 00:00:00 2001 From: Benjamin Evenson <2031163+benjiro@users.noreply.github.com> Date: Sun, 30 Oct 2022 21:40:23 +1000 Subject: [PATCH 01/14] feat: implement the flagd provider Signed-off-by: Benjamin Evenson <2031163+benjiro@users.noreply.github.com> Signed-off-by: Florian Bacher --- .gitmodules | 3 + build/Common.tests.props | 4 +- .../FlagdProvider.cs | 225 ++ ...OpenFeature.Contrib.Providers.Flagd.csproj | 43 +- .../Proto/csharp/Schema.cs | 2943 +++++++++++++++++ .../Proto/csharp/SchemaGrpc.cs | 348 ++ .../Stub.cs | 18 - .../schemas | 1 + .../UnitTest1.cs | 4 +- 9 files changed, 3551 insertions(+), 38 deletions(-) create mode 100644 .gitmodules create mode 100644 src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs create mode 100644 src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/Schema.cs create mode 100644 src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/SchemaGrpc.cs delete mode 100644 src/OpenFeature.Contrib.Providers.Flagd/Stub.cs create mode 160000 src/OpenFeature.Contrib.Providers.Flagd/schemas diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..fab85575 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/OpenFeature.Contrib.Providers.Flagd/schemas"] + path = src/OpenFeature.Contrib.Providers.Flagd/schemas + url = git@github.com:open-feature/schemas.git diff --git a/build/Common.tests.props b/build/Common.tests.props index 80191fca..71b4578e 100644 --- a/build/Common.tests.props +++ b/build/Common.tests.props @@ -45,8 +45,8 @@ [4.17.0] [3.1.2] [6.7.0] - [17.2.0] - [4.18.1] + [17.3.2] + [4.18.2] [2.4.3,3.0) [2.4.1,3.0) diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs new file mode 100644 index 00000000..dd11a06d --- /dev/null +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -0,0 +1,225 @@ +using System; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using Google.Protobuf.WellKnownTypes; +using Grpc.Net.Client; +using OpenFeature.Model; +using Schema.V1; +using Value = OpenFeature.Model.Value; +using ProtoValue = Google.Protobuf.WellKnownTypes.Value; + +namespace OpenFeature.Contrib.Providers.Flagd +{ + /// + /// A stub class. + /// + public sealed class FlagdProvider : FeatureProvider + { + private readonly Service.ServiceClient _client; + private readonly Metadata _providerMetadata = new Metadata("flagD Provider"); + + public FlagdProvider(Uri url) + { + if (url == null) + { + throw new ArgumentNullException(nameof(url)); + } + +#if NETSTANDARD2_0 + _client = new Service.ServiceClient(GrpcChannel.ForAddress(url)); +#else + _client = new Service.ServiceClient(GrpcChannel.ForAddress(url, new GrpcChannelOptions + { + HttpHandler = new WinHttpHandler() + })); +#endif + } + + /// + /// Get the provider name. + /// + public static string GetProviderName() + { + return Api.Instance.GetProviderMetadata().Name; + } + + public override Metadata GetMetadata() => _providerMetadata; + + public override async Task> ResolveBooleanValue(string flagKey, bool defaultValue, EvaluationContext context = null) + { + var resolveBooleanResponse = await _client.ResolveBooleanAsync(new ResolveBooleanRequest + { + Context = ConvertToContext(context), + FlagKey = flagKey + }); + + return new ResolutionDetails( + flagKey: flagKey, + value: resolveBooleanResponse.Value, + reason: resolveBooleanResponse.Reason, + variant: resolveBooleanResponse.Variant + ); + } + + public override async Task> ResolveStringValue(string flagKey, string defaultValue, EvaluationContext context = null) + { + var resolveBooleanResponse = await _client.ResolveStringAsync(new ResolveStringRequest + { + Context = ConvertToContext(context), + FlagKey = flagKey + }); + + return new ResolutionDetails( + flagKey: flagKey, + value: resolveBooleanResponse.Value, + reason: resolveBooleanResponse.Reason, + variant: resolveBooleanResponse.Variant + ); + } + + public override async Task> ResolveIntegerValue(string flagKey, int defaultValue, EvaluationContext context = null) + { + var resolveIntResponse = await _client.ResolveIntAsync(new ResolveIntRequest + { + Context = ConvertToContext(context), + FlagKey = flagKey + }); + + return new ResolutionDetails( + flagKey: flagKey, + value: (int)resolveIntResponse.Value, + reason: resolveIntResponse.Reason, + variant: resolveIntResponse.Variant + ); + } + + public override async Task> ResolveDoubleValue(string flagKey, double defaultValue, EvaluationContext context = null) + { + var resolveDoubleResponse = await _client.ResolveFloatAsync(new ResolveFloatRequest + { + Context = ConvertToContext(context), + FlagKey = flagKey + }); + + return new ResolutionDetails( + flagKey: flagKey, + value: resolveDoubleResponse.Value, + reason: resolveDoubleResponse.Reason, + variant: resolveDoubleResponse.Variant + ); + } + + public override async Task> ResolveStructureValue(string flagKey, Value defaultValue, EvaluationContext context = null) + { + var resolveObjectResponse = await _client.ResolveObjectAsync(new ResolveObjectRequest + { + Context = ConvertToContext(context), + FlagKey = flagKey + }); + + return new ResolutionDetails( + flagKey: flagKey, + value: ConvertObjectToValue(resolveObjectResponse.Value), + reason: resolveObjectResponse.Reason, + variant: resolveObjectResponse.Variant + ); + } + + private static Struct ConvertToContext(EvaluationContext ctx) + { + if (ctx == null) + { + return new Struct(); + } + + var values = new Struct(); + foreach (var entry in ctx) + { + values.Fields.Add(entry.Key, ConvertToProtoValue(entry.Value)); + } + + return values; + } + + private static ProtoValue ConvertToProtoValue(Value value) + { + if (value.IsList) + { + return ProtoValue.ForList(value.AsList.Select(ConvertToProtoValue).ToArray()); + } + + if (value.IsStructure) + { + var values = new Struct(); + + foreach (var entry in value.AsStructure) + { + values.Fields.Add(entry.Key, ConvertToProtoValue(entry.Value)); + } + + return ProtoValue.ForStruct(values); + } + + if (value.IsBoolean) + { + return ProtoValue.ForBool(value.AsBoolean ?? false); + } + + if (value.IsString) + { + return ProtoValue.ForString(value.AsString); + } + + if (value.IsNumber) + { + return ProtoValue.ForNumber(value.AsDouble ?? 0.0); + } + + return ProtoValue.ForNull(); + } + + private static Value ConvertObjectToValue(Struct src) => + new Value(new Structure(src.Fields + .ToDictionary(entry => entry.Key, entry => ConvertToValue(entry.Value)))); + + private static Value ConvertToValue(ProtoValue src) + { + switch (src.KindCase) + { + case ProtoValue.KindOneofCase.ListValue: + return new Value(src.ListValue.Values.Select(ConvertToValue).ToList()); + case ProtoValue.KindOneofCase.StructValue: + return new Value(ConvertObjectToValue(src.StructValue)); + case ProtoValue.KindOneofCase.None: + case ProtoValue.KindOneofCase.NullValue: + case ProtoValue.KindOneofCase.NumberValue: + case ProtoValue.KindOneofCase.StringValue: + case ProtoValue.KindOneofCase.BoolValue: + default: + return ConvertToPrimitiveValue(src); + } + } + + private static Value ConvertToPrimitiveValue(ProtoValue value) + { + switch (value.KindCase) + { + case ProtoValue.KindOneofCase.BoolValue: + return new Value(value.BoolValue); + case ProtoValue.KindOneofCase.StringValue: + return new Value(value.StringValue); + case ProtoValue.KindOneofCase.NumberValue: + return new Value(value.NumberValue); + case ProtoValue.KindOneofCase.NullValue: + case ProtoValue.KindOneofCase.StructValue: + case ProtoValue.KindOneofCase.ListValue: + case ProtoValue.KindOneofCase.None: + default: + return new Value(); + } + } + } +} + + diff --git a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj index 7f17a553..eb777fc5 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj +++ b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj @@ -1,15 +1,28 @@ - - - - OpenFeature.Contrib.Providers.Flagd - 0.1.0 - $(VersionNumber) - $(VersionNumber) - $(VersionNumber) - flagd provider for .NET - https://openfeature.dev - https://github.com/open-feature/dotnet-sdk-contrib - Todd Baert - - - + + + + OpenFeature.Providers.Flagd + 0.0.2 + $(VersionNumber) + $(VersionNumber) + $(VersionNumber) + flagd provider for .NET + https://openfeature.dev + https://github.com/open-feature/dotnet-sdk-contrib + Todd Baert + + + + + + + + + + + + + + + + diff --git a/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/Schema.cs b/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/Schema.cs new file mode 100644 index 00000000..d6e4322d --- /dev/null +++ b/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/Schema.cs @@ -0,0 +1,2943 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: schema/v1/schema.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Schema.V1 { + + /// Holder for reflection information generated from schema/v1/schema.proto + public static partial class SchemaReflection { + + #region Descriptor + /// File descriptor for schema/v1/schema.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static SchemaReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChZzY2hlbWEvdjEvc2NoZW1hLnByb3RvEglzY2hlbWEudjEaHGdvb2dsZS9w", + "cm90b2J1Zi9zdHJ1Y3QucHJvdG8aG2dvb2dsZS9wcm90b2J1Zi9lbXB0eS5w", + "cm90byJlChVSZXNvbHZlQm9vbGVhblJlcXVlc3QSGQoIZmxhZ19rZXkYASAB", + "KAlSB2ZsYWdLZXkSMQoHY29udGV4dBgCIAEoCzIXLmdvb2dsZS5wcm90b2J1", + "Zi5TdHJ1Y3RSB2NvbnRleHQiYAoWUmVzb2x2ZUJvb2xlYW5SZXNwb25zZRIU", + "CgV2YWx1ZRgBIAEoCFIFdmFsdWUSFgoGcmVhc29uGAIgASgJUgZyZWFzb24S", + "GAoHdmFyaWFudBgDIAEoCVIHdmFyaWFudCJkChRSZXNvbHZlU3RyaW5nUmVx", + "dWVzdBIZCghmbGFnX2tleRgBIAEoCVIHZmxhZ0tleRIxCgdjb250ZXh0GAIg", + "ASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdFIHY29udGV4dCJfChVSZXNv", + "bHZlU3RyaW5nUmVzcG9uc2USFAoFdmFsdWUYASABKAlSBXZhbHVlEhYKBnJl", + "YXNvbhgCIAEoCVIGcmVhc29uEhgKB3ZhcmlhbnQYAyABKAlSB3ZhcmlhbnQi", + "YwoTUmVzb2x2ZUZsb2F0UmVxdWVzdBIZCghmbGFnX2tleRgBIAEoCVIHZmxh", + "Z0tleRIxCgdjb250ZXh0GAIgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVj", + "dFIHY29udGV4dCJeChRSZXNvbHZlRmxvYXRSZXNwb25zZRIUCgV2YWx1ZRgB", + "IAEoAVIFdmFsdWUSFgoGcmVhc29uGAIgASgJUgZyZWFzb24SGAoHdmFyaWFu", + "dBgDIAEoCVIHdmFyaWFudCJhChFSZXNvbHZlSW50UmVxdWVzdBIZCghmbGFn", + "X2tleRgBIAEoCVIHZmxhZ0tleRIxCgdjb250ZXh0GAIgASgLMhcuZ29vZ2xl", + "LnByb3RvYnVmLlN0cnVjdFIHY29udGV4dCJcChJSZXNvbHZlSW50UmVzcG9u", + "c2USFAoFdmFsdWUYASABKANSBXZhbHVlEhYKBnJlYXNvbhgCIAEoCVIGcmVh", + "c29uEhgKB3ZhcmlhbnQYAyABKAlSB3ZhcmlhbnQiZAoUUmVzb2x2ZU9iamVj", + "dFJlcXVlc3QSGQoIZmxhZ19rZXkYASABKAlSB2ZsYWdLZXkSMQoHY29udGV4", + "dBgCIAEoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3RSB2NvbnRleHQieAoV", + "UmVzb2x2ZU9iamVjdFJlc3BvbnNlEi0KBXZhbHVlGAEgASgLMhcuZ29vZ2xl", + "LnByb3RvYnVmLlN0cnVjdFIFdmFsdWUSFgoGcmVhc29uGAIgASgJUgZyZWFz", + "b24SGAoHdmFyaWFudBgDIAEoCVIHdmFyaWFudCJWChNFdmVudFN0cmVhbVJl", + "c3BvbnNlEhIKBHR5cGUYASABKAlSBHR5cGUSKwoEZGF0YRgCIAEoCzIXLmdv", + "b2dsZS5wcm90b2J1Zi5TdHJ1Y3RSBGRhdGEy+QMKB1NlcnZpY2USVwoOUmVz", + "b2x2ZUJvb2xlYW4SIC5zY2hlbWEudjEuUmVzb2x2ZUJvb2xlYW5SZXF1ZXN0", + "GiEuc2NoZW1hLnYxLlJlc29sdmVCb29sZWFuUmVzcG9uc2UiABJUCg1SZXNv", + "bHZlU3RyaW5nEh8uc2NoZW1hLnYxLlJlc29sdmVTdHJpbmdSZXF1ZXN0GiAu", + "c2NoZW1hLnYxLlJlc29sdmVTdHJpbmdSZXNwb25zZSIAElEKDFJlc29sdmVG", + "bG9hdBIeLnNjaGVtYS52MS5SZXNvbHZlRmxvYXRSZXF1ZXN0Gh8uc2NoZW1h", + "LnYxLlJlc29sdmVGbG9hdFJlc3BvbnNlIgASSwoKUmVzb2x2ZUludBIcLnNj", + "aGVtYS52MS5SZXNvbHZlSW50UmVxdWVzdBodLnNjaGVtYS52MS5SZXNvbHZl", + "SW50UmVzcG9uc2UiABJUCg1SZXNvbHZlT2JqZWN0Eh8uc2NoZW1hLnYxLlJl", + "c29sdmVPYmplY3RSZXF1ZXN0GiAuc2NoZW1hLnYxLlJlc29sdmVPYmplY3RS", + "ZXNwb25zZSIAEkkKC0V2ZW50U3RyZWFtEhYuZ29vZ2xlLnByb3RvYnVmLkVt", + "cHR5Gh4uc2NoZW1hLnYxLkV2ZW50U3RyZWFtUmVzcG9uc2UiADABQnQKDWNv", + "bS5zY2hlbWEudjFCC1NjaGVtYVByb3RvUAFaEXNjaGVtYS9zZXJ2aWNlL3Yx", + "ogIDU1hYqgIJU2NoZW1hLlYxygIJU2NoZW1hXFYx4gIVU2NoZW1hXFYxXEdQ", + "Qk1ldGFkYXRh6gIKU2NoZW1hOjpWMWIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.EmptyReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveBooleanRequest), global::Schema.V1.ResolveBooleanRequest.Parser, new[]{ "FlagKey", "Context" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveBooleanResponse), global::Schema.V1.ResolveBooleanResponse.Parser, new[]{ "Value", "Reason", "Variant" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveStringRequest), global::Schema.V1.ResolveStringRequest.Parser, new[]{ "FlagKey", "Context" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveStringResponse), global::Schema.V1.ResolveStringResponse.Parser, new[]{ "Value", "Reason", "Variant" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveFloatRequest), global::Schema.V1.ResolveFloatRequest.Parser, new[]{ "FlagKey", "Context" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveFloatResponse), global::Schema.V1.ResolveFloatResponse.Parser, new[]{ "Value", "Reason", "Variant" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveIntRequest), global::Schema.V1.ResolveIntRequest.Parser, new[]{ "FlagKey", "Context" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveIntResponse), global::Schema.V1.ResolveIntResponse.Parser, new[]{ "Value", "Reason", "Variant" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveObjectRequest), global::Schema.V1.ResolveObjectRequest.Parser, new[]{ "FlagKey", "Context" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveObjectResponse), global::Schema.V1.ResolveObjectResponse.Parser, new[]{ "Value", "Reason", "Variant" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.EventStreamResponse), global::Schema.V1.EventStreamResponse.Parser, new[]{ "Type", "Data" }, null, null, null, null) + })); + } + #endregion + + } + #region Messages + /// + /// Request body for boolean flag evaluation, used by the ResolveBoolean rpc. + /// + public sealed partial class ResolveBooleanRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveBooleanRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveBooleanRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveBooleanRequest(ResolveBooleanRequest other) : this() { + flagKey_ = other.flagKey_; + context_ = other.context_ != null ? other.context_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveBooleanRequest Clone() { + return new ResolveBooleanRequest(this); + } + + /// Field number for the "flag_key" field. + public const int FlagKeyFieldNumber = 1; + private string flagKey_ = ""; + /// + /// Flag key of the requested flag. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string FlagKey { + get { return flagKey_; } + set { + flagKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "context" field. + public const int ContextFieldNumber = 2; + private global::Google.Protobuf.WellKnownTypes.Struct context_; + /// + /// Object structure describing the EvaluationContext used in the flag evaluation, see https://docs.openfeature.dev/docs/reference/concepts/evaluation-context + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Google.Protobuf.WellKnownTypes.Struct Context { + get { return context_; } + set { + context_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as ResolveBooleanRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(ResolveBooleanRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (FlagKey != other.FlagKey) return false; + if (!object.Equals(Context, other.Context)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (FlagKey.Length != 0) hash ^= FlagKey.GetHashCode(); + if (context_ != null) hash ^= Context.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (FlagKey.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FlagKey); + } + if (context_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Context); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (FlagKey.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FlagKey); + } + if (context_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Context); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (FlagKey.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FlagKey); + } + if (context_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(ResolveBooleanRequest other) { + if (other == null) { + return; + } + if (other.FlagKey.Length != 0) { + FlagKey = other.FlagKey; + } + if (other.context_ != null) { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + Context.MergeFrom(other.Context); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + FlagKey = input.ReadString(); + break; + } + case 18: { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Context); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + FlagKey = input.ReadString(); + break; + } + case 18: { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Context); + break; + } + } + } + } + #endif + + } + + /// + /// Response body for boolean flag evaluation. used by the ResolveBoolean rpc. + /// + public sealed partial class ResolveBooleanResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveBooleanResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveBooleanResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveBooleanResponse(ResolveBooleanResponse other) : this() { + value_ = other.value_; + reason_ = other.reason_; + variant_ = other.variant_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveBooleanResponse Clone() { + return new ResolveBooleanResponse(this); + } + + /// Field number for the "value" field. + public const int ValueFieldNumber = 1; + private bool value_; + /// + /// The response value of the boolean flag evaluation, will be unset in the case of error. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Value { + get { return value_; } + set { + value_ = value; + } + } + + /// Field number for the "reason" field. + public const int ReasonFieldNumber = 2; + private string reason_ = ""; + /// + /// The reason for the given return value, see https://docs.openfeature.dev/docs/specification/types#resolution-details + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Reason { + get { return reason_; } + set { + reason_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "variant" field. + public const int VariantFieldNumber = 3; + private string variant_ = ""; + /// + /// The variant name of the returned flag value. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Variant { + get { return variant_; } + set { + variant_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as ResolveBooleanResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(ResolveBooleanResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + if (Reason != other.Reason) return false; + if (Variant != other.Variant) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (Value != false) hash ^= Value.GetHashCode(); + if (Reason.Length != 0) hash ^= Reason.GetHashCode(); + if (Variant.Length != 0) hash ^= Variant.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (Value != false) { + output.WriteRawTag(8); + output.WriteBool(Value); + } + if (Reason.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Reason); + } + if (Variant.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Variant); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (Value != false) { + output.WriteRawTag(8); + output.WriteBool(Value); + } + if (Reason.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Reason); + } + if (Variant.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Variant); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (Value != false) { + size += 1 + 1; + } + if (Reason.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Reason); + } + if (Variant.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Variant); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(ResolveBooleanResponse other) { + if (other == null) { + return; + } + if (other.Value != false) { + Value = other.Value; + } + if (other.Reason.Length != 0) { + Reason = other.Reason; + } + if (other.Variant.Length != 0) { + Variant = other.Variant; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Value = input.ReadBool(); + break; + } + case 18: { + Reason = input.ReadString(); + break; + } + case 26: { + Variant = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Value = input.ReadBool(); + break; + } + case 18: { + Reason = input.ReadString(); + break; + } + case 26: { + Variant = input.ReadString(); + break; + } + } + } + } + #endif + + } + + /// + /// Request body for string flag evaluation, used by the ResolveString rpc. + /// + public sealed partial class ResolveStringRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveStringRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveStringRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveStringRequest(ResolveStringRequest other) : this() { + flagKey_ = other.flagKey_; + context_ = other.context_ != null ? other.context_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveStringRequest Clone() { + return new ResolveStringRequest(this); + } + + /// Field number for the "flag_key" field. + public const int FlagKeyFieldNumber = 1; + private string flagKey_ = ""; + /// + /// Flag key of the requested flag. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string FlagKey { + get { return flagKey_; } + set { + flagKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "context" field. + public const int ContextFieldNumber = 2; + private global::Google.Protobuf.WellKnownTypes.Struct context_; + /// + /// Object structure describing the EvaluationContext used in the flag evaluation, see https://docs.openfeature.dev/docs/reference/concepts/evaluation-context + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Google.Protobuf.WellKnownTypes.Struct Context { + get { return context_; } + set { + context_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as ResolveStringRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(ResolveStringRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (FlagKey != other.FlagKey) return false; + if (!object.Equals(Context, other.Context)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (FlagKey.Length != 0) hash ^= FlagKey.GetHashCode(); + if (context_ != null) hash ^= Context.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (FlagKey.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FlagKey); + } + if (context_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Context); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (FlagKey.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FlagKey); + } + if (context_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Context); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (FlagKey.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FlagKey); + } + if (context_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(ResolveStringRequest other) { + if (other == null) { + return; + } + if (other.FlagKey.Length != 0) { + FlagKey = other.FlagKey; + } + if (other.context_ != null) { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + Context.MergeFrom(other.Context); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + FlagKey = input.ReadString(); + break; + } + case 18: { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Context); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + FlagKey = input.ReadString(); + break; + } + case 18: { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Context); + break; + } + } + } + } + #endif + + } + + /// + /// Response body for string flag evaluation. used by the ResolveString rpc. + /// + public sealed partial class ResolveStringResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveStringResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveStringResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveStringResponse(ResolveStringResponse other) : this() { + value_ = other.value_; + reason_ = other.reason_; + variant_ = other.variant_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveStringResponse Clone() { + return new ResolveStringResponse(this); + } + + /// Field number for the "value" field. + public const int ValueFieldNumber = 1; + private string value_ = ""; + /// + /// The response value of the string flag evaluation, will be unset in the case of error. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Value { + get { return value_; } + set { + value_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "reason" field. + public const int ReasonFieldNumber = 2; + private string reason_ = ""; + /// + /// The reason for the given return value, see https://docs.openfeature.dev/docs/specification/types#resolution-details + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Reason { + get { return reason_; } + set { + reason_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "variant" field. + public const int VariantFieldNumber = 3; + private string variant_ = ""; + /// + /// The variant name of the returned flag value. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Variant { + get { return variant_; } + set { + variant_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as ResolveStringResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(ResolveStringResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + if (Reason != other.Reason) return false; + if (Variant != other.Variant) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (Value.Length != 0) hash ^= Value.GetHashCode(); + if (Reason.Length != 0) hash ^= Reason.GetHashCode(); + if (Variant.Length != 0) hash ^= Variant.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (Value.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Value); + } + if (Reason.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Reason); + } + if (Variant.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Variant); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (Value.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Value); + } + if (Reason.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Reason); + } + if (Variant.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Variant); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (Value.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Value); + } + if (Reason.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Reason); + } + if (Variant.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Variant); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(ResolveStringResponse other) { + if (other == null) { + return; + } + if (other.Value.Length != 0) { + Value = other.Value; + } + if (other.Reason.Length != 0) { + Reason = other.Reason; + } + if (other.Variant.Length != 0) { + Variant = other.Variant; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Value = input.ReadString(); + break; + } + case 18: { + Reason = input.ReadString(); + break; + } + case 26: { + Variant = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Value = input.ReadString(); + break; + } + case 18: { + Reason = input.ReadString(); + break; + } + case 26: { + Variant = input.ReadString(); + break; + } + } + } + } + #endif + + } + + /// + /// Request body for float flag evaluation, used by the ResolveFloat rpc. + /// + public sealed partial class ResolveFloatRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveFloatRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveFloatRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveFloatRequest(ResolveFloatRequest other) : this() { + flagKey_ = other.flagKey_; + context_ = other.context_ != null ? other.context_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveFloatRequest Clone() { + return new ResolveFloatRequest(this); + } + + /// Field number for the "flag_key" field. + public const int FlagKeyFieldNumber = 1; + private string flagKey_ = ""; + /// + /// Flag key of the requested flag. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string FlagKey { + get { return flagKey_; } + set { + flagKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "context" field. + public const int ContextFieldNumber = 2; + private global::Google.Protobuf.WellKnownTypes.Struct context_; + /// + /// Object structure describing the EvaluationContext used in the flag evaluation, see https://docs.openfeature.dev/docs/reference/concepts/evaluation-context + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Google.Protobuf.WellKnownTypes.Struct Context { + get { return context_; } + set { + context_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as ResolveFloatRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(ResolveFloatRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (FlagKey != other.FlagKey) return false; + if (!object.Equals(Context, other.Context)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (FlagKey.Length != 0) hash ^= FlagKey.GetHashCode(); + if (context_ != null) hash ^= Context.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (FlagKey.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FlagKey); + } + if (context_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Context); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (FlagKey.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FlagKey); + } + if (context_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Context); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (FlagKey.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FlagKey); + } + if (context_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(ResolveFloatRequest other) { + if (other == null) { + return; + } + if (other.FlagKey.Length != 0) { + FlagKey = other.FlagKey; + } + if (other.context_ != null) { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + Context.MergeFrom(other.Context); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + FlagKey = input.ReadString(); + break; + } + case 18: { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Context); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + FlagKey = input.ReadString(); + break; + } + case 18: { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Context); + break; + } + } + } + } + #endif + + } + + /// + /// Response body for float flag evaluation. used by the ResolveFloat rpc. + /// + public sealed partial class ResolveFloatResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveFloatResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveFloatResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveFloatResponse(ResolveFloatResponse other) : this() { + value_ = other.value_; + reason_ = other.reason_; + variant_ = other.variant_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveFloatResponse Clone() { + return new ResolveFloatResponse(this); + } + + /// Field number for the "value" field. + public const int ValueFieldNumber = 1; + private double value_; + /// + /// The response value of the float flag evaluation, will be empty in the case of error. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public double Value { + get { return value_; } + set { + value_ = value; + } + } + + /// Field number for the "reason" field. + public const int ReasonFieldNumber = 2; + private string reason_ = ""; + /// + /// The reason for the given return value, see https://docs.openfeature.dev/docs/specification/types#resolution-details + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Reason { + get { return reason_; } + set { + reason_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "variant" field. + public const int VariantFieldNumber = 3; + private string variant_ = ""; + /// + /// The variant name of the returned flag value. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Variant { + get { return variant_; } + set { + variant_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as ResolveFloatResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(ResolveFloatResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(Value, other.Value)) return false; + if (Reason != other.Reason) return false; + if (Variant != other.Variant) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (Value != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Value); + if (Reason.Length != 0) hash ^= Reason.GetHashCode(); + if (Variant.Length != 0) hash ^= Variant.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (Value != 0D) { + output.WriteRawTag(9); + output.WriteDouble(Value); + } + if (Reason.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Reason); + } + if (Variant.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Variant); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (Value != 0D) { + output.WriteRawTag(9); + output.WriteDouble(Value); + } + if (Reason.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Reason); + } + if (Variant.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Variant); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (Value != 0D) { + size += 1 + 8; + } + if (Reason.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Reason); + } + if (Variant.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Variant); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(ResolveFloatResponse other) { + if (other == null) { + return; + } + if (other.Value != 0D) { + Value = other.Value; + } + if (other.Reason.Length != 0) { + Reason = other.Reason; + } + if (other.Variant.Length != 0) { + Variant = other.Variant; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 9: { + Value = input.ReadDouble(); + break; + } + case 18: { + Reason = input.ReadString(); + break; + } + case 26: { + Variant = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 9: { + Value = input.ReadDouble(); + break; + } + case 18: { + Reason = input.ReadString(); + break; + } + case 26: { + Variant = input.ReadString(); + break; + } + } + } + } + #endif + + } + + /// + /// Request body for int flag evaluation, used by the ResolveInt rpc. + /// + public sealed partial class ResolveIntRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveIntRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[6]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveIntRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveIntRequest(ResolveIntRequest other) : this() { + flagKey_ = other.flagKey_; + context_ = other.context_ != null ? other.context_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveIntRequest Clone() { + return new ResolveIntRequest(this); + } + + /// Field number for the "flag_key" field. + public const int FlagKeyFieldNumber = 1; + private string flagKey_ = ""; + /// + /// Flag key of the requested flag. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string FlagKey { + get { return flagKey_; } + set { + flagKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "context" field. + public const int ContextFieldNumber = 2; + private global::Google.Protobuf.WellKnownTypes.Struct context_; + /// + /// Object structure describing the EvaluationContext used in the flag evaluation, see https://docs.openfeature.dev/docs/reference/concepts/evaluation-context + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Google.Protobuf.WellKnownTypes.Struct Context { + get { return context_; } + set { + context_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as ResolveIntRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(ResolveIntRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (FlagKey != other.FlagKey) return false; + if (!object.Equals(Context, other.Context)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (FlagKey.Length != 0) hash ^= FlagKey.GetHashCode(); + if (context_ != null) hash ^= Context.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (FlagKey.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FlagKey); + } + if (context_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Context); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (FlagKey.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FlagKey); + } + if (context_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Context); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (FlagKey.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FlagKey); + } + if (context_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(ResolveIntRequest other) { + if (other == null) { + return; + } + if (other.FlagKey.Length != 0) { + FlagKey = other.FlagKey; + } + if (other.context_ != null) { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + Context.MergeFrom(other.Context); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + FlagKey = input.ReadString(); + break; + } + case 18: { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Context); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + FlagKey = input.ReadString(); + break; + } + case 18: { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Context); + break; + } + } + } + } + #endif + + } + + /// + /// Response body for int flag evaluation. used by the ResolveInt rpc. + /// + public sealed partial class ResolveIntResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveIntResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[7]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveIntResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveIntResponse(ResolveIntResponse other) : this() { + value_ = other.value_; + reason_ = other.reason_; + variant_ = other.variant_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveIntResponse Clone() { + return new ResolveIntResponse(this); + } + + /// Field number for the "value" field. + public const int ValueFieldNumber = 1; + private long value_; + /// + /// The response value of the int flag evaluation, will be unset in the case of error. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public long Value { + get { return value_; } + set { + value_ = value; + } + } + + /// Field number for the "reason" field. + public const int ReasonFieldNumber = 2; + private string reason_ = ""; + /// + /// The reason for the given return value, see https://docs.openfeature.dev/docs/specification/types#resolution-details + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Reason { + get { return reason_; } + set { + reason_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "variant" field. + public const int VariantFieldNumber = 3; + private string variant_ = ""; + /// + /// The variant name of the returned flag value. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Variant { + get { return variant_; } + set { + variant_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as ResolveIntResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(ResolveIntResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Value != other.Value) return false; + if (Reason != other.Reason) return false; + if (Variant != other.Variant) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (Value != 0L) hash ^= Value.GetHashCode(); + if (Reason.Length != 0) hash ^= Reason.GetHashCode(); + if (Variant.Length != 0) hash ^= Variant.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (Value != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Value); + } + if (Reason.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Reason); + } + if (Variant.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Variant); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (Value != 0L) { + output.WriteRawTag(8); + output.WriteInt64(Value); + } + if (Reason.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Reason); + } + if (Variant.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Variant); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (Value != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Value); + } + if (Reason.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Reason); + } + if (Variant.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Variant); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(ResolveIntResponse other) { + if (other == null) { + return; + } + if (other.Value != 0L) { + Value = other.Value; + } + if (other.Reason.Length != 0) { + Reason = other.Reason; + } + if (other.Variant.Length != 0) { + Variant = other.Variant; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + Value = input.ReadInt64(); + break; + } + case 18: { + Reason = input.ReadString(); + break; + } + case 26: { + Variant = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + Value = input.ReadInt64(); + break; + } + case 18: { + Reason = input.ReadString(); + break; + } + case 26: { + Variant = input.ReadString(); + break; + } + } + } + } + #endif + + } + + /// + /// Request body for object flag evaluation, used by the ResolveObject rpc. + /// + public sealed partial class ResolveObjectRequest : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveObjectRequest()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[8]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveObjectRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveObjectRequest(ResolveObjectRequest other) : this() { + flagKey_ = other.flagKey_; + context_ = other.context_ != null ? other.context_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveObjectRequest Clone() { + return new ResolveObjectRequest(this); + } + + /// Field number for the "flag_key" field. + public const int FlagKeyFieldNumber = 1; + private string flagKey_ = ""; + /// + /// Flag key of the requested flag. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string FlagKey { + get { return flagKey_; } + set { + flagKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "context" field. + public const int ContextFieldNumber = 2; + private global::Google.Protobuf.WellKnownTypes.Struct context_; + /// + /// Object structure describing the EvaluationContext used in the flag evaluation, see https://docs.openfeature.dev/docs/reference/concepts/evaluation-context + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Google.Protobuf.WellKnownTypes.Struct Context { + get { return context_; } + set { + context_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as ResolveObjectRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(ResolveObjectRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (FlagKey != other.FlagKey) return false; + if (!object.Equals(Context, other.Context)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (FlagKey.Length != 0) hash ^= FlagKey.GetHashCode(); + if (context_ != null) hash ^= Context.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (FlagKey.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FlagKey); + } + if (context_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Context); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (FlagKey.Length != 0) { + output.WriteRawTag(10); + output.WriteString(FlagKey); + } + if (context_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Context); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (FlagKey.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(FlagKey); + } + if (context_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(ResolveObjectRequest other) { + if (other == null) { + return; + } + if (other.FlagKey.Length != 0) { + FlagKey = other.FlagKey; + } + if (other.context_ != null) { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + Context.MergeFrom(other.Context); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + FlagKey = input.ReadString(); + break; + } + case 18: { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Context); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + FlagKey = input.ReadString(); + break; + } + case 18: { + if (context_ == null) { + Context = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Context); + break; + } + } + } + } + #endif + + } + + /// + /// Response body for object flag evaluation. used by the ResolveObject rpc. + /// + public sealed partial class ResolveObjectResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveObjectResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[9]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveObjectResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveObjectResponse(ResolveObjectResponse other) : this() { + value_ = other.value_ != null ? other.value_.Clone() : null; + reason_ = other.reason_; + variant_ = other.variant_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public ResolveObjectResponse Clone() { + return new ResolveObjectResponse(this); + } + + /// Field number for the "value" field. + public const int ValueFieldNumber = 1; + private global::Google.Protobuf.WellKnownTypes.Struct value_; + /// + /// The response value of the object flag evaluation, will be unset in the case of error. + /// + /// NOTE: This structure will need to be decoded from google/protobuf/struct.proto before it is returned to the SDK + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Google.Protobuf.WellKnownTypes.Struct Value { + get { return value_; } + set { + value_ = value; + } + } + + /// Field number for the "reason" field. + public const int ReasonFieldNumber = 2; + private string reason_ = ""; + /// + /// The reason for the given return value, see https://docs.openfeature.dev/docs/specification/types#resolution-details + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Reason { + get { return reason_; } + set { + reason_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "variant" field. + public const int VariantFieldNumber = 3; + private string variant_ = ""; + /// + /// The variant name of the returned flag value. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Variant { + get { return variant_; } + set { + variant_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as ResolveObjectResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(ResolveObjectResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Value, other.Value)) return false; + if (Reason != other.Reason) return false; + if (Variant != other.Variant) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (value_ != null) hash ^= Value.GetHashCode(); + if (Reason.Length != 0) hash ^= Reason.GetHashCode(); + if (Variant.Length != 0) hash ^= Variant.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (value_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Value); + } + if (Reason.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Reason); + } + if (Variant.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Variant); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (value_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Value); + } + if (Reason.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Reason); + } + if (Variant.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Variant); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (value_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Value); + } + if (Reason.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Reason); + } + if (Variant.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Variant); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(ResolveObjectResponse other) { + if (other == null) { + return; + } + if (other.value_ != null) { + if (value_ == null) { + Value = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + Value.MergeFrom(other.Value); + } + if (other.Reason.Length != 0) { + Reason = other.Reason; + } + if (other.Variant.Length != 0) { + Variant = other.Variant; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + if (value_ == null) { + Value = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Value); + break; + } + case 18: { + Reason = input.ReadString(); + break; + } + case 26: { + Variant = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (value_ == null) { + Value = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Value); + break; + } + case 18: { + Reason = input.ReadString(); + break; + } + case 26: { + Variant = input.ReadString(); + break; + } + } + } + } + #endif + + } + + /// + /// Response body for the EvenntStream stream response + /// + public sealed partial class EventStreamResponse : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EventStreamResponse()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[10]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public EventStreamResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public EventStreamResponse(EventStreamResponse other) : this() { + type_ = other.type_; + data_ = other.data_ != null ? other.data_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public EventStreamResponse Clone() { + return new EventStreamResponse(this); + } + + /// Field number for the "type" field. + public const int TypeFieldNumber = 1; + private string type_ = ""; + /// + /// String key indicating the type of event that is being received, e.g. provider_ready or configuration_change + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Type { + get { return type_; } + set { + type_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "data" field. + public const int DataFieldNumber = 2; + private global::Google.Protobuf.WellKnownTypes.Struct data_; + /// + /// Object structure for use when sending relevant metadata to provide context to the event. + /// Can be left unset when it is not required. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Google.Protobuf.WellKnownTypes.Struct Data { + get { return data_; } + set { + data_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as EventStreamResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(EventStreamResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Type != other.Type) return false; + if (!object.Equals(Data, other.Data)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (Type.Length != 0) hash ^= Type.GetHashCode(); + if (data_ != null) hash ^= Data.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (Type.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Type); + } + if (data_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (Type.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Type); + } + if (data_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Data); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (Type.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Type); + } + if (data_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Data); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(EventStreamResponse other) { + if (other == null) { + return; + } + if (other.Type.Length != 0) { + Type = other.Type; + } + if (other.data_ != null) { + if (data_ == null) { + Data = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + Data.MergeFrom(other.Data); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Type = input.ReadString(); + break; + } + case 18: { + if (data_ == null) { + Data = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Data); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Type = input.ReadString(); + break; + } + case 18: { + if (data_ == null) { + Data = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(Data); + break; + } + } + } + } + #endif + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/SchemaGrpc.cs b/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/SchemaGrpc.cs new file mode 100644 index 00000000..72bda6d6 --- /dev/null +++ b/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/SchemaGrpc.cs @@ -0,0 +1,348 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: schema/v1/schema.proto +// +#pragma warning disable 0414, 1591, 8981 +#region Designer generated code + +using grpc = global::Grpc.Core; + +namespace Schema.V1 { + /// + /// Service defines the exposed rpcs of flagd + /// + public static partial class Service + { + static readonly string __ServiceName = "schema.v1.Service"; + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (message is global::Google.Protobuf.IBufferMessage) + { + context.SetPayloadLength(message.CalculateSize()); + global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); + context.Complete(); + return; + } + #endif + context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); + } + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static class __Helper_MessageCache + { + public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); + } + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage + { + #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION + if (__Helper_MessageCache.IsBufferMessage) + { + return parser.ParseFrom(context.PayloadAsReadOnlySequence()); + } + #endif + return parser.ParseFrom(context.PayloadAsNewBuffer()); + } + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveBooleanRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveBooleanRequest.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveBooleanResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveBooleanResponse.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveStringRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveStringRequest.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveStringResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveStringResponse.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveFloatRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveFloatRequest.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveFloatResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveFloatResponse.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveIntRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveIntRequest.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveIntResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveIntResponse.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveObjectRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveObjectRequest.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveObjectResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveObjectResponse.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_google_protobuf_Empty = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Google.Protobuf.WellKnownTypes.Empty.Parser)); + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Marshaller __Marshaller_schema_v1_EventStreamResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.EventStreamResponse.Parser)); + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Method __Method_ResolveBoolean = new grpc::Method( + grpc::MethodType.Unary, + __ServiceName, + "ResolveBoolean", + __Marshaller_schema_v1_ResolveBooleanRequest, + __Marshaller_schema_v1_ResolveBooleanResponse); + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Method __Method_ResolveString = new grpc::Method( + grpc::MethodType.Unary, + __ServiceName, + "ResolveString", + __Marshaller_schema_v1_ResolveStringRequest, + __Marshaller_schema_v1_ResolveStringResponse); + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Method __Method_ResolveFloat = new grpc::Method( + grpc::MethodType.Unary, + __ServiceName, + "ResolveFloat", + __Marshaller_schema_v1_ResolveFloatRequest, + __Marshaller_schema_v1_ResolveFloatResponse); + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Method __Method_ResolveInt = new grpc::Method( + grpc::MethodType.Unary, + __ServiceName, + "ResolveInt", + __Marshaller_schema_v1_ResolveIntRequest, + __Marshaller_schema_v1_ResolveIntResponse); + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Method __Method_ResolveObject = new grpc::Method( + grpc::MethodType.Unary, + __ServiceName, + "ResolveObject", + __Marshaller_schema_v1_ResolveObjectRequest, + __Marshaller_schema_v1_ResolveObjectResponse); + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + static readonly grpc::Method __Method_EventStream = new grpc::Method( + grpc::MethodType.ServerStreaming, + __ServiceName, + "EventStream", + __Marshaller_google_protobuf_Empty, + __Marshaller_schema_v1_EventStreamResponse); + + /// Service descriptor + public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor + { + get { return global::Schema.V1.SchemaReflection.Descriptor.Services[0]; } + } + + /// Base class for server-side implementations of Service + [grpc::BindServiceMethod(typeof(Service), "BindService")] + public abstract partial class ServiceBase + { + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::System.Threading.Tasks.Task ResolveBoolean(global::Schema.V1.ResolveBooleanRequest request, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::System.Threading.Tasks.Task ResolveString(global::Schema.V1.ResolveStringRequest request, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::System.Threading.Tasks.Task ResolveFloat(global::Schema.V1.ResolveFloatRequest request, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::System.Threading.Tasks.Task ResolveInt(global::Schema.V1.ResolveIntRequest request, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::System.Threading.Tasks.Task ResolveObject(global::Schema.V1.ResolveObjectRequest request, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::System.Threading.Tasks.Task EventStream(global::Google.Protobuf.WellKnownTypes.Empty request, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + + } + + /// Client for Service + public partial class ServiceClient : grpc::ClientBase + { + /// Creates a new client for Service + /// The channel to use to make remote calls. + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public ServiceClient(grpc::ChannelBase channel) : base(channel) + { + } + /// Creates a new client for Service that uses a custom CallInvoker. + /// The callInvoker to use to make remote calls. + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public ServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) + { + } + /// Protected parameterless constructor to allow creation of test doubles. + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + protected ServiceClient() : base() + { + } + /// Protected constructor to allow creation of configured clients. + /// The client configuration. + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + protected ServiceClient(ClientBaseConfiguration configuration) : base(configuration) + { + } + + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::Schema.V1.ResolveBooleanResponse ResolveBoolean(global::Schema.V1.ResolveBooleanRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return ResolveBoolean(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::Schema.V1.ResolveBooleanResponse ResolveBoolean(global::Schema.V1.ResolveBooleanRequest request, grpc::CallOptions options) + { + return CallInvoker.BlockingUnaryCall(__Method_ResolveBoolean, null, options, request); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncUnaryCall ResolveBooleanAsync(global::Schema.V1.ResolveBooleanRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return ResolveBooleanAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncUnaryCall ResolveBooleanAsync(global::Schema.V1.ResolveBooleanRequest request, grpc::CallOptions options) + { + return CallInvoker.AsyncUnaryCall(__Method_ResolveBoolean, null, options, request); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::Schema.V1.ResolveStringResponse ResolveString(global::Schema.V1.ResolveStringRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return ResolveString(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::Schema.V1.ResolveStringResponse ResolveString(global::Schema.V1.ResolveStringRequest request, grpc::CallOptions options) + { + return CallInvoker.BlockingUnaryCall(__Method_ResolveString, null, options, request); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncUnaryCall ResolveStringAsync(global::Schema.V1.ResolveStringRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return ResolveStringAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncUnaryCall ResolveStringAsync(global::Schema.V1.ResolveStringRequest request, grpc::CallOptions options) + { + return CallInvoker.AsyncUnaryCall(__Method_ResolveString, null, options, request); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::Schema.V1.ResolveFloatResponse ResolveFloat(global::Schema.V1.ResolveFloatRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return ResolveFloat(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::Schema.V1.ResolveFloatResponse ResolveFloat(global::Schema.V1.ResolveFloatRequest request, grpc::CallOptions options) + { + return CallInvoker.BlockingUnaryCall(__Method_ResolveFloat, null, options, request); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncUnaryCall ResolveFloatAsync(global::Schema.V1.ResolveFloatRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return ResolveFloatAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncUnaryCall ResolveFloatAsync(global::Schema.V1.ResolveFloatRequest request, grpc::CallOptions options) + { + return CallInvoker.AsyncUnaryCall(__Method_ResolveFloat, null, options, request); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::Schema.V1.ResolveIntResponse ResolveInt(global::Schema.V1.ResolveIntRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return ResolveInt(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::Schema.V1.ResolveIntResponse ResolveInt(global::Schema.V1.ResolveIntRequest request, grpc::CallOptions options) + { + return CallInvoker.BlockingUnaryCall(__Method_ResolveInt, null, options, request); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncUnaryCall ResolveIntAsync(global::Schema.V1.ResolveIntRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return ResolveIntAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncUnaryCall ResolveIntAsync(global::Schema.V1.ResolveIntRequest request, grpc::CallOptions options) + { + return CallInvoker.AsyncUnaryCall(__Method_ResolveInt, null, options, request); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::Schema.V1.ResolveObjectResponse ResolveObject(global::Schema.V1.ResolveObjectRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return ResolveObject(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual global::Schema.V1.ResolveObjectResponse ResolveObject(global::Schema.V1.ResolveObjectRequest request, grpc::CallOptions options) + { + return CallInvoker.BlockingUnaryCall(__Method_ResolveObject, null, options, request); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncUnaryCall ResolveObjectAsync(global::Schema.V1.ResolveObjectRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return ResolveObjectAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncUnaryCall ResolveObjectAsync(global::Schema.V1.ResolveObjectRequest request, grpc::CallOptions options) + { + return CallInvoker.AsyncUnaryCall(__Method_ResolveObject, null, options, request); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncServerStreamingCall EventStream(global::Google.Protobuf.WellKnownTypes.Empty request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return EventStream(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public virtual grpc::AsyncServerStreamingCall EventStream(global::Google.Protobuf.WellKnownTypes.Empty request, grpc::CallOptions options) + { + return CallInvoker.AsyncServerStreamingCall(__Method_EventStream, null, options, request); + } + /// Creates a new instance of client from given ClientBaseConfiguration. + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + protected override ServiceClient NewInstance(ClientBaseConfiguration configuration) + { + return new ServiceClient(configuration); + } + } + + /// Creates service definition that can be registered with a server + /// An object implementing the server-side handling logic. + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public static grpc::ServerServiceDefinition BindService(ServiceBase serviceImpl) + { + return grpc::ServerServiceDefinition.CreateBuilder() + .AddMethod(__Method_ResolveBoolean, serviceImpl.ResolveBoolean) + .AddMethod(__Method_ResolveString, serviceImpl.ResolveString) + .AddMethod(__Method_ResolveFloat, serviceImpl.ResolveFloat) + .AddMethod(__Method_ResolveInt, serviceImpl.ResolveInt) + .AddMethod(__Method_ResolveObject, serviceImpl.ResolveObject) + .AddMethod(__Method_EventStream, serviceImpl.EventStream).Build(); + } + + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. + /// Note: this method is part of an experimental API that can change or be removed without any prior notice. + /// Service methods will be bound by calling AddMethod on this object. + /// An object implementing the server-side handling logic. + [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] + public static void BindService(grpc::ServiceBinderBase serviceBinder, ServiceBase serviceImpl) + { + serviceBinder.AddMethod(__Method_ResolveBoolean, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.ResolveBoolean)); + serviceBinder.AddMethod(__Method_ResolveString, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.ResolveString)); + serviceBinder.AddMethod(__Method_ResolveFloat, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.ResolveFloat)); + serviceBinder.AddMethod(__Method_ResolveInt, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.ResolveInt)); + serviceBinder.AddMethod(__Method_ResolveObject, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.ResolveObject)); + serviceBinder.AddMethod(__Method_EventStream, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod(serviceImpl.EventStream)); + } + + } +} +#endregion diff --git a/src/OpenFeature.Contrib.Providers.Flagd/Stub.cs b/src/OpenFeature.Contrib.Providers.Flagd/Stub.cs deleted file mode 100644 index da7665e8..00000000 --- a/src/OpenFeature.Contrib.Providers.Flagd/Stub.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace OpenFeature.Contrib.Providers.Flagd -{ - /// - /// A stub class. - /// - public class Stub - { - /// - /// Get the provider name. - /// - public static string GetProviderName() - { - return Api.Instance.GetProviderMetadata().Name; - } - } -} - - diff --git a/src/OpenFeature.Contrib.Providers.Flagd/schemas b/src/OpenFeature.Contrib.Providers.Flagd/schemas new file mode 160000 index 00000000..d638ecf9 --- /dev/null +++ b/src/OpenFeature.Contrib.Providers.Flagd/schemas @@ -0,0 +1 @@ +Subproject commit d638ecf9501fefa83ec0fad2bbe96af1f6f1899d diff --git a/test/OpenFeature.Contrib.Providers.Flagd.Test/UnitTest1.cs b/test/OpenFeature.Contrib.Providers.Flagd.Test/UnitTest1.cs index 06c21539..6e580874 100644 --- a/test/OpenFeature.Contrib.Providers.Flagd.Test/UnitTest1.cs +++ b/test/OpenFeature.Contrib.Providers.Flagd.Test/UnitTest1.cs @@ -1,6 +1,4 @@ - using Xunit; -using OpenFeature.Contrib.Providers.Flagd; namespace OpenFeature.Contrib.Providers.Flagd.Test { @@ -9,7 +7,7 @@ public class UnitTest1 [Fact] public void TestMethod1() { - Assert.Equal("No-op Provider", Stub.GetProviderName()); + Assert.Equal("No-op Provider", FlagdProvider.GetProviderName()); } } } From aa8b6ca6bd6b60a56f9e576f49dd71c174833bbf Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Tue, 31 Jan 2023 15:17:08 +0100 Subject: [PATCH 02/14] added unit tests, xml doc and readme Signed-off-by: Florian Bacher --- .../FlagdProvider.cs | 266 +++++++++++++---- ...OpenFeature.Contrib.Providers.Flagd.csproj | 18 +- .../README.md | 74 ++++- .../FlagdProviderTest.cs | 278 ++++++++++++++++++ ...eature.Contrib.Providers.Flagd.Test.csproj | 6 +- .../UnitTest1.cs | 13 - 6 files changed, 578 insertions(+), 77 deletions(-) create mode 100644 test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs delete mode 100644 test/OpenFeature.Contrib.Providers.Flagd.Test/UnitTest1.cs diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs index dd11a06d..a5a21175 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -1,10 +1,10 @@ using System; using System.Linq; -using System.Net.Http; using System.Threading.Tasks; using Google.Protobuf.WellKnownTypes; using Grpc.Net.Client; using OpenFeature.Model; + using Schema.V1; using Value = OpenFeature.Model.Value; using ProtoValue = Google.Protobuf.WellKnownTypes.Value; @@ -12,21 +12,26 @@ namespace OpenFeature.Contrib.Providers.Flagd { /// - /// A stub class. + /// FlagdProvider is the OpenFeature provider for flagD. /// public sealed class FlagdProvider : FeatureProvider { private readonly Service.ServiceClient _client; private readonly Metadata _providerMetadata = new Metadata("flagD Provider"); + /// + /// Constructor of the provider. + /// The URL of the flagD server + /// if no url is provided. + /// public FlagdProvider(Uri url) { if (url == null) { throw new ArgumentNullException(nameof(url)); } - -#if NETSTANDARD2_0 + + #if NETSTANDARD2_0 _client = new Service.ServiceClient(GrpcChannel.ForAddress(url)); #else _client = new Service.ServiceClient(GrpcChannel.ForAddress(url, new GrpcChannelOptions @@ -35,6 +40,16 @@ public FlagdProvider(Uri url) })); #endif } + + /// + /// Constructor of the provider. + /// The Grpc client used to communicate with the server + /// if no url is provided. + /// + public FlagdProvider(Service.ServiceClient client) + { + _client = client; + } /// /// Get the provider name. @@ -44,88 +59,214 @@ public static string GetProviderName() return Api.Instance.GetProviderMetadata().Name; } + /// + /// Return the metadata associated to this provider. + /// public override Metadata GetMetadata() => _providerMetadata; + /// + /// ResolveBooleanValue resolve the value for a Boolean Flag. + /// + /// Name of the flag + /// Default value used in case of error. + /// Context about the user + /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveBooleanValue(string flagKey, bool defaultValue, EvaluationContext context = null) { - var resolveBooleanResponse = await _client.ResolveBooleanAsync(new ResolveBooleanRequest + try { - Context = ConvertToContext(context), - FlagKey = flagKey - }); + var resolveBooleanResponse = await _client.ResolveBooleanAsync(new ResolveBooleanRequest + { + Context = ConvertToContext(context), + FlagKey = flagKey + }); - return new ResolutionDetails( - flagKey: flagKey, - value: resolveBooleanResponse.Value, - reason: resolveBooleanResponse.Reason, - variant: resolveBooleanResponse.Variant - ); + return new ResolutionDetails( + flagKey: flagKey, + value: resolveBooleanResponse.Value, + reason: resolveBooleanResponse.Reason, + variant: resolveBooleanResponse.Variant + ); + } + catch (Grpc.Core.RpcException e) + { + return GetDefaultWithException(e, flagKey, defaultValue); + } } + /// + /// ResolveStringValue resolve the value for a string Flag. + /// + /// Name of the flag + /// Default value used in case of error. + /// Context about the user + /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveStringValue(string flagKey, string defaultValue, EvaluationContext context = null) { - var resolveBooleanResponse = await _client.ResolveStringAsync(new ResolveStringRequest + try { - Context = ConvertToContext(context), - FlagKey = flagKey - }); + var resolveBooleanResponse = await _client.ResolveStringAsync(new ResolveStringRequest + { + Context = ConvertToContext(context), + FlagKey = flagKey + }); - return new ResolutionDetails( - flagKey: flagKey, - value: resolveBooleanResponse.Value, - reason: resolveBooleanResponse.Reason, - variant: resolveBooleanResponse.Variant - ); + return new ResolutionDetails( + flagKey: flagKey, + value: resolveBooleanResponse.Value, + reason: resolveBooleanResponse.Reason, + variant: resolveBooleanResponse.Variant + ); + } + catch (Grpc.Core.RpcException e) + { + return GetDefaultWithException(e, flagKey, defaultValue); + } + } + /// + /// ResolveIntegerValue resolve the value for an int Flag. + /// + /// Name of the flag + /// Default value used in case of error. + /// Context about the user + /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveIntegerValue(string flagKey, int defaultValue, EvaluationContext context = null) { - var resolveIntResponse = await _client.ResolveIntAsync(new ResolveIntRequest + try { - Context = ConvertToContext(context), - FlagKey = flagKey - }); + var resolveIntResponse = await _client.ResolveIntAsync(new ResolveIntRequest + { + Context = ConvertToContext(context), + FlagKey = flagKey + }); - return new ResolutionDetails( - flagKey: flagKey, - value: (int)resolveIntResponse.Value, - reason: resolveIntResponse.Reason, - variant: resolveIntResponse.Variant - ); + return new ResolutionDetails( + flagKey: flagKey, + value: (int)resolveIntResponse.Value, + reason: resolveIntResponse.Reason, + variant: resolveIntResponse.Variant + ); + } + catch (Grpc.Core.RpcException e) + { + return GetDefaultWithException(e, flagKey, defaultValue); + } } + /// + /// ResolveDoubleValue resolve the value for a double Flag. + /// + /// Name of the flag + /// Default value used in case of error. + /// Context about the user + /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveDoubleValue(string flagKey, double defaultValue, EvaluationContext context = null) { - var resolveDoubleResponse = await _client.ResolveFloatAsync(new ResolveFloatRequest + try { - Context = ConvertToContext(context), - FlagKey = flagKey - }); + var resolveDoubleResponse = await _client.ResolveFloatAsync(new ResolveFloatRequest + { + Context = ConvertToContext(context), + FlagKey = flagKey + }); - return new ResolutionDetails( - flagKey: flagKey, - value: resolveDoubleResponse.Value, - reason: resolveDoubleResponse.Reason, - variant: resolveDoubleResponse.Variant - ); + return new ResolutionDetails( + flagKey: flagKey, + value: resolveDoubleResponse.Value, + reason: resolveDoubleResponse.Reason, + variant: resolveDoubleResponse.Variant + ); + } + catch (Grpc.Core.RpcException e) + { + return GetDefaultWithException(e, flagKey, defaultValue); + } } + /// + /// ResolveStructureValue resolve the value for a Boolean Flag. + /// + /// Name of the flag + /// Default value used in case of error. + /// Context about the user + /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveStructureValue(string flagKey, Value defaultValue, EvaluationContext context = null) { - var resolveObjectResponse = await _client.ResolveObjectAsync(new ResolveObjectRequest + try + { + var resolveObjectResponse = await _client.ResolveObjectAsync(new ResolveObjectRequest + { + Context = ConvertToContext(context), + FlagKey = flagKey + }); + + return new ResolutionDetails( + flagKey: flagKey, + value: ConvertObjectToValue(resolveObjectResponse.Value), + reason: resolveObjectResponse.Reason, + variant: resolveObjectResponse.Variant + ); + } + catch (Grpc.Core.RpcException e) { - Context = ConvertToContext(context), - FlagKey = flagKey - }); + return GetDefaultWithException(e, flagKey, defaultValue); + } + } - return new ResolutionDetails( + /// + /// GetDefaultWithException returns the default value for a flag, together with some error information about why thy flag could not be retrieved by the provider. + /// + /// The exception thrown by the Grpc client + /// Name of the flag + /// Default value to return + /// A ResolutionDetails object containing the value of your flag + private ResolutionDetails GetDefaultWithException(Grpc.Core.RpcException e, String flagKey, T defaultValue) + { + if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound) + { + return new ResolutionDetails( + flagKey: flagKey, + value: defaultValue, + reason: Constant.Reason.Error, + errorType: Constant.ErrorType.FlagNotFound, + errorMessage: e.Status.Detail.ToString() + ); + } + else if (e.Status.StatusCode == Grpc.Core.StatusCode.Unavailable) + { + return new ResolutionDetails( + flagKey: flagKey, + value: defaultValue, + reason: Constant.Reason.Error, + errorType: Constant.ErrorType.ProviderNotReady, + errorMessage: e.Status.Detail.ToString() + ); + } + else if (e.Status.StatusCode == Grpc.Core.StatusCode.InvalidArgument) { + return new ResolutionDetails( + flagKey: flagKey, + value: defaultValue, + reason: Constant.Reason.Error, + errorType: Constant.ErrorType.TypeMismatch, + errorMessage: e.Status.Detail.ToString() + ); + } + return new ResolutionDetails( flagKey: flagKey, - value: ConvertObjectToValue(resolveObjectResponse.Value), - reason: resolveObjectResponse.Reason, - variant: resolveObjectResponse.Variant + value: defaultValue, + reason: Constant.Reason.Error, + errorType: Constant.ErrorType.General, + errorMessage: e.Status.Detail.ToString() ); } + /// + /// ConvertToContext converts the given EvaluationContext to a Struct. + /// + /// The evaluation context + /// A Struct object containing the evaluation context private static Struct ConvertToContext(EvaluationContext ctx) { if (ctx == null) @@ -142,6 +283,11 @@ private static Struct ConvertToContext(EvaluationContext ctx) return values; } + /// + /// ConvertToProtoValue converts the given Value to a ProtoValue. + /// + /// The value + /// A ProtoValue object representing the given value private static ProtoValue ConvertToProtoValue(Value value) { if (value.IsList) @@ -179,10 +325,20 @@ private static ProtoValue ConvertToProtoValue(Value value) return ProtoValue.ForNull(); } + /// + /// ConvertObjectToValue converts the given Struct to a Value. + /// + /// The struct + /// A Value object representing the given struct private static Value ConvertObjectToValue(Struct src) => new Value(new Structure(src.Fields .ToDictionary(entry => entry.Key, entry => ConvertToValue(entry.Value)))); + /// + /// ConvertToValue converts the given ProtoValue to a Value. + /// + /// The value, represented as ProtoValue + /// A Value object representing the given value private static Value ConvertToValue(ProtoValue src) { switch (src.KindCase) @@ -201,6 +357,11 @@ private static Value ConvertToValue(ProtoValue src) } } + /// + /// ConvertToPrimitiveValue converts the given ProtoValue to a Value. + /// + /// The value, represented as ProtoValue + /// A Value object representing the given value as a primitive data type private static Value ConvertToPrimitiveValue(ProtoValue value) { switch (value.KindCase) @@ -222,4 +383,3 @@ private static Value ConvertToPrimitiveValue(ProtoValue value) } } - diff --git a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj index eb777fc5..7b982ca9 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj +++ b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj @@ -1,8 +1,8 @@ - OpenFeature.Providers.Flagd - 0.0.2 + OpenFeature.Contrib.Providers.Flagd + 0.1.0 $(VersionNumber) $(VersionNumber) $(VersionNumber) @@ -12,17 +12,19 @@ Todd Baert + - - + - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + - diff --git a/src/OpenFeature.Contrib.Providers.Flagd/README.md b/src/OpenFeature.Contrib.Providers.Flagd/README.md index e9d8384f..14e477bf 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/README.md +++ b/src/OpenFeature.Contrib.Providers.Flagd/README.md @@ -1,3 +1,73 @@ -# OpenFeature flagd Provider for .NET +# Flagd Feature Flag .NET Provider -Coming soon! +The Flagd Flag provider allows you to connect to your Flagd instance. + +# .Net SDK usage + +## Install dependencies + +The first things we will do is install the **Open Feature SDK** and the **GO Feature Flag provider**. + +### .NET Cli +```shell +dotnet add package OpenFeature.Contrib.Providers.Flagd +``` +### Package Manager + +```shell +NuGet\Install-Package OpenFeature.Contrib.Providers.Flagd +``` +### Package Reference + +```xml + +``` +### Packet cli + +```shell +paket add OpenFeature.Contrib.Providers.Flagd +``` + +### Cake + +```shell +// Install OpenFeature.Contrib.Providers.Flagd as a Cake Addin +#addin nuget:?package=OpenFeature.Contrib.Providers.Flagd + +// Install OpenFeature.Contrib.Providers.Flagd as a Cake Tool +#tool nuget:?package=OpenFeature.Contrib.Providers.Flagd +``` + +## Using the FlagdProvider with the OpenFeature SDK + +This example assumes that the flagd server is running locally +For example, you can start flagd with the following example configuration: + +```shell +flagd start --uri https://raw.githubusercontent.com/open-feature/flagd/main/config/samples/example_flags.json +``` + +When the flagd service is running, you can use the SDK with the FlagdProvider as in the following example console application: + +```csharp +using OpenFeature.Contrib.Providers.Flagd; + +namespace OpenFeatureTestApp +{ + class Hello { + static void Main(string[] args) { + var flagdProvider = new FlagdProvider(new Uri("http://localhost:8013")); + + // Set the flagdProvider as the provider for the OpenFeature SDK + OpenFeature.Api.Instance.SetProvider(flagdProvider); + + var client = OpenFeature.Api.Instance.GetClient("my-app"); + + var val = client.GetBooleanValue("myBoolFlag", false, null); + + // Print the value of the 'myBoolFlag' feature flag + System.Console.WriteLine(val.Result.ToString()); + } + } +} +``` diff --git a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs new file mode 100644 index 00000000..156825c5 --- /dev/null +++ b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs @@ -0,0 +1,278 @@ +using Xunit; +using Moq; +using Schema.V1; +using Grpc.Core; +using Google.Protobuf.WellKnownTypes; +using ProtoValue = Google.Protobuf.WellKnownTypes.Value; + +namespace OpenFeature.Contrib.Providers.Flagd.Test +{ + public class UnitTestFlagdProvider + { + [Fact] + public void TestGetProviderName() + { + Assert.Equal("No-op Provider", FlagdProvider.GetProviderName()); + } + + [Fact] + public void TestResolveBooleanValue() + { + var resp = new ResolveBooleanResponse(); + resp.Value = true; + + var grpcResp = new AsyncUnaryCall( + System.Threading.Tasks.Task.FromResult(resp), + System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), + () => Status.DefaultSuccess, + () => new Grpc.Core.Metadata(), + () => { }); + + var mockGrpcClient = new Mock(); + mockGrpcClient + .Setup(m => m.ResolveBooleanAsync( + It.IsAny(), null, null, System.Threading.CancellationToken.None)) + .Returns(grpcResp); + + var flagdProvider = new FlagdProvider(mockGrpcClient.Object); + + // resolve with default set to false to make sure we return what the grpc server gives us + var val = flagdProvider.ResolveBooleanValue("my-key", false, null); + + Assert.True(val.Result.Value); + } + + [Fact] + public void TestResolveStringValue() + { + var resp = new ResolveStringResponse(); + resp.Value = "my-value"; + + var grpcResp = new AsyncUnaryCall( + System.Threading.Tasks.Task.FromResult(resp), + System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), + () => Status.DefaultSuccess, + () => new Grpc.Core.Metadata(), + () => { }); + + var mockGrpcClient = new Mock(); + mockGrpcClient + .Setup(m => m.ResolveStringAsync( + It.IsAny(), null, null, System.Threading.CancellationToken.None)) + .Returns(grpcResp); + + var flagdProvider = new FlagdProvider(mockGrpcClient.Object); + + var val = flagdProvider.ResolveStringValue("my-key", "", null); + + Assert.Equal("my-value", val.Result.Value); + } + + [Fact] + public void TestResolveIntegerValue() + { + var resp = new ResolveIntResponse(); + resp.Value = 10; + + var grpcResp = new AsyncUnaryCall( + System.Threading.Tasks.Task.FromResult(resp), + System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), + () => Status.DefaultSuccess, + () => new Grpc.Core.Metadata(), + () => { }); + + var mockGrpcClient = new Mock(); + mockGrpcClient + .Setup(m => m.ResolveIntAsync( + It.IsAny(), null, null, System.Threading.CancellationToken.None)) + .Returns(grpcResp); + + var flagdProvider = new FlagdProvider(mockGrpcClient.Object); + + var val = flagdProvider.ResolveIntegerValue("my-key", 0, null); + + Assert.Equal(10, val.Result.Value); + } + + [Fact] + public void TestResolveDoubleValue() + { + var resp = new ResolveFloatResponse(); + resp.Value = 10.0; + + var grpcResp = new AsyncUnaryCall( + System.Threading.Tasks.Task.FromResult(resp), + System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), + () => Status.DefaultSuccess, + () => new Grpc.Core.Metadata(), + () => { }); + + var mockGrpcClient = new Mock(); + mockGrpcClient + .Setup(m => m.ResolveFloatAsync( + It.IsAny(), null, null, System.Threading.CancellationToken.None)) + .Returns(grpcResp); + + var flagdProvider = new FlagdProvider(mockGrpcClient.Object); + + var val = flagdProvider.ResolveDoubleValue("my-key", 0.0, null); + + Assert.Equal(10.0, val.Result.Value); + } + + [Fact] + public void TestResolveStructureValue() + { + var resp = new ResolveObjectResponse(); + + var returnedValue = new Struct(); + returnedValue.Fields.Add("my-key", ProtoValue.ForString("my-value")); + + + resp.Value = returnedValue; + + var grpcResp = new AsyncUnaryCall( + System.Threading.Tasks.Task.FromResult(resp), + System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), + () => Status.DefaultSuccess, + () => new Grpc.Core.Metadata(), + () => { }); + + var mockGrpcClient = new Mock(); + mockGrpcClient + .Setup(m => m.ResolveObjectAsync( + It.IsAny(), null, null, System.Threading.CancellationToken.None)) + .Returns(grpcResp); + + var flagdProvider = new FlagdProvider(mockGrpcClient.Object); + + var val = flagdProvider.ResolveStructureValue("my-key", null, null); + + Assert.True(val.Result.Value.AsStructure.ContainsKey("my-key")); + } + + [Fact] + public void TestResolveFlagNotFound() + { + var exc = new RpcException(new Grpc.Core.Status(Grpc.Core.StatusCode.NotFound, Constant.ErrorType.FlagNotFound.ToString())); + + var grpcResp = new AsyncUnaryCall( + System.Threading.Tasks.Task.FromException(exc), + System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), + () => Status.DefaultSuccess, + () => new Grpc.Core.Metadata(), + () => { }); + + var mockGrpcClient = new Mock(); + mockGrpcClient + .Setup(m => m.ResolveBooleanAsync( + It.IsAny(), null, null, System.Threading.CancellationToken.None)) + .Returns(grpcResp); + + var flagdProvider = new FlagdProvider(mockGrpcClient.Object); + + // resolve with default set to true + var val = flagdProvider.ResolveBooleanValue("my-key", true, null); + + // here we should get the default value regardless of the failed grpc call + Assert.True(val.Result.Value); + // check for error information to be included in the result + Assert.Equal(Constant.Reason.Error, val.Result.Reason); + Assert.Equal(Constant.ErrorType.FlagNotFound, val.Result.ErrorType); + Assert.Equal(Constant.ErrorType.FlagNotFound.ToString(), val.Result.ErrorMessage); + } + + [Fact] + public void TestResolveGrpcHostUnavailable() + { + var exc = new RpcException(new Grpc.Core.Status(Grpc.Core.StatusCode.Unavailable, Constant.ErrorType.ProviderNotReady.ToString())); + + var grpcResp = new AsyncUnaryCall( + System.Threading.Tasks.Task.FromException(exc), + System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), + () => Status.DefaultSuccess, + () => new Grpc.Core.Metadata(), + () => { }); + + var mockGrpcClient = new Mock(); + mockGrpcClient + .Setup(m => m.ResolveBooleanAsync( + It.IsAny(), null, null, System.Threading.CancellationToken.None)) + .Returns(grpcResp); + + var flagdProvider = new FlagdProvider(mockGrpcClient.Object); + + // resolve with default set to true + var val = flagdProvider.ResolveBooleanValue("my-key", true, null); + + // here we should get the default value regardless of the failed grpc call + Assert.True(val.Result.Value); + // check for error information to be included in the result + Assert.Equal(Constant.Reason.Error, val.Result.Reason); + Assert.Equal(Constant.ErrorType.ProviderNotReady, val.Result.ErrorType); + Assert.Equal(Constant.ErrorType.ProviderNotReady.ToString(), val.Result.ErrorMessage); + } + + [Fact] + public void TestResolveTypeMismatch() + { + var exc = new RpcException(new Grpc.Core.Status(Grpc.Core.StatusCode.InvalidArgument, Constant.ErrorType.TypeMismatch.ToString())); + + var grpcResp = new AsyncUnaryCall( + System.Threading.Tasks.Task.FromException(exc), + System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), + () => Status.DefaultSuccess, + () => new Grpc.Core.Metadata(), + () => { }); + + var mockGrpcClient = new Mock(); + mockGrpcClient + .Setup(m => m.ResolveBooleanAsync( + It.IsAny(), null, null, System.Threading.CancellationToken.None)) + .Returns(grpcResp); + + var flagdProvider = new FlagdProvider(mockGrpcClient.Object); + + // resolve with default set to true + var val = flagdProvider.ResolveBooleanValue("my-key", true, null); + + // here we should get the default value regardless of the failed grpc call + Assert.True(val.Result.Value); + // check for error information to be included in the result + Assert.Equal(Constant.Reason.Error, val.Result.Reason); + Assert.Equal(Constant.ErrorType.TypeMismatch, val.Result.ErrorType); + Assert.Equal(Constant.ErrorType.TypeMismatch.ToString(), val.Result.ErrorMessage); + } + + [Fact] + public void TestResolveUnknownError() + { + var exc = new RpcException(new Grpc.Core.Status(Grpc.Core.StatusCode.Internal, "unknown error")); + + var grpcResp = new AsyncUnaryCall( + System.Threading.Tasks.Task.FromException(exc), + System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), + () => Status.DefaultSuccess, + () => new Grpc.Core.Metadata(), + () => { }); + + var mockGrpcClient = new Mock(); + mockGrpcClient + .Setup(m => m.ResolveBooleanAsync( + It.IsAny(), null, null, System.Threading.CancellationToken.None)) + .Returns(grpcResp); + + var flagdProvider = new FlagdProvider(mockGrpcClient.Object); + + // resolve with default set to true + var val = flagdProvider.ResolveBooleanValue("my-key", true, null); + + // here we should get the default value regardless of the failed grpc call + Assert.True(val.Result.Value); + // check for error information to be included in the result + Assert.Equal(Constant.Reason.Error, val.Result.Reason); + Assert.Equal(Constant.ErrorType.General, val.Result.ErrorType); + Assert.Equal("unknown error", val.Result.ErrorMessage); + } + } +} diff --git a/test/OpenFeature.Contrib.Providers.Flagd.Test/OpenFeature.Contrib.Providers.Flagd.Test.csproj b/test/OpenFeature.Contrib.Providers.Flagd.Test/OpenFeature.Contrib.Providers.Flagd.Test.csproj index ffa7b98c..743279a6 100644 --- a/test/OpenFeature.Contrib.Providers.Flagd.Test/OpenFeature.Contrib.Providers.Flagd.Test.csproj +++ b/test/OpenFeature.Contrib.Providers.Flagd.Test/OpenFeature.Contrib.Providers.Flagd.Test.csproj @@ -4,4 +4,8 @@ - + + + + + \ No newline at end of file diff --git a/test/OpenFeature.Contrib.Providers.Flagd.Test/UnitTest1.cs b/test/OpenFeature.Contrib.Providers.Flagd.Test/UnitTest1.cs deleted file mode 100644 index 6e580874..00000000 --- a/test/OpenFeature.Contrib.Providers.Flagd.Test/UnitTest1.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace OpenFeature.Contrib.Providers.Flagd.Test -{ - public class UnitTest1 - { - [Fact] - public void TestMethod1() - { - Assert.Equal("No-op Provider", FlagdProvider.GetProviderName()); - } - } -} From a4411fb04a4141e1e7f22fe87c7e0d4891eea266 Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Tue, 31 Jan 2023 15:35:58 +0100 Subject: [PATCH 03/14] apply dotnet-format Signed-off-by: Florian Bacher --- .../FlagdProvider.cs | 67 ++++++++++--------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs index a5a21175..630dc431 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -31,7 +31,7 @@ public FlagdProvider(Uri url) throw new ArgumentNullException(nameof(url)); } - #if NETSTANDARD2_0 +#if NETSTANDARD2_0 _client = new Service.ServiceClient(GrpcChannel.ForAddress(url)); #else _client = new Service.ServiceClient(GrpcChannel.ForAddress(url, new GrpcChannelOptions @@ -50,7 +50,7 @@ public FlagdProvider(Service.ServiceClient client) { _client = client; } - + /// /// Get the provider name. /// @@ -58,7 +58,7 @@ public static string GetProviderName() { return Api.Instance.GetProviderMetadata().Name; } - + /// /// Return the metadata associated to this provider. /// @@ -82,9 +82,9 @@ public override async Task> ResolveBooleanValue(string f }); return new ResolutionDetails( - flagKey: flagKey, + flagKey: flagKey, value: resolveBooleanResponse.Value, - reason: resolveBooleanResponse.Reason, + reason: resolveBooleanResponse.Reason, variant: resolveBooleanResponse.Variant ); } @@ -103,7 +103,7 @@ public override async Task> ResolveBooleanValue(string f /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveStringValue(string flagKey, string defaultValue, EvaluationContext context = null) { - try + try { var resolveBooleanResponse = await _client.ResolveStringAsync(new ResolveStringRequest { @@ -112,9 +112,9 @@ public override async Task> ResolveStringValue(string }); return new ResolutionDetails( - flagKey: flagKey, + flagKey: flagKey, value: resolveBooleanResponse.Value, - reason: resolveBooleanResponse.Reason, + reason: resolveBooleanResponse.Reason, variant: resolveBooleanResponse.Variant ); } @@ -122,7 +122,7 @@ public override async Task> ResolveStringValue(string { return GetDefaultWithException(e, flagKey, defaultValue); } - + } /// @@ -134,7 +134,7 @@ public override async Task> ResolveStringValue(string /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveIntegerValue(string flagKey, int defaultValue, EvaluationContext context = null) { - try + try { var resolveIntResponse = await _client.ResolveIntAsync(new ResolveIntRequest { @@ -143,9 +143,9 @@ public override async Task> ResolveIntegerValue(string fl }); return new ResolutionDetails( - flagKey: flagKey, + flagKey: flagKey, value: (int)resolveIntResponse.Value, - reason: resolveIntResponse.Reason, + reason: resolveIntResponse.Reason, variant: resolveIntResponse.Variant ); } @@ -164,7 +164,7 @@ public override async Task> ResolveIntegerValue(string fl /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveDoubleValue(string flagKey, double defaultValue, EvaluationContext context = null) { - try + try { var resolveDoubleResponse = await _client.ResolveFloatAsync(new ResolveFloatRequest { @@ -173,9 +173,9 @@ public override async Task> ResolveDoubleValue(string }); return new ResolutionDetails( - flagKey: flagKey, + flagKey: flagKey, value: resolveDoubleResponse.Value, - reason: resolveDoubleResponse.Reason, + reason: resolveDoubleResponse.Reason, variant: resolveDoubleResponse.Variant ); } @@ -203,9 +203,9 @@ public override async Task> ResolveStructureValue(strin }); return new ResolutionDetails( - flagKey: flagKey, + flagKey: flagKey, value: ConvertObjectToValue(resolveObjectResponse.Value), - reason: resolveObjectResponse.Reason, + reason: resolveObjectResponse.Reason, variant: resolveObjectResponse.Variant ); } @@ -224,29 +224,30 @@ public override async Task> ResolveStructureValue(strin /// A ResolutionDetails object containing the value of your flag private ResolutionDetails GetDefaultWithException(Grpc.Core.RpcException e, String flagKey, T defaultValue) { - if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound) + if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound) { return new ResolutionDetails( - flagKey: flagKey, + flagKey: flagKey, value: defaultValue, reason: Constant.Reason.Error, errorType: Constant.ErrorType.FlagNotFound, errorMessage: e.Status.Detail.ToString() - ); + ); } - else if (e.Status.StatusCode == Grpc.Core.StatusCode.Unavailable) + else if (e.Status.StatusCode == Grpc.Core.StatusCode.Unavailable) { - return new ResolutionDetails( - flagKey: flagKey, - value: defaultValue, - reason: Constant.Reason.Error, - errorType: Constant.ErrorType.ProviderNotReady, - errorMessage: e.Status.Detail.ToString() - ); + return new ResolutionDetails( + flagKey: flagKey, + value: defaultValue, + reason: Constant.Reason.Error, + errorType: Constant.ErrorType.ProviderNotReady, + errorMessage: e.Status.Detail.ToString() + ); } - else if (e.Status.StatusCode == Grpc.Core.StatusCode.InvalidArgument) { + else if (e.Status.StatusCode == Grpc.Core.StatusCode.InvalidArgument) + { return new ResolutionDetails( - flagKey: flagKey, + flagKey: flagKey, value: defaultValue, reason: Constant.Reason.Error, errorType: Constant.ErrorType.TypeMismatch, @@ -254,7 +255,7 @@ private ResolutionDetails GetDefaultWithException(Grpc.Core.RpcException e ); } return new ResolutionDetails( - flagKey: flagKey, + flagKey: flagKey, value: defaultValue, reason: Constant.Reason.Error, errorType: Constant.ErrorType.General, @@ -273,13 +274,13 @@ private static Struct ConvertToContext(EvaluationContext ctx) { return new Struct(); } - + var values = new Struct(); foreach (var entry in ctx) { values.Fields.Add(entry.Key, ConvertToProtoValue(entry.Value)); } - + return values; } From a8ec6f18a159c2c794950fdcb133d1b4c69dab27 Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Tue, 31 Jan 2023 15:39:16 +0100 Subject: [PATCH 04/14] apply dotnet-format Signed-off-by: Florian Bacher --- .../FlagdProviderTest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs index 156825c5..62bfb6ba 100644 --- a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs +++ b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs @@ -124,7 +124,7 @@ public void TestResolveDoubleValue() public void TestResolveStructureValue() { var resp = new ResolveObjectResponse(); - + var returnedValue = new Struct(); returnedValue.Fields.Add("my-key", ProtoValue.ForString("my-value")); @@ -155,7 +155,7 @@ public void TestResolveStructureValue() public void TestResolveFlagNotFound() { var exc = new RpcException(new Grpc.Core.Status(Grpc.Core.StatusCode.NotFound, Constant.ErrorType.FlagNotFound.ToString())); - + var grpcResp = new AsyncUnaryCall( System.Threading.Tasks.Task.FromException(exc), System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), @@ -186,7 +186,7 @@ public void TestResolveFlagNotFound() public void TestResolveGrpcHostUnavailable() { var exc = new RpcException(new Grpc.Core.Status(Grpc.Core.StatusCode.Unavailable, Constant.ErrorType.ProviderNotReady.ToString())); - + var grpcResp = new AsyncUnaryCall( System.Threading.Tasks.Task.FromException(exc), System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), @@ -217,7 +217,7 @@ public void TestResolveGrpcHostUnavailable() public void TestResolveTypeMismatch() { var exc = new RpcException(new Grpc.Core.Status(Grpc.Core.StatusCode.InvalidArgument, Constant.ErrorType.TypeMismatch.ToString())); - + var grpcResp = new AsyncUnaryCall( System.Threading.Tasks.Task.FromException(exc), System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), @@ -248,7 +248,7 @@ public void TestResolveTypeMismatch() public void TestResolveUnknownError() { var exc = new RpcException(new Grpc.Core.Status(Grpc.Core.StatusCode.Internal, "unknown error")); - + var grpcResp = new AsyncUnaryCall( System.Threading.Tasks.Task.FromException(exc), System.Threading.Tasks.Task.FromResult(new Grpc.Core.Metadata()), From ff2178555da3963f15ef6caa16c9d7b9f63c8b19 Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Tue, 31 Jan 2023 15:56:36 +0100 Subject: [PATCH 05/14] remove reference to WinHttpHandler Signed-off-by: Florian Bacher --- src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs index 630dc431..fd707582 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -31,14 +31,7 @@ public FlagdProvider(Uri url) throw new ArgumentNullException(nameof(url)); } -#if NETSTANDARD2_0 _client = new Service.ServiceClient(GrpcChannel.ForAddress(url)); -#else - _client = new Service.ServiceClient(GrpcChannel.ForAddress(url, new GrpcChannelOptions - { - HttpHandler = new WinHttpHandler() - })); -#endif } /// From b6cfdb1fdae672226d36671b91934fffd7218146 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Thu, 2 Feb 2023 15:46:44 -0500 Subject: [PATCH 06/14] fixup: make one constructor internal Signed-off-by: Todd Baert --- src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs | 8 ++------ .../OpenFeature.Contrib.Providers.Flagd.csproj | 6 ++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs index fd707582..0e7c0668 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -34,12 +34,8 @@ public FlagdProvider(Uri url) _client = new Service.ServiceClient(GrpcChannel.ForAddress(url)); } - /// - /// Constructor of the provider. - /// The Grpc client used to communicate with the server - /// if no url is provided. - /// - public FlagdProvider(Service.ServiceClient client) + // just for testing, internal but visible in tests + internal FlagdProvider(Service.ServiceClient client) { _client = client; } diff --git a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj index 7b982ca9..916488a9 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj +++ b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj @@ -16,6 +16,12 @@ + + + + <_Parameter1>$(MSBuildProjectName).Test + + From 56b44dbaebf8af5337db9711447ab85c451e337d Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Wed, 8 Feb 2023 10:25:15 +0100 Subject: [PATCH 07/14] added empty constructor to make use of environment variables Signed-off-by: Florian Bacher --- .../FlagdProvider.cs | 34 ++++++++++++++++++- ...OpenFeature.Contrib.Providers.Flagd.csproj | 1 - .../README.md | 23 +++++++++++++ .../FlagdProviderTest.cs | 10 ++++++ 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs index 0e7c0668..1a885b29 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -9,6 +9,7 @@ using Value = OpenFeature.Model.Value; using ProtoValue = Google.Protobuf.WellKnownTypes.Value; + namespace OpenFeature.Contrib.Providers.Flagd { /// @@ -17,8 +18,34 @@ namespace OpenFeature.Contrib.Providers.Flagd public sealed class FlagdProvider : FeatureProvider { private readonly Service.ServiceClient _client; - private readonly Metadata _providerMetadata = new Metadata("flagD Provider"); + private readonly Metadata _providerMetadata = new Metadata("flagd Provider"); + /// + /// Constructor of the provider. This constructor uses the value of the following + /// environment variables to initialise its client: + /// FLAGD_HOST - The host name of the flagd server (default="localhost") + /// FLAGD_PORT - The port of the flagd server (default="8013") + /// FLAGD_TLS - Determines whether to use https or not (default="false") + /// + public FlagdProvider() + { + var flagdHost = Environment.GetEnvironmentVariable("FLAGD_HOST") ?? "localhost"; + var flagdPort = Environment.GetEnvironmentVariable("FLAGD_PORT") ?? "8013"; + var flagdUseTLSStr = Environment.GetEnvironmentVariable("FLAGD_TLS") ?? "false"; + + + var protocol = "http"; + var useTLS = bool.Parse(flagdUseTLSStr); + + if (useTLS) + { + protocol = "https"; + } + + var url = new Uri(protocol + "://" + flagdHost + ":" + flagdPort); + _client = new Service.ServiceClient(GrpcChannel.ForAddress(url)); + } + /// /// Constructor of the provider. /// The URL of the flagD server @@ -52,6 +79,11 @@ public static string GetProviderName() /// Return the metadata associated to this provider. /// public override Metadata GetMetadata() => _providerMetadata; + + /// + /// Return the Grpc client of the provider + /// + public Service.ServiceClient GetClient() => _client; /// /// ResolveBooleanValue resolve the value for a Boolean Flag. diff --git a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj index 916488a9..4c30b386 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj +++ b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj @@ -12,7 +12,6 @@ Todd Baert - diff --git a/src/OpenFeature.Contrib.Providers.Flagd/README.md b/src/OpenFeature.Contrib.Providers.Flagd/README.md index 14e477bf..c77b18ae 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/README.md +++ b/src/OpenFeature.Contrib.Providers.Flagd/README.md @@ -71,3 +71,26 @@ namespace OpenFeatureTestApp } } ``` + +### Configuring the FlagdProvider + +The URI of the flagd server to which the `FlagdProvider` connects to can either be passed directly to the constructor, or be configured using the following environment variables: + +| Option name | Environment variable name | Type | Default | Values | +| --------------------- | ------------------------------- | ------- | --------- | ------------- | +| host | FLAGD_HOST | string | localhost | | +| port | FLAGD_PORT | number | 8013 | | +| tls | FLAGD_TLS | boolean | false | | + +So for example, if you would like to pass the URI directly, you can initialise it as follows: + +```csharp +var flagdProvider = new FlagdProvider(new Uri("http://localhost:8013")); +``` + +Or, if you rely on the environment variables listed above, you can use the empty costructor: + + +```csharp +var flagdProvider = new FlagdProvider(); +``` diff --git a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs index 62bfb6ba..fff004fb 100644 --- a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs +++ b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs @@ -14,6 +14,16 @@ public void TestGetProviderName() { Assert.Equal("No-op Provider", FlagdProvider.GetProviderName()); } + + [Fact] + public void TestGetProviderWithDefaultConfig() + { + var flagdProvider = new FlagdProvider(); + + var client = flagdProvider.GetClient(); + + Assert.NotNull(client); + } [Fact] public void TestResolveBooleanValue() From b45b2501f3a6febcdded38db96cafef5e53e5e03 Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Wed, 8 Feb 2023 11:27:03 +0100 Subject: [PATCH 08/14] map exception to FeatureFlagProviderException with appropriate error codes Signed-off-by: Florian Bacher --- .../FlagdProvider.cs | 84 ++++++++-------- .../FlagdProviderTest.cs | 95 +++++++++++-------- 2 files changed, 104 insertions(+), 75 deletions(-) diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs index 1a885b29..32dfc237 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -4,6 +4,7 @@ using Google.Protobuf.WellKnownTypes; using Grpc.Net.Client; using OpenFeature.Model; +using OpenFeature.Error; using Schema.V1; using Value = OpenFeature.Model.Value; @@ -111,7 +112,7 @@ public override async Task> ResolveBooleanValue(string f } catch (Grpc.Core.RpcException e) { - return GetDefaultWithException(e, flagKey, defaultValue); + throw GetOFException(e); } } @@ -141,9 +142,8 @@ public override async Task> ResolveStringValue(string } catch (Grpc.Core.RpcException e) { - return GetDefaultWithException(e, flagKey, defaultValue); + throw GetOFException(e); } - } /// @@ -172,7 +172,7 @@ public override async Task> ResolveIntegerValue(string fl } catch (Grpc.Core.RpcException e) { - return GetDefaultWithException(e, flagKey, defaultValue); + throw GetOFException(e); } } @@ -202,7 +202,7 @@ public override async Task> ResolveDoubleValue(string } catch (Grpc.Core.RpcException e) { - return GetDefaultWithException(e, flagKey, defaultValue); + throw GetOFException(e); } } @@ -232,21 +232,22 @@ public override async Task> ResolveStructureValue(strin } catch (Grpc.Core.RpcException e) { - return GetDefaultWithException(e, flagKey, defaultValue); + throw GetOFException(e); } } /// - /// GetDefaultWithException returns the default value for a flag, together with some error information about why thy flag could not be retrieved by the provider. + /// GetOFException returns a OpenFeature Exception containing an error code to describe the encountered error. /// /// The exception thrown by the Grpc client - /// Name of the flag - /// Default value to return /// A ResolutionDetails object containing the value of your flag - private ResolutionDetails GetDefaultWithException(Grpc.Core.RpcException e, String flagKey, T defaultValue) + private FeatureProviderException GetOFException(Grpc.Core.RpcException e) { - if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound) + switch (e.Status.StatusCode) { + case Grpc.Core.StatusCode.NotFound: + return new FeatureProviderException(Constant.ErrorType.FlagNotFound, e.Status.Detail, e); + /* return new ResolutionDetails( flagKey: flagKey, value: defaultValue, @@ -254,34 +255,41 @@ private ResolutionDetails GetDefaultWithException(Grpc.Core.RpcException e errorType: Constant.ErrorType.FlagNotFound, errorMessage: e.Status.Detail.ToString() ); + */ + case Grpc.Core.StatusCode.Unavailable: + return new FeatureProviderException(Constant.ErrorType.ProviderNotReady, e.Status.Detail, e); + /* + return new ResolutionDetails( + flagKey: flagKey, + value: defaultValue, + reason: Constant.Reason.Error, + errorType: Constant.ErrorType.ProviderNotReady, + errorMessage: e.Status.Detail.ToString() + ); + */ + case Grpc.Core.StatusCode.InvalidArgument: + return new FeatureProviderException(Constant.ErrorType.TypeMismatch, e.Status.Detail, e); + /* + return new ResolutionDetails( + flagKey: flagKey, + value: defaultValue, + reason: Constant.Reason.Error, + errorType: Constant.ErrorType.TypeMismatch, + errorMessage: e.Status.Detail.ToString() + ); + */ + default: + return new FeatureProviderException(Constant.ErrorType.General, e.Status.Detail, e); + /* + return new ResolutionDetails( + flagKey: flagKey, + value: defaultValue, + reason: Constant.Reason.Error, + errorType: Constant.ErrorType.General, + errorMessage: e.Status.Detail.ToString() + ); + */ } - else if (e.Status.StatusCode == Grpc.Core.StatusCode.Unavailable) - { - return new ResolutionDetails( - flagKey: flagKey, - value: defaultValue, - reason: Constant.Reason.Error, - errorType: Constant.ErrorType.ProviderNotReady, - errorMessage: e.Status.Detail.ToString() - ); - } - else if (e.Status.StatusCode == Grpc.Core.StatusCode.InvalidArgument) - { - return new ResolutionDetails( - flagKey: flagKey, - value: defaultValue, - reason: Constant.Reason.Error, - errorType: Constant.ErrorType.TypeMismatch, - errorMessage: e.Status.Detail.ToString() - ); - } - return new ResolutionDetails( - flagKey: flagKey, - value: defaultValue, - reason: Constant.Reason.Error, - errorType: Constant.ErrorType.General, - errorMessage: e.Status.Detail.ToString() - ); } /// diff --git a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs index fff004fb..cb5fe01c 100644 --- a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs +++ b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs @@ -3,6 +3,7 @@ using Schema.V1; using Grpc.Core; using Google.Protobuf.WellKnownTypes; +using OpenFeature.Error; using ProtoValue = Google.Protobuf.WellKnownTypes.Value; namespace OpenFeature.Contrib.Providers.Flagd.Test @@ -181,15 +182,20 @@ public void TestResolveFlagNotFound() var flagdProvider = new FlagdProvider(mockGrpcClient.Object); - // resolve with default set to true - var val = flagdProvider.ResolveBooleanValue("my-key", true, null); - - // here we should get the default value regardless of the failed grpc call - Assert.True(val.Result.Value); - // check for error information to be included in the result - Assert.Equal(Constant.Reason.Error, val.Result.Reason); - Assert.Equal(Constant.ErrorType.FlagNotFound, val.Result.ErrorType); - Assert.Equal(Constant.ErrorType.FlagNotFound.ToString(), val.Result.ErrorMessage); + // make sure the correct exception is thrown + Assert.ThrowsAsync(async () => + { + try + { + await flagdProvider.ResolveBooleanValue("my-key", true, null); + } + catch (FeatureProviderException e) + { + Assert.Equal(Constant.ErrorType.FlagNotFound, e.ErrorType); + Assert.Equal(Constant.ErrorType.FlagNotFound.ToString(), e.Message); + throw; + } + }); } [Fact] @@ -211,16 +217,21 @@ public void TestResolveGrpcHostUnavailable() .Returns(grpcResp); var flagdProvider = new FlagdProvider(mockGrpcClient.Object); - - // resolve with default set to true - var val = flagdProvider.ResolveBooleanValue("my-key", true, null); - - // here we should get the default value regardless of the failed grpc call - Assert.True(val.Result.Value); - // check for error information to be included in the result - Assert.Equal(Constant.Reason.Error, val.Result.Reason); - Assert.Equal(Constant.ErrorType.ProviderNotReady, val.Result.ErrorType); - Assert.Equal(Constant.ErrorType.ProviderNotReady.ToString(), val.Result.ErrorMessage); + + // make sure the correct exception is thrown + Assert.ThrowsAsync(async () => + { + try + { + await flagdProvider.ResolveBooleanValue("my-key", true, null); + } + catch (FeatureProviderException e) + { + Assert.Equal(Constant.ErrorType.ProviderNotReady, e.ErrorType); + Assert.Equal(Constant.ErrorType.ProviderNotReady.ToString(), e.Message); + throw; + } + }); } [Fact] @@ -243,15 +254,20 @@ public void TestResolveTypeMismatch() var flagdProvider = new FlagdProvider(mockGrpcClient.Object); - // resolve with default set to true - var val = flagdProvider.ResolveBooleanValue("my-key", true, null); - - // here we should get the default value regardless of the failed grpc call - Assert.True(val.Result.Value); - // check for error information to be included in the result - Assert.Equal(Constant.Reason.Error, val.Result.Reason); - Assert.Equal(Constant.ErrorType.TypeMismatch, val.Result.ErrorType); - Assert.Equal(Constant.ErrorType.TypeMismatch.ToString(), val.Result.ErrorMessage); + // make sure the correct exception is thrown + Assert.ThrowsAsync(async () => + { + try + { + await flagdProvider.ResolveBooleanValue("my-key", true, null); + } + catch (FeatureProviderException e) + { + Assert.Equal(Constant.ErrorType.TypeMismatch, e.ErrorType); + Assert.Equal(Constant.ErrorType.TypeMismatch.ToString(), e.Message); + throw; + } + }); } [Fact] @@ -274,15 +290,20 @@ public void TestResolveUnknownError() var flagdProvider = new FlagdProvider(mockGrpcClient.Object); - // resolve with default set to true - var val = flagdProvider.ResolveBooleanValue("my-key", true, null); - - // here we should get the default value regardless of the failed grpc call - Assert.True(val.Result.Value); - // check for error information to be included in the result - Assert.Equal(Constant.Reason.Error, val.Result.Reason); - Assert.Equal(Constant.ErrorType.General, val.Result.ErrorType); - Assert.Equal("unknown error", val.Result.ErrorMessage); + // make sure the correct exception is thrown + Assert.ThrowsAsync(async () => + { + try + { + await flagdProvider.ResolveBooleanValue("my-key", true, null); + } + catch (FeatureProviderException e) + { + Assert.Equal(Constant.ErrorType.General, e.ErrorType); + Assert.Equal(Constant.ErrorType.General.ToString(), e.Message); + throw; + } + }); } } } From c52f2b3fe4b324bacfe8d2634666f0250e1efcd4 Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Wed, 8 Feb 2023 13:38:43 +0100 Subject: [PATCH 09/14] added generic Resolve function Signed-off-by: Florian Bacher --- .../FlagdProvider.cs | 103 ++++++------------ 1 file changed, 32 insertions(+), 71 deletions(-) diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs index 32dfc237..64a359ce 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -1,12 +1,15 @@ using System; using System.Linq; using System.Threading.Tasks; +using Google.Protobuf; using Google.Protobuf.WellKnownTypes; +using Grpc.Core; using Grpc.Net.Client; using OpenFeature.Model; using OpenFeature.Error; using Schema.V1; +using Metadata = OpenFeature.Model.Metadata; using Value = OpenFeature.Model.Value; using ProtoValue = Google.Protobuf.WellKnownTypes.Value; @@ -95,11 +98,11 @@ public static string GetProviderName() /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveBooleanValue(string flagKey, bool defaultValue, EvaluationContext context = null) { - try + return await ResolveValue(async contextStruct => { var resolveBooleanResponse = await _client.ResolveBooleanAsync(new ResolveBooleanRequest { - Context = ConvertToContext(context), + Context = contextStruct, FlagKey = flagKey }); @@ -109,11 +112,7 @@ public override async Task> ResolveBooleanValue(string f reason: resolveBooleanResponse.Reason, variant: resolveBooleanResponse.Variant ); - } - catch (Grpc.Core.RpcException e) - { - throw GetOFException(e); - } + }, context); } /// @@ -125,25 +124,21 @@ public override async Task> ResolveBooleanValue(string f /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveStringValue(string flagKey, string defaultValue, EvaluationContext context = null) { - try + return await ResolveValue(async contextStruct => { - var resolveBooleanResponse = await _client.ResolveStringAsync(new ResolveStringRequest + var resolveStringResponse = await _client.ResolveStringAsync(new ResolveStringRequest { - Context = ConvertToContext(context), + Context = contextStruct, FlagKey = flagKey }); return new ResolutionDetails( flagKey: flagKey, - value: resolveBooleanResponse.Value, - reason: resolveBooleanResponse.Reason, - variant: resolveBooleanResponse.Variant + value: resolveStringResponse.Value, + reason: resolveStringResponse.Reason, + variant: resolveStringResponse.Variant ); - } - catch (Grpc.Core.RpcException e) - { - throw GetOFException(e); - } + }, context); } /// @@ -155,11 +150,11 @@ public override async Task> ResolveStringValue(string /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveIntegerValue(string flagKey, int defaultValue, EvaluationContext context = null) { - try + return await ResolveValue(async contextStruct => { var resolveIntResponse = await _client.ResolveIntAsync(new ResolveIntRequest { - Context = ConvertToContext(context), + Context = contextStruct, FlagKey = flagKey }); @@ -169,11 +164,7 @@ public override async Task> ResolveIntegerValue(string fl reason: resolveIntResponse.Reason, variant: resolveIntResponse.Variant ); - } - catch (Grpc.Core.RpcException e) - { - throw GetOFException(e); - } + }, context); } /// @@ -185,11 +176,11 @@ public override async Task> ResolveIntegerValue(string fl /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveDoubleValue(string flagKey, double defaultValue, EvaluationContext context = null) { - try + return await ResolveValue(async contextStruct => { var resolveDoubleResponse = await _client.ResolveFloatAsync(new ResolveFloatRequest { - Context = ConvertToContext(context), + Context = contextStruct, FlagKey = flagKey }); @@ -199,11 +190,7 @@ public override async Task> ResolveDoubleValue(string reason: resolveDoubleResponse.Reason, variant: resolveDoubleResponse.Variant ); - } - catch (Grpc.Core.RpcException e) - { - throw GetOFException(e); - } + }, context); } /// @@ -215,11 +202,11 @@ public override async Task> ResolveDoubleValue(string /// A ResolutionDetails object containing the value of your flag public override async Task> ResolveStructureValue(string flagKey, Value defaultValue, EvaluationContext context = null) { - try + return await ResolveValue(async contextStruct => { var resolveObjectResponse = await _client.ResolveObjectAsync(new ResolveObjectRequest { - Context = ConvertToContext(context), + Context = contextStruct, FlagKey = flagKey }); @@ -229,8 +216,18 @@ public override async Task> ResolveStructureValue(strin reason: resolveObjectResponse.Reason, variant: resolveObjectResponse.Variant ); + }, context); + } + + private async Task> ResolveValue(Func>> resolveDelegate, EvaluationContext context = null) + { + try + { + var result = await resolveDelegate.Invoke(ConvertToContext(context)); + + return result; } - catch (Grpc.Core.RpcException e) + catch (RpcException e) { throw GetOFException(e); } @@ -247,48 +244,12 @@ private FeatureProviderException GetOFException(Grpc.Core.RpcException e) { case Grpc.Core.StatusCode.NotFound: return new FeatureProviderException(Constant.ErrorType.FlagNotFound, e.Status.Detail, e); - /* - return new ResolutionDetails( - flagKey: flagKey, - value: defaultValue, - reason: Constant.Reason.Error, - errorType: Constant.ErrorType.FlagNotFound, - errorMessage: e.Status.Detail.ToString() - ); - */ case Grpc.Core.StatusCode.Unavailable: return new FeatureProviderException(Constant.ErrorType.ProviderNotReady, e.Status.Detail, e); - /* - return new ResolutionDetails( - flagKey: flagKey, - value: defaultValue, - reason: Constant.Reason.Error, - errorType: Constant.ErrorType.ProviderNotReady, - errorMessage: e.Status.Detail.ToString() - ); - */ case Grpc.Core.StatusCode.InvalidArgument: return new FeatureProviderException(Constant.ErrorType.TypeMismatch, e.Status.Detail, e); - /* - return new ResolutionDetails( - flagKey: flagKey, - value: defaultValue, - reason: Constant.Reason.Error, - errorType: Constant.ErrorType.TypeMismatch, - errorMessage: e.Status.Detail.ToString() - ); - */ default: return new FeatureProviderException(Constant.ErrorType.General, e.Status.Detail, e); - /* - return new ResolutionDetails( - flagKey: flagKey, - value: defaultValue, - reason: Constant.Reason.Error, - errorType: Constant.ErrorType.General, - errorMessage: e.Status.Detail.ToString() - ); - */ } } From 96e305cdc1796fc02c88099f2f8f4726e340258d Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Wed, 8 Feb 2023 15:28:31 +0100 Subject: [PATCH 10/14] generate grpc client during build, remove auto generated code from repo Signed-off-by: Florian Bacher --- .../FlagdProvider.cs | 3 +- ...OpenFeature.Contrib.Providers.Flagd.csproj | 3 +- .../Proto/csharp/Schema.cs | 2943 ----------------- .../Proto/csharp/SchemaGrpc.cs | 348 -- .../FlagdProviderTest.cs | 2 +- 5 files changed, 4 insertions(+), 3295 deletions(-) delete mode 100644 src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/Schema.cs delete mode 100644 src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/SchemaGrpc.cs diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs index 64a359ce..083a4569 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -1,14 +1,13 @@ using System; using System.Linq; using System.Threading.Tasks; -using Google.Protobuf; using Google.Protobuf.WellKnownTypes; using Grpc.Core; using Grpc.Net.Client; using OpenFeature.Model; using OpenFeature.Error; -using Schema.V1; +using OpenFeature.Flagd.Grpc; using Metadata = OpenFeature.Model.Metadata; using Value = OpenFeature.Model.Value; using ProtoValue = Google.Protobuf.WellKnownTypes.Value; diff --git a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj index 4c30b386..5810367a 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj +++ b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj @@ -13,8 +13,9 @@ - + + diff --git a/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/Schema.cs b/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/Schema.cs deleted file mode 100644 index d6e4322d..00000000 --- a/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/Schema.cs +++ /dev/null @@ -1,2943 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: schema/v1/schema.proto -// -#pragma warning disable 1591, 0612, 3021, 8981 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Schema.V1 { - - /// Holder for reflection information generated from schema/v1/schema.proto - public static partial class SchemaReflection { - - #region Descriptor - /// File descriptor for schema/v1/schema.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static SchemaReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "ChZzY2hlbWEvdjEvc2NoZW1hLnByb3RvEglzY2hlbWEudjEaHGdvb2dsZS9w", - "cm90b2J1Zi9zdHJ1Y3QucHJvdG8aG2dvb2dsZS9wcm90b2J1Zi9lbXB0eS5w", - "cm90byJlChVSZXNvbHZlQm9vbGVhblJlcXVlc3QSGQoIZmxhZ19rZXkYASAB", - "KAlSB2ZsYWdLZXkSMQoHY29udGV4dBgCIAEoCzIXLmdvb2dsZS5wcm90b2J1", - "Zi5TdHJ1Y3RSB2NvbnRleHQiYAoWUmVzb2x2ZUJvb2xlYW5SZXNwb25zZRIU", - "CgV2YWx1ZRgBIAEoCFIFdmFsdWUSFgoGcmVhc29uGAIgASgJUgZyZWFzb24S", - "GAoHdmFyaWFudBgDIAEoCVIHdmFyaWFudCJkChRSZXNvbHZlU3RyaW5nUmVx", - "dWVzdBIZCghmbGFnX2tleRgBIAEoCVIHZmxhZ0tleRIxCgdjb250ZXh0GAIg", - "ASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdFIHY29udGV4dCJfChVSZXNv", - "bHZlU3RyaW5nUmVzcG9uc2USFAoFdmFsdWUYASABKAlSBXZhbHVlEhYKBnJl", - "YXNvbhgCIAEoCVIGcmVhc29uEhgKB3ZhcmlhbnQYAyABKAlSB3ZhcmlhbnQi", - "YwoTUmVzb2x2ZUZsb2F0UmVxdWVzdBIZCghmbGFnX2tleRgBIAEoCVIHZmxh", - "Z0tleRIxCgdjb250ZXh0GAIgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVj", - "dFIHY29udGV4dCJeChRSZXNvbHZlRmxvYXRSZXNwb25zZRIUCgV2YWx1ZRgB", - "IAEoAVIFdmFsdWUSFgoGcmVhc29uGAIgASgJUgZyZWFzb24SGAoHdmFyaWFu", - "dBgDIAEoCVIHdmFyaWFudCJhChFSZXNvbHZlSW50UmVxdWVzdBIZCghmbGFn", - "X2tleRgBIAEoCVIHZmxhZ0tleRIxCgdjb250ZXh0GAIgASgLMhcuZ29vZ2xl", - "LnByb3RvYnVmLlN0cnVjdFIHY29udGV4dCJcChJSZXNvbHZlSW50UmVzcG9u", - "c2USFAoFdmFsdWUYASABKANSBXZhbHVlEhYKBnJlYXNvbhgCIAEoCVIGcmVh", - "c29uEhgKB3ZhcmlhbnQYAyABKAlSB3ZhcmlhbnQiZAoUUmVzb2x2ZU9iamVj", - "dFJlcXVlc3QSGQoIZmxhZ19rZXkYASABKAlSB2ZsYWdLZXkSMQoHY29udGV4", - "dBgCIAEoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3RSB2NvbnRleHQieAoV", - "UmVzb2x2ZU9iamVjdFJlc3BvbnNlEi0KBXZhbHVlGAEgASgLMhcuZ29vZ2xl", - "LnByb3RvYnVmLlN0cnVjdFIFdmFsdWUSFgoGcmVhc29uGAIgASgJUgZyZWFz", - "b24SGAoHdmFyaWFudBgDIAEoCVIHdmFyaWFudCJWChNFdmVudFN0cmVhbVJl", - "c3BvbnNlEhIKBHR5cGUYASABKAlSBHR5cGUSKwoEZGF0YRgCIAEoCzIXLmdv", - "b2dsZS5wcm90b2J1Zi5TdHJ1Y3RSBGRhdGEy+QMKB1NlcnZpY2USVwoOUmVz", - "b2x2ZUJvb2xlYW4SIC5zY2hlbWEudjEuUmVzb2x2ZUJvb2xlYW5SZXF1ZXN0", - "GiEuc2NoZW1hLnYxLlJlc29sdmVCb29sZWFuUmVzcG9uc2UiABJUCg1SZXNv", - "bHZlU3RyaW5nEh8uc2NoZW1hLnYxLlJlc29sdmVTdHJpbmdSZXF1ZXN0GiAu", - "c2NoZW1hLnYxLlJlc29sdmVTdHJpbmdSZXNwb25zZSIAElEKDFJlc29sdmVG", - "bG9hdBIeLnNjaGVtYS52MS5SZXNvbHZlRmxvYXRSZXF1ZXN0Gh8uc2NoZW1h", - "LnYxLlJlc29sdmVGbG9hdFJlc3BvbnNlIgASSwoKUmVzb2x2ZUludBIcLnNj", - "aGVtYS52MS5SZXNvbHZlSW50UmVxdWVzdBodLnNjaGVtYS52MS5SZXNvbHZl", - "SW50UmVzcG9uc2UiABJUCg1SZXNvbHZlT2JqZWN0Eh8uc2NoZW1hLnYxLlJl", - "c29sdmVPYmplY3RSZXF1ZXN0GiAuc2NoZW1hLnYxLlJlc29sdmVPYmplY3RS", - "ZXNwb25zZSIAEkkKC0V2ZW50U3RyZWFtEhYuZ29vZ2xlLnByb3RvYnVmLkVt", - "cHR5Gh4uc2NoZW1hLnYxLkV2ZW50U3RyZWFtUmVzcG9uc2UiADABQnQKDWNv", - "bS5zY2hlbWEudjFCC1NjaGVtYVByb3RvUAFaEXNjaGVtYS9zZXJ2aWNlL3Yx", - "ogIDU1hYqgIJU2NoZW1hLlYxygIJU2NoZW1hXFYx4gIVU2NoZW1hXFYxXEdQ", - "Qk1ldGFkYXRh6gIKU2NoZW1hOjpWMWIGcHJvdG8z")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.EmptyReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveBooleanRequest), global::Schema.V1.ResolveBooleanRequest.Parser, new[]{ "FlagKey", "Context" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveBooleanResponse), global::Schema.V1.ResolveBooleanResponse.Parser, new[]{ "Value", "Reason", "Variant" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveStringRequest), global::Schema.V1.ResolveStringRequest.Parser, new[]{ "FlagKey", "Context" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveStringResponse), global::Schema.V1.ResolveStringResponse.Parser, new[]{ "Value", "Reason", "Variant" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveFloatRequest), global::Schema.V1.ResolveFloatRequest.Parser, new[]{ "FlagKey", "Context" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveFloatResponse), global::Schema.V1.ResolveFloatResponse.Parser, new[]{ "Value", "Reason", "Variant" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveIntRequest), global::Schema.V1.ResolveIntRequest.Parser, new[]{ "FlagKey", "Context" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveIntResponse), global::Schema.V1.ResolveIntResponse.Parser, new[]{ "Value", "Reason", "Variant" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveObjectRequest), global::Schema.V1.ResolveObjectRequest.Parser, new[]{ "FlagKey", "Context" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.ResolveObjectResponse), global::Schema.V1.ResolveObjectResponse.Parser, new[]{ "Value", "Reason", "Variant" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Schema.V1.EventStreamResponse), global::Schema.V1.EventStreamResponse.Parser, new[]{ "Type", "Data" }, null, null, null, null) - })); - } - #endregion - - } - #region Messages - /// - /// Request body for boolean flag evaluation, used by the ResolveBoolean rpc. - /// - public sealed partial class ResolveBooleanRequest : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveBooleanRequest()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveBooleanRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveBooleanRequest(ResolveBooleanRequest other) : this() { - flagKey_ = other.flagKey_; - context_ = other.context_ != null ? other.context_.Clone() : null; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveBooleanRequest Clone() { - return new ResolveBooleanRequest(this); - } - - /// Field number for the "flag_key" field. - public const int FlagKeyFieldNumber = 1; - private string flagKey_ = ""; - /// - /// Flag key of the requested flag. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string FlagKey { - get { return flagKey_; } - set { - flagKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "context" field. - public const int ContextFieldNumber = 2; - private global::Google.Protobuf.WellKnownTypes.Struct context_; - /// - /// Object structure describing the EvaluationContext used in the flag evaluation, see https://docs.openfeature.dev/docs/reference/concepts/evaluation-context - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::Google.Protobuf.WellKnownTypes.Struct Context { - get { return context_; } - set { - context_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ResolveBooleanRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ResolveBooleanRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (FlagKey != other.FlagKey) return false; - if (!object.Equals(Context, other.Context)) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (FlagKey.Length != 0) hash ^= FlagKey.GetHashCode(); - if (context_ != null) hash ^= Context.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (FlagKey.Length != 0) { - output.WriteRawTag(10); - output.WriteString(FlagKey); - } - if (context_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Context); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (FlagKey.Length != 0) { - output.WriteRawTag(10); - output.WriteString(FlagKey); - } - if (context_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Context); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (FlagKey.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(FlagKey); - } - if (context_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ResolveBooleanRequest other) { - if (other == null) { - return; - } - if (other.FlagKey.Length != 0) { - FlagKey = other.FlagKey; - } - if (other.context_ != null) { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - Context.MergeFrom(other.Context); - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - FlagKey = input.ReadString(); - break; - } - case 18: { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Context); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - FlagKey = input.ReadString(); - break; - } - case 18: { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Context); - break; - } - } - } - } - #endif - - } - - /// - /// Response body for boolean flag evaluation. used by the ResolveBoolean rpc. - /// - public sealed partial class ResolveBooleanResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveBooleanResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveBooleanResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveBooleanResponse(ResolveBooleanResponse other) : this() { - value_ = other.value_; - reason_ = other.reason_; - variant_ = other.variant_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveBooleanResponse Clone() { - return new ResolveBooleanResponse(this); - } - - /// Field number for the "value" field. - public const int ValueFieldNumber = 1; - private bool value_; - /// - /// The response value of the boolean flag evaluation, will be unset in the case of error. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Value { - get { return value_; } - set { - value_ = value; - } - } - - /// Field number for the "reason" field. - public const int ReasonFieldNumber = 2; - private string reason_ = ""; - /// - /// The reason for the given return value, see https://docs.openfeature.dev/docs/specification/types#resolution-details - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Reason { - get { return reason_; } - set { - reason_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "variant" field. - public const int VariantFieldNumber = 3; - private string variant_ = ""; - /// - /// The variant name of the returned flag value. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Variant { - get { return variant_; } - set { - variant_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ResolveBooleanResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ResolveBooleanResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Value != other.Value) return false; - if (Reason != other.Reason) return false; - if (Variant != other.Variant) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (Value != false) hash ^= Value.GetHashCode(); - if (Reason.Length != 0) hash ^= Reason.GetHashCode(); - if (Variant.Length != 0) hash ^= Variant.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (Value != false) { - output.WriteRawTag(8); - output.WriteBool(Value); - } - if (Reason.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Reason); - } - if (Variant.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Variant); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (Value != false) { - output.WriteRawTag(8); - output.WriteBool(Value); - } - if (Reason.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Reason); - } - if (Variant.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Variant); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (Value != false) { - size += 1 + 1; - } - if (Reason.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Reason); - } - if (Variant.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Variant); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ResolveBooleanResponse other) { - if (other == null) { - return; - } - if (other.Value != false) { - Value = other.Value; - } - if (other.Reason.Length != 0) { - Reason = other.Reason; - } - if (other.Variant.Length != 0) { - Variant = other.Variant; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - Value = input.ReadBool(); - break; - } - case 18: { - Reason = input.ReadString(); - break; - } - case 26: { - Variant = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - Value = input.ReadBool(); - break; - } - case 18: { - Reason = input.ReadString(); - break; - } - case 26: { - Variant = input.ReadString(); - break; - } - } - } - } - #endif - - } - - /// - /// Request body for string flag evaluation, used by the ResolveString rpc. - /// - public sealed partial class ResolveStringRequest : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveStringRequest()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[2]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveStringRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveStringRequest(ResolveStringRequest other) : this() { - flagKey_ = other.flagKey_; - context_ = other.context_ != null ? other.context_.Clone() : null; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveStringRequest Clone() { - return new ResolveStringRequest(this); - } - - /// Field number for the "flag_key" field. - public const int FlagKeyFieldNumber = 1; - private string flagKey_ = ""; - /// - /// Flag key of the requested flag. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string FlagKey { - get { return flagKey_; } - set { - flagKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "context" field. - public const int ContextFieldNumber = 2; - private global::Google.Protobuf.WellKnownTypes.Struct context_; - /// - /// Object structure describing the EvaluationContext used in the flag evaluation, see https://docs.openfeature.dev/docs/reference/concepts/evaluation-context - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::Google.Protobuf.WellKnownTypes.Struct Context { - get { return context_; } - set { - context_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ResolveStringRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ResolveStringRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (FlagKey != other.FlagKey) return false; - if (!object.Equals(Context, other.Context)) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (FlagKey.Length != 0) hash ^= FlagKey.GetHashCode(); - if (context_ != null) hash ^= Context.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (FlagKey.Length != 0) { - output.WriteRawTag(10); - output.WriteString(FlagKey); - } - if (context_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Context); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (FlagKey.Length != 0) { - output.WriteRawTag(10); - output.WriteString(FlagKey); - } - if (context_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Context); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (FlagKey.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(FlagKey); - } - if (context_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ResolveStringRequest other) { - if (other == null) { - return; - } - if (other.FlagKey.Length != 0) { - FlagKey = other.FlagKey; - } - if (other.context_ != null) { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - Context.MergeFrom(other.Context); - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - FlagKey = input.ReadString(); - break; - } - case 18: { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Context); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - FlagKey = input.ReadString(); - break; - } - case 18: { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Context); - break; - } - } - } - } - #endif - - } - - /// - /// Response body for string flag evaluation. used by the ResolveString rpc. - /// - public sealed partial class ResolveStringResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveStringResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[3]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveStringResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveStringResponse(ResolveStringResponse other) : this() { - value_ = other.value_; - reason_ = other.reason_; - variant_ = other.variant_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveStringResponse Clone() { - return new ResolveStringResponse(this); - } - - /// Field number for the "value" field. - public const int ValueFieldNumber = 1; - private string value_ = ""; - /// - /// The response value of the string flag evaluation, will be unset in the case of error. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Value { - get { return value_; } - set { - value_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "reason" field. - public const int ReasonFieldNumber = 2; - private string reason_ = ""; - /// - /// The reason for the given return value, see https://docs.openfeature.dev/docs/specification/types#resolution-details - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Reason { - get { return reason_; } - set { - reason_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "variant" field. - public const int VariantFieldNumber = 3; - private string variant_ = ""; - /// - /// The variant name of the returned flag value. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Variant { - get { return variant_; } - set { - variant_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ResolveStringResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ResolveStringResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Value != other.Value) return false; - if (Reason != other.Reason) return false; - if (Variant != other.Variant) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (Value.Length != 0) hash ^= Value.GetHashCode(); - if (Reason.Length != 0) hash ^= Reason.GetHashCode(); - if (Variant.Length != 0) hash ^= Variant.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (Value.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Value); - } - if (Reason.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Reason); - } - if (Variant.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Variant); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (Value.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Value); - } - if (Reason.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Reason); - } - if (Variant.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Variant); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (Value.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Value); - } - if (Reason.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Reason); - } - if (Variant.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Variant); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ResolveStringResponse other) { - if (other == null) { - return; - } - if (other.Value.Length != 0) { - Value = other.Value; - } - if (other.Reason.Length != 0) { - Reason = other.Reason; - } - if (other.Variant.Length != 0) { - Variant = other.Variant; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - Value = input.ReadString(); - break; - } - case 18: { - Reason = input.ReadString(); - break; - } - case 26: { - Variant = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - Value = input.ReadString(); - break; - } - case 18: { - Reason = input.ReadString(); - break; - } - case 26: { - Variant = input.ReadString(); - break; - } - } - } - } - #endif - - } - - /// - /// Request body for float flag evaluation, used by the ResolveFloat rpc. - /// - public sealed partial class ResolveFloatRequest : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveFloatRequest()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[4]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveFloatRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveFloatRequest(ResolveFloatRequest other) : this() { - flagKey_ = other.flagKey_; - context_ = other.context_ != null ? other.context_.Clone() : null; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveFloatRequest Clone() { - return new ResolveFloatRequest(this); - } - - /// Field number for the "flag_key" field. - public const int FlagKeyFieldNumber = 1; - private string flagKey_ = ""; - /// - /// Flag key of the requested flag. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string FlagKey { - get { return flagKey_; } - set { - flagKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "context" field. - public const int ContextFieldNumber = 2; - private global::Google.Protobuf.WellKnownTypes.Struct context_; - /// - /// Object structure describing the EvaluationContext used in the flag evaluation, see https://docs.openfeature.dev/docs/reference/concepts/evaluation-context - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::Google.Protobuf.WellKnownTypes.Struct Context { - get { return context_; } - set { - context_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ResolveFloatRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ResolveFloatRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (FlagKey != other.FlagKey) return false; - if (!object.Equals(Context, other.Context)) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (FlagKey.Length != 0) hash ^= FlagKey.GetHashCode(); - if (context_ != null) hash ^= Context.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (FlagKey.Length != 0) { - output.WriteRawTag(10); - output.WriteString(FlagKey); - } - if (context_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Context); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (FlagKey.Length != 0) { - output.WriteRawTag(10); - output.WriteString(FlagKey); - } - if (context_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Context); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (FlagKey.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(FlagKey); - } - if (context_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ResolveFloatRequest other) { - if (other == null) { - return; - } - if (other.FlagKey.Length != 0) { - FlagKey = other.FlagKey; - } - if (other.context_ != null) { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - Context.MergeFrom(other.Context); - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - FlagKey = input.ReadString(); - break; - } - case 18: { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Context); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - FlagKey = input.ReadString(); - break; - } - case 18: { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Context); - break; - } - } - } - } - #endif - - } - - /// - /// Response body for float flag evaluation. used by the ResolveFloat rpc. - /// - public sealed partial class ResolveFloatResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveFloatResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[5]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveFloatResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveFloatResponse(ResolveFloatResponse other) : this() { - value_ = other.value_; - reason_ = other.reason_; - variant_ = other.variant_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveFloatResponse Clone() { - return new ResolveFloatResponse(this); - } - - /// Field number for the "value" field. - public const int ValueFieldNumber = 1; - private double value_; - /// - /// The response value of the float flag evaluation, will be empty in the case of error. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public double Value { - get { return value_; } - set { - value_ = value; - } - } - - /// Field number for the "reason" field. - public const int ReasonFieldNumber = 2; - private string reason_ = ""; - /// - /// The reason for the given return value, see https://docs.openfeature.dev/docs/specification/types#resolution-details - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Reason { - get { return reason_; } - set { - reason_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "variant" field. - public const int VariantFieldNumber = 3; - private string variant_ = ""; - /// - /// The variant name of the returned flag value. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Variant { - get { return variant_; } - set { - variant_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ResolveFloatResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ResolveFloatResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(Value, other.Value)) return false; - if (Reason != other.Reason) return false; - if (Variant != other.Variant) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (Value != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Value); - if (Reason.Length != 0) hash ^= Reason.GetHashCode(); - if (Variant.Length != 0) hash ^= Variant.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (Value != 0D) { - output.WriteRawTag(9); - output.WriteDouble(Value); - } - if (Reason.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Reason); - } - if (Variant.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Variant); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (Value != 0D) { - output.WriteRawTag(9); - output.WriteDouble(Value); - } - if (Reason.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Reason); - } - if (Variant.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Variant); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (Value != 0D) { - size += 1 + 8; - } - if (Reason.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Reason); - } - if (Variant.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Variant); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ResolveFloatResponse other) { - if (other == null) { - return; - } - if (other.Value != 0D) { - Value = other.Value; - } - if (other.Reason.Length != 0) { - Reason = other.Reason; - } - if (other.Variant.Length != 0) { - Variant = other.Variant; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 9: { - Value = input.ReadDouble(); - break; - } - case 18: { - Reason = input.ReadString(); - break; - } - case 26: { - Variant = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 9: { - Value = input.ReadDouble(); - break; - } - case 18: { - Reason = input.ReadString(); - break; - } - case 26: { - Variant = input.ReadString(); - break; - } - } - } - } - #endif - - } - - /// - /// Request body for int flag evaluation, used by the ResolveInt rpc. - /// - public sealed partial class ResolveIntRequest : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveIntRequest()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[6]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveIntRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveIntRequest(ResolveIntRequest other) : this() { - flagKey_ = other.flagKey_; - context_ = other.context_ != null ? other.context_.Clone() : null; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveIntRequest Clone() { - return new ResolveIntRequest(this); - } - - /// Field number for the "flag_key" field. - public const int FlagKeyFieldNumber = 1; - private string flagKey_ = ""; - /// - /// Flag key of the requested flag. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string FlagKey { - get { return flagKey_; } - set { - flagKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "context" field. - public const int ContextFieldNumber = 2; - private global::Google.Protobuf.WellKnownTypes.Struct context_; - /// - /// Object structure describing the EvaluationContext used in the flag evaluation, see https://docs.openfeature.dev/docs/reference/concepts/evaluation-context - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::Google.Protobuf.WellKnownTypes.Struct Context { - get { return context_; } - set { - context_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ResolveIntRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ResolveIntRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (FlagKey != other.FlagKey) return false; - if (!object.Equals(Context, other.Context)) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (FlagKey.Length != 0) hash ^= FlagKey.GetHashCode(); - if (context_ != null) hash ^= Context.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (FlagKey.Length != 0) { - output.WriteRawTag(10); - output.WriteString(FlagKey); - } - if (context_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Context); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (FlagKey.Length != 0) { - output.WriteRawTag(10); - output.WriteString(FlagKey); - } - if (context_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Context); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (FlagKey.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(FlagKey); - } - if (context_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ResolveIntRequest other) { - if (other == null) { - return; - } - if (other.FlagKey.Length != 0) { - FlagKey = other.FlagKey; - } - if (other.context_ != null) { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - Context.MergeFrom(other.Context); - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - FlagKey = input.ReadString(); - break; - } - case 18: { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Context); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - FlagKey = input.ReadString(); - break; - } - case 18: { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Context); - break; - } - } - } - } - #endif - - } - - /// - /// Response body for int flag evaluation. used by the ResolveInt rpc. - /// - public sealed partial class ResolveIntResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveIntResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[7]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveIntResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveIntResponse(ResolveIntResponse other) : this() { - value_ = other.value_; - reason_ = other.reason_; - variant_ = other.variant_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveIntResponse Clone() { - return new ResolveIntResponse(this); - } - - /// Field number for the "value" field. - public const int ValueFieldNumber = 1; - private long value_; - /// - /// The response value of the int flag evaluation, will be unset in the case of error. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public long Value { - get { return value_; } - set { - value_ = value; - } - } - - /// Field number for the "reason" field. - public const int ReasonFieldNumber = 2; - private string reason_ = ""; - /// - /// The reason for the given return value, see https://docs.openfeature.dev/docs/specification/types#resolution-details - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Reason { - get { return reason_; } - set { - reason_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "variant" field. - public const int VariantFieldNumber = 3; - private string variant_ = ""; - /// - /// The variant name of the returned flag value. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Variant { - get { return variant_; } - set { - variant_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ResolveIntResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ResolveIntResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Value != other.Value) return false; - if (Reason != other.Reason) return false; - if (Variant != other.Variant) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (Value != 0L) hash ^= Value.GetHashCode(); - if (Reason.Length != 0) hash ^= Reason.GetHashCode(); - if (Variant.Length != 0) hash ^= Variant.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (Value != 0L) { - output.WriteRawTag(8); - output.WriteInt64(Value); - } - if (Reason.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Reason); - } - if (Variant.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Variant); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (Value != 0L) { - output.WriteRawTag(8); - output.WriteInt64(Value); - } - if (Reason.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Reason); - } - if (Variant.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Variant); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (Value != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(Value); - } - if (Reason.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Reason); - } - if (Variant.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Variant); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ResolveIntResponse other) { - if (other == null) { - return; - } - if (other.Value != 0L) { - Value = other.Value; - } - if (other.Reason.Length != 0) { - Reason = other.Reason; - } - if (other.Variant.Length != 0) { - Variant = other.Variant; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 8: { - Value = input.ReadInt64(); - break; - } - case 18: { - Reason = input.ReadString(); - break; - } - case 26: { - Variant = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 8: { - Value = input.ReadInt64(); - break; - } - case 18: { - Reason = input.ReadString(); - break; - } - case 26: { - Variant = input.ReadString(); - break; - } - } - } - } - #endif - - } - - /// - /// Request body for object flag evaluation, used by the ResolveObject rpc. - /// - public sealed partial class ResolveObjectRequest : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveObjectRequest()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[8]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveObjectRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveObjectRequest(ResolveObjectRequest other) : this() { - flagKey_ = other.flagKey_; - context_ = other.context_ != null ? other.context_.Clone() : null; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveObjectRequest Clone() { - return new ResolveObjectRequest(this); - } - - /// Field number for the "flag_key" field. - public const int FlagKeyFieldNumber = 1; - private string flagKey_ = ""; - /// - /// Flag key of the requested flag. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string FlagKey { - get { return flagKey_; } - set { - flagKey_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "context" field. - public const int ContextFieldNumber = 2; - private global::Google.Protobuf.WellKnownTypes.Struct context_; - /// - /// Object structure describing the EvaluationContext used in the flag evaluation, see https://docs.openfeature.dev/docs/reference/concepts/evaluation-context - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::Google.Protobuf.WellKnownTypes.Struct Context { - get { return context_; } - set { - context_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ResolveObjectRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ResolveObjectRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (FlagKey != other.FlagKey) return false; - if (!object.Equals(Context, other.Context)) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (FlagKey.Length != 0) hash ^= FlagKey.GetHashCode(); - if (context_ != null) hash ^= Context.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (FlagKey.Length != 0) { - output.WriteRawTag(10); - output.WriteString(FlagKey); - } - if (context_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Context); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (FlagKey.Length != 0) { - output.WriteRawTag(10); - output.WriteString(FlagKey); - } - if (context_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Context); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (FlagKey.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(FlagKey); - } - if (context_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Context); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ResolveObjectRequest other) { - if (other == null) { - return; - } - if (other.FlagKey.Length != 0) { - FlagKey = other.FlagKey; - } - if (other.context_ != null) { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - Context.MergeFrom(other.Context); - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - FlagKey = input.ReadString(); - break; - } - case 18: { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Context); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - FlagKey = input.ReadString(); - break; - } - case 18: { - if (context_ == null) { - Context = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Context); - break; - } - } - } - } - #endif - - } - - /// - /// Response body for object flag evaluation. used by the ResolveObject rpc. - /// - public sealed partial class ResolveObjectResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResolveObjectResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[9]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveObjectResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveObjectResponse(ResolveObjectResponse other) : this() { - value_ = other.value_ != null ? other.value_.Clone() : null; - reason_ = other.reason_; - variant_ = other.variant_; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public ResolveObjectResponse Clone() { - return new ResolveObjectResponse(this); - } - - /// Field number for the "value" field. - public const int ValueFieldNumber = 1; - private global::Google.Protobuf.WellKnownTypes.Struct value_; - /// - /// The response value of the object flag evaluation, will be unset in the case of error. - /// - /// NOTE: This structure will need to be decoded from google/protobuf/struct.proto before it is returned to the SDK - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::Google.Protobuf.WellKnownTypes.Struct Value { - get { return value_; } - set { - value_ = value; - } - } - - /// Field number for the "reason" field. - public const int ReasonFieldNumber = 2; - private string reason_ = ""; - /// - /// The reason for the given return value, see https://docs.openfeature.dev/docs/specification/types#resolution-details - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Reason { - get { return reason_; } - set { - reason_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "variant" field. - public const int VariantFieldNumber = 3; - private string variant_ = ""; - /// - /// The variant name of the returned flag value. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Variant { - get { return variant_; } - set { - variant_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as ResolveObjectResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(ResolveObjectResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!object.Equals(Value, other.Value)) return false; - if (Reason != other.Reason) return false; - if (Variant != other.Variant) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (value_ != null) hash ^= Value.GetHashCode(); - if (Reason.Length != 0) hash ^= Reason.GetHashCode(); - if (Variant.Length != 0) hash ^= Variant.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (value_ != null) { - output.WriteRawTag(10); - output.WriteMessage(Value); - } - if (Reason.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Reason); - } - if (Variant.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Variant); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (value_ != null) { - output.WriteRawTag(10); - output.WriteMessage(Value); - } - if (Reason.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Reason); - } - if (Variant.Length != 0) { - output.WriteRawTag(26); - output.WriteString(Variant); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (value_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Value); - } - if (Reason.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Reason); - } - if (Variant.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Variant); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(ResolveObjectResponse other) { - if (other == null) { - return; - } - if (other.value_ != null) { - if (value_ == null) { - Value = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - Value.MergeFrom(other.Value); - } - if (other.Reason.Length != 0) { - Reason = other.Reason; - } - if (other.Variant.Length != 0) { - Variant = other.Variant; - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - if (value_ == null) { - Value = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Value); - break; - } - case 18: { - Reason = input.ReadString(); - break; - } - case 26: { - Variant = input.ReadString(); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - if (value_ == null) { - Value = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Value); - break; - } - case 18: { - Reason = input.ReadString(); - break; - } - case 26: { - Variant = input.ReadString(); - break; - } - } - } - } - #endif - - } - - /// - /// Response body for the EvenntStream stream response - /// - public sealed partial class EventStreamResponse : pb::IMessage - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - , pb::IBufferMessage - #endif - { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EventStreamResponse()); - private pb::UnknownFieldSet _unknownFields; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public static pbr::MessageDescriptor Descriptor { - get { return global::Schema.V1.SchemaReflection.Descriptor.MessageTypes[10]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public EventStreamResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public EventStreamResponse(EventStreamResponse other) : this() { - type_ = other.type_; - data_ = other.data_ != null ? other.data_.Clone() : null; - _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public EventStreamResponse Clone() { - return new EventStreamResponse(this); - } - - /// Field number for the "type" field. - public const int TypeFieldNumber = 1; - private string type_ = ""; - /// - /// String key indicating the type of event that is being received, e.g. provider_ready or configuration_change - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public string Type { - get { return type_; } - set { - type_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "data" field. - public const int DataFieldNumber = 2; - private global::Google.Protobuf.WellKnownTypes.Struct data_; - /// - /// Object structure for use when sending relevant metadata to provide context to the event. - /// Can be left unset when it is not required. - /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public global::Google.Protobuf.WellKnownTypes.Struct Data { - get { return data_; } - set { - data_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override bool Equals(object other) { - return Equals(other as EventStreamResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public bool Equals(EventStreamResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Type != other.Type) return false; - if (!object.Equals(Data, other.Data)) return false; - return Equals(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override int GetHashCode() { - int hash = 1; - if (Type.Length != 0) hash ^= Type.GetHashCode(); - if (data_ != null) hash ^= Data.GetHashCode(); - if (_unknownFields != null) { - hash ^= _unknownFields.GetHashCode(); - } - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void WriteTo(pb::CodedOutputStream output) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - output.WriteRawMessage(this); - #else - if (Type.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Type); - } - if (data_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Data); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(output); - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { - if (Type.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Type); - } - if (data_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Data); - } - if (_unknownFields != null) { - _unknownFields.WriteTo(ref output); - } - } - #endif - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public int CalculateSize() { - int size = 0; - if (Type.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Type); - } - if (data_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Data); - } - if (_unknownFields != null) { - size += _unknownFields.CalculateSize(); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(EventStreamResponse other) { - if (other == null) { - return; - } - if (other.Type.Length != 0) { - Type = other.Type; - } - if (other.data_ != null) { - if (data_ == null) { - Data = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - Data.MergeFrom(other.Data); - } - _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - public void MergeFrom(pb::CodedInputStream input) { - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - input.ReadRawMessage(this); - #else - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); - break; - case 10: { - Type = input.ReadString(); - break; - } - case 18: { - if (data_ == null) { - Data = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Data); - break; - } - } - } - #endif - } - - #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] - void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); - break; - case 10: { - Type = input.ReadString(); - break; - } - case 18: { - if (data_ == null) { - Data = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(Data); - break; - } - } - } - } - #endif - - } - - #endregion - -} - -#endregion Designer generated code diff --git a/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/SchemaGrpc.cs b/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/SchemaGrpc.cs deleted file mode 100644 index 72bda6d6..00000000 --- a/src/OpenFeature.Contrib.Providers.Flagd/Proto/csharp/SchemaGrpc.cs +++ /dev/null @@ -1,348 +0,0 @@ -// -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: schema/v1/schema.proto -// -#pragma warning disable 0414, 1591, 8981 -#region Designer generated code - -using grpc = global::Grpc.Core; - -namespace Schema.V1 { - /// - /// Service defines the exposed rpcs of flagd - /// - public static partial class Service - { - static readonly string __ServiceName = "schema.v1.Service"; - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static void __Helper_SerializeMessage(global::Google.Protobuf.IMessage message, grpc::SerializationContext context) - { - #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION - if (message is global::Google.Protobuf.IBufferMessage) - { - context.SetPayloadLength(message.CalculateSize()); - global::Google.Protobuf.MessageExtensions.WriteTo(message, context.GetBufferWriter()); - context.Complete(); - return; - } - #endif - context.Complete(global::Google.Protobuf.MessageExtensions.ToByteArray(message)); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static class __Helper_MessageCache - { - public static readonly bool IsBufferMessage = global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T)); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static T __Helper_DeserializeMessage(grpc::DeserializationContext context, global::Google.Protobuf.MessageParser parser) where T : global::Google.Protobuf.IMessage - { - #if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION - if (__Helper_MessageCache.IsBufferMessage) - { - return parser.ParseFrom(context.PayloadAsReadOnlySequence()); - } - #endif - return parser.ParseFrom(context.PayloadAsNewBuffer()); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveBooleanRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveBooleanRequest.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveBooleanResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveBooleanResponse.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveStringRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveStringRequest.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveStringResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveStringResponse.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveFloatRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveFloatRequest.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveFloatResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveFloatResponse.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveIntRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveIntRequest.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveIntResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveIntResponse.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveObjectRequest = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveObjectRequest.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_ResolveObjectResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.ResolveObjectResponse.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_google_protobuf_Empty = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Google.Protobuf.WellKnownTypes.Empty.Parser)); - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Marshaller __Marshaller_schema_v1_EventStreamResponse = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Schema.V1.EventStreamResponse.Parser)); - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Method __Method_ResolveBoolean = new grpc::Method( - grpc::MethodType.Unary, - __ServiceName, - "ResolveBoolean", - __Marshaller_schema_v1_ResolveBooleanRequest, - __Marshaller_schema_v1_ResolveBooleanResponse); - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Method __Method_ResolveString = new grpc::Method( - grpc::MethodType.Unary, - __ServiceName, - "ResolveString", - __Marshaller_schema_v1_ResolveStringRequest, - __Marshaller_schema_v1_ResolveStringResponse); - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Method __Method_ResolveFloat = new grpc::Method( - grpc::MethodType.Unary, - __ServiceName, - "ResolveFloat", - __Marshaller_schema_v1_ResolveFloatRequest, - __Marshaller_schema_v1_ResolveFloatResponse); - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Method __Method_ResolveInt = new grpc::Method( - grpc::MethodType.Unary, - __ServiceName, - "ResolveInt", - __Marshaller_schema_v1_ResolveIntRequest, - __Marshaller_schema_v1_ResolveIntResponse); - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Method __Method_ResolveObject = new grpc::Method( - grpc::MethodType.Unary, - __ServiceName, - "ResolveObject", - __Marshaller_schema_v1_ResolveObjectRequest, - __Marshaller_schema_v1_ResolveObjectResponse); - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - static readonly grpc::Method __Method_EventStream = new grpc::Method( - grpc::MethodType.ServerStreaming, - __ServiceName, - "EventStream", - __Marshaller_google_protobuf_Empty, - __Marshaller_schema_v1_EventStreamResponse); - - /// Service descriptor - public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor - { - get { return global::Schema.V1.SchemaReflection.Descriptor.Services[0]; } - } - - /// Base class for server-side implementations of Service - [grpc::BindServiceMethod(typeof(Service), "BindService")] - public abstract partial class ServiceBase - { - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::System.Threading.Tasks.Task ResolveBoolean(global::Schema.V1.ResolveBooleanRequest request, grpc::ServerCallContext context) - { - throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::System.Threading.Tasks.Task ResolveString(global::Schema.V1.ResolveStringRequest request, grpc::ServerCallContext context) - { - throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::System.Threading.Tasks.Task ResolveFloat(global::Schema.V1.ResolveFloatRequest request, grpc::ServerCallContext context) - { - throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::System.Threading.Tasks.Task ResolveInt(global::Schema.V1.ResolveIntRequest request, grpc::ServerCallContext context) - { - throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::System.Threading.Tasks.Task ResolveObject(global::Schema.V1.ResolveObjectRequest request, grpc::ServerCallContext context) - { - throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::System.Threading.Tasks.Task EventStream(global::Google.Protobuf.WellKnownTypes.Empty request, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) - { - throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); - } - - } - - /// Client for Service - public partial class ServiceClient : grpc::ClientBase - { - /// Creates a new client for Service - /// The channel to use to make remote calls. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public ServiceClient(grpc::ChannelBase channel) : base(channel) - { - } - /// Creates a new client for Service that uses a custom CallInvoker. - /// The callInvoker to use to make remote calls. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public ServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) - { - } - /// Protected parameterless constructor to allow creation of test doubles. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - protected ServiceClient() : base() - { - } - /// Protected constructor to allow creation of configured clients. - /// The client configuration. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - protected ServiceClient(ClientBaseConfiguration configuration) : base(configuration) - { - } - - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::Schema.V1.ResolveBooleanResponse ResolveBoolean(global::Schema.V1.ResolveBooleanRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ResolveBoolean(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::Schema.V1.ResolveBooleanResponse ResolveBoolean(global::Schema.V1.ResolveBooleanRequest request, grpc::CallOptions options) - { - return CallInvoker.BlockingUnaryCall(__Method_ResolveBoolean, null, options, request); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncUnaryCall ResolveBooleanAsync(global::Schema.V1.ResolveBooleanRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ResolveBooleanAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncUnaryCall ResolveBooleanAsync(global::Schema.V1.ResolveBooleanRequest request, grpc::CallOptions options) - { - return CallInvoker.AsyncUnaryCall(__Method_ResolveBoolean, null, options, request); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::Schema.V1.ResolveStringResponse ResolveString(global::Schema.V1.ResolveStringRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ResolveString(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::Schema.V1.ResolveStringResponse ResolveString(global::Schema.V1.ResolveStringRequest request, grpc::CallOptions options) - { - return CallInvoker.BlockingUnaryCall(__Method_ResolveString, null, options, request); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncUnaryCall ResolveStringAsync(global::Schema.V1.ResolveStringRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ResolveStringAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncUnaryCall ResolveStringAsync(global::Schema.V1.ResolveStringRequest request, grpc::CallOptions options) - { - return CallInvoker.AsyncUnaryCall(__Method_ResolveString, null, options, request); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::Schema.V1.ResolveFloatResponse ResolveFloat(global::Schema.V1.ResolveFloatRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ResolveFloat(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::Schema.V1.ResolveFloatResponse ResolveFloat(global::Schema.V1.ResolveFloatRequest request, grpc::CallOptions options) - { - return CallInvoker.BlockingUnaryCall(__Method_ResolveFloat, null, options, request); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncUnaryCall ResolveFloatAsync(global::Schema.V1.ResolveFloatRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ResolveFloatAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncUnaryCall ResolveFloatAsync(global::Schema.V1.ResolveFloatRequest request, grpc::CallOptions options) - { - return CallInvoker.AsyncUnaryCall(__Method_ResolveFloat, null, options, request); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::Schema.V1.ResolveIntResponse ResolveInt(global::Schema.V1.ResolveIntRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ResolveInt(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::Schema.V1.ResolveIntResponse ResolveInt(global::Schema.V1.ResolveIntRequest request, grpc::CallOptions options) - { - return CallInvoker.BlockingUnaryCall(__Method_ResolveInt, null, options, request); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncUnaryCall ResolveIntAsync(global::Schema.V1.ResolveIntRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ResolveIntAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncUnaryCall ResolveIntAsync(global::Schema.V1.ResolveIntRequest request, grpc::CallOptions options) - { - return CallInvoker.AsyncUnaryCall(__Method_ResolveInt, null, options, request); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::Schema.V1.ResolveObjectResponse ResolveObject(global::Schema.V1.ResolveObjectRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ResolveObject(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual global::Schema.V1.ResolveObjectResponse ResolveObject(global::Schema.V1.ResolveObjectRequest request, grpc::CallOptions options) - { - return CallInvoker.BlockingUnaryCall(__Method_ResolveObject, null, options, request); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncUnaryCall ResolveObjectAsync(global::Schema.V1.ResolveObjectRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return ResolveObjectAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncUnaryCall ResolveObjectAsync(global::Schema.V1.ResolveObjectRequest request, grpc::CallOptions options) - { - return CallInvoker.AsyncUnaryCall(__Method_ResolveObject, null, options, request); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncServerStreamingCall EventStream(global::Google.Protobuf.WellKnownTypes.Empty request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) - { - return EventStream(request, new grpc::CallOptions(headers, deadline, cancellationToken)); - } - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public virtual grpc::AsyncServerStreamingCall EventStream(global::Google.Protobuf.WellKnownTypes.Empty request, grpc::CallOptions options) - { - return CallInvoker.AsyncServerStreamingCall(__Method_EventStream, null, options, request); - } - /// Creates a new instance of client from given ClientBaseConfiguration. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - protected override ServiceClient NewInstance(ClientBaseConfiguration configuration) - { - return new ServiceClient(configuration); - } - } - - /// Creates service definition that can be registered with a server - /// An object implementing the server-side handling logic. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public static grpc::ServerServiceDefinition BindService(ServiceBase serviceImpl) - { - return grpc::ServerServiceDefinition.CreateBuilder() - .AddMethod(__Method_ResolveBoolean, serviceImpl.ResolveBoolean) - .AddMethod(__Method_ResolveString, serviceImpl.ResolveString) - .AddMethod(__Method_ResolveFloat, serviceImpl.ResolveFloat) - .AddMethod(__Method_ResolveInt, serviceImpl.ResolveInt) - .AddMethod(__Method_ResolveObject, serviceImpl.ResolveObject) - .AddMethod(__Method_EventStream, serviceImpl.EventStream).Build(); - } - - /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. - /// Note: this method is part of an experimental API that can change or be removed without any prior notice. - /// Service methods will be bound by calling AddMethod on this object. - /// An object implementing the server-side handling logic. - [global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)] - public static void BindService(grpc::ServiceBinderBase serviceBinder, ServiceBase serviceImpl) - { - serviceBinder.AddMethod(__Method_ResolveBoolean, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.ResolveBoolean)); - serviceBinder.AddMethod(__Method_ResolveString, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.ResolveString)); - serviceBinder.AddMethod(__Method_ResolveFloat, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.ResolveFloat)); - serviceBinder.AddMethod(__Method_ResolveInt, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.ResolveInt)); - serviceBinder.AddMethod(__Method_ResolveObject, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.ResolveObject)); - serviceBinder.AddMethod(__Method_EventStream, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod(serviceImpl.EventStream)); - } - - } -} -#endregion diff --git a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs index cb5fe01c..643cb9ab 100644 --- a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs +++ b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs @@ -1,6 +1,6 @@ using Xunit; using Moq; -using Schema.V1; +using OpenFeature.Flagd.Grpc; using Grpc.Core; using Google.Protobuf.WellKnownTypes; using OpenFeature.Error; From 9830a755acce1004de5a1b8085804ed9910765fb Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Fri, 10 Feb 2023 14:48:04 -0500 Subject: [PATCH 11/14] fixup: run dotnet format Signed-off-by: Todd Baert --- src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs | 8 ++++---- .../FlagdProviderTest.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs index 083a4569..e86d5023 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -36,7 +36,7 @@ public FlagdProvider() var flagdPort = Environment.GetEnvironmentVariable("FLAGD_PORT") ?? "8013"; var flagdUseTLSStr = Environment.GetEnvironmentVariable("FLAGD_TLS") ?? "false"; - + var protocol = "http"; var useTLS = bool.Parse(flagdUseTLSStr); @@ -48,7 +48,7 @@ public FlagdProvider() var url = new Uri(protocol + "://" + flagdHost + ":" + flagdPort); _client = new Service.ServiceClient(GrpcChannel.ForAddress(url)); } - + /// /// Constructor of the provider. /// The URL of the flagD server @@ -82,7 +82,7 @@ public static string GetProviderName() /// Return the metadata associated to this provider. /// public override Metadata GetMetadata() => _providerMetadata; - + /// /// Return the Grpc client of the provider /// @@ -217,7 +217,7 @@ public override async Task> ResolveStructureValue(strin ); }, context); } - + private async Task> ResolveValue(Func>> resolveDelegate, EvaluationContext context = null) { try diff --git a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs index 643cb9ab..7a62ee46 100644 --- a/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs +++ b/test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs @@ -15,7 +15,7 @@ public void TestGetProviderName() { Assert.Equal("No-op Provider", FlagdProvider.GetProviderName()); } - + [Fact] public void TestGetProviderWithDefaultConfig() { @@ -217,7 +217,7 @@ public void TestResolveGrpcHostUnavailable() .Returns(grpcResp); var flagdProvider = new FlagdProvider(mockGrpcClient.Object); - + // make sure the correct exception is thrown Assert.ThrowsAsync(async () => { From 27f592fc469c9163506ed22e477486341e5aabac Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Fri, 10 Feb 2023 14:50:19 -0500 Subject: [PATCH 12/14] fixup: pull submodule in ci Signed-off-by: Todd Baert --- .github/workflows/linux-ci.yml | 1 + .github/workflows/windows-ci.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 5378f5f5..0bba8c63 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -22,6 +22,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + submodules: recursive - name: Install dependencies run: dotnet restore diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 16eaaf8e..e254da25 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -22,6 +22,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + submodules: recursive - name: Install dependencies run: dotnet restore From 8877ada4b08f7a1e58723d29e712b83e97fef5ab Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Fri, 10 Feb 2023 15:23:32 -0500 Subject: [PATCH 13/14] fixup: support 462 Signed-off-by: Todd Baert --- .../FlagdProvider.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs index e86d5023..81d9d2e6 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs +++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs @@ -11,7 +11,7 @@ using Metadata = OpenFeature.Model.Metadata; using Value = OpenFeature.Model.Value; using ProtoValue = Google.Protobuf.WellKnownTypes.Value; - +using System.Net.Http; namespace OpenFeature.Contrib.Providers.Flagd { @@ -46,7 +46,7 @@ public FlagdProvider() } var url = new Uri(protocol + "://" + flagdHost + ":" + flagdPort); - _client = new Service.ServiceClient(GrpcChannel.ForAddress(url)); + _client = buildClientForPlatform(url); } /// @@ -61,7 +61,7 @@ public FlagdProvider(Uri url) throw new ArgumentNullException(nameof(url)); } - _client = new Service.ServiceClient(GrpcChannel.ForAddress(url)); + _client = buildClientForPlatform(url); } // just for testing, internal but visible in tests @@ -370,6 +370,18 @@ private static Value ConvertToPrimitiveValue(ProtoValue value) return new Value(); } } + + private static Service.ServiceClient buildClientForPlatform(Uri url) + { +#if NETSTANDARD2_0 + return new Service.ServiceClient(GrpcChannel.ForAddress(url)); +#else + return new Service.ServiceClient(GrpcChannel.ForAddress(url, new GrpcChannelOptions + { + HttpHandler = new WinHttpHandler() + })); +#endif + } } } From ade7d012aebc1da70411af76610ef9a4ab57eac2 Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Mon, 13 Feb 2023 07:36:43 +0100 Subject: [PATCH 14/14] incorporated suggestion for .csproj structure Signed-off-by: Florian Bacher --- .../OpenFeature.Contrib.Providers.Flagd.csproj | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj index 5810367a..cb449a49 100644 --- a/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj +++ b/src/OpenFeature.Contrib.Providers.Flagd/OpenFeature.Contrib.Providers.Flagd.csproj @@ -11,10 +11,6 @@ https://github.com/open-feature/dotnet-sdk-contrib Todd Baert - - - - @@ -26,6 +22,9 @@ + + +