Skip to content

Commit 3db86e0

Browse files
Adds the ApiCenterProductionVersionPlugin (#656)
1 parent 80e6080 commit 3db86e0

File tree

4 files changed

+720
-415
lines changed

4 files changed

+720
-415
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using System.Net.Http.Headers;
5+
using Azure.Core;
6+
7+
namespace Microsoft.DevProxy.Plugins;
8+
9+
internal class AuthenticationDelegatingHandler : DelegatingHandler
10+
{
11+
private readonly TokenCredential _credential;
12+
private readonly string[] _scopes;
13+
14+
public AuthenticationDelegatingHandler(TokenCredential credential, string[] scopes)
15+
{
16+
_credential = credential;
17+
_scopes = scopes;
18+
}
19+
20+
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
21+
{
22+
var accessToken = await _credential.GetTokenAsync(new TokenRequestContext(_scopes), cancellationToken);
23+
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Token);
24+
25+
return await base.SendAsync(request, cancellationToken);
26+
}
27+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using System.Text.Json.Serialization;
5+
using Microsoft.OpenApi.Models;
6+
7+
namespace Microsoft.DevProxy.Plugins.RequestLogs.ApiCenter;
8+
9+
internal class Collection<T>()
10+
{
11+
public T[] Value { get; set; } = [];
12+
}
13+
14+
internal class Api
15+
{
16+
public ApiProperties? Properties { get; set; }
17+
public string? Name { get; set; }
18+
public string? Id { get; set; }
19+
}
20+
21+
internal class ApiProperties
22+
{
23+
public string? Title { get; set; }
24+
public string? Summary { get; set; }
25+
[JsonConverter(typeof(JsonStringEnumConverter))]
26+
public ApiKind? Kind { get; set; }
27+
[JsonConverter(typeof(JsonStringEnumConverter))]
28+
public ApiLifecycleStage? LifecycleStage { get; set; }
29+
public ApiContact[] Contacts { get; set; } = [];
30+
public dynamic CustomProperties { get; set; } = new object();
31+
}
32+
33+
internal class ApiContact
34+
{
35+
public string? Name { get; set; }
36+
public string? Email { get; set; }
37+
public string? Url { get; set; }
38+
}
39+
40+
internal class ApiDeployment
41+
{
42+
public ApiDeploymentProperties? Properties { get; set; }
43+
public string? Name { get; set; }
44+
}
45+
46+
internal class ApiDeploymentProperties
47+
{
48+
public string? Title { get; set; }
49+
public string? DefinitionId { get; set; }
50+
public ApiDeploymentServer? Server { get; set; }
51+
public dynamic CustomProperties { get; set; } = new object();
52+
}
53+
54+
internal class ApiDeploymentServer
55+
{
56+
public string[] RuntimeUri { get; set; } = [];
57+
}
58+
59+
internal class ApiDefinition
60+
{
61+
public string? Id { get; set; }
62+
public ApiDefinitionProperties? Properties { get; set; }
63+
public OpenApiDocument? Definition { get; set; }
64+
}
65+
66+
internal class ApiDefinitionProperties
67+
{
68+
public ApiDefinitionPropertiesSpecification? Specification { get; set; }
69+
}
70+
71+
internal class ApiDefinitionPropertiesSpecification
72+
{
73+
public string? Name { get; set; }
74+
}
75+
76+
internal class ApiSpecExportResult
77+
{
78+
[JsonConverter(typeof(JsonStringEnumConverter))]
79+
public ApiSpecExportResultFormat? Format { get; set; }
80+
public string? Value { get; set; }
81+
}
82+
83+
internal class ApiVersion
84+
{
85+
public ApiVersionProperties? Properties { get; set; }
86+
public string? Id { get; set; }
87+
public string? Name { get; set; }
88+
}
89+
90+
internal class ApiVersionProperties
91+
{
92+
public string? Title { get; set; }
93+
[JsonConverter(typeof(JsonStringEnumConverter))]
94+
public ApiLifecycleStage LifecycleStage { get; set; }
95+
}
96+
97+
internal enum ApiSpecExportResultFormat
98+
{
99+
Inline,
100+
Link
101+
}
102+
103+
internal enum ApiKind
104+
{
105+
GraphQL,
106+
gRPC,
107+
REST,
108+
SOAP,
109+
Webhook,
110+
WebSocket
111+
}
112+
113+
internal enum ApiLifecycleStage
114+
{
115+
Deprecated,
116+
Design,
117+
Development,
118+
Preview,
119+
Production,
120+
Retired,
121+
Testing
122+
}

0 commit comments

Comments
 (0)