Skip to content

Commit

Permalink
Add support for problem details (#20)
Browse files Browse the repository at this point in the history
* Add support for problem details responses
* Prevent redaction of api-supported-versions header
* Bump minimum target frameworks and packages
* Improve script for client generation
  • Loading branch information
ChristopherMann authored Jun 12, 2024
1 parent f2449d2 commit 3990835
Show file tree
Hide file tree
Showing 37 changed files with 1,646 additions and 818 deletions.
2 changes: 1 addition & 1 deletion build/Eryph.IdentityClient.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ PowerShellVersion = '5.1'
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
DotNetFrameworkVersion = '4.6.1'
DotNetFrameworkVersion = '4.6.2'

# Minimum version of the Identity language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
ClrVersion = '4.0'
Expand Down
4 changes: 2 additions & 2 deletions build/build-cmdlet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ mkdir coreclr | Out-Null
mkdir desktop | Out-Null

cp $rootDir\build\${cmdletName}* .
cp $rootDir\src\${cmdletName}.Commands\bin\${Configuration}\netcoreapp3.1\* coreclr -Exclude $excludedFiles -Recurse
cp $rootDir\src\${cmdletName}.Commands\bin\${Configuration}\net461\* desktop -Exclude $excludedFiles -Recurse
cp $rootDir\src\${cmdletName}.Commands\bin\${Configuration}\net6.0\* coreclr -Exclude $excludedFiles -Recurse
cp $rootDir\src\${cmdletName}.Commands\bin\${Configuration}\net462\* desktop -Exclude $excludedFiles -Recurse

$config = gc "${cmdletName}.psd1" -Raw
$config = $config.Replace("ModuleVersion = '0.1'", "ModuleVersion = '${Env:GITVERSION_MajorMinorPatch}'");
Expand Down
35 changes: 30 additions & 5 deletions gen/generate_local.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
Push-Location $PSScriptRoot
$settings = Get-Content -Raw -Path "config.json" | ConvertFrom-Json
cd ..
$location = Get-Location
#Requires -Version 7.4
<#
.SYNOPSIS
Generates the REST client locally
.DESCRIPTION
This script generates the REST client locally.
#>
[CmdletBinding()]
param()

$PSNativeCommandUseErrorActionPreference = $true
$ErrorActionPreference = 'Stop'

# Update the version in the csproj when changing this
$autoRestCSharpVersion = "3.0.0-beta.20240527.2"

$settings = Get-Content -Raw -Path "$PSScriptRoot/config.json" | ConvertFrom-Json
$tag = $settings.tag
$spec = $settings.spec

autorest ..\eryph-api-spec\specification\$spec --tag=$tag --csharp-src-folder=$location --v3 --csharp --verbose
npm exec --package="autorest@3.7.1" -- `
autorest `
--version="3.10.2" `
--use="@autorest/csharp@$autoRestCSharpVersion" `
--use="@autorest/modelerfour@4.27.0" `
"$PSScriptRoot/../../eryph-api-spec/specification/$spec" `
--tag=$tag `
--csharp-src-folder="$PSScriptRoot/.." `
--v3 `
--csharp `
--skip-csproj=true `
--generate-sample-project=false `
--verbose
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net461</TargetFrameworks>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Eryph.ClientRuntime.Powershell" Version="0.5.0" />
<PackageReference Include="Eryph.ClientRuntime.Powershell" Version="0.7.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
3 changes: 2 additions & 1 deletion src/Eryph.IdentityClient.Commands/IdentityCmdLet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ protected override void BeginProcessing()
{
IsDistributedTracingEnabled = true,
IsLoggingEnabled = IsDebugEnabled,
IsLoggingContentEnabled = IsDebugEnabled
IsLoggingContentEnabled = IsDebugEnabled,
LoggedHeaderNames = { "api-supported-versions" },
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/Eryph.IdentityClient.Commands/NewEryphClientCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ protected override void ProcessRecord()
{
Id = result.Id,
Name = result.Name,
TenantId = result.TenantId,
};

foreach (var allowedScope in result.AllowedScopes)
{
eryphClient.AllowedScopes.Add(allowedScope);

}

WriteObject(eryphClient);
Expand Down
12 changes: 12 additions & 0 deletions src/Eryph.IdentityClient.Commands/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"Eryph.IdentityClient.Commands": {
"commandName": "Project"
},
"Run in Powershell": {
"commandName": "Executable",
"executablePath": "powershell.exe",
"commandLineArgs": "-NoProfile -NoExit -Command \"Import-Module $(TargetPath)\""
}
}
}
2 changes: 1 addition & 1 deletion src/Eryph.IdentityClient.Commands/UnsafeAssemblyHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET461
#if NET462

using System;
using System.IO;
Expand Down
6 changes: 3 additions & 3 deletions src/Eryph.IdentityClient/Eryph.IdentityClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
</PropertyGroup>

<PropertyGroup>
<LangVersion>11.0</LangVersion>
<LangVersion>12</LangVersion>
<IncludeGeneratorSharedCode>true</IncludeGeneratorSharedCode>
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Eryph.ClientRuntime.Authentication" Version="0.5.0" />
<PackageReference Include="Eryph.ClientRuntime.Authentication" Version="0.7.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20231020.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20240527.2" PrivateAssets="All" />
</ItemGroup>
</Project>
36 changes: 18 additions & 18 deletions src/Eryph.IdentityClient/Generated/ClientsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal ClientsClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipelin
}

