From 095c5d4e653078ad0fee54f8d6a33d45b5de7480 Mon Sep 17 00:00:00 2001 From: Frederik Date: Fri, 27 Aug 2021 12:11:04 +0200 Subject: [PATCH 1/5] Add support for Actions Management APIs --- src/Auth0.ManagementApi/Actions/Action.cs | 27 ++ src/Auth0.ManagementApi/Actions/ActionBase.cs | 23 ++ .../Actions/ActionDependency.cs | 12 + .../Actions/ActionError.cs | 16 ++ .../Actions/ActionExecution.cs | 27 ++ .../Actions/ActionExecutionResult.cs | 17 ++ .../Actions/ActionSecret.cs | 17 ++ .../Actions/ActionSupportedTrigger.cs | 12 + .../Actions/ActionVersion.cs | 45 ++++ .../Actions/ActionsClient.cs | 253 ++++++++++++++++++ .../Actions/CreateActionRequest.cs | 11 + .../Actions/DeleteActionRequest.cs | 10 + .../Actions/GetActionsRequest.cs | 10 + src/Auth0.ManagementApi/Actions/Trigger.cs | 23 ++ .../Actions/TriggerBinding.cs | 26 ++ .../Actions/UpdateActionRequest.cs | 7 + .../Actions/UpdateTriggerBindingEntry.cs | 21 ++ .../Actions/UpdateTriggerBindingsRequest.cs | 11 + .../HttpClientManagementConnection.cs | 8 +- .../IManagementConnection.cs | 3 +- src/Auth0.ManagementApi/ListConverter.cs | 53 ++++ .../ManagementApiClient.cs | 7 + .../ActionsTests.cs | 173 ++++++++++++ .../ManagementApiClientTests.cs | 4 +- 24 files changed, 809 insertions(+), 7 deletions(-) create mode 100644 src/Auth0.ManagementApi/Actions/Action.cs create mode 100644 src/Auth0.ManagementApi/Actions/ActionBase.cs create mode 100644 src/Auth0.ManagementApi/Actions/ActionDependency.cs create mode 100644 src/Auth0.ManagementApi/Actions/ActionError.cs create mode 100644 src/Auth0.ManagementApi/Actions/ActionExecution.cs create mode 100644 src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs create mode 100644 src/Auth0.ManagementApi/Actions/ActionSecret.cs create mode 100644 src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs create mode 100644 src/Auth0.ManagementApi/Actions/ActionVersion.cs create mode 100644 src/Auth0.ManagementApi/Actions/ActionsClient.cs create mode 100644 src/Auth0.ManagementApi/Actions/CreateActionRequest.cs create mode 100644 src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs create mode 100644 src/Auth0.ManagementApi/Actions/GetActionsRequest.cs create mode 100644 src/Auth0.ManagementApi/Actions/Trigger.cs create mode 100644 src/Auth0.ManagementApi/Actions/TriggerBinding.cs create mode 100644 src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs create mode 100644 src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs create mode 100644 src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs create mode 100644 src/Auth0.ManagementApi/ListConverter.cs create mode 100644 tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs diff --git a/src/Auth0.ManagementApi/Actions/Action.cs b/src/Auth0.ManagementApi/Actions/Action.cs new file mode 100644 index 000000000..be36ecdd4 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/Action.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class Action: ActionBase + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("status")] + public string Status { get; set; } + + [JsonProperty("all_changes_deployed")] + public bool AllChangesDeployed { get; set; } + + [JsonProperty("created_at")] + public DateTime CreatedAt { get; set; } + + [JsonProperty("updated_at")] + public DateTime UpdatedAt { get; set; } + + [JsonProperty("supported_triggers")] + public IList SupportedTriggers { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/ActionBase.cs b/src/Auth0.ManagementApi/Actions/ActionBase.cs new file mode 100644 index 000000000..a044af6cb --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/ActionBase.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class ActionBase + { + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("code")] + public string Code { get; set; } + + [JsonProperty("dependencies")] + public IList Dependencies { get; set; } + + [JsonProperty("runtime")] + public string Runtime { get; set; } + + [JsonProperty("secrets")] + public IList Secrets { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/ActionDependency.cs b/src/Auth0.ManagementApi/Actions/ActionDependency.cs new file mode 100644 index 000000000..49adeb4ba --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/ActionDependency.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class ActionDependency + { + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("version")] + public string Version { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/ActionError.cs b/src/Auth0.ManagementApi/Actions/ActionError.cs new file mode 100644 index 000000000..abaf4d9a9 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/ActionError.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class ActionError + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("msg")] + public string Message { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/ActionExecution.cs b/src/Auth0.ManagementApi/Actions/ActionExecution.cs new file mode 100644 index 000000000..cecf04ef7 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/ActionExecution.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class ActionExecution + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("trigger_id")] + public string TriggerId { get; set; } + + [JsonProperty("status")] + public string Status { get; set; } + + [JsonProperty("results")] + public IList Results { get; set; } + + [JsonProperty("created_at")] + public DateTime CreatedAt { get; set; } + + [JsonProperty("updated_at")] + public DateTime UpdatedAt { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs b/src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs new file mode 100644 index 000000000..1593d2b53 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs @@ -0,0 +1,17 @@ +using System; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class ActionExecutionResult + { + [JsonProperty("action_name")] + public string ActionName { get; set; } + + [JsonProperty("started_at")] + public DateTime StartedAt { get; set; } + + [JsonProperty("ended_at")] + public DateTime EndedAt { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/ActionSecret.cs b/src/Auth0.ManagementApi/Actions/ActionSecret.cs new file mode 100644 index 000000000..32d2a9de5 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/ActionSecret.cs @@ -0,0 +1,17 @@ +using System; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class ActionSecret + { + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("updated_at")] + public DateTime UpdatedAt { get; set; } + + [JsonProperty("value")] + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs b/src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs new file mode 100644 index 000000000..5e0973092 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class ActionSupportedTrigger + { + [JsonProperty("id")] + public string Id { get; set; } + [JsonProperty("version")] + public string Version { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/ActionVersion.cs b/src/Auth0.ManagementApi/Actions/ActionVersion.cs new file mode 100644 index 000000000..1ed46b769 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/ActionVersion.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class ActionVersion + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("code")] + public string Code { get; set; } + + [JsonProperty("runtime")] + public string Runtime { get; set; } + + [JsonProperty("number")] + public int Number { get; set; } + + [JsonProperty("deployed")] + public bool? Deployed { get; set; } + + [JsonProperty("dependencies")] + public IList Dependencies { get; set; } + + [JsonProperty("status")] + public string Status { get; set; } + + [JsonProperty("created_at")] + public DateTime CreatedAt { get; set; } + + [JsonProperty("updated_at")] + public DateTime UpdatedAt { get; set; } + + [JsonProperty("action")] + public Action Action { get; set; } + + [JsonProperty("secrets")] + public IList Secrets { get; set; } + + [JsonProperty("errors")] + public IList Errors { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/ActionsClient.cs b/src/Auth0.ManagementApi/Actions/ActionsClient.cs new file mode 100644 index 000000000..81860795b --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/ActionsClient.cs @@ -0,0 +1,253 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Auth0.ManagementApi.Clients; +using Auth0.ManagementApi.Models; +using Auth0.ManagementApi.Paging; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + /// + /// Contains methods to access the /actions endpoints. + /// + public class ActionsClient : BaseClient + { + private const string ActionsBasePath = "actions"; + private const string ActionsPath = "actions"; + private const string TriggersPath = "triggers"; + private const string ExecutionsPath = "executions"; + private const string VersionsPath = "versions"; + private const string BindingsPath = "bindings"; + private const string DeployPath = "deploy"; + + private readonly JsonConverter[] _actionsConverters = { new PagedListConverter("actions") }; + private readonly JsonConverter[] _triggersConverters = { new ListConverter("triggers") }; + private readonly JsonConverter[] _versionsConverters = { new PagedListConverter("versions") }; + private readonly JsonConverter[] _triggerBindingsConverters = { new PagedListConverter("bindings") }; + private readonly JsonConverter[] _triggerBindingsListConverters = { new ListConverter("bindings") }; + + public ActionsClient(IManagementConnection connection, Uri baseUri, IDictionary defaultHeaders) : base(connection, baseUri, defaultHeaders) + { + } + + /// + /// Retrieve all actions. + /// + /// Specifies criteria to use when querying actions. + /// Specifies pagination info to use. + /// The cancellation token to cancel operation. + /// An containing the actions. + public Task> GetAllAsync(GetActionsRequest request, PaginationInfo pagination, CancellationToken cancellationToken = default) + { + if (request == null) + throw new ArgumentNullException(nameof(request)); + if (pagination == null) + throw new ArgumentNullException(nameof(pagination)); + + var queryStrings = new Dictionary + { + {"triggerId", request.TriggerId}, + {"actionName", request.ActionName}, + {"deployed", request.Deployed?.ToString()}, + {"page", pagination.PageNo.ToString()}, + {"per_page", pagination.PerPage.ToString()}, + // Uncomment below once "include_totals" is supported. + // {"include_totals", pagination.IncludeTotals.ToString()}, + {"installed", request.Installed?.ToString()}, + }; + + return Connection.GetAsync>(BuildUri($"{ActionsBasePath}/{ActionsPath}", queryStrings), DefaultHeaders, _actionsConverters, cancellationToken); + } + + /// + /// Retrieve an action by its ID. + /// + /// The ID of the action to retrieve. + /// The cancellation token to cancel operation. + /// The retrieved action. + public Task GetAsync(string id, CancellationToken cancellationToken = default) + { + return Connection.GetAsync(BuildUri($"{ActionsBasePath}/{ActionsPath}/{EncodePath(id)}"), DefaultHeaders, cancellationToken: cancellationToken); + } + + /// + /// Create an action. + /// + /// + /// Once an action is created, it must be deployed, and then bound to a trigger before it will be executed as part of a flow. + /// + /// Specifies criteria to use when creating an action. + /// The cancellation token to cancel operation. + /// The new that has been created. + public Task CreateAsync(CreateActionRequest request, CancellationToken cancellationToken = default) + { + return Connection.SendAsync(HttpMethod.Post, BuildUri($"{ActionsBasePath}/{ActionsPath}"), request, DefaultHeaders, cancellationToken: cancellationToken); + } + + /// + /// Update an existing action. + /// + /// + /// If this action is currently bound to a trigger, updating it will not affect any user flows until the action is deployed. + /// + /// The id of the action to update. + /// Specifies criteria to use when updating an action. + /// The cancellation token to cancel operation. + /// The that was updated. + public Task UpdateAsync(string id, UpdateActionRequest request, CancellationToken cancellationToken = default) + { + return Connection.SendAsync(new HttpMethod("PATCH"), BuildUri($"{ActionsBasePath}/{ActionsPath}/{EncodePath(id)}"), request, DefaultHeaders, cancellationToken: cancellationToken); + } + + /// + /// Deletes an action and all of its associated versions. + /// + /// + /// An action must be unbound from all triggers before it can be deleted. + /// + /// The ID of the action to delete. + /// Specifies criteria to use when deleting an action. + /// The cancellation token to cancel operation. + /// A that represents the asynchronous delete operation. + public Task DeleteAsync(string id, DeleteActionRequest request = null, CancellationToken cancellationToken = default) + { + return Connection.SendAsync(HttpMethod.Delete, BuildUri($"{ActionsBasePath}/{ActionsPath}/{EncodePath(id)}"), request, DefaultHeaders, cancellationToken: cancellationToken); + } + + + /// + /// Retrieve the set of triggers currently available within actions. A trigger is an extensibility point to which actions can be bound + /// + /// The cancellation token to cancel operation. + /// A list containing the triggers. + public Task> GetAllTriggersAsync(CancellationToken cancellationToken = default) + { + return Connection.GetAsync>(BuildUri($"{ActionsBasePath}/{TriggersPath}"), DefaultHeaders, _triggersConverters, cancellationToken); + } + + /// + /// Retrieve information about a specific execution of a trigger. + /// + /// + /// Relevant execution IDs will be included in tenant logs generated as part of that authentication flow. + /// Executions will only be stored for 10 days after their creation. + /// + /// The ID of the execution to retrieve. + /// The cancellation token to cancel operation. + /// The retrieved execution. + public Task GetExecutionAsync(string id, CancellationToken cancellationToken = default) + { + return Connection.GetAsync(BuildUri($"{ActionsBasePath}/{ExecutionsPath}/{EncodePath(id)}"), DefaultHeaders, cancellationToken: cancellationToken); + } + + /// + /// Retrieve all versions of an action. + /// + /// + /// An action version is created whenever an action is deployed. An action version is immutable, once created. + /// + /// The ID of the action. + /// Specifies pagination info to use. + /// The cancellation token to cancel operation. + /// The retrieved versions of the specified action. + public Task> GetAllVersionsAsync(string actionId, PaginationInfo pagination, CancellationToken cancellationToken = default) + { + var queryStrings = new Dictionary + { + {"page", pagination.PageNo.ToString()}, + {"per_page", pagination.PerPage.ToString()}, + // {"include_totals", pagination.IncludeTotals.ToString()} + }; + + return Connection.GetAsync>(BuildUri($"{ActionsBasePath}/{ActionsPath}/{EncodePath(actionId)}/{VersionsPath}", queryStrings), DefaultHeaders, _versionsConverters, cancellationToken); + } + + /// + /// Retrieve a specific version of an action. + /// + /// + /// An action version is created whenever an action is deployed. An action version is immutable, once created. + /// + /// The ID of the action. + /// The ID of the action version. + /// The cancellation token to cancel operation. + /// The retrieved version of the specified action. + public Task GetVersionAsync(string actionId, string versionId, CancellationToken cancellationToken = default) + { + return Connection.GetAsync(BuildUri($"{ActionsBasePath}/{ActionsPath}/{EncodePath(actionId)}/{VersionsPath}/{EncodePath(versionId)}"), DefaultHeaders, cancellationToken: cancellationToken); + } + + + /// + /// Retrieve the actions that are bound to a trigger. + /// + /// + /// Once an action is created and deployed, it must be attached (i.e. bound) to a trigger so that it will be executed as part of a flow. + /// The list of actions returned reflects the order in which they will be executed during the appropriate flow. + /// + /// An actions extensibility point. + /// Specifies pagination info to use. + /// The cancellation token to cancel operation. + /// The retrieved trigger bindings. + public Task> GetAllTriggerBindingsAsync(string triggerId, PaginationInfo pagination, CancellationToken cancellationToken = default) + { + var queryStrings = new Dictionary + { + {"page", pagination.PageNo.ToString()}, + {"per_page", pagination.PerPage.ToString()}, + // {"include_totals", pagination.IncludeTotals.ToString()} + }; + + return Connection.GetAsync>(BuildUri($"{ActionsBasePath}/{TriggersPath}/{EncodePath(triggerId)}/{BindingsPath}", queryStrings), DefaultHeaders, _triggerBindingsConverters, cancellationToken); + } + + /// + /// Update the actions that are bound (i.e. attached) to a trigger. + /// Once an action is created and deployed, it must be attached(i.e.bound) to a trigger so that it will be executed as part of a flow. + /// The order in which the actions are provided will determine the order in which they are executed. + /// + /// An actions extensibility point. + /// Specifies criteria to use when updating the trigger bindings. + /// The cancellation token to cancel operation. + /// The trigger bindings. + public Task> UpdateTriggerBindingsAsync(string triggerId, UpdateTriggerBindingsRequest request, CancellationToken cancellationToken = default) + { + return Connection.SendAsync>(new HttpMethod("PATCH"), BuildUri($"{ActionsBasePath}/{TriggersPath}/{EncodePath(triggerId)}/{BindingsPath}"), request, DefaultHeaders, null, _triggerBindingsListConverters, cancellationToken); + } + + /// + /// Deploy an action. + /// + /// + /// Deploying an action will create a new immutable version of the action. If the action is currently bound to a trigger, + /// then the system will begin executing the newly deployed version of the action immediately.Otherwise, the action will only be executed as a part of a flow once it is bound to that flow. + /// + /// The ID of the action to deploy. + /// The cancellation token to cancel operation. + /// The action version that was created. + public Task DeployAsync(string id, CancellationToken cancellationToken = default) + { + return Connection.SendAsync(HttpMethod.Post, BuildUri($"{ActionsBasePath}/{ActionsPath}/{EncodePath(id)}/{DeployPath}"), null, DefaultHeaders, cancellationToken: cancellationToken); + } + + /// + /// Performs the equivalent of a roll-back of an action to an earlier, specified version. + /// + /// + /// Creates a new, deployed action version that is identical to the specified version. + /// If this action is currently bound to a trigger, the system will begin executing the newly-created version immediately. + /// + /// The ID of the action. + /// The ID of the version to deploy. + /// The cancellation token to cancel operation. + /// A that represents the asynchronous delete operation. + public Task RollbackToVersionAsync(string actionId, string versionId, CancellationToken cancellationToken = default) + { + return Connection.SendAsync(HttpMethod.Post, BuildUri($"{ActionsBasePath}/{ActionsPath}/{EncodePath(actionId)}/versions/{versionId}/deploy"), new {}, DefaultHeaders, cancellationToken: cancellationToken); + } + } +} diff --git a/src/Auth0.ManagementApi/Actions/CreateActionRequest.cs b/src/Auth0.ManagementApi/Actions/CreateActionRequest.cs new file mode 100644 index 000000000..3ba1e9591 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/CreateActionRequest.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class CreateActionRequest: ActionBase + { + [JsonProperty("supported_triggers")] + public IList SupportedTriggers { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs b/src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs new file mode 100644 index 000000000..0f16aa3bc --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class DeleteActionRequest + { + [JsonProperty("force")] + public bool? Force { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/GetActionsRequest.cs b/src/Auth0.ManagementApi/Actions/GetActionsRequest.cs new file mode 100644 index 000000000..4d329e870 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/GetActionsRequest.cs @@ -0,0 +1,10 @@ +namespace Auth0.ManagementApi.Actions +{ + public class GetActionsRequest + { + public string TriggerId { get; set; } + public string ActionName { get; set; } + public bool? Deployed { get; set; } + public bool? Installed { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/Trigger.cs b/src/Auth0.ManagementApi/Actions/Trigger.cs new file mode 100644 index 000000000..33717455a --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/Trigger.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class Trigger + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("runtimes")] + public IList Runtimes { get; set; } + + [JsonProperty("default_runtime")] + public string DefaultRuntime { get; set; } + + [JsonProperty("version")] + public string Version { get; set; } + + [JsonProperty("status")] + public string Status { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/TriggerBinding.cs b/src/Auth0.ManagementApi/Actions/TriggerBinding.cs new file mode 100644 index 000000000..b9e9ca763 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/TriggerBinding.cs @@ -0,0 +1,26 @@ +using System; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class TriggerBinding + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("trigger_id")] + public string TriggerId { get; set; } + + [JsonProperty("action")] + public Action Action { get; set; } + + [JsonProperty("created_at")] + public DateTime CreatedAt { get; set; } + + [JsonProperty("updated_at")] + public DateTime UpdatedAt { get; set; } + + [JsonProperty("display_name")] + public string DisplayName { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs b/src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs new file mode 100644 index 000000000..8c5f5d906 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs @@ -0,0 +1,7 @@ +namespace Auth0.ManagementApi.Actions +{ + public class UpdateActionRequest: ActionBase + { + + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs b/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs new file mode 100644 index 000000000..93fac6968 --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs @@ -0,0 +1,21 @@ +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class UpdateTriggerBindingEntry + { + public class BindingRef + { + [JsonProperty("type")] + public string Type { get; set; } + [JsonProperty("value")] + public string Value { get; set; } + } + + [JsonProperty("ref")] + public BindingRef Ref { get; set; } + + [JsonProperty("display_name")] + public string DisplayName { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs b/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs new file mode 100644 index 000000000..ce1afe2bf --- /dev/null +++ b/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Auth0.ManagementApi.Actions +{ + public class UpdateTriggerBindingsRequest + { + [JsonProperty("bindings")] + public IList Bindings { get; set; } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/HttpClientManagementConnection.cs b/src/Auth0.ManagementApi/HttpClientManagementConnection.cs index bb7a7cf38..97476622e 100644 --- a/src/Auth0.ManagementApi/HttpClientManagementConnection.cs +++ b/src/Auth0.ManagementApi/HttpClientManagementConnection.cs @@ -62,9 +62,9 @@ public async Task GetAsync(Uri uri, IDictionary headers, J } /// - public async Task SendAsync(HttpMethod method, Uri uri, object body, IDictionary headers, IList files = null, CancellationToken cancellationToken = default) + public async Task SendAsync(HttpMethod method, Uri uri, object body, IDictionary headers, IList files = null, JsonConverter[] converters = null, CancellationToken cancellationToken = default) { - return await Retry(async () => await SendAsyncInternal(method, uri, body, headers, files, cancellationToken)).ConfigureAwait(false); + return await Retry(async () => await SendAsyncInternal(method, uri, body, headers, files, converters, cancellationToken)).ConfigureAwait(false); } private async Task GetAsyncInternal(Uri uri, IDictionary headers, JsonConverter[] converters = null, CancellationToken cancellationToken = default) @@ -76,12 +76,12 @@ private async Task GetAsyncInternal(Uri uri, IDictionary h } } - private async Task SendAsyncInternal(HttpMethod method, Uri uri, object body, IDictionary headers, IList files = null, CancellationToken cancellationToken = default) + private async Task SendAsyncInternal(HttpMethod method, Uri uri, object body, IDictionary headers, IList files = null, JsonConverter[] converters = null, CancellationToken cancellationToken = default) { using (var request = new HttpRequestMessage(method, uri) { Content = BuildMessageContent(body, files) }) { ApplyHeaders(request.Headers, headers); - return await SendRequest(request, cancellationToken: cancellationToken).ConfigureAwait(false); + return await SendRequest(request, converters, cancellationToken).ConfigureAwait(false); } } diff --git a/src/Auth0.ManagementApi/IManagementConnection.cs b/src/Auth0.ManagementApi/IManagementConnection.cs index 37e86eeda..f0b12731b 100644 --- a/src/Auth0.ManagementApi/IManagementConnection.cs +++ b/src/Auth0.ManagementApi/IManagementConnection.cs @@ -41,11 +41,12 @@ public interface IManagementConnection /// otherwise containing the JSON representation of the object is expected. /// Dictionary containing additional headers that may override the defaults. /// Optional containing file contents to upload as a post. + /// Optional array of s used to deserialize the resulting . /// The cancellation token to cancel operation. /// representing the async operation containing response body as . /// /// can only be specified if is a Dictionary%lt;string, object%gt;"/>. /// - Task SendAsync(HttpMethod method, Uri uri, object body, IDictionary headers, IList files = null, CancellationToken cancellationToken = default); + Task SendAsync(HttpMethod method, Uri uri, object body, IDictionary headers, IList files = null, JsonConverter[] converters = null, CancellationToken cancellationToken = default); } } diff --git a/src/Auth0.ManagementApi/ListConverter.cs b/src/Auth0.ManagementApi/ListConverter.cs new file mode 100644 index 000000000..a6ea51e47 --- /dev/null +++ b/src/Auth0.ManagementApi/ListConverter.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using Auth0.ManagementApi.Paging; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Auth0.ManagementApi +{ + internal class ListConverter : JsonConverter + { + private readonly string _collectionFieldName; + + public ListConverter(string collectionFieldName) + { + _collectionFieldName = collectionFieldName; + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new NotImplementedException(); + } + + public override bool CanConvert(Type objectType) + { + return typeof(IList).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo()); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, + JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.StartObject) + { + JObject item = JObject.Load(reader); + + if (item[_collectionFieldName] != null) + { + return item[_collectionFieldName].ToObject>(serializer); + } + } + else + { + JArray array = JArray.Load(reader); + + var collection = array.ToObject>(); + + return new PagedList(collection); + } + + return null; + } + } +} \ No newline at end of file diff --git a/src/Auth0.ManagementApi/ManagementApiClient.cs b/src/Auth0.ManagementApi/ManagementApiClient.cs index 7b70ab5f3..ff52e8abe 100644 --- a/src/Auth0.ManagementApi/ManagementApiClient.cs +++ b/src/Auth0.ManagementApi/ManagementApiClient.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Net.Http; using System.Text; +using Auth0.ManagementApi.Actions; namespace Auth0.ManagementApi { @@ -16,6 +17,11 @@ public class ManagementApiClient : IDisposable protected readonly IManagementConnection connection; IDisposable connectionToDispose; + /// + /// Contains all the methods to call the /actions endpoints. + /// + public ActionsClient Actions { get; } + /// /// Contains all the methods to call the /blacklists/tokens endpoints. /// @@ -151,6 +157,7 @@ public ManagementApiClient(string token, Uri baseUri, IManagementConnection mana var defaultHeaders = CreateDefaultHeaders(token); + Actions = new ActionsClient(managementConnection, baseUri, defaultHeaders); BlacklistedTokens = new BlacklistedTokensClient(managementConnection, baseUri, defaultHeaders); Branding = new BrandingClient(managementConnection, baseUri, defaultHeaders); ClientGrants = new ClientGrantsClient(managementConnection, baseUri, defaultHeaders); diff --git a/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs b/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs new file mode 100644 index 000000000..94d7c53c3 --- /dev/null +++ b/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Auth0.ManagementApi.Actions; +using Auth0.ManagementApi.Paging; +using Auth0.Tests.Shared; +using FluentAssertions; +using Xunit; + +namespace Auth0.ManagementApi.IntegrationTests +{ + public class ActionsTests : TestBase, IAsyncLifetime + { + private ManagementApiClient _apiClient; + public async Task InitializeAsync() + { + string token = await GenerateManagementApiToken(); + + _apiClient = new ManagementApiClient(token, GetVariable("AUTH0_MANAGEMENT_API_URL"), new HttpClientManagementConnection(options: new HttpClientManagementConnectionOptions { NumberOfHttpRetries = 9 })); + } + + public Task DisposeAsync() + { + _apiClient.Dispose(); + return Task.CompletedTask; + } + + [Fact] + public async Task Test_actions_crud_sequence() + { + var actionsBeforeCreate = await _apiClient.Actions.GetAllAsync(new GetActionsRequest(), new PaginationInfo()); + + var createdAction = await _apiClient.Actions.CreateAsync(new CreateActionRequest + { + Name = $"Int-Test-Action-{Guid.NewGuid()}", + Code = "module.exports = () => {}", + Runtime = "node12", + Secrets = new List { new ActionSecret { Name = "My_Secret", Value = "Test123" } }, + SupportedTriggers = new List { new ActionSupportedTrigger { Id = "post-login", Version = "v2"} } + }); + + var actionsAfterCreate = await _apiClient.Actions.GetAllAsync(new GetActionsRequest(), new PaginationInfo()); + + actionsAfterCreate.Count.Should().Be(actionsBeforeCreate.Count + 1); + createdAction.Should().BeEquivalentTo(actionsAfterCreate.Last(), options => options.Excluding(o => o.Status)); + + var updatedAction = await _apiClient.Actions.UpdateAsync(createdAction.Id, new UpdateActionRequest + { + Code = "module.exports = () => { console.log(true); }" + }); + + updatedAction.Should().BeEquivalentTo(createdAction, options => options.Excluding(o => o.Code).Excluding(o => o.UpdatedAt)); + updatedAction.Code.Should().Be("module.exports = () => { console.log(true); }"); + + var actionAfterUpdate = await _apiClient.Actions.GetAsync(updatedAction.Id); + + updatedAction.Should().BeEquivalentTo(actionAfterUpdate, options => options.Excluding(o => o.Status)); + actionAfterUpdate.Code.Should().Be("module.exports = () => { console.log(true); }"); + + await _apiClient.Actions.DeleteAsync(actionAfterUpdate.Id); + + var actionsAfterDelete = await _apiClient.Actions.GetAllAsync(new GetActionsRequest(), new PaginationInfo()); + actionsAfterDelete.Count.Should().Be(actionsBeforeCreate.Count); + } + + [Fact] + public async Task Test_get_triggers() + { + var triggers = await _apiClient.Actions.GetAllTriggersAsync(); + + triggers.Should().NotBeEmpty(); + } + + [Fact] + public async Task Test_get_and_update_trigger_bindings() + { + var triggerBindingsBeforeCreate = await _apiClient.Actions.GetAllTriggerBindingsAsync("post-login", new PaginationInfo()); + + var createdAction = await _apiClient.Actions.CreateAsync(new CreateActionRequest + { + Name = $"Int-Test-Action-{Guid.NewGuid()}", + Code = "module.exports = () => {}", + Runtime = "node12", + Secrets = new List { new ActionSecret { Name = "My_Secret", Value = "Test123" } }, + SupportedTriggers = new List { new ActionSupportedTrigger { Id = "post-login", Version = "v2" } } + }); + + await _apiClient.Actions.DeployAsync(createdAction.Id); + + await _apiClient.Actions.UpdateTriggerBindingsAsync("post-login", new UpdateTriggerBindingsRequest + { + Bindings = new List + { + new UpdateTriggerBindingEntry + { + Ref = new UpdateTriggerBindingEntry.BindingRef + { + Type = "action_id", + Value = createdAction.Id + }, + DisplayName = "My Action" + } + } + }); + + var triggerBindingsAfterCreate = await _apiClient.Actions.GetAllTriggerBindingsAsync("post-login", new PaginationInfo()); + + triggerBindingsAfterCreate.Count.Should().Be(triggerBindingsBeforeCreate.Count + 1); + + await _apiClient.Actions.DeleteAsync(createdAction.Id); + } + + [Fact] + public async Task Test_action_version_crud_sequence() + { + // 1. Create a new Action + var createdAction = await _apiClient.Actions.CreateAsync(new CreateActionRequest + { + Name = $"Int-Test-Action-{Guid.NewGuid()}", + Code = "module.exports = () => {}", + Runtime = "node12", + Secrets = new List { new ActionSecret { Name = "My_Secret", Value = "Test123" } }, + SupportedTriggers = new List { new ActionSupportedTrigger { Id = "post-login", Version = "v2" } } + }); + + // 2. Get all the versions after the action was created + var versionsAfterCreate = await _apiClient.Actions.GetAllVersionsAsync(createdAction.Id, new PaginationInfo()); + + versionsAfterCreate.Count.Should().Be(0); + + // 3. Deploy the current version + await _apiClient.Actions.DeployAsync(createdAction.Id); + + // 4. Get all the versions after the action was deployed + var versionsAfterDeploy = await _apiClient.Actions.GetAllVersionsAsync(createdAction.Id, new PaginationInfo()); + + versionsAfterDeploy.Count.Should().Be(1); + + // 5. Update the action + await _apiClient.Actions.UpdateAsync(createdAction.Id, new UpdateActionRequest + { + Code = "module.exports = () => { console.log(true); }" + }); + + // 6. Deploy the latest version + var deployedVersion = await _apiClient.Actions.DeployAsync(createdAction.Id); + + // 7. Get all the versions after the action was updated + var versionsAfterSecondDeploy = await _apiClient.Actions.GetAllVersionsAsync(createdAction.Id, new PaginationInfo()); + + versionsAfterSecondDeploy.Count.Should().Be(2); + versionsAfterSecondDeploy.Single(v => v.Id == deployedVersion.Id).Deployed.Should().BeTrue(); + versionsAfterSecondDeploy.Single(v => v.Id != deployedVersion.Id).Deployed.Should().BeFalse(); + + // 9. Rollback + var rollbackedVersion = await _apiClient.Actions.RollbackToVersionAsync(createdAction.Id, versionsAfterDeploy.Single().Id); + + // 10. Get all the versions after the action was rollbacked + var versionsAfterRollback = await _apiClient.Actions.GetAllVersionsAsync(createdAction.Id, new PaginationInfo()); + var versionAfterRollback = await _apiClient.Actions.GetVersionAsync(createdAction.Id, rollbackedVersion.Id); + + versionsAfterRollback.Count.Should().Be(3); + versionsAfterRollback.Single(v => v.Id == versionAfterRollback.Id).Should().BeEquivalentTo(versionAfterRollback); + versionsAfterRollback.Single(v => v.Id == versionAfterRollback.Id).Deployed.Should().BeTrue(); + versionsAfterRollback.Where(v => v.Id != versionAfterRollback.Id).ToList().ForEach(v => v.Deployed.Should().BeFalse()); + + // 10. Delete Action + await _apiClient.Actions.DeleteAsync(createdAction.Id); + } + } +} diff --git a/tests/Auth0.ManagementApi.IntegrationTests/ManagementApiClientTests.cs b/tests/Auth0.ManagementApi.IntegrationTests/ManagementApiClientTests.cs index e0a086480..40bfa1018 100644 --- a/tests/Auth0.ManagementApi.IntegrationTests/ManagementApiClientTests.cs +++ b/tests/Auth0.ManagementApi.IntegrationTests/ManagementApiClientTests.cs @@ -57,7 +57,7 @@ public Task GetAsync(Uri uri, IDictionary headers = null, return Task.FromResult(default(T)); } - public Task SendAsync(HttpMethod method, Uri uri, object body, IDictionary headers = null, IList files = null, CancellationToken cancellationToken = default) + public Task SendAsync(HttpMethod method, Uri uri, object body, IDictionary headers = null, IList files = null, JsonConverter[] converters = null, CancellationToken cancellationToken = default) { return Task.FromResult(default(T)); } @@ -104,7 +104,7 @@ public Task GetAsync(Uri uri, IDictionary headers = null, return Task.FromResult(default(T)); } - public Task SendAsync(HttpMethod method, Uri uri, object body, IDictionary headers = null, IList files = null, CancellationToken cancellationToken = default) + public Task SendAsync(HttpMethod method, Uri uri, object body, IDictionary headers = null, IList files = null, JsonConverter[] converters = null, CancellationToken cancellationToken = default) { LastHeaders = headers; return Task.FromResult(default(T)); From c62f7fdb053829dd4a34856028dc967c22d26ce1 Mon Sep 17 00:00:00 2001 From: Frederik Date: Fri, 27 Aug 2021 12:30:01 +0200 Subject: [PATCH 2/5] Clear bindings --- tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs b/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs index 94d7c53c3..f0f3fa6f4 100644 --- a/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs +++ b/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs @@ -109,6 +109,11 @@ public async Task Test_get_and_update_trigger_bindings() triggerBindingsAfterCreate.Count.Should().Be(triggerBindingsBeforeCreate.Count + 1); + await _apiClient.Actions.UpdateTriggerBindingsAsync("post-login", new UpdateTriggerBindingsRequest + { + Bindings = new List() + }); + await _apiClient.Actions.DeleteAsync(createdAction.Id); } From afe1c260e5de9f06d0a1010c9861f913e0cc6599 Mon Sep 17 00:00:00 2001 From: Frederik Date: Fri, 27 Aug 2021 13:22:37 +0200 Subject: [PATCH 3/5] Update XML documentation --- src/Auth0.ManagementApi/Actions/Action.cs | 5 ++- src/Auth0.ManagementApi/Actions/ActionBase.cs | 17 +++++++- .../Actions/ActionDependency.cs | 10 +++++ .../Actions/ActionExecution.cs | 18 +++++++++ .../Actions/ActionExecutionResult.cs | 12 ++++++ .../Actions/ActionSecret.cs | 11 +++++- .../Actions/ActionSupportedTrigger.cs | 7 ++++ .../Actions/ActionVersion.cs | 39 +++++++++++++++++++ .../Actions/ActionsClient.cs | 1 - .../Actions/CreateActionRequest.cs | 8 +++- .../Actions/DeleteActionRequest.cs | 6 +++ .../Actions/GetActionsRequest.cs | 18 +++++++++ src/Auth0.ManagementApi/Actions/Trigger.cs | 18 +++++++++ .../Actions/TriggerBinding.cs | 21 ++++++++++ .../Actions/UpdateActionRequest.cs | 3 ++ .../Actions/UpdateTriggerBindingEntry.cs | 13 +++++++ .../Actions/UpdateTriggerBindingsRequest.cs | 6 +++ 17 files changed, 208 insertions(+), 5 deletions(-) diff --git a/src/Auth0.ManagementApi/Actions/Action.cs b/src/Auth0.ManagementApi/Actions/Action.cs index be36ecdd4..9e8970c31 100644 --- a/src/Auth0.ManagementApi/Actions/Action.cs +++ b/src/Auth0.ManagementApi/Actions/Action.cs @@ -4,7 +4,10 @@ namespace Auth0.ManagementApi.Actions { - public class Action: ActionBase + /// + /// Represents an action in Auth0 + /// + public class Action : ActionBase { [JsonProperty("id")] public string Id { get; set; } diff --git a/src/Auth0.ManagementApi/Actions/ActionBase.cs b/src/Auth0.ManagementApi/Actions/ActionBase.cs index a044af6cb..dab3e2075 100644 --- a/src/Auth0.ManagementApi/Actions/ActionBase.cs +++ b/src/Auth0.ManagementApi/Actions/ActionBase.cs @@ -3,20 +3,35 @@ namespace Auth0.ManagementApi.Actions { - public class ActionBase + public abstract class ActionBase { + /// + /// The name of an action. + /// [JsonProperty("name")] public string Name { get; set; } + /// + /// The source code of the action. + /// [JsonProperty("code")] public string Code { get; set; } + /// + /// The list of third party npm modules, and their versions, that this action depends on. + /// [JsonProperty("dependencies")] public IList Dependencies { get; set; } + /// + /// The Node runtime. For example: node12, defaults to node12 + /// [JsonProperty("runtime")] public string Runtime { get; set; } + /// + /// The list of secrets that are included in an action or a version of an action. + /// [JsonProperty("secrets")] public IList Secrets { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/ActionDependency.cs b/src/Auth0.ManagementApi/Actions/ActionDependency.cs index 49adeb4ba..2473f890e 100644 --- a/src/Auth0.ManagementApi/Actions/ActionDependency.cs +++ b/src/Auth0.ManagementApi/Actions/ActionDependency.cs @@ -2,10 +2,20 @@ namespace Auth0.ManagementApi.Actions { + /// + /// Represent an npm dependency for an action or an action's version. + /// public class ActionDependency { + /// + /// The name of the npm module, e.g. 'lodash' + /// [JsonProperty("name")] public string Name { get; set; } + + /// + /// The version of the npm module, e.g. '4.17.1' + /// [JsonProperty("version")] public string Version { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/ActionExecution.cs b/src/Auth0.ManagementApi/Actions/ActionExecution.cs index cecf04ef7..d5e153943 100644 --- a/src/Auth0.ManagementApi/Actions/ActionExecution.cs +++ b/src/Auth0.ManagementApi/Actions/ActionExecution.cs @@ -6,21 +6,39 @@ namespace Auth0.ManagementApi.Actions { public class ActionExecution { + /// + /// Identifies a specific execution. + /// [JsonProperty("id")] public string Id { get; set; } + /// + /// The actions extensibility point. + /// [JsonProperty("trigger_id")] public string TriggerId { get; set; } + /// + /// The overall status of an execution. + /// [JsonProperty("status")] public string Status { get; set; } + /// + /// Captures the results of a single action being executed. + /// [JsonProperty("results")] public IList Results { get; set; } + /// + /// The time that the execution was started. + /// [JsonProperty("created_at")] public DateTime CreatedAt { get; set; } + /// + /// The time that the execution finished executing. + /// [JsonProperty("updated_at")] public DateTime UpdatedAt { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs b/src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs index 1593d2b53..67c0118a2 100644 --- a/src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs +++ b/src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs @@ -3,14 +3,26 @@ namespace Auth0.ManagementApi.Actions { + /// + /// Captures the results of a single action being executed. + /// public class ActionExecutionResult { + /// + /// The name of the action that was executed. + /// [JsonProperty("action_name")] public string ActionName { get; set; } + /// + /// The time when the action was started. + /// [JsonProperty("started_at")] public DateTime StartedAt { get; set; } + /// + /// The time when the action finished executing. + /// [JsonProperty("ended_at")] public DateTime EndedAt { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/ActionSecret.cs b/src/Auth0.ManagementApi/Actions/ActionSecret.cs index 32d2a9de5..bb55a39c6 100644 --- a/src/Auth0.ManagementApi/Actions/ActionSecret.cs +++ b/src/Auth0.ManagementApi/Actions/ActionSecret.cs @@ -5,12 +5,21 @@ namespace Auth0.ManagementApi.Actions { public class ActionSecret { + /// + /// The name of the particular secret, e.g. API_KEY. + /// [JsonProperty("name")] public string Name { get; set; } + /// + /// The time when the secret was last updated. + /// [JsonProperty("updated_at")] - public DateTime UpdatedAt { get; set; } + public DateTime UpdatedAt { get; private set; } + /// + /// The value of the particular secret, e.g. secret123. A secret's value can only be set upon creation. A secret's value will never be returned by the API. + /// [JsonProperty("value")] public string Value { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs b/src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs index 5e0973092..822bf54f4 100644 --- a/src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs +++ b/src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs @@ -4,8 +4,15 @@ namespace Auth0.ManagementApi.Actions { public class ActionSupportedTrigger { + /// + /// The actions extensibility point + /// [JsonProperty("id")] public string Id { get; set; } + + /// + /// The version of a trigger. v1, v2, etc. + /// [JsonProperty("version")] public string Version { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/ActionVersion.cs b/src/Auth0.ManagementApi/Actions/ActionVersion.cs index 1ed46b769..53610632b 100644 --- a/src/Auth0.ManagementApi/Actions/ActionVersion.cs +++ b/src/Auth0.ManagementApi/Actions/ActionVersion.cs @@ -4,41 +4,80 @@ namespace Auth0.ManagementApi.Actions { + /// + /// Represents a version for an action in Auth0 + /// public class ActionVersion { + /// + /// The unique id of an action version. + /// [JsonProperty("id")] public string Id { get; set; } + /// + /// The source code of this specific version of the action. + /// [JsonProperty("code")] public string Code { get; set; } + /// + /// The Node runtime. For example: `node12` + /// [JsonProperty("runtime")] public string Runtime { get; set; } + /// + /// The index of this version in list of versions for the action. + /// [JsonProperty("number")] public int Number { get; set; } + /// + /// Indicates if this specific version is the currently one deployed. + /// [JsonProperty("deployed")] public bool? Deployed { get; set; } + /// + /// The list of third party npm modules, and their versions, that this specific version depends on. + /// [JsonProperty("dependencies")] public IList Dependencies { get; set; } + /// + /// The build status of this specific version. + /// [JsonProperty("status")] public string Status { get; set; } + /// + /// The time when this version was created. + /// [JsonProperty("created_at")] public DateTime CreatedAt { get; set; } + /// + /// The time when a version was updated. Versions are never updated externally. Only Auth0 will update an action version as it is being built. + /// [JsonProperty("updated_at")] public DateTime UpdatedAt { get; set; } + /// + /// The action to which this version belongs. + /// [JsonProperty("action")] public Action Action { get; set; } + /// + /// The list of secrets that are included in the version. + /// [JsonProperty("secrets")] public IList Secrets { get; set; } + /// + /// Any errors that occurred while the version was being built. + /// [JsonProperty("errors")] public IList Errors { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/ActionsClient.cs b/src/Auth0.ManagementApi/Actions/ActionsClient.cs index 81860795b..43ed11d99 100644 --- a/src/Auth0.ManagementApi/Actions/ActionsClient.cs +++ b/src/Auth0.ManagementApi/Actions/ActionsClient.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks; diff --git a/src/Auth0.ManagementApi/Actions/CreateActionRequest.cs b/src/Auth0.ManagementApi/Actions/CreateActionRequest.cs index 3ba1e9591..b23c54539 100644 --- a/src/Auth0.ManagementApi/Actions/CreateActionRequest.cs +++ b/src/Auth0.ManagementApi/Actions/CreateActionRequest.cs @@ -3,8 +3,14 @@ namespace Auth0.ManagementApi.Actions { - public class CreateActionRequest: ActionBase + /// + /// Request configuration for creating an action. + /// + public class CreateActionRequest : ActionBase { + /// + /// The list of triggers that this action supports. At this time, an action can only target a single trigger at a time. + /// [JsonProperty("supported_triggers")] public IList SupportedTriggers { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs b/src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs index 0f16aa3bc..aa4fca156 100644 --- a/src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs +++ b/src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs @@ -2,8 +2,14 @@ namespace Auth0.ManagementApi.Actions { + /// + /// Request configuration for deleting an action. + /// public class DeleteActionRequest { + /// + /// Force action deletion detaching bindings + /// [JsonProperty("force")] public bool? Force { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/GetActionsRequest.cs b/src/Auth0.ManagementApi/Actions/GetActionsRequest.cs index 4d329e870..932cf863c 100644 --- a/src/Auth0.ManagementApi/Actions/GetActionsRequest.cs +++ b/src/Auth0.ManagementApi/Actions/GetActionsRequest.cs @@ -1,10 +1,28 @@ namespace Auth0.ManagementApi.Actions { + /// + /// Request configuration for retrieving all actions. + /// public class GetActionsRequest { + /// + /// An actions extensibility point. + /// public string TriggerId { get; set; } + + /// + /// The name of the action to retrieve. + /// public string ActionName { get; set; } + + /// + /// Optional filter to only retrieve actions that are deployed. + /// public bool? Deployed { get; set; } + + /// + /// Optional. When true, return only installed actions. When false, return only custom actions. Returns all actions by default. + /// public bool? Installed { get; set; } } } \ No newline at end of file diff --git a/src/Auth0.ManagementApi/Actions/Trigger.cs b/src/Auth0.ManagementApi/Actions/Trigger.cs index 33717455a..98d2e815b 100644 --- a/src/Auth0.ManagementApi/Actions/Trigger.cs +++ b/src/Auth0.ManagementApi/Actions/Trigger.cs @@ -3,20 +3,38 @@ namespace Auth0.ManagementApi.Actions { + /// + /// Represents a Trigger in Auth0 + /// public class Trigger { + /// + /// The actions extensibility point. + /// [JsonProperty("id")] public string Id { get; set; } + /// + /// Runtimes supported by this trigger. + /// [JsonProperty("runtimes")] public IList Runtimes { get; set; } + /// + /// Runtime that will be used when none is specified when creating an action. + /// [JsonProperty("default_runtime")] public string DefaultRuntime { get; set; } + /// + /// The version of a trigger. v1, v2, etc. + /// [JsonProperty("version")] public string Version { get; set; } + /// + /// The trigger's status. + /// [JsonProperty("status")] public string Status { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/TriggerBinding.cs b/src/Auth0.ManagementApi/Actions/TriggerBinding.cs index b9e9ca763..f2744e9c8 100644 --- a/src/Auth0.ManagementApi/Actions/TriggerBinding.cs +++ b/src/Auth0.ManagementApi/Actions/TriggerBinding.cs @@ -3,23 +3,44 @@ namespace Auth0.ManagementApi.Actions { + /// + /// Represents a Trigger Binding in Auth0 + /// public class TriggerBinding { + /// + /// The unique ID of this binding. + /// [JsonProperty("id")] public string Id { get; set; } + /// + /// The actions extensibility point. + /// [JsonProperty("trigger_id")] public string TriggerId { get; set; } + /// + /// The connected action. + /// [JsonProperty("action")] public Action Action { get; set; } + /// + /// The time when the binding was created. + /// [JsonProperty("created_at")] public DateTime CreatedAt { get; set; } + /// + /// The time when the binding was updated. + /// [JsonProperty("updated_at")] public DateTime UpdatedAt { get; set; } + /// + /// The name of the binding. + /// [JsonProperty("display_name")] public string DisplayName { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs b/src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs index 8c5f5d906..0ce16b922 100644 --- a/src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs +++ b/src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs @@ -1,5 +1,8 @@ namespace Auth0.ManagementApi.Actions { + /// + /// Request configuration for updating an action. + /// public class UpdateActionRequest: ActionBase { diff --git a/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs b/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs index 93fac6968..5b39f80fe 100644 --- a/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs +++ b/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs @@ -6,15 +6,28 @@ public class UpdateTriggerBindingEntry { public class BindingRef { + /// + /// How the action is being referred to: `action_id` or `action_name`. + /// [JsonProperty("type")] public string Type { get; set; } + + /// + /// The id or name of an action that is being bound to a trigger. + /// [JsonProperty("value")] public string Value { get; set; } } + /// + /// A reference to an action. An action can be referred to by ID or by Name. + /// [JsonProperty("ref")] public BindingRef Ref { get; set; } + /// + /// The name of the binding. + /// [JsonProperty("display_name")] public string DisplayName { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs b/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs index ce1afe2bf..6ea6a291b 100644 --- a/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs +++ b/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs @@ -3,8 +3,14 @@ namespace Auth0.ManagementApi.Actions { + /// + /// Request configuration to update the actions that are bound (i.e. attached) to a trigger. + /// public class UpdateTriggerBindingsRequest { + /// + /// The actions that will be bound to this trigger. The order in which they are included will be the order in which they are executed. + /// [JsonProperty("bindings")] public IList Bindings { get; set; } } From 1893953ae59aea1c3efd0753de22bc277d377bac Mon Sep 17 00:00:00 2001 From: Frederik Date: Fri, 27 Aug 2021 16:18:36 +0200 Subject: [PATCH 4/5] Move files --- .../{Actions => Clients}/ActionsClient.cs | 5 +++-- .../ManagementApiClient.cs | 1 - .../{ => Models}/Actions/Action.cs | 22 +++++++++++++++++-- .../{ => Models}/Actions/ActionBase.cs | 2 +- .../{ => Models}/Actions/ActionDependency.cs | 2 +- .../{ => Models}/Actions/ActionError.cs | 2 +- .../{ => Models}/Actions/ActionExecution.cs | 2 +- .../Actions/ActionExecutionResult.cs | 2 +- .../{ => Models}/Actions/ActionSecret.cs | 2 +- .../Actions/ActionSupportedTrigger.cs | 2 +- .../{ => Models}/Actions/ActionVersion.cs | 2 +- .../Actions/CreateActionRequest.cs | 2 +- .../Actions/DeleteActionRequest.cs | 2 +- .../{ => Models}/Actions/GetActionsRequest.cs | 2 +- .../{ => Models}/Actions/Trigger.cs | 2 +- .../{ => Models}/Actions/TriggerBinding.cs | 2 +- .../Actions/UpdateActionRequest.cs | 2 +- .../Actions/UpdateTriggerBindingEntry.cs | 2 +- .../Actions/UpdateTriggerBindingsRequest.cs | 2 +- .../ActionsTests.cs | 3 +-- 20 files changed, 40 insertions(+), 23 deletions(-) rename src/Auth0.ManagementApi/{Actions => Clients}/ActionsClient.cs (99%) rename src/Auth0.ManagementApi/{ => Models}/Actions/Action.cs (54%) rename src/Auth0.ManagementApi/{ => Models}/Actions/ActionBase.cs (96%) rename src/Auth0.ManagementApi/{ => Models}/Actions/ActionDependency.cs (92%) rename src/Auth0.ManagementApi/{ => Models}/Actions/ActionError.cs (86%) rename src/Auth0.ManagementApi/{ => Models}/Actions/ActionExecution.cs (96%) rename src/Auth0.ManagementApi/{ => Models}/Actions/ActionExecutionResult.cs (94%) rename src/Auth0.ManagementApi/{ => Models}/Actions/ActionSecret.cs (94%) rename src/Auth0.ManagementApi/{ => Models}/Actions/ActionSupportedTrigger.cs (90%) rename src/Auth0.ManagementApi/{ => Models}/Actions/ActionVersion.cs (98%) rename src/Auth0.ManagementApi/{ => Models}/Actions/CreateActionRequest.cs (91%) rename src/Auth0.ManagementApi/{ => Models}/Actions/DeleteActionRequest.cs (88%) rename src/Auth0.ManagementApi/{ => Models}/Actions/GetActionsRequest.cs (94%) rename src/Auth0.ManagementApi/{ => Models}/Actions/Trigger.cs (95%) rename src/Auth0.ManagementApi/{ => Models}/Actions/TriggerBinding.cs (96%) rename src/Auth0.ManagementApi/{ => Models}/Actions/UpdateActionRequest.cs (76%) rename src/Auth0.ManagementApi/{ => Models}/Actions/UpdateTriggerBindingEntry.cs (95%) rename src/Auth0.ManagementApi/{ => Models}/Actions/UpdateTriggerBindingsRequest.cs (92%) diff --git a/src/Auth0.ManagementApi/Actions/ActionsClient.cs b/src/Auth0.ManagementApi/Clients/ActionsClient.cs similarity index 99% rename from src/Auth0.ManagementApi/Actions/ActionsClient.cs rename to src/Auth0.ManagementApi/Clients/ActionsClient.cs index 43ed11d99..bf5210795 100644 --- a/src/Auth0.ManagementApi/Actions/ActionsClient.cs +++ b/src/Auth0.ManagementApi/Clients/ActionsClient.cs @@ -3,12 +3,13 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using Auth0.ManagementApi.Clients; using Auth0.ManagementApi.Models; +using Auth0.ManagementApi.Models.Actions; using Auth0.ManagementApi.Paging; using Newtonsoft.Json; +using Action = Auth0.ManagementApi.Models.Actions.Action; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Clients { /// /// Contains methods to access the /actions endpoints. diff --git a/src/Auth0.ManagementApi/ManagementApiClient.cs b/src/Auth0.ManagementApi/ManagementApiClient.cs index ff52e8abe..05fa064c9 100644 --- a/src/Auth0.ManagementApi/ManagementApiClient.cs +++ b/src/Auth0.ManagementApi/ManagementApiClient.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Net.Http; using System.Text; -using Auth0.ManagementApi.Actions; namespace Auth0.ManagementApi { diff --git a/src/Auth0.ManagementApi/Actions/Action.cs b/src/Auth0.ManagementApi/Models/Actions/Action.cs similarity index 54% rename from src/Auth0.ManagementApi/Actions/Action.cs rename to src/Auth0.ManagementApi/Models/Actions/Action.cs index 9e8970c31..a197f857e 100644 --- a/src/Auth0.ManagementApi/Actions/Action.cs +++ b/src/Auth0.ManagementApi/Models/Actions/Action.cs @@ -2,28 +2,46 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Represents an action in Auth0 /// public class Action : ActionBase { + /// + /// The unique ID of the action. + /// [JsonProperty("id")] public string Id { get; set; } - + + /// + /// The build status of this action. + /// [JsonProperty("status")] public string Status { get; set; } + /// + /// True if all of an Action's contents have been deployed. + /// [JsonProperty("all_changes_deployed")] public bool AllChangesDeployed { get; set; } + /// + /// The time when this action was created. + /// [JsonProperty("created_at")] public DateTime CreatedAt { get; set; } + /// + /// The time when this action was updated. + /// [JsonProperty("updated_at")] public DateTime UpdatedAt { get; set; } + /// + /// The list of triggers that this action supports. + /// [JsonProperty("supported_triggers")] public IList SupportedTriggers { get; set; } } diff --git a/src/Auth0.ManagementApi/Actions/ActionBase.cs b/src/Auth0.ManagementApi/Models/Actions/ActionBase.cs similarity index 96% rename from src/Auth0.ManagementApi/Actions/ActionBase.cs rename to src/Auth0.ManagementApi/Models/Actions/ActionBase.cs index dab3e2075..6f2fc0c4a 100644 --- a/src/Auth0.ManagementApi/Actions/ActionBase.cs +++ b/src/Auth0.ManagementApi/Models/Actions/ActionBase.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { public abstract class ActionBase { diff --git a/src/Auth0.ManagementApi/Actions/ActionDependency.cs b/src/Auth0.ManagementApi/Models/Actions/ActionDependency.cs similarity index 92% rename from src/Auth0.ManagementApi/Actions/ActionDependency.cs rename to src/Auth0.ManagementApi/Models/Actions/ActionDependency.cs index 2473f890e..66cace207 100644 --- a/src/Auth0.ManagementApi/Actions/ActionDependency.cs +++ b/src/Auth0.ManagementApi/Models/Actions/ActionDependency.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Represent an npm dependency for an action or an action's version. diff --git a/src/Auth0.ManagementApi/Actions/ActionError.cs b/src/Auth0.ManagementApi/Models/Actions/ActionError.cs similarity index 86% rename from src/Auth0.ManagementApi/Actions/ActionError.cs rename to src/Auth0.ManagementApi/Models/Actions/ActionError.cs index abaf4d9a9..db4db0889 100644 --- a/src/Auth0.ManagementApi/Actions/ActionError.cs +++ b/src/Auth0.ManagementApi/Models/Actions/ActionError.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { public class ActionError { diff --git a/src/Auth0.ManagementApi/Actions/ActionExecution.cs b/src/Auth0.ManagementApi/Models/Actions/ActionExecution.cs similarity index 96% rename from src/Auth0.ManagementApi/Actions/ActionExecution.cs rename to src/Auth0.ManagementApi/Models/Actions/ActionExecution.cs index d5e153943..a0a47f390 100644 --- a/src/Auth0.ManagementApi/Actions/ActionExecution.cs +++ b/src/Auth0.ManagementApi/Models/Actions/ActionExecution.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { public class ActionExecution { diff --git a/src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs b/src/Auth0.ManagementApi/Models/Actions/ActionExecutionResult.cs similarity index 94% rename from src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs rename to src/Auth0.ManagementApi/Models/Actions/ActionExecutionResult.cs index 67c0118a2..95041112b 100644 --- a/src/Auth0.ManagementApi/Actions/ActionExecutionResult.cs +++ b/src/Auth0.ManagementApi/Models/Actions/ActionExecutionResult.cs @@ -1,7 +1,7 @@ using System; using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Captures the results of a single action being executed. diff --git a/src/Auth0.ManagementApi/Actions/ActionSecret.cs b/src/Auth0.ManagementApi/Models/Actions/ActionSecret.cs similarity index 94% rename from src/Auth0.ManagementApi/Actions/ActionSecret.cs rename to src/Auth0.ManagementApi/Models/Actions/ActionSecret.cs index bb55a39c6..2662567fb 100644 --- a/src/Auth0.ManagementApi/Actions/ActionSecret.cs +++ b/src/Auth0.ManagementApi/Models/Actions/ActionSecret.cs @@ -1,7 +1,7 @@ using System; using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { public class ActionSecret { diff --git a/src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs b/src/Auth0.ManagementApi/Models/Actions/ActionSupportedTrigger.cs similarity index 90% rename from src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs rename to src/Auth0.ManagementApi/Models/Actions/ActionSupportedTrigger.cs index 822bf54f4..a96370448 100644 --- a/src/Auth0.ManagementApi/Actions/ActionSupportedTrigger.cs +++ b/src/Auth0.ManagementApi/Models/Actions/ActionSupportedTrigger.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { public class ActionSupportedTrigger { diff --git a/src/Auth0.ManagementApi/Actions/ActionVersion.cs b/src/Auth0.ManagementApi/Models/Actions/ActionVersion.cs similarity index 98% rename from src/Auth0.ManagementApi/Actions/ActionVersion.cs rename to src/Auth0.ManagementApi/Models/Actions/ActionVersion.cs index 53610632b..012ba8189 100644 --- a/src/Auth0.ManagementApi/Actions/ActionVersion.cs +++ b/src/Auth0.ManagementApi/Models/Actions/ActionVersion.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Represents a version for an action in Auth0 diff --git a/src/Auth0.ManagementApi/Actions/CreateActionRequest.cs b/src/Auth0.ManagementApi/Models/Actions/CreateActionRequest.cs similarity index 91% rename from src/Auth0.ManagementApi/Actions/CreateActionRequest.cs rename to src/Auth0.ManagementApi/Models/Actions/CreateActionRequest.cs index b23c54539..04baa1d22 100644 --- a/src/Auth0.ManagementApi/Actions/CreateActionRequest.cs +++ b/src/Auth0.ManagementApi/Models/Actions/CreateActionRequest.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Request configuration for creating an action. diff --git a/src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs b/src/Auth0.ManagementApi/Models/Actions/DeleteActionRequest.cs similarity index 88% rename from src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs rename to src/Auth0.ManagementApi/Models/Actions/DeleteActionRequest.cs index aa4fca156..40c762e0e 100644 --- a/src/Auth0.ManagementApi/Actions/DeleteActionRequest.cs +++ b/src/Auth0.ManagementApi/Models/Actions/DeleteActionRequest.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Request configuration for deleting an action. diff --git a/src/Auth0.ManagementApi/Actions/GetActionsRequest.cs b/src/Auth0.ManagementApi/Models/Actions/GetActionsRequest.cs similarity index 94% rename from src/Auth0.ManagementApi/Actions/GetActionsRequest.cs rename to src/Auth0.ManagementApi/Models/Actions/GetActionsRequest.cs index 932cf863c..8ff59ad22 100644 --- a/src/Auth0.ManagementApi/Actions/GetActionsRequest.cs +++ b/src/Auth0.ManagementApi/Models/Actions/GetActionsRequest.cs @@ -1,4 +1,4 @@ -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Request configuration for retrieving all actions. diff --git a/src/Auth0.ManagementApi/Actions/Trigger.cs b/src/Auth0.ManagementApi/Models/Actions/Trigger.cs similarity index 95% rename from src/Auth0.ManagementApi/Actions/Trigger.cs rename to src/Auth0.ManagementApi/Models/Actions/Trigger.cs index 98d2e815b..2b68c4c81 100644 --- a/src/Auth0.ManagementApi/Actions/Trigger.cs +++ b/src/Auth0.ManagementApi/Models/Actions/Trigger.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Represents a Trigger in Auth0 diff --git a/src/Auth0.ManagementApi/Actions/TriggerBinding.cs b/src/Auth0.ManagementApi/Models/Actions/TriggerBinding.cs similarity index 96% rename from src/Auth0.ManagementApi/Actions/TriggerBinding.cs rename to src/Auth0.ManagementApi/Models/Actions/TriggerBinding.cs index f2744e9c8..8c6db023e 100644 --- a/src/Auth0.ManagementApi/Actions/TriggerBinding.cs +++ b/src/Auth0.ManagementApi/Models/Actions/TriggerBinding.cs @@ -1,7 +1,7 @@ using System; using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Represents a Trigger Binding in Auth0 diff --git a/src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs b/src/Auth0.ManagementApi/Models/Actions/UpdateActionRequest.cs similarity index 76% rename from src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs rename to src/Auth0.ManagementApi/Models/Actions/UpdateActionRequest.cs index 0ce16b922..dd83599a3 100644 --- a/src/Auth0.ManagementApi/Actions/UpdateActionRequest.cs +++ b/src/Auth0.ManagementApi/Models/Actions/UpdateActionRequest.cs @@ -1,4 +1,4 @@ -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Request configuration for updating an action. diff --git a/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs b/src/Auth0.ManagementApi/Models/Actions/UpdateTriggerBindingEntry.cs similarity index 95% rename from src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs rename to src/Auth0.ManagementApi/Models/Actions/UpdateTriggerBindingEntry.cs index 5b39f80fe..fca875801 100644 --- a/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingEntry.cs +++ b/src/Auth0.ManagementApi/Models/Actions/UpdateTriggerBindingEntry.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { public class UpdateTriggerBindingEntry { diff --git a/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs b/src/Auth0.ManagementApi/Models/Actions/UpdateTriggerBindingsRequest.cs similarity index 92% rename from src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs rename to src/Auth0.ManagementApi/Models/Actions/UpdateTriggerBindingsRequest.cs index 6ea6a291b..8efc71038 100644 --- a/src/Auth0.ManagementApi/Actions/UpdateTriggerBindingsRequest.cs +++ b/src/Auth0.ManagementApi/Models/Actions/UpdateTriggerBindingsRequest.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace Auth0.ManagementApi.Actions +namespace Auth0.ManagementApi.Models.Actions { /// /// Request configuration to update the actions that are bound (i.e. attached) to a trigger. diff --git a/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs b/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs index f0f3fa6f4..019770372 100644 --- a/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs +++ b/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs @@ -1,9 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading.Tasks; -using Auth0.ManagementApi.Actions; +using Auth0.ManagementApi.Models.Actions; using Auth0.ManagementApi.Paging; using Auth0.Tests.Shared; using FluentAssertions; From 36992d7d3a15979fe927d579bf08b8da05dab5b0 Mon Sep 17 00:00:00 2001 From: Frederik Date: Fri, 27 Aug 2021 16:45:14 +0200 Subject: [PATCH 5/5] Support `deployed_version` --- src/Auth0.ManagementApi/Models/Actions/Action.cs | 6 ++++++ tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/Auth0.ManagementApi/Models/Actions/Action.cs b/src/Auth0.ManagementApi/Models/Actions/Action.cs index a197f857e..bbaa8141e 100644 --- a/src/Auth0.ManagementApi/Models/Actions/Action.cs +++ b/src/Auth0.ManagementApi/Models/Actions/Action.cs @@ -21,6 +21,12 @@ public class Action : ActionBase [JsonProperty("status")] public string Status { get; set; } + /// + /// The version of the action that is currently deployed. + /// + [JsonProperty("deployed_version")] + public ActionVersion DeployedVersion { get; set; } + /// /// True if all of an Action's contents have been deployed. /// diff --git a/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs b/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs index 019770372..cb1a16335 100644 --- a/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs +++ b/tests/Auth0.ManagementApi.IntegrationTests/ActionsTests.cs @@ -158,6 +158,9 @@ public async Task Test_action_version_crud_sequence() versionsAfterSecondDeploy.Single(v => v.Id == deployedVersion.Id).Deployed.Should().BeTrue(); versionsAfterSecondDeploy.Single(v => v.Id != deployedVersion.Id).Deployed.Should().BeFalse(); + var action = await _apiClient.Actions.GetAsync(createdAction.Id); + action.DeployedVersion.Id.Should().Be(deployedVersion.Id); + // 9. Rollback var rollbackedVersion = await _apiClient.Actions.RollbackToVersionAsync(createdAction.Id, versionsAfterDeploy.Single().Id);