Skip to content

Commit b0ca338

Browse files
authored
Merge pull request #179 from digipost/archive_api_support
New project in solution to fetch from Archive
2 parents ff20c82 + 7c68e7b commit b0ca338

File tree

40 files changed

+4352
-4068
lines changed

40 files changed

+4352
-4068
lines changed

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-xscgen": {
6+
"version": "2.0.594",
7+
"commands": [
8+
"xscgen"
9+
]
10+
}
11+
}
12+
}

.github/workflows/release.yml

Lines changed: 70 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Release
22

3-
on:
3+
on:
44
push:
55
tags:
66
- '*'
@@ -9,70 +9,72 @@ jobs:
99
release:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
13-
- name: Setup .NET Core
14-
uses: actions/setup-dotnet@v1
15-
with:
16-
dotnet-version: 3.1.101
17-
- name: Print openssl version
18-
run: |
19-
openssl version
20-
- name: Decrypt signing key to use for strong-name
21-
env:
22-
SIGNINGKEY_ENC_PASSWORD: ${{ secrets.signingkeyEncPassword }}
23-
run: |
24-
openssl aes-256-cbc -salt -pbkdf2 -k "$SIGNINGKEY_ENC_PASSWORD" -in signingkey.snk.enc -out signingkey.snk -d
25-
- name: Install dependencies
26-
run: dotnet restore
27-
- name: Build
28-
run: dotnet build --configuration Release --no-restore
29-
- name: Test
30-
run: dotnet test --no-restore --verbosity normal
31-
- name: Set release version
32-
run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF:10})
33-
- name: Set assembly version to major semver
34-
run: echo ::set-env name=ASSEMBLY_VERSION::$(echo ${GITHUB_REF:10} | cut -d '.' -f 1).0.0
35-
- name: Print assembly version
36-
run: echo $ASSEMBLY_VERSION
37-
- name: Pack nupkg
38-
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client
39-
- name: Pack nupkg
40-
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Common
41-
- name: Pack nupkg
42-
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Docs
43-
- name: Pack nupkg
44-
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Inbox
45-
- name: Pack nupkg
46-
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Resources
47-
- name: Pack nupkg
48-
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Scripts
49-
- name: Pack nupkg
50-
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Send
51-
- name: Push Client to NuGet
52-
env:
53-
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
54-
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
55-
- name: Push Common to NuGet
56-
env:
57-
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
58-
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Common.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
59-
- name: Push Docs to NuGet
60-
env:
61-
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
62-
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Docs.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
63-
- name: Push Inbox to NuGet
64-
env:
65-
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
66-
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Inbox.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
67-
- name: Push Resources to NuGet
68-
env:
69-
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
70-
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Resources.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
71-
- name: Push Scripts to NuGet
72-
env:
73-
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
74-
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Scripts.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
75-
- name: Push Send to NuGet
76-
env:
77-
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
78-
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Send.$RELEASE_VERSION.nupkg" --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
12+
- uses: actions/checkout@v2
13+
- name: Setup .NET Core
14+
uses: actions/setup-dotnet@v1
15+
with:
16+
dotnet-version: 3.1.101
17+
- name: Print openssl version
18+
run: |
19+
openssl version
20+
- name: Decrypt signing key to use for strong-name
21+
env:
22+
SIGNINGKEY_ENC_PASSWORD: ${{ secrets.signingkeyEncPassword }}
23+
run: |
24+
openssl aes-256-cbc -salt -pbkdf2 -k "$SIGNINGKEY_ENC_PASSWORD" -in signingkey.snk.enc -out signingkey.snk -d
25+
- name: Install dependencies
26+
run: dotnet restore
27+
- name: Build
28+
run: dotnet build --configuration Release --no-restore
29+
- name: Test
30+
run: dotnet test --no-restore --verbosity normal
31+
- name: Set RELEASE_VERSION environment variable
32+
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV
33+
- name: Set ASSEMBLY_VERSION environment variable
34+
run: echo "ASSEMBLY_VERSION=$(echo $(echo ${GITHUB_REF:10} | cut -d '.' -f 1).0.0)" >> $GITHUB_ENV
35+
- name: Print relese version
36+
run: echo $RELEASE_VERSION
37+
- name: Print assembly version
38+
run: echo $ASSEMBLY_VERSION
39+
- name: Pack nupkg
40+
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client
41+
- name: Pack nupkg
42+
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Common
43+
- name: Pack nupkg
44+
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Docs
45+
- name: Pack nupkg
46+
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Inbox
47+
- name: Pack nupkg
48+
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Archive
49+
- name: Pack nupkg
50+
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Resources
51+
- name: Pack nupkg
52+
run: dotnet pack -p:PackageVersion=$RELEASE_VERSION -p:AssemblyVersion=$ASSEMBLY_VERSION --configuration Release --no-build --output digipost/packed Digipost.Api.Client.Send
53+
- name: Push Client to NuGet
54+
env:
55+
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
56+
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
57+
- name: Push Common to NuGet
58+
env:
59+
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
60+
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Common.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
61+
- name: Push Docs to NuGet
62+
env:
63+
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
64+
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Docs.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
65+
- name: Push Inbox to NuGet
66+
env:
67+
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
68+
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Inbox.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
69+
- name: Push Archive to NuGet
70+
env:
71+
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
72+
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Archive.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
73+
- name: Push Resources to NuGet
74+
env:
75+
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
76+
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Resources.$RELEASE_VERSION.nupkg" --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
77+
- name: Push Send to NuGet
78+
env:
79+
NUGET_API_KEY: ${{ secrets.nugetApiKey }}
80+
run: dotnet nuget push "digipost/packed/Digipost.Api.Client.Send.$RELEASE_VERSION.nupkg" --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.ComponentModel;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Digipost.Api.Client.Common;
7+
using Digipost.Api.Client.Common.Utilities;
8+
9+
10+
namespace Digipost.Api.Client.Archive
11+
{
12+
public class Archive : IArchive
13+
{
14+
private readonly string _archiveRoot;
15+
private readonly RequestHelper _requestHelper;
16+
17+
internal Archive(Sender sender, RequestHelper requestHelper)
18+
{
19+
Sender = sender;
20+
_archiveRoot = $"{Sender.Id}/archive";
21+
_requestHelper = requestHelper;
22+
}
23+
24+
internal RequestHelper RequestHelper { get; set; }
25+
26+
public Sender Sender { get; set; }
27+
28+
public Task<Stream> StreamDocumentFromExternalId(String externalId)
29+
{
30+
var nameUuidFromBytes = UUIDInterop.NameUUIDFromBytes(externalId);
31+
return StreamDocumentFromExternalId(Guid.Parse(nameUuidFromBytes));
32+
}
33+
34+
public async Task<Stream> StreamDocumentFromExternalId(Guid guid)
35+
{
36+
var documentNyUuid = new Uri($"{_archiveRoot}/document/uuid/{guid.ToString()}", UriKind.Relative);
37+
var archive = await _requestHelper.Get<V7.Archive>(documentNyUuid).ConfigureAwait(false);
38+
var first = archive.Documents[0].Link.First(link => link.Rel.EndsWith("get_archive_document_content_stream"));
39+
40+
return await _requestHelper.GetStream(new Uri(first.Uri, UriKind.Absolute)).ConfigureAwait(false);
41+
}
42+
43+
}
44+
}

