Skip to content

Commit

Permalink
Add client configuration for azure API
Browse files Browse the repository at this point in the history
  • Loading branch information
tmarkovski committed Jul 29, 2019
1 parent 9a64a7e commit 049f0e6
Show file tree
Hide file tree
Showing 7 changed files with 1,375 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

.DS_Store

# User-specific files
*.suo
*.user
Expand Down
2 changes: 2 additions & 0 deletions command.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
autorest --input-file=http://localhost:5009/swagger/v1/swagger.json --csharp --output-folder=src/Streetcred.Cloud.Client --namespace=Streetcred.Cloud.Client --add-credentials --override-client-name=CloudServiceClient

autorest --input-file=http://localhost:5000/swagger/v1/swagger.json --csharp --output-folder=src/Streetcred.Portal.Client --namespace=Streetcred.Portal.Client --add-credentials --override-client-name=PortalServiceClient

autorest --input-file=swagger.json --csharp --output-folder=csharp/Generated --namespace=Streetcred.ServiceClients --add-credentials --override-client-name=AgencyServiceClient
1 change: 1 addition & 0 deletions csharp/Generated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cs
8 changes: 8 additions & 0 deletions csharp/ServiceClientOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Microsoft.Extensions.DependencyInjection
{
public class ServiceClientOptions
{
public string AccessToken { get; set; }
public string SubscriptionKey { get; set; }
}
}
23 changes: 23 additions & 0 deletions csharp/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using Microsoft.Rest;
using Streetcred.ServiceClients;

namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddStreetcredClient(this IServiceCollection services, Action<ServiceClientOptions> configure)
{
services.Configure(configure);
services.AddSingleton<StreetcredClientCredentials>();
services.AddSingleton<IAgencyServiceClient, AgencyServiceClient>(provider =>
new AgencyServiceClient(provider.GetRequiredService<StreetcredClientCredentials>()));
return services;
}

public static IServiceCollection AddStreetcredClient(this IServiceCollection services)
{
return AddStreetcredClient(services, options => { });
}
}
}
13 changes: 13 additions & 0 deletions csharp/Streetcred.ServiceClients.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.0.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.20" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
</ItemGroup>
</Project>

0 comments on commit 049f0e6

Please sign in to comment.