/// <summary> Creates a new client. </summary>
/// <param name="body"> The Client to use. </param>
/// <param name="body"> The <see cref="Client"/> to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <remarks> Creates a client. </remarks>
public virtual async Task<Response<ClientWithSecret>> CreateAsync(Client body = null, CancellationToken cancellationToken = default)
Expand All @@ -60,7 +60,7 @@ public virtual async Task<Response<ClientWithSecret>> CreateAsync(Client body =
}

/// <summary> Creates a new client. </summary>
/// <param name="body"> The Client to use. </param>
/// <param name="body"> The <see cref="Client"/> to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <remarks> Creates a client. </remarks>
public virtual Response<ClientWithSecret> Create(Client body = null, CancellationToken cancellationToken = default)
Expand All @@ -79,7 +79,7 @@ public virtual Response<ClientWithSecret> Create(Client body = null, Cancellatio
}

/// <summary> Deletes a client. </summary>
/// <param name="id"> The String to use. </param>
/// <param name="id"> The <see cref="string"/> to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async Task<Response> DeleteAsync(string id, CancellationToken cancellationToken = default)
{
Expand All @@ -97,7 +97,7 @@ public virtual async Task<Response> DeleteAsync(string id, CancellationToken can
}

/// <summary> Deletes a client. </summary>
/// <param name="id"> The String to use. </param>
/// <param name="id"> The <see cref="string"/> to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Response Delete(string id, CancellationToken cancellationToken = default)
{
Expand All @@ -115,7 +115,7 @@ public virtual Response Delete(string id, CancellationToken cancellationToken =
}

/// <summary> Get a client. </summary>
/// <param name="id"> The String to use. </param>
/// <param name="id"> The <see cref="string"/> to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async Task<Response<Client>> GetAsync(string id, CancellationToken cancellationToken = default)
{
Expand All @@ -133,7 +133,7 @@ public virtual async Task<Response<Client>> GetAsync(string id, CancellationToke
}

/// <summary> Get a client. </summary>
/// <param name="id"> The String to use. </param>
/// <param name="id"> The <see cref="string"/> to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Response<Client> Get(string id, CancellationToken cancellationToken = default)
{
Expand All @@ -151,10 +151,10 @@ public virtual Response<Client> Get(string id, CancellationToken cancellationTok
}

/// <summary> Updates a client. </summary>
/// <param name="id"> The String to use. </param>
/// <param name="body"> The Client to use. </param>
/// <param name="id"> The <see cref="string"/> to use. </param>
/// <param name="body"> The <see cref="Client"/> to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async Task<Response<Client>> UpdateAsync(string id, Client body = null, CancellationToken cancellationToken = default)
public virtual async Task<Response<Client>> UpdateAsync(string id, Client body, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ClientsClient.Update");
scope.Start();
Expand All @@ -170,10 +170,10 @@ public virtual async Task<Response<Client>> UpdateAsync(string id, Client body =
}

/// <summary> Updates a client. </summary>
/// <param name="id"> The String to use. </param>
/// <param name="body"> The Client to use. </param>
/// <param name="id"> The <see cref="string"/> to use. </param>
/// <param name="body"> The <see cref="Client"/> to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Response<Client> Update(string id, Client body = null, CancellationToken cancellationToken = default)
public virtual Response<Client> Update(string id, Client body, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ClientsClient.Update");
scope.Start();
Expand All @@ -189,10 +189,10 @@ public virtual Response<Client> Update(string id, Client body = null, Cancellati
}

/// <summary> Updates a client key. </summary>
/// <param name="id"> The String to use. </param>
/// <param name="body"> The NewClientKeyRequestBody to use. </param>
/// <param name="id"> The <see cref="string"/> to use. </param>
/// <param name="body"> The <see cref="NewClientKeyRequestBody"/> to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async Task<Response<ClientWithSecret>> NewKeyAsync(string id, NewClientKeyRequestBody body = null, CancellationToken cancellationToken = default)
public virtual async Task<Response<ClientWithSecret>> NewKeyAsync(string id, NewClientKeyRequestBody body, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ClientsClient.NewKey");
scope.Start();
Expand All @@ -208,10 +208,10 @@ public virtual async Task<Response<ClientWithSecret>> NewKeyAsync(string id, New
}

/// <summary> Updates a client key. </summary>
/// <param name="id"> The String to use. </param>
/// <param name="body"> The NewClientKeyRequestBody to use. </param>
/// <param name="id"> The <see cref="string"/> to use. </param>
/// <param name="body"> The <see cref="NewClientKeyRequestBody"/> to use. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Response<ClientWithSecret> NewKey(string id, NewClientKeyRequestBody body = null, CancellationToken cancellationToken = default)
public virtual Response<ClientWithSecret> NewKey(string id, NewClientKeyRequestBody body, CancellationToken cancellationToken = default)
{
using var scope = _clientDiagnostics.CreateScope("ClientsClient.NewKey");
scope.Start();
Expand Down
Loading

0 comments on commit 3990835

Please sign in to comment.