Digipost.Api.Client.Scripts/Digipost.Api.Client.Scripts.csproj renamed to Digipost.Api.Client.Archive/Digipost.Api.Client.Archive.csproj

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build">
22

33
<PropertyGroup>
4-
<Title>Digipost Api Client Scripts</Title>
5-
<PackageId>Digipost.Api.Client.Scripts</PackageId>
4+
<Title>Digipost Api Client Archive</Title>
5+
<PackageId>Digipost.Api.Client.Archive</PackageId>
66
<SignAssembly>true</SignAssembly>
77
<AssemblyOriginatorKeyFile>..\signingkey.snk</AssemblyOriginatorKeyFile>
88
</PropertyGroup>
9-
9+
1010
<PropertyGroup>
1111
<TargetFramework>netstandard2.0</TargetFramework>
12-
<RootNamespace>Digipost.Api.Client.Scripts</RootNamespace>
13-
<AssemblyName>Digipost.Api.Client.Scripts</AssemblyName>
14-
<ProjectGuid>{A0F4D5F2-F2C7-4DDA-8B94-0057A96DA5A0}</ProjectGuid>
12+
<RootNamespace>Digipost.Api.Client.Archive</RootNamespace>
13+
<AssemblyName>Digipost.Api.Client.Archive</AssemblyName>
14+
<ProjectGuid>{1BEC9279-D6C5-4C26-B926-13081F1C3DBC}</ProjectGuid>
1515
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1616
</PropertyGroup>
1717

