-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/resourceregistryserialization (#11173)
* Fixed serialization * Fixed enum * Fixed formatting. Added Competent authority on save * Code smell * Code smell
- Loading branch information
1 parent
5103a0b
commit c02de0a
Showing
12 changed files
with
217 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
namespace Altinn.ResourceRegistry.Core.Models | ||
{ | ||
/// <summary> | ||
/// Describes an organization | ||
/// </summary> | ||
public class Org | ||
{ | ||
/// <summary> | ||
/// Name of organization. With lanugage support | ||
/// </summary> | ||
[JsonProperty("name")] | ||
public Dictionary<string, string> Name { get; set; } | ||
|
||
/// <summary> | ||
/// The logo | ||
/// </summary> | ||
public string Logo { get; set; } | ||
|
||
/// <summary> | ||
/// The organization number | ||
/// </summary> | ||
public string Orgnr { get; set; } | ||
|
||
/// <summary> | ||
/// The homepage | ||
/// </summary> | ||
public string Homepage { get; set; } | ||
|
||
/// <summary> | ||
/// The environments available for the organzation | ||
/// </summary> | ||
public List<string> Environments { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Collections.Generic; | ||
using Altinn.ResourceRegistry.Core.Models; | ||
using Newtonsoft.Json; | ||
|
||
namespace Altinn.Studio.Designer.Models | ||
{ | ||
/// <summary> | ||
/// Defines a list of orgs | ||
/// </summary> | ||
public class OrgList | ||
{ | ||
/// <summary> | ||
/// Dictionary of orgs | ||
/// </summary> | ||
public Dictionary<string, Org> Orgs { get; set; } | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
backend/src/Designer/Services/Implementation/OrgService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Altinn.Studio.Designer.Configuration; | ||
using Altinn.Studio.Designer.Models; | ||
using Altinn.Studio.Designer.Services.Interfaces; | ||
|
||
namespace Altinn.Studio.Designer.Services.Implementation | ||
{ | ||
/// <summary> | ||
/// Client responsible for collection | ||
/// </summary> | ||
public class OrgService : IOrgService | ||
{ | ||
private readonly HttpClient _client; | ||
private readonly GeneralSettings _generalSettings; | ||
|
||
/// <summary> | ||
/// Default constructor | ||
/// </summary> | ||
public OrgService(HttpClient client, GeneralSettings generalSettingsOptions) | ||
{ | ||
_client = client; | ||
_generalSettings = generalSettingsOptions; | ||
} | ||
|
||
/// <summary> | ||
/// Returns configured org list | ||
/// </summary> | ||
public async Task<OrgList> GetOrgList() | ||
{ | ||
HttpResponseMessage response = await _client.GetAsync(_generalSettings.OrganizationsUrl); | ||
response.EnsureSuccessStatusCode(); | ||
string orgListString = await response.Content.ReadAsStringAsync(); | ||
OrgList orgList = System.Text.Json.JsonSerializer.Deserialize<OrgList>(orgListString, new System.Text.Json.JsonSerializerOptions() { PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase }); | ||
return orgList; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.