Skip to content

Commit

Permalink
Merge pull request #55 from dragonfruitnetwork/api-updates
Browse files Browse the repository at this point in the history
API Updates
  • Loading branch information
aspriddell authored Dec 19, 2023
2 parents 4706577 + ccdc845 commit f3f3647
Show file tree
Hide file tree
Showing 38 changed files with 171 additions and 203 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: dotnet publish -c Release -p:Version=${{ github.event.release.tag_name }} DragonFruit.Sakura

- name: Package Output
run: dotnet pack -c Release -p:Version=${{ github.event.inputs.version }} -o ./packages --no-build DragonFruit.Sakura
run: dotnet pack -c Release -p:PackageVersion=${{ github.event.inputs.version }} -o ./packages --no-build DragonFruit.Sakura

- name: Upload Package
run: dotnet nuget push -s https://nuget.pkg.github.com/dragonfruitnetwork/index.json -k ${{ github.token }} ./packages/*.nupkg
Expand Down
1 change: 1 addition & 0 deletions DragonFruit.Sakura.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ Licensed under GNU AGPLv3. Refer to the LICENSE file for more info</s:String>
<s:Boolean x:Key="/Default/CodeStyle/EncapsulateField/MakeFieldPrivate/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/EncapsulateField/UseAutoProperty/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AS/@EntryIndexedValue">AS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GUID/@EntryIndexedValue">GUID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IL/@EntryIndexedValue">IL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IOS/@EntryIndexedValue">IOS</s:String>
Expand Down
14 changes: 7 additions & 7 deletions DragonFruit.Sakura/Administration/Changelogs.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class Changelogs