@@ -35,9 +35,19 @@
3535
<ErrorReport>prompt</ErrorReport>
3636
<WarningLevel>4</WarningLevel>
3737
<NoWarn>1591</NoWarn>
38-
<DocumentationFile>bin\Release\Digipost.Api.Client.Send.XML</DocumentationFile>
38+
<DocumentationFile>bin\Release\Digipost.Api.Client.Archive.XML</DocumentationFile>
3939
</PropertyGroup>
4040

41+
<ItemGroup>
42+
<PackageReference Include="Portable.BouncyCastle" Version="1.8.6.7" />
43+
<PackageReference Include="Difi.Felles.Utility" Version="5.0.0" />
44+
<PackageReference Include="Digipost.Api.Client.Shared" Version="7.0.0" />
45+
<ProjectReference Include="..\Digipost.Api.Client.Common\Digipost.Api.Client.Common.csproj">
46+
<Project>{CD338E5A-1ED0-4331-B34E-8292FA8E387B}</Project>
47+
<Name>Digipost.Api.Client.Common</Name>
48+
</ProjectReference>
49+
</ItemGroup>
50+
4151
<ItemGroup>
4252
<Compile Include="..\SharedAssemblyInfo.cs">
4353
<Link>Properties\SharedAssemblyInfo.cs</Link>
@@ -48,9 +58,4 @@
4858
<Link>signingkey.snk</Link>
4959
</None>
5060
</ItemGroup>
51-
<ItemGroup>
52-
<PackageReference Include="Portable.BouncyCastle" Version="1.8.6.7" />
53-
<PackageReference Include="Difi.Felles.Utility" Version="5.0.0" />
54-
<PackageReference Include="Digipost.Api.Client.Shared" Version="7.0.0" />
55-
</ItemGroup>
5661
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
5+
namespace Digipost.Api.Client.Archive
6+
{
7+
internal interface IArchive
8+
{
9+
/**
10+
* This will hash and create a Guid the same way as java UUID.nameUUIDFromBytes
11+
*/
12+
Task<Stream> StreamDocumentFromExternalId(String externalId);
13+
Task<Stream> StreamDocumentFromExternalId(Guid externalId_guid);
14+
15+
}
16+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
[assembly: AssemblyTitle("Digipost.Api.Client.Archive")]
5+
[assembly: InternalsVisibleTo("Digipost.Api.Client,PublicKey=0024000004800000940000000602000000240000525341310004000001000100f71f491a4cebe0a3d18a61744f92edfca908e4d756aa1140ebceeffb1fc4aa2e7bbe4d672067e2c0a3afd8c4511ef84cc1267ba04d8041e24d96c3d93e268fd69abc712fa81bcbae729f1c0524eef0254705bb2fcf1ffd43a647e9306b93e8dd7afd094a61ca2761fe87c20fdda758ad55d2c5ba6ad6edc9493309a355e51f99")]

0 commit comments

Comments
 (0)