Skip to content

Commit

Permalink
Second half of changes (2/2) (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
anchitj authored Aug 16, 2024
1 parent 564aa11 commit 395328b
Show file tree
Hide file tree
Showing 188 changed files with 949 additions and 913 deletions.
6 changes: 3 additions & 3 deletions src/Confluent.SchemaRegistry/NoneAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ namespace Confluent.SchemaRegistry
public class NoneAction : IRuleAction
{
public static readonly string ActionType = "NONE";

public void Configure(IEnumerable<KeyValuePair<string, string>> config)
{
}

public string Type()
{
return ActionType;
}

public Task Run(RuleContext ctx, object message, RuleException exception = null)
{
return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public enum ReferenceSubjectNameStrategy
/// </summary>
ReferenceName
}


/// <summary>
/// Extension methods for the ReferenceSubjectNameStrategy type.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2018 Confluent Inc.
// Copyright 2016-2018 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2018 Confluent Inc.
// Copyright 2016-2018 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Confluent Inc.
// Copyright 2018 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,7 +51,7 @@ public enum Compatibility
/// </summary>
[EnumMember(Value = "FULL")]
Full,

/// <summary>
/// Forward transitive schema compatibility.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2017 Confluent Inc.
// Copyright 2016-2017 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@ namespace Confluent.SchemaRegistry
[DataContract]
internal class CompatibilityCheck
{
[DataMember(Name="is_compatible")]
[DataMember(Name = "is_compatible")]
public bool IsCompatible { get; set; }

public CompatibilityCheck(bool isCompatible)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2017 Confluent Inc.
// Copyright 2016-2017 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,7 +36,7 @@ public ErrorMessage(int errorCode, string message)
ErrorCode = errorCode;
Message = message;
}

public override string ToString()
=> $"{{error_code={ErrorCode}, message={Message}}}";
}
Expand Down
10 changes: 5 additions & 5 deletions src/Confluent.SchemaRegistry/Rest/DataContracts/Metadata.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Confluent Inc.
// Copyright 2022 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,8 +37,8 @@ public class Metadata : IEquatable<Metadata>
/// </summary>
private Metadata() { }

public Metadata(IDictionary<string, ISet<string>> tags,
IDictionary<string, string> properties,
public Metadata(IDictionary<string, ISet<string>> tags,
IDictionary<string, string> properties,
ISet<string> sensitive)
{
Tags = tags;
Expand All @@ -50,10 +50,10 @@ public bool Equals(Metadata other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Utils.DictEquals(Tags, other.Tags) && Utils.DictEquals(Properties, other.Properties) &&
return Utils.DictEquals(Tags, other.Tags) && Utils.DictEquals(Properties, other.Properties) &&
Utils.SetEquals(Sensitive, other.Sensitive);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2017 Confluent Inc.
// Copyright 2016-2017 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,7 +70,7 @@ public Schema Schema
/// Included to enable API backwards compatibility only, do not use.
/// </summary>
[Obsolete("Included to enable API backwards compatibility. This will be removed in a future release.")]
protected RegisteredSchema() {}
protected RegisteredSchema() { }

/// <summary>
/// Initializes a new instance of this class.
Expand Down
32 changes: 16 additions & 16 deletions src/Confluent.SchemaRegistry/Rest/DataContracts/Rule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Confluent Inc.
// Copyright 2022 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -25,37 +25,37 @@ public class Rule : IEquatable<Rule>
{
[DataMember(Name = "name")]
public string Name { get; set; }

[DataMember(Name = "doc")]
public string Doc { get; set; }

[DataMember(Name = "kind")]
public RuleKind Kind { get; set; }

[DataMember(Name = "mode")]
public RuleMode Mode { get; set; }

[DataMember(Name = "type")]
public string Type { get; set; }

[DataMember(Name = "tags")]
public ISet<string> Tags { get; set; }

[DataMember(Name = "params")]
public IDictionary<string, string> Params { get; set; }

[DataMember(Name = "expr")]
public string Expr { get; set; }

[DataMember(Name = "onSuccess")]
public string OnSuccess { get; set; }

[DataMember(Name = "onFailure")]
public string OnFailure { get; set; }

[DataMember(Name = "disabled")]
public bool Disabled { get; set; }

/// <summary>
/// <summary>
/// Empty constructor for serialization
Expand All @@ -72,8 +72,8 @@ public Rule(string name, RuleKind kind, RuleMode mode, string type, ISet<string>
Tags = tags;
Params = parameters;
}
public Rule(string name, RuleKind kind, RuleMode mode, string type, ISet<string> tags,

public Rule(string name, RuleKind kind, RuleMode mode, string type, ISet<string> tags,
IDictionary<string, string> parameters, string expr, string onSuccess, string onFailure, bool disabled)
{
Name = name;
Expand All @@ -93,8 +93,8 @@ public bool Equals(Rule other)
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Name == other.Name && Doc == other.Doc && Kind == other.Kind && Mode == other.Mode &&
Type == other.Type && Utils.SetEquals(Tags, other.Tags) &&
Utils.DictEquals(Params, other.Params) && Expr == other.Expr &&
Type == other.Type && Utils.SetEquals(Tags, other.Tags) &&
Utils.DictEquals(Params, other.Params) && Expr == other.Expr &&
OnSuccess == other.OnSuccess && OnFailure == other.OnFailure &&
Disabled == other.Disabled;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Confluent Inc.
// Copyright 2022 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
8 changes: 4 additions & 4 deletions src/Confluent.SchemaRegistry/Rest/DataContracts/RuleMode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Confluent Inc.
// Copyright 2022 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,19 +44,19 @@ public enum RuleMode
/// </summary>
[EnumMember(Value = "UPDOWN")]
UpDown,

/// <summary>
/// A rule used during read (consuming).
/// </summary>
[EnumMember(Value = "READ")]
Read,

/// <summary>
/// A rule used during write (producing).
/// </summary>
[EnumMember(Value = "WRITE")]
Write,

/// <summary>
/// A rule used during both write and read (producing and consuming).
/// </summary>
Expand Down
76 changes: 39 additions & 37 deletions src/Confluent.SchemaRegistry/Rest/DataContracts/RuleSet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Confluent Inc.
// Copyright 2022 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -26,7 +26,7 @@ public class RuleSet : IEquatable<RuleSet>
{
[DataMember(Name = "migrationRules")]
public IList<Rule> MigrationRules { get; set; }

[DataMember(Name = "domainRules")]
public IList<Rule> DomainRules { get; set; }

Expand All @@ -40,46 +40,48 @@ public RuleSet(IList<Rule> migrationRules, IList<Rule> domainRules)
MigrationRules = migrationRules;
DomainRules = domainRules;
}

public bool HasRules(RuleMode mode) {
switch (mode) {
case RuleMode.Upgrade:
case RuleMode.Downgrade:
return MigrationRules.Any(r => r.Mode == mode || r.Mode == RuleMode.UpDown);
case RuleMode.UpDown:
return MigrationRules.Any(r => r.Mode == mode);
case RuleMode.Write:
case RuleMode.Read:
return DomainRules.Any(r => r.Mode == mode || r.Mode == RuleMode.Write);
case RuleMode.WriteRead:
return DomainRules.Any(r => r.Mode == mode);
default:
return false;

public bool HasRules(RuleMode mode)
{
switch (mode)
{
case RuleMode.Upgrade:
case RuleMode.Downgrade:
return MigrationRules.Any(r => r.Mode == mode || r.Mode == RuleMode.UpDown);
case RuleMode.UpDown:
return MigrationRules.Any(r => r.Mode == mode);
case RuleMode.Write:
case RuleMode.Read:
return DomainRules.Any(r => r.Mode == mode || r.Mode == RuleMode.Write);
case RuleMode.WriteRead:
return DomainRules.Any(r => r.Mode == mode);
default:
return false;
}
}
}

public bool Equals(RuleSet other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Equals(MigrationRules, other.MigrationRules) && Equals(DomainRules, other.DomainRules);
}
public bool Equals(RuleSet other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Equals(MigrationRules, other.MigrationRules) && Equals(DomainRules, other.DomainRules);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((RuleSet)obj);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((RuleSet)obj);
}

public override int GetHashCode()
{
unchecked
public override int GetHashCode()
{
return ((MigrationRules != null ? MigrationRules.GetHashCode() : 0) * 397) ^
(DomainRules != null ? DomainRules.GetHashCode() : 0);
unchecked
{
return ((MigrationRules != null ? MigrationRules.GetHashCode() : 0) * 397) ^
(DomainRules != null ? DomainRules.GetHashCode() : 0);
}
}
}
}
}
4 changes: 2 additions & 2 deletions src/Confluent.SchemaRegistry/Rest/DataContracts/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Collections.Generic;


namespace Confluent.SchemaRegistry
namespace Confluent.SchemaRegistry
{
/// <summary>
/// Represents a schema.
Expand Down Expand Up @@ -103,7 +103,7 @@ public Schema(string subject, int version, int id, string schemaString)

[DataMember(Name = "schemaType")]
internal string SchemaType_String { get; set; }

/// <summary>
/// Metadata for the schema
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Confluent.SchemaRegistry/Rest/DataContracts/SchemaId.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2017 Confluent Inc.
// Copyright 2016-2017 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@
using System.Runtime.Serialization;


namespace Confluent.SchemaRegistry
namespace Confluent.SchemaRegistry
{
[DataContract]
internal class SchemaId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class SchemaReference : IComparable<SchemaReference>, IEquatable<SchemaRe
[DataMember(Name = "version")]
public int Version { get; set; }

private SchemaReference() {}
private SchemaReference() { }

/// <summary>
/// Initializes a new instance of the SchemaReference class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2017 Confluent Inc.
// Copyright 2016-2017 Confluent Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@
using System.Runtime.Serialization;


namespace Confluent.SchemaRegistry
namespace Confluent.SchemaRegistry
{
[DataContract]
internal class SchemaString
Expand Down
Loading

0 comments on commit 395328b

Please sign in to comment.