protected override async Task OnParametersSetAsync()
{
var versionsRequest = new AdminApiChangelogVersionListingRequest(TargetApp.Id);
var versionsRequest = new ChangelogVersionListingRequest(TargetApp.Id);
var releases = await Client.PerformAsync<IReadOnlyCollection<ApiChangelogRelease>>(versionsRequest).ConfigureAwait(false);

VersionHints = releases.Select(x => x.VersionName).ToList();
Expand Down Expand Up @@ -65,7 +65,7 @@ private async Task LoadRelease()
{
try
{
var changelogs = new ApiChangelogsRequest(TargetApp.Id, RequestVersion);
var changelogs = new ChangelogsRequest(TargetApp.Id, RequestVersion);

Target = await Client.PerformAsync<ApiChangelogRelease>(changelogs).ConfigureAwait(false);
IsTargetNew = false;
Expand All @@ -89,7 +89,7 @@ private async Task SaveNewRelease()

Target.Release = DateTime.UtcNow;

var request = new AdminApiChangelogsCreationRequest(TargetApp.Id, Target);
var request = new ChangelogsCreationRequest(TargetApp.Id, Target);
Target = await Client.PerformAsync<ApiChangelogRelease>(request).ConfigureAwait(false);

IsTargetNew = false;
Expand All @@ -101,7 +101,7 @@ private async Task DeleteRelease()
// todo add confirmation
if (!IsTargetNew)
{
var deletionRequest = new AdminApiChangelogsDeletionRequest(TargetApp.Id, Target.VersionName);
var deletionRequest = new ChangelogsDeletionRequest(TargetApp.Id, Target.VersionName);
using var deletionResponse = await Client.PerformAsync(deletionRequest);
deletionResponse.EnsureSuccessStatusCode();
}
Expand All @@ -115,8 +115,8 @@ private async Task SaveModification(ApiChangelogModification modification)
throw new InvalidCastException($"{nameof(SaveModification)} can only be called on live changelog releases");

var request = modification.Id > 0
? new AdminApiChangelogModificationEditRequest(Target.AppId, Target.VersionName, modification)
: new AdminApiChangelogModificationCreationRequest(Target.AppId, Target.VersionName, modification) as YunaApiRequest;
? new ChangelogModificationEditRequest(Target.AppId, Target.VersionName, modification)
: new ChangelogModificationCreationRequest(Target.AppId, Target.VersionName, modification) as YunaApiRequest;

var newModification = await Client.PerformAsync<ApiChangelogModification>(request).ConfigureAwait(false);

Expand All @@ -129,7 +129,7 @@ private async ValueTask DeleteModification(ApiChangelogModification modification
if (modification.Id > 1)
{
// if the id is non-zero, it is on the server and needs to be deleted there first
var request = new AdminApiChangelogModificationDeletionRequest(Target.AppId, Target.VersionName, modification.Id);
var request = new ChangelogModificationDeletionRequest(Target.AppId, Target.VersionName, modification.Id);
using var response = await Client.PerformAsync(request).ConfigureAwait(false);

response.EnsureSuccessStatusCode();
Expand Down
12 changes: 6 additions & 6 deletions DragonFruit.Sakura/Administration/Distribution.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected override async Task OnParametersSetAsync()
Branches = null;
SelectedBranch = null;

var request = new AdminApiDistributionBranchesRequest(TargetApp.Id);
var request = new DistributionBranchesRequest(TargetApp.Id);
Branches = await Client.PerformAsync<IList<ApiDistributionBranch>>(request).ConfigureAwait(false);

// load first branch in to fill page with data
Expand All @@ -44,21 +44,21 @@ private async Task SwitchToBranch(ApiDistributionBranch branch)
{
SelectedBranch = null;

var request = new AdminApiDistributionBranchRequest(TargetApp.Id, branch.Name);
var request = new DistributionBranchRequest(TargetApp.Id, branch.Name);
SelectedBranch = await Client.PerformAsync<ApiDistributionBranch>(request).ConfigureAwait(false);
}

private async Task CreateBranch(string name)
{
var request = new AdminApiDistributionBranchCreationRequest(TargetApp.Id, name);
var request = new DistributionBranchCreationRequest(TargetApp.Id, name);
var branch = await Client.PerformAsync<ApiDistributionBranch>(request).ConfigureAwait(false);

Branches.Add(branch);
}

private async Task DeleteBranch(ApiDistributionBranch branch)
{
var request = new AdminApiDistributionBranchDeletionRequest(TargetApp.Id, branch.Name);
var request = new DistributionBranchDeletionRequest(TargetApp.Id, branch.Name);
using var response = await Client.PerformAsync(request).ConfigureAwait(false);

if (response.IsSuccessStatusCode)
Expand All @@ -69,7 +69,7 @@ private async Task DeleteBranch(ApiDistributionBranch branch)

private async Task PromoteRelease(ApiDistributionRelease release)
{
var request = new AdminApiDistributionActiveReleaseRequest(TargetApp.Id, SelectedBranch.Name, release.Id);
var request = new DistributionActiveReleaseRequest(TargetApp.Id, SelectedBranch.Name, release.Id);
using var response = await Client.PerformAsync(request).ConfigureAwait(false);

if (response.StatusCode == HttpStatusCode.OK)
Expand All @@ -89,7 +89,7 @@ private async Task DeleteRelease(ApiDistributionRelease release)
return;
}

var request = new AdminApiDistributionReleaseDeletionRequest(TargetApp.Id, SelectedBranch.Name, release.Id);
var request = new DistributionReleaseDeletionRequest(TargetApp.Id, SelectedBranch.Name, release.Id);
using var response = await Client.PerformAsync(request).ConfigureAwait(false);

if (response.IsSuccessStatusCode)
Expand Down
2 changes: 1 addition & 1 deletion DragonFruit.Sakura/Administration/Index.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private AppFeatures SelectedAppFeature

protected override async Task OnInitializedAsync()
{
Apps = await Client.PerformAsync<IReadOnlyList<ApiAppInfo>>(new AdminApiAppsListingRequest()).ConfigureAwait(false);
Apps = await Client.PerformAsync<IReadOnlyList<ApiAppInfo>>(new AppsListingRequest()).ConfigureAwait(false);
Name = await AuthenticationStateProvider.GetAuthenticationStateAsync().ContinueWith(t => t.Result.User.Identity?.Name).ConfigureAwait(false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions DragonFruit.Sakura/Administration/Keychain.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private async Task LoadNextPage()
if (!AllowLoadingMoreKeys)
return;

var request = new AdminApiKeychainListingRequest { Limit = PageSize, Offset = (_currentPage++ - 1) * PageSize };
var request = new KeychainListingRequest { Limit = PageSize, Offset = (_currentPage++ - 1) * PageSize };
var nextPageContents = await Client.PerformAsync<IReadOnlyCollection<ApiUserKeychainEntry>>(request).ConfigureAwait(false);

Keys.AddRange(nextPageContents);
Expand All @@ -42,7 +42,7 @@ private async Task LoadNextPage()

private async Task AddKey(InputFileChangeEventArgs args)
{
var request = new AdminApiKeychainAdditionRequest(args.File.OpenReadStream(80000), NewKeyExpiry);
var request = new KeychainItemAdditionRequest(args.File.OpenReadStream(80000), NewKeyExpiry);
var newKey = await Client.PerformAsync<ApiUserKeychainEntry>(request).ConfigureAwait(false);

Keys.Add(newKey);
Expand All @@ -55,7 +55,7 @@ private async Task DeleteKey(ApiUserKeychainEntry key)
return;
}

using var response = await Client.PerformAsync(new AdminApiKeychainDeletionRequest(key.KeyId)).ConfigureAwait(false);
using var response = await Client.PerformAsync(new KeychainItemDeletionRequest(key.KeyId)).ConfigureAwait(false);

if (response.IsSuccessStatusCode)
{
Expand Down
7 changes: 1 addition & 6 deletions DragonFruit.Sakura/Changelogs/Index.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under GNU AGPLv3. Refer to the LICENSE file for more info

using System.Net;
using DragonFruit.Data;
using DragonFruit.Sakura.Network;
using DragonFruit.Sakura.Network.Requests;
using Microsoft.AspNetCore.Components;
Expand Down Expand Up @@ -35,13 +34,9 @@ protected override async Task OnParametersSetAsync()
return;
}

var releaseRequest = string.IsNullOrEmpty(AppName)
? new ApiDefaultChangelogsRequest()
: new ApiChangelogsRequest(AppName, VersionName) as ApiRequest;

try
{
Release = await Client.PerformAsync<ApiChangelogRelease>(releaseRequest).ConfigureAwait(false);
Release = await Client.PerformAsync<ApiChangelogRelease>(new ChangelogsRequest(AppName, VersionName)).ConfigureAwait(false);
}
catch (HttpRequestException e) when (e.StatusCode == HttpStatusCode.NotFound)
{
Expand Down
30 changes: 19 additions & 11 deletions DragonFruit.Sakura/DragonFruit.Sakura.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>true</IsPackable>
</PropertyGroup>

<PropertyGroup>
<Title>DragonFruit Sakura</Title>
<Authors>DragonFruit Network</Authors>
<Copyright>Copyright (c) DragonFruit Network</Copyright>
<Description>The face of DragonFruit Network</Description>
</PropertyGroup>

<PropertyGroup>
<PackageIcon>icon.png</PackageIcon>
<PackageId>DragonFruit.Sakura</PackageId>
Expand All @@ -22,18 +22,26 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DragonFruit.Data" Version="0.9.3-beta" />
<PackageReference Include="DragonFruit.Data.Roslyn" Version="0.9.3-beta" PrivateAssets="all" />
<PackageReference Include="Markdig" Version="0.34.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.0" />
<PackageReference Include="MudBlazor" Version="6.11.1" />
<PackageReference Include="Sentry.Extensions.Logging" Version="3.41.3" />
<PackageReference Include="SharpYaml" Version="2.1.0" />
<PackageReference Include="DragonFruit.Data" Version="4.0.0" />
<PackageReference Include="DragonFruit.Data.Roslyn" Version="4.0.0" PrivateAssets="all" />
<PackageReference Include="Google.Protobuf" Version="3.25.1" />
<PackageReference Include="Grpc.Tools" Version="2.60.0" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Markdig" Version="0.34.0"/>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0"/>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.0"/>
<PackageReference Include="MudBlazor" Version="6.11.2" />
<PackageReference Include="Sentry.Extensions.Logging" Version="3.41.3"/>
<PackageReference Include="SharpYaml" Version="2.1.0"/>
</ItemGroup>

<ItemGroup>
<Protobuf Include="OnionFruit\onionlite.proto" GrpcServices="Client" />
</ItemGroup>

<ItemGroup>
<None Include="..\icon.png" Pack="true" PackagePath="."/>
<None Include="..\icon.png" Pack="true" PackagePath="." Visible="false"/>
</ItemGroup>

</Project>
38 changes: 0 additions & 38 deletions DragonFruit.Sakura/Network/OnionCountryInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@

namespace DragonFruit.Sakura.Network
{
public class ApiGeolocationInfo
public class OnionFruitGeolocationInfo
{
[JsonPropertyName("ip_address")]
public string IPAddress { get; set; }

[JsonPropertyName("country_code")]
public string CountryCode { get; set; }

[JsonPropertyName("country_name")]
public string Country { get; set; }
public string CountryName { get; set; }

[JsonPropertyName("as_number")]
public int? AS { get; set; }

[JsonPropertyName("as_name")]
public string ASName { get; set; }

[JsonPropertyName("is_tor")]
public bool? IsConnectedToTor { get; set; }
Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions DragonFruit.Sakura/Network/Requests/ApiGeolocationInfoRequest.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace DragonFruit.Sakura.Network.Requests
{
public partial class AdminApiAppsListingRequest : YunaApiRequest
public partial class AppsListingRequest : YunaApiRequest
{
protected override string Stub => "/apps";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace DragonFruit.Sakura.Network.Requests
{
public partial class AdminApiChangelogModificationCreationRequest(string appId, string version, ApiChangelogModification modification) : YunaApiRequest
public partial class ChangelogModificationCreationRequest(string appId, string version, ApiChangelogModification modification) : YunaApiRequest
{
public override HttpMethod RequestMethod => HttpMethod.Post;
protected override string Stub => $"/{AppId}/changelogs/{Version}/modifications";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace DragonFruit.Sakura.Network.Requests
{
public partial class AdminApiChangelogModificationDeletionRequest(string appId, string version, int modificationId) : YunaApiRequest
public partial class ChangelogModificationDeletionRequest(string appId, string version, int modificationId) : YunaApiRequest
{
public override HttpMethod RequestMethod => HttpMethod.Delete;
protected override string Stub => $"/{AppId}/changelogs/{Version}/modifications/{ModificationId}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,17 @@

namespace DragonFruit.Sakura.Network.Requests
{
public partial class AdminApiChangelogModificationEditRequest : YunaApiRequest
public partial class ChangelogModificationEditRequest(string appId, string version, ApiChangelogModification modification) : YunaApiRequest
{
public override HttpMethod RequestMethod => HttpMethod.Patch;
protected override string Stub => $"/{AppId}/changelogs/{Version}/modifications/{Modification.Id}";

protected internal override bool RequiresAuthentication => true;

public AdminApiChangelogModificationEditRequest(string appId, string version, ApiChangelogModification modification)
{
AppId = appId;
Version = version;
Modification = modification;
}

public string AppId { get; }
public string Version { get; }
public string AppId { get; } = appId;
public string Version { get; } = version;

[RequestBody]
public ApiChangelogModification Modification { get; }
public ApiChangelogModification Modification { get; } = modification;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

namespace DragonFruit.Sakura.Network.Requests
{
public partial class ApiChangelogsRequest(string appId, string versionName) : YunaApiRequest
public partial class ChangelogVersionListingRequest(string appId) : YunaApiRequest
{
protected override string Stub => $"/{AppId}/changelogs/{VersionName}";
protected override string Stub => $"/{AppId}/changelogs/list";

public string AppId { get; } = appId;
public string VersionName { get; } = versionName ?? "latest";
}
}
Loading

0 comments on commit f3f3647

Please sign in to comment.