Skip to content

Commit a6cdb41

Browse files
API updates (Azure#25099)
1 parent 620383e commit a6cdb41

File tree

11 files changed

+102
-61
lines changed

11 files changed

+102
-61
lines changed

sdk/schemaregistry/Azure.Data.SchemaRegistry/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ Register a schema to be stored in the Azure Schema Registry.
9191
```C# Snippet:SchemaRegistryRegisterSchema
9292
string name = "employeeSample";
9393
SchemaFormat format = SchemaFormat.Avro;
94-
// Example schema's content
95-
string content = @"
94+
// Example schema's definition
95+
string definition = @"
9696
{
9797
""type"" : ""record"",
9898
""namespace"" : ""TestSchema"",
@@ -103,7 +103,7 @@ string content = @"
103103
]
104104
}";
105105

106-
Response<SchemaProperties> schemaProperties = client.RegisterSchema(groupName, name, content, format);
106+
Response<SchemaProperties> schemaProperties = client.RegisterSchema(groupName, name, definition, format);
107107
```
108108

109109
### Retrieve a schema ID
@@ -135,7 +135,7 @@ Retrieve a previously registered schema's content from the Azure Schema Registry
135135

136136
```C# Snippet:SchemaRegistryRetrieveSchema
137137
SchemaRegistrySchema schema = client.GetSchema(schemaId);
138-
string content = schema.Content;
138+
string definition = schema.Definition;
139139
```
140140

141141
## Troubleshooting

sdk/schemaregistry/Azure.Data.SchemaRegistry/api/Azure.Data.SchemaRegistry.netstandard2.0.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public SchemaRegistryClient(string fullyQualifiedNamespace, Azure.Core.TokenCred
3131
public string FullyQualifiedNamespace { get { throw null; } }
3232
public virtual Azure.Response<Azure.Data.SchemaRegistry.SchemaRegistrySchema> GetSchema(string schemaId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
3333
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Data.SchemaRegistry.SchemaRegistrySchema>> GetSchemaAsync(string schemaId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
34-
public virtual Azure.Response<Azure.Data.SchemaRegistry.SchemaProperties> GetSchemaProperties(string groupName, string name, string schemaDefinition, Azure.Data.SchemaRegistry.SchemaFormat format, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
35-
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Data.SchemaRegistry.SchemaProperties>> GetSchemaPropertiesAsync(string groupName, string name, string schemaDefinition, Azure.Data.SchemaRegistry.SchemaFormat format, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
36-
public virtual Azure.Response<Azure.Data.SchemaRegistry.SchemaProperties> RegisterSchema(string groupName, string name, string schemaDefinition, Azure.Data.SchemaRegistry.SchemaFormat format, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
37-
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Data.SchemaRegistry.SchemaProperties>> RegisterSchemaAsync(string groupName, string name, string schemaDefinition, Azure.Data.SchemaRegistry.SchemaFormat format, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
34+
public virtual Azure.Response<Azure.Data.SchemaRegistry.SchemaProperties> GetSchemaProperties(string groupName, string schemaName, string schemaDefinition, Azure.Data.SchemaRegistry.SchemaFormat format, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
35+
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Data.SchemaRegistry.SchemaProperties>> GetSchemaPropertiesAsync(string groupName, string schemaName, string schemaDefinition, Azure.Data.SchemaRegistry.SchemaFormat format, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
36+
public virtual Azure.Response<Azure.Data.SchemaRegistry.SchemaProperties> RegisterSchema(string groupName, string schemaName, string schemaDefinition, Azure.Data.SchemaRegistry.SchemaFormat format, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
37+
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Data.SchemaRegistry.SchemaProperties>> RegisterSchemaAsync(string groupName, string schemaName, string schemaDefinition, Azure.Data.SchemaRegistry.SchemaFormat format, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
3838
}
3939
public partial class SchemaRegistryClientOptions : Azure.Core.ClientOptions
4040
{
@@ -45,10 +45,14 @@ public enum ServiceVersion
4545
V2020_09_01_preview = 2,
4646
}
4747
}
48+
public static partial class SchemaRegistryModelFactory
49+
{
50+
public static Azure.Data.SchemaRegistry.SchemaProperties SchemaProperties(Azure.Data.SchemaRegistry.SchemaFormat format, string schemaId) { throw null; }
51+
}
4852
public partial class SchemaRegistrySchema
4953
{
5054
internal SchemaRegistrySchema() { }
51-
public string Content { get { throw null; } }
55+
public string Definition { get { throw null; } }
5256
public Azure.Data.SchemaRegistry.SchemaProperties Properties { get { throw null; } }
5357
}
5458
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Runtime.CompilerServices;
5+
6+
[assembly: InternalsVisibleTo("Azure.Data.SchemaRegistry.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")]

sdk/schemaregistry/Azure.Data.SchemaRegistry/src/SchemaProperties.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,20 @@ namespace Azure.Data.SchemaRegistry
88
/// </summary>
99
public class SchemaProperties
1010
{
11-
internal SchemaProperties(string location, SchemaFormat format, string schemaId, int? schemaVersion)
11+
internal SchemaProperties(SchemaFormat format, string schemaId)
1212
{
1313
Id = schemaId;
14-
Location = location;
1514
Format = format;
16-
Version = schemaVersion ?? 0;
1715
}
1816

1917
/// <summary>
2018
/// The schema ID that uniquely identifies a schema in the registry namespace.
2119
/// </summary>
2220
public string Id { get; }
2321

24-
/// <summary>
25-
/// The location of the schema.
26-
/// </summary>
27-
internal string Location { get; }
28-
2922
/// <summary>
3023
/// Serialization type for the schema being stored.
3124
/// </summary>
3225
public SchemaFormat Format { get; }
33-
34-
/// <summary>
35-
/// Version of the schema.
36-
/// </summary>
37-
internal int Version { get; }
3826
}
3927
}

sdk/schemaregistry/Azure.Data.SchemaRegistry/src/SchemaRegistryClient.cs

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Licensed under the MIT License.
33

44
using System;
5-
using System.Collections.Concurrent;
6-
using System.Collections.Generic;
75
using System.Threading;
86
using System.Threading.Tasks;
97
using Azure.Core;
@@ -69,18 +67,18 @@ internal SchemaRegistryClient(ClientDiagnostics clientDiagnostics, HttpPipeline
6967
/// Registers a schema with the SchemaRegistry service.
7068
/// </summary>
7169
/// <param name="groupName">The name of the SchemaRegistry group.</param>
72-
/// <param name="name">The name of the schema.</param>
70+
/// <param name="schemaName">The name of the schema.</param>
7371
/// <param name="schemaDefinition">The string representation of the schema's content.</param>
7472
/// <param name="format">The serialization format of the schema.</param>
7573
/// <param name="cancellationToken">The cancellation token for the operation.</param>
7674
/// <returns>The properties of the schema.</returns>
7775
public virtual async Task<Response<SchemaProperties>> RegisterSchemaAsync(
7876
string groupName,
79-
string name,
77+
string schemaName,
8078
string schemaDefinition,
8179
SchemaFormat format,
8280
CancellationToken cancellationToken = default) =>
83-
await RegisterSchemaInternalAsync(groupName, name, schemaDefinition, format, true, cancellationToken)
81+
await RegisterSchemaInternalAsync(groupName, schemaName, schemaDefinition, format, true, cancellationToken)
8482
.ConfigureAwait(false);
8583

8684
/// <summary>
@@ -89,23 +87,23 @@ await RegisterSchemaInternalAsync(groupName, name, schemaDefinition, format, tru
8987
/// If the schema did previous exist in the Schema Registry instance, a new version of the schema is added to the instance and assigned a new schema ID.
9088
/// </summary>
9189
/// <param name="groupName">The name of the SchemaRegistry group.</param>
92-
/// <param name="name">The name of the schema.</param>
90+
/// <param name="schemaName">The name of the schema.</param>
9391
/// <param name="schemaDefinition">The string representation of the schema's content.</param>
9492
/// <param name="format">The serialization format of the schema.</param>
9593
/// <param name="cancellationToken">The cancellation token for the operation.</param>
9694
/// <returns>The properties of the schema.</returns>
9795
public virtual Response<SchemaProperties> RegisterSchema(
9896
string groupName,
99-
string name,
97+
string schemaName,
10098
string schemaDefinition,
10199
SchemaFormat format,
102100
CancellationToken cancellationToken = default) =>
103-
RegisterSchemaInternalAsync(groupName, name, schemaDefinition, format, false, cancellationToken)
101+
RegisterSchemaInternalAsync(groupName, schemaName, schemaDefinition, format, false, cancellationToken)
104102
.EnsureCompleted();
105103

106104
private async Task<Response<SchemaProperties>> RegisterSchemaInternalAsync(
107105
string groupName,
108-
string name,
106+
string schemaName,
109107
string schemaDefinition,
110108
SchemaFormat format,
111109
bool async,
@@ -118,14 +116,14 @@ private async Task<Response<SchemaProperties>> RegisterSchemaInternalAsync(
118116
ResponseWithHeaders<SchemaId, SchemaRegisterHeaders> response;
119117
if (async)
120118
{
121-
response = await RestClient.RegisterAsync(groupName, name, format, schemaDefinition, cancellationToken).ConfigureAwait(false);
119+
response = await RestClient.RegisterAsync(groupName, schemaName, format, schemaDefinition, cancellationToken).ConfigureAwait(false);
122120
}
123121
else
124122
{
125-
response = RestClient.Register(groupName, name, format, schemaDefinition, cancellationToken);
123+
response = RestClient.Register(groupName, schemaName, format, schemaDefinition, cancellationToken);
126124
}
127125

128-
var properties = new SchemaProperties(response.Headers.Location, response.Headers.SerializationType, response.Headers.SchemaId, response.Headers.SchemaVersion);
126+
var properties = new SchemaProperties(response.Headers.SerializationType, response.Headers.SchemaId);
129127

130128
return Response.FromValue(properties, response);
131129
}
@@ -140,44 +138,44 @@ private async Task<Response<SchemaProperties>> RegisterSchemaInternalAsync(
140138
/// Gets the schema ID associated with the schema from the SchemaRegistry service.
141139
/// </summary>
142140
/// <param name="groupName">The name of the SchemaRegistry group.</param>
143-
/// <param name="name">The name of the schema.</param>
141+
/// <param name="schemaName">The name of the schema.</param>
144142
/// <param name="schemaDefinition">The string representation of the schema's content.</param>
145143
/// <param name="format">The serialization format of the schema.</param>
146144
/// <param name="cancellationToken">The cancellation token for the operation.</param>
147145
/// <returns>The properties of the schema, including the schema ID provided by the service.</returns>
148146
#pragma warning disable AZC0015 // Unexpected client method return type.
149147
public virtual async Task<Response<SchemaProperties>> GetSchemaPropertiesAsync(
150148
string groupName,
151-
string name,
149+
string schemaName,
152150
string schemaDefinition,
153151
SchemaFormat format,
154152
CancellationToken cancellationToken = default) =>
155153
#pragma warning restore AZC0015 // Unexpected client method return type.
156-
await GetSchemaPropertiesInternalAsync(groupName, name, schemaDefinition, format, true, cancellationToken)
154+
await GetSchemaPropertiesInternalAsync(groupName, schemaName, schemaDefinition, format, true, cancellationToken)
157155
.ConfigureAwait(false);
158156

159157
/// <summary>
160158
/// Gets the schema ID associated with the schema from the SchemaRegistry service.
161159
/// </summary>
162160
/// <param name="groupName">The name of the SchemaRegistry group.</param>
163-
/// <param name="name">The name of the schema.</param>
161+
/// <param name="schemaName">The name of the schema.</param>
164162
/// <param name="schemaDefinition">The string representation of the schema's content.</param>
165163
/// <param name="format">The serialization format of the schema.</param>
166164
/// <param name="cancellationToken">The cancellation token for the operation.</param>
167165
/// <returns>The properties of the schema, including the schema ID provided by the service.</returns>
168166
#pragma warning disable AZC0015 // Unexpected client method return type.
169167
public virtual Response<SchemaProperties> GetSchemaProperties(
170168
string groupName,
171-
string name,
169+
string schemaName,
172170
string schemaDefinition,
173171
SchemaFormat format,
174172
CancellationToken cancellationToken = default) =>
175173
#pragma warning restore AZC0015 // Unexpected client method return type.
176-
GetSchemaPropertiesInternalAsync(groupName, name, schemaDefinition, format, false, cancellationToken).EnsureCompleted();
174+
GetSchemaPropertiesInternalAsync(groupName, schemaName, schemaDefinition, format, false, cancellationToken).EnsureCompleted();
177175

178176
private async Task<Response<SchemaProperties>> GetSchemaPropertiesInternalAsync(
179177
string groupName,
180-
string name,
178+
string schemaName,
181179
string schemaDefinition,
182180
SchemaFormat format,
183181
bool async,
@@ -190,14 +188,14 @@ private async Task<Response<SchemaProperties>> GetSchemaPropertiesInternalAsync(
190188
ResponseWithHeaders<SchemaId, SchemaQueryIdByContentHeaders> response;
191189
if (async)
192190
{
193-
response = await RestClient.QueryIdByContentAsync(groupName, name, format, schemaDefinition, cancellationToken).ConfigureAwait(false);
191+
response = await RestClient.QueryIdByContentAsync(groupName, schemaName, format, schemaDefinition, cancellationToken).ConfigureAwait(false);
194192
}
195193
else
196194
{
197-
response = RestClient.QueryIdByContent(groupName, name, format, schemaDefinition, cancellationToken);
195+
response = RestClient.QueryIdByContent(groupName, schemaName, format, schemaDefinition, cancellationToken);
198196
}
199197

200-
var properties = new SchemaProperties(response.Headers.Location, response.Headers.SerializationType, response.Headers.SchemaId, response.Headers.SchemaVersion);
198+
var properties = new SchemaProperties(response.Headers.SerializationType, response.Headers.SchemaId);
201199

202200
return Response.FromValue(properties, response);
203201
}
@@ -246,7 +244,7 @@ private async Task<Response<SchemaRegistrySchema>> GetSchemaInternalAsync(string
246244
response = RestClient.GetById(schemaId, cancellationToken);
247245
}
248246

249-
var properties = new SchemaProperties(response.Headers.Location, response.Headers.SerializationType, response.Headers.SchemaId, response.Headers.SchemaVersion);
247+
var properties = new SchemaProperties(response.Headers.SerializationType, response.Headers.SchemaId);
250248
var schema = new SchemaRegistrySchema(properties, response.Value);
251249

252250
return Response.FromValue(schema, response);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
namespace Azure.Data.SchemaRegistry
5+
{
6+
/// <summary>
7+
/// This class contains methods to create Schema Registry models for mocking purposes.
8+
/// </summary>
9+
public static class SchemaRegistryModelFactory
10+
{
11+
/// <summary>
12+
/// Constructs a SchemaProperties instance for mocking.
13+
/// </summary>
14+
/// <param name="format">The format for the schema.</param>
15+
/// <param name="schemaId">The ID of the schema.</param>
16+
/// <returns></returns>
17+
public static SchemaProperties SchemaProperties(SchemaFormat format, string schemaId) => new(format, schemaId);
18+
}
19+
}

sdk/schemaregistry/Azure.Data.SchemaRegistry/src/SchemaRegistrySchema.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ namespace Azure.Data.SchemaRegistry
88
/// </summary>
99
public class SchemaRegistrySchema
1010
{
11-
internal SchemaRegistrySchema(SchemaProperties properties, string content)
11+
internal SchemaRegistrySchema(SchemaProperties properties, string definition)
1212
{
1313
Properties = properties;
14-
Content = content;
14+
Definition = definition;
1515
}
1616

1717
/// <summary>
@@ -20,8 +20,8 @@ internal SchemaRegistrySchema(SchemaProperties properties, string content)
2020
public SchemaProperties Properties { get; }
2121

2222
/// <summary>
23-
/// The schema content of the SchemaRegistry schema.
23+
/// The schema definition of the SchemaRegistry schema.
2424
/// </summary>
25-
public string Content { get; }
25+
public string Definition { get; }
2626
}
2727
}

sdk/schemaregistry/Azure.Data.SchemaRegistry/tests/Samples/Sample01_ReadmeSnippets.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Sample01_ReadmeSnippets : SamplesBase<SchemaRegistryClientTestEnvir
1414
private SchemaRegistryClient client;
1515
#pragma warning restore IDE1006 // Naming Styles
1616
private SchemaProperties _schemaProperties;
17-
private string _content;
17+
private string _definition;
1818

1919
[OneTimeSetUp]
2020
public void CreateSchemaRegistryClient()
@@ -40,8 +40,8 @@ public void RegisterSchema()
4040
#region Snippet:SchemaRegistryRegisterSchema
4141
string name = "employeeSample";
4242
SchemaFormat format = SchemaFormat.Avro;
43-
// Example schema's content
44-
string content = @"
43+
// Example schema's definition
44+
string definition = @"
4545
{
4646
""type"" : ""record"",
4747
""namespace"" : ""TestSchema"",
@@ -52,12 +52,12 @@ public void RegisterSchema()
5252
]
5353
}";
5454

55-
Response<SchemaProperties> schemaProperties = client.RegisterSchema(groupName, name, content, format);
55+
Response<SchemaProperties> schemaProperties = client.RegisterSchema(groupName, name, definition, format);
5656
#endregion
5757

5858
Assert.NotNull(schemaProperties);
5959
_schemaProperties = schemaProperties.Value;
60-
_content = content;
60+
_definition = definition;
6161
}
6262

6363
[Test]
@@ -96,10 +96,10 @@ public void RetrieveSchema()
9696

9797
#region Snippet:SchemaRegistryRetrieveSchema
9898
SchemaRegistrySchema schema = client.GetSchema(schemaId);
99-
string content = schema.Content;
99+
string definition = schema.Definition;
100100
#endregion
101101

102-
Assert.AreEqual(Regex.Replace(_content, @"\s+", string.Empty), content);
102+
Assert.AreEqual(Regex.Replace(_definition, @"\s+", string.Empty), definition);
103103
}
104104
}
105105
}

0 commit comments

Comments
 (0)