From 560f2e316cf369a191f2cc1422fc54e5c5180640 Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 4 Nov 2024 18:48:14 +0900 Subject: [PATCH 01/84] :books::bug: fix: `Get-AnsibleCredential` -> `Get-Credential` --- docs/en-US/cmdlets/New-AnsibleUser.md | 6 +++--- docs/en-US/cmdlets/Update-AnsibleUser.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/en-US/cmdlets/New-AnsibleUser.md b/docs/en-US/cmdlets/New-AnsibleUser.md index 1d5fed1..e169251 100644 --- a/docs/en-US/cmdlets/New-AnsibleUser.md +++ b/docs/en-US/cmdlets/New-AnsibleUser.md @@ -47,14 +47,14 @@ Input UserName and Password via prompts. ### Example 2 ```powershell -PS C:\> New-AnsibleUser -Credential (Microsoft.PowerShell.Security\Get-AnsibleCredential -UserName user2) +PS C:\> New-AnsibleUser -Credential (Get-Credential -UserName user2) PowerShell credential request Enter your credentials. Password for user user2: ******** ``` -Input UserName and Password via `Microsoft.PowerShell.Security\Get-AnsibleCredential`. +Input UserName and Password via `Microsoft.PowerShell.Security\Get-Credential`. ### Example 3 ```powershell @@ -71,7 +71,7 @@ Input Password via a prompt. ### -Credential Credential (UserName and Password) -See: `Get-AnsibleHelp Microsoft.PowerShell.Security\Get-AnsibleCredential`. +See: `Get-Help Get-Credential`. ```yaml Type: PSCredential diff --git a/docs/en-US/cmdlets/Update-AnsibleUser.md b/docs/en-US/cmdlets/Update-AnsibleUser.md index 4cb1f70..6aa0b1a 100644 --- a/docs/en-US/cmdlets/Update-AnsibleUser.md +++ b/docs/en-US/cmdlets/Update-AnsibleUser.md @@ -124,7 +124,7 @@ Accept wildcard characters: False ``` ### -Password -Specify `SecureString` object. generated by commands such as `ConvertTo-SecureString` or `(Microsoft.PowerShell.Security\Get-AnsibleCredential).Password`. +Specify `SecureString` object. generated by commands such as `ConvertTo-SecureString` or `(Get-Credential).Password`. ```yaml Type: SecureString From 646217dd9925e3661003a75bb982ccb22352b030 Mon Sep 17 00:00:00 2001 From: teramako Date: Tue, 5 Nov 2024 23:31:10 +0900 Subject: [PATCH 02/84] :sparkles: Implement OrderByCompleter - `OrderByCompleter` - `OrderByCompletionAttribute` --- .../Cmdlets/Completer/OrderByCompleter.cs | 33 +++++++++++++++++++ .../Completer/OrderByCompletionAttribute.cs | 12 +++++++ 2 files changed, 45 insertions(+) create mode 100644 src/Jagabata/Cmdlets/Completer/OrderByCompleter.cs create mode 100644 src/Jagabata/Cmdlets/Completer/OrderByCompletionAttribute.cs diff --git a/src/Jagabata/Cmdlets/Completer/OrderByCompleter.cs b/src/Jagabata/Cmdlets/Completer/OrderByCompleter.cs new file mode 100644 index 0000000..485b95e --- /dev/null +++ b/src/Jagabata/Cmdlets/Completer/OrderByCompleter.cs @@ -0,0 +1,33 @@ +using System.Collections; +using System.Management.Automation; +using System.Management.Automation.Language; + +namespace Jagabata.Cmdlets.Completer; + +internal class OrderByCompleter : IArgumentCompleter +{ + public OrderByCompleter(params string[] keys) + { + Keys = keys; + } + public string[] Keys { get; init; } + public IEnumerable CompleteArgument(string commandName, string parameterName, + string wordToComplete, CommandAst commandAst, + IDictionary fakeBoundParameters) + { + var word = wordToComplete.StartsWith('!') + ? wordToComplete[1..].ToLowerInvariant() + : wordToComplete.ToLowerInvariant(); + foreach (var key in Keys) + { + if (!key.StartsWith(word, StringComparison.InvariantCulture)) + { + continue; + } + + yield return new CompletionResult(key, key, CompletionResultType.Keyword, $"Order by {key} ascending"); + var descendingProp = '!' + key; + yield return new CompletionResult(descendingProp, descendingProp, CompletionResultType.Keyword, $"Order by {key} descending"); + } + } +} diff --git a/src/Jagabata/Cmdlets/Completer/OrderByCompletionAttribute.cs b/src/Jagabata/Cmdlets/Completer/OrderByCompletionAttribute.cs new file mode 100644 index 0000000..7eea5b4 --- /dev/null +++ b/src/Jagabata/Cmdlets/Completer/OrderByCompletionAttribute.cs @@ -0,0 +1,12 @@ +using System.Management.Automation; + +namespace Jagabata.Cmdlets.Completer; + +internal class OrderByCompletionAttribute : ArgumentCompleterAttribute, IArgumentCompleterFactory +{ + public string[] Keys { get; init; } = []; + public IArgumentCompleter Create() + { + return new OrderByCompleter(Keys); + } +} From 40236da00d17636da8de370dbb0d8aafa004ef5d Mon Sep 17 00:00:00 2001 From: teramako Date: Wed, 6 Nov 2024 22:10:25 +0900 Subject: [PATCH 03/84] :sparkles: Set OrderBy completer for `Find-ActivityStream` --- src/Jagabata/Cmdlets/ActivityStreamCommand.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Jagabata/Cmdlets/ActivityStreamCommand.cs b/src/Jagabata/Cmdlets/ActivityStreamCommand.cs index b13998f..483280c 100644 --- a/src/Jagabata/Cmdlets/ActivityStreamCommand.cs +++ b/src/Jagabata/Cmdlets/ActivityStreamCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -71,6 +72,7 @@ public class FindActivityStreamCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "timestamp", "operation", "changes", "object1", "object2", "action_node"])] public override string[] OrderBy { get; set; } = ["!id"]; protected override void BeginProcessing() From b10b1aa701f4d38710fb2979c326f87c7fd629c3 Mon Sep 17 00:00:00 2001 From: teramako Date: Wed, 6 Nov 2024 22:19:29 +0900 Subject: [PATCH 04/84] :sparkles: Set OrderBy completer for `Find-AdHocCommand` --- src/Jagabata/Cmdlets/AdHocCommandCommand.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Jagabata/Cmdlets/AdHocCommandCommand.cs b/src/Jagabata/Cmdlets/AdHocCommandCommand.cs index 80fcf8a..9404093 100644 --- a/src/Jagabata/Cmdlets/AdHocCommandCommand.cs +++ b/src/Jagabata/Cmdlets/AdHocCommandCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Collections; using System.Management.Automation; @@ -39,6 +40,12 @@ public class FindAdHocCommandJobCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "launch_type", "status", "execution_environment", + "failed", "started", "finished", "canceled_on", "elapsed", "job_explanation", + "execution_node", "controller_node", "work_unit_id", "job_type", "inventory", "limit", + "credential", "module_name", "module_args", "forks", "verbosity", "become_enabled", + "diff_mode", "hosts", "organization", "schedule", "created_by", "modified_by", + "instance_group", "labels"])] public override string[] OrderBy { get; set; } = ["!id"]; From c517337ced39d5d003984835539ab3ae69fa1865 Mon Sep 17 00:00:00 2001 From: teramako Date: Wed, 6 Nov 2024 22:40:16 +0900 Subject: [PATCH 05/84] :sparkles: Set OrderBy completer for `Find-Application` --- src/Jagabata/Cmdlets/ApplicationCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/ApplicationCommand.cs b/src/Jagabata/Cmdlets/ApplicationCommand.cs index d6f3e07..2e0bfeb 100644 --- a/src/Jagabata/Cmdlets/ApplicationCommand.cs +++ b/src/Jagabata/Cmdlets/ApplicationCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -38,6 +39,8 @@ public class FindApplicationCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "name", "description", "client_type", "redirect_uris", + "authorization_grant_type", "skip_authorization", "organization", "user"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 98da84888d12e19f639cd3c46f4f1fb707e77b75 Mon Sep 17 00:00:00 2001 From: teramako Date: Wed, 6 Nov 2024 22:50:43 +0900 Subject: [PATCH 06/84] :sparkles: Set OrderBy completer for `Find-Credential` --- src/Jagabata/Cmdlets/CredentialCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/CredentialCommand.cs b/src/Jagabata/Cmdlets/CredentialCommand.cs index 578572a..da29bfd 100644 --- a/src/Jagabata/Cmdlets/CredentialCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Collections; using System.Management.Automation; @@ -64,6 +65,8 @@ public class FindCredentialCommand : FindCommandBase /// Only affected for an Organization /// [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "organization", + "credential_type", "managed", "created_by", "modified_by"])] public SwitchParameter Galaxy { get; set; } [Parameter()] From b3fc8374a17d3ce3959a8122edbf7446127b2231 Mon Sep 17 00:00:00 2001 From: teramako Date: Wed, 6 Nov 2024 22:56:52 +0900 Subject: [PATCH 07/84] :sparkles: Set OrderBy completer for `Find-CredentialInputSource` --- src/Jagabata/Cmdlets/CredentialInputSourceCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/CredentialInputSourceCommand.cs b/src/Jagabata/Cmdlets/CredentialInputSourceCommand.cs index acebcac..ba56def 100644 --- a/src/Jagabata/Cmdlets/CredentialInputSourceCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialInputSourceCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -29,6 +30,8 @@ public class FindCredentialInputSourceCommand : FindCommandBase public ulong Credential { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "description", "input_field_name", + "metadata", "target_credential", "source_credential"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From e481167c4c4ad8f11f20eacf5d90fd1e1139297e Mon Sep 17 00:00:00 2001 From: teramako Date: Wed, 6 Nov 2024 23:18:29 +0900 Subject: [PATCH 08/84] :sparkles: Set OrderBy completer for `Find-CredentialType` --- src/Jagabata/Cmdlets/CredentialTypeCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/CredentialTypeCommand.cs b/src/Jagabata/Cmdlets/CredentialTypeCommand.cs index 8a7f340..d423069 100644 --- a/src/Jagabata/Cmdlets/CredentialTypeCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialTypeCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Collections; using System.Management.Automation; @@ -29,6 +30,8 @@ public class FindCredentialTypeCommand : FindCommandBase public CredentialTypeKind[]? Kind { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "kind", "namespace", + "managed", "inputs", "injectors", "created_by", "modified_by"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 5ef71a3ccaf55c79f821a90357f8ff2ce202c348 Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 7 Nov 2024 20:58:08 +0900 Subject: [PATCH 09/84] :sparkles: Set OrderBy completer for `Find-ExecutionEnvironment` --- src/Jagabata/Cmdlets/ExecutionEnvironmentCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/ExecutionEnvironmentCommand.cs b/src/Jagabata/Cmdlets/ExecutionEnvironmentCommand.cs index fbead76..587d8fb 100644 --- a/src/Jagabata/Cmdlets/ExecutionEnvironmentCommand.cs +++ b/src/Jagabata/Cmdlets/ExecutionEnvironmentCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -28,6 +29,8 @@ public class FindExecutionEnvironmentCommand : FindCommandBase public ulong Organization { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "organization", + "image", "managed", "credential", "pull"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 142085b8867768b20bea1f35a892a83bd1fb0c10 Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 7 Nov 2024 21:12:24 +0900 Subject: [PATCH 10/84] :sparkles: Set OrderBy completer for `Find-Group` --- src/Jagabata/Cmdlets/GroupCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/GroupCommand.cs b/src/Jagabata/Cmdlets/GroupCommand.cs index 8720723..1402256 100644 --- a/src/Jagabata/Cmdlets/GroupCommand.cs +++ b/src/Jagabata/Cmdlets/GroupCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -60,6 +61,8 @@ public class FindGroupCommand : FindCommandBase public SwitchParameter OnlyParnets { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "inventory", "variables", + "parents", "created_by", "modified_by", "children", "hosts"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 2f116eba58f1fac6cc19cc370e7b78cb281b4b7b Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 7 Nov 2024 21:21:01 +0900 Subject: [PATCH 11/84] :sparkles: Set OrderBy completer for `Find-Host` --- src/Jagabata/Cmdlets/HostCommand.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Jagabata/Cmdlets/HostCommand.cs b/src/Jagabata/Cmdlets/HostCommand.cs index 218f031..b43e289 100644 --- a/src/Jagabata/Cmdlets/HostCommand.cs +++ b/src/Jagabata/Cmdlets/HostCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -50,6 +51,9 @@ public class FindHostCommand : FindCommandBase public SwitchParameter OnlyChildren { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "inventory", "enabled", + "instance_id", "variables", "last_job", "last_job_host_summary", + "ansible_facts_modified", "groups", "created_by", "modified_by"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 614ed3e32410607b5f0c9cc911e25d8f199711cb Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 7 Nov 2024 21:26:33 +0900 Subject: [PATCH 12/84] :sparkles: Set OrderBy completer for `Find-HostMetric` --- src/Jagabata/Cmdlets/HostMetricsCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/HostMetricsCommand.cs b/src/Jagabata/Cmdlets/HostMetricsCommand.cs index 73876d1..c022152 100644 --- a/src/Jagabata/Cmdlets/HostMetricsCommand.cs +++ b/src/Jagabata/Cmdlets/HostMetricsCommand.cs @@ -1,3 +1,4 @@ +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -24,6 +25,8 @@ protected override void EndProcessing() public class FindHostMetricCommand : FindCommandBase { [Parameter()] + [OrderByCompletion(Keys = ["id", "hostname", "first_automation", "last_automation", "last_deleted", + "automated_counter", "deleted_counter", "deleted", "used_in_inventories"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 233914eb101de6b1f2dca36668db3896fdfd1da1 Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 7 Nov 2024 21:35:10 +0900 Subject: [PATCH 13/84] :sparkles: Set OrderBy completer for `Find-Instance` --- src/Jagabata/Cmdlets/InstanceCommand.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Jagabata/Cmdlets/InstanceCommand.cs b/src/Jagabata/Cmdlets/InstanceCommand.cs index 969c696..9495419 100644 --- a/src/Jagabata/Cmdlets/InstanceCommand.cs +++ b/src/Jagabata/Cmdlets/InstanceCommand.cs @@ -1,3 +1,4 @@ +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -27,6 +28,10 @@ public class FindInstanceCommand : FindCommandBase public ulong InstanceGroup { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "hostname", "uuid", "created", "modified", "last_seen", "health_check_started", + "last_health_check", "errors", "capacity_adjustment", "version", "capacity", "cpu", + "memory", "cpu_capacity", "mem_capacity", "enabled", "managed_by_policy", "node_type", + "node_state", "ip_address", "listener_port", "peers_from_control_nodes"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 36522a90d29782aeac61caae0e6ca969e3231071 Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 7 Nov 2024 21:53:39 +0900 Subject: [PATCH 14/84] :sparkles: Set OrderBy completer for `Find-InstanceGroup` --- src/Jagabata/Cmdlets/InstanceGroupCommand.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Jagabata/Cmdlets/InstanceGroupCommand.cs b/src/Jagabata/Cmdlets/InstanceGroupCommand.cs index cfff4da..5b47026 100644 --- a/src/Jagabata/Cmdlets/InstanceGroupCommand.cs +++ b/src/Jagabata/Cmdlets/InstanceGroupCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -49,6 +50,9 @@ public class FindInstanceGroupCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "name", "created", "modified", "max_concurrent_jobs", "max_forks", + "is_container_group", "credential", "policy_instance_percentage", + "policy_instance_minimum", "policy_instance_list"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 1d090d02eb2155d358f4d800c048f455f469da16 Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 7 Nov 2024 22:00:22 +0900 Subject: [PATCH 15/84] :sparkles: Set OrderBy completer for `Find-Inventory` --- src/Jagabata/Cmdlets/InventoryCommand.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Jagabata/Cmdlets/InventoryCommand.cs b/src/Jagabata/Cmdlets/InventoryCommand.cs index 4b1cf2c..8312cde 100644 --- a/src/Jagabata/Cmdlets/InventoryCommand.cs +++ b/src/Jagabata/Cmdlets/InventoryCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -45,6 +46,11 @@ public class FindInventoryCommand : FindCommandBase public InventoryKind Kind { get; set; } = InventoryKind.All; [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "organization", "kind", + "host_filter", "variables", "has_active_failures", "total_hosts", + "hosts_with_active_failures", "total_groups", "has_inventory_sources", + "total_inventory_sources", "inventory_sources_with_failures", "pending_deletion", + "prevent_instance_group_fallback", "created_by", "modified_by"])] public override string[] OrderBy { get; set; } = ["id"]; public enum InventoryKind From f5149df963a14e1b63586b42deb00b758e98dd6e Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 7 Nov 2024 22:06:05 +0900 Subject: [PATCH 16/84] :sparkles: Set OrderBy completer for `Find-InventorySource` --- src/Jagabata/Cmdlets/InventorySourceCommand.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Jagabata/Cmdlets/InventorySourceCommand.cs b/src/Jagabata/Cmdlets/InventorySourceCommand.cs index b26fad4..c7f1bf8 100644 --- a/src/Jagabata/Cmdlets/InventorySourceCommand.cs +++ b/src/Jagabata/Cmdlets/InventorySourceCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -43,6 +44,11 @@ public class FindInventorySourceCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "source", "source_path", + "source_vars", "scm_branch", "enabled_var", "enabled_value", "host_filter", "overwrite", + "overwrite_vars", "timeout", "verbosity", "limit", "last_job_run", "last_job_failed", + "next_job_run", "status", "execution_environment", "inventory", "update_on_launch", + "update_cache_timeout", "source_project"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 6f2f13a6997cef201711023e4f9418e74ef7563a Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 7 Nov 2024 22:14:41 +0900 Subject: [PATCH 17/84] :sparkles: Set OrderBy completer for `Find-InventoryUpdateJob` --- src/Jagabata/Cmdlets/InventoryUpdateCommand.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Jagabata/Cmdlets/InventoryUpdateCommand.cs b/src/Jagabata/Cmdlets/InventoryUpdateCommand.cs index 5ff56e2..1fdbc3b 100644 --- a/src/Jagabata/Cmdlets/InventoryUpdateCommand.cs +++ b/src/Jagabata/Cmdlets/InventoryUpdateCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -36,6 +37,12 @@ public class FindInventoryUpdateJobCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "unified_job_template", "launch_type", "status", "execution_environment", "failed", + "started", "finished", "canceled_on", "elapsed", "job_explanation", "execution_node", + "controller_node", "work_unit_id", "source", "source_path", "source_vars", "scm_branch", + "enabled_var", "enabled_value", "enabled_value", "overwrite", "overwrite_vars", + "timeout", "verbosity", "limit", "inventory", "inventory_source", "license_error", + "org_host_limit_error", "source_project_update", "instance_group", "scm_revision"])] public override string[] OrderBy { get; set; } = ["!id"]; protected override void BeginProcessing() From 91d5dd13fb84b4337c923d9980e3caa9a3961379 Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 7 Nov 2024 23:05:55 +0900 Subject: [PATCH 18/84] :sparkles: Set OrderBy completer for `Find-Job` --- src/Jagabata/Cmdlets/JobCommand.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Jagabata/Cmdlets/JobCommand.cs b/src/Jagabata/Cmdlets/JobCommand.cs index 46ea23b..70f8666 100644 --- a/src/Jagabata/Cmdlets/JobCommand.cs +++ b/src/Jagabata/Cmdlets/JobCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -37,6 +38,15 @@ public class FindJobTemplateJobCommand : FindCommandBase public string[]? LaunchType { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "unified_job_template", + "launch_type", "status", "execution_environment", "failed", "started", "finished", + "canceled_on", "elapsed", "job_explanation", "execution_node", "controller_node", + "work_unit_id", "job_type", "inventory", "project", "playbook", "scm_branch", "forks", + "limit", "verbosity", "job_tags", "force_handlers", "skip_tags", "start_at_task", + "timeout", "use_fact_cache", "organization", "job_template", "allow_simultaneous", + "artifacts", "scm_revision", "instance_group", "diff_mode", "job_slice_number", + "job_slice_count", "webhook_service", "webhook_credential", "webhook_credential", + "schedule", "created_by", "modified_by", "labels"])] public override string[] OrderBy { get; set; } = ["!id"]; From cabf7a25dfdd75c64179af3e5489675ea8aa7f73 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 8 Nov 2024 21:43:16 +0900 Subject: [PATCH 19/84] :sparkles: Set OrderBy completer for `Find-JobEvent` --- src/Jagabata/Cmdlets/JobEventCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/JobEventCommand.cs b/src/Jagabata/Cmdlets/JobEventCommand.cs index f700f0c..6f7b00d 100644 --- a/src/Jagabata/Cmdlets/JobEventCommand.cs +++ b/src/Jagabata/Cmdlets/JobEventCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -37,6 +38,8 @@ public class FindJobEventCommand : FindCommandBase public SwitchParameter AdHocCommandEvent { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "event", "counter", "event_data", "failed", "changed", + "uuid", "stdout", "start_line", "end_line", "verbosity"])] public override string[] OrderBy { get; set; } = ["counter"]; protected override void ProcessRecord() From 5c9c51a7bca12bcd682349c9fda6a8d8f6e4cea7 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 8 Nov 2024 21:59:40 +0900 Subject: [PATCH 20/84] :sparkles: Set OrderBy completer for `Find-JobHostSummary` --- src/Jagabata/Cmdlets/JobHostSummaryCommand.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Jagabata/Cmdlets/JobHostSummaryCommand.cs b/src/Jagabata/Cmdlets/JobHostSummaryCommand.cs index 4c17a54..49655cd 100644 --- a/src/Jagabata/Cmdlets/JobHostSummaryCommand.cs +++ b/src/Jagabata/Cmdlets/JobHostSummaryCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -38,6 +39,9 @@ public class FindJobHostSummaryCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "job", "host", "constructed_host", "host_name", + "changed", "dark", "failures", "ok", "processed", "skipped", "failed", + "ignored", "rescued"])] public override string[] OrderBy { get; set; } = ["!id"]; protected override void ProcessRecord() From 4148f6120249473ac10593d70b01b24dc34ec10e Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 8 Nov 2024 22:07:44 +0900 Subject: [PATCH 21/84] :sparkles: Set OrderBy completer for `Find-JobTemplate` --- src/Jagabata/Cmdlets/JobTemplateCommand.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Jagabata/Cmdlets/JobTemplateCommand.cs b/src/Jagabata/Cmdlets/JobTemplateCommand.cs index 6a2e82d..e267007 100644 --- a/src/Jagabata/Cmdlets/JobTemplateCommand.cs +++ b/src/Jagabata/Cmdlets/JobTemplateCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Cmdlets.Utilities; using Jagabata.Resources; using System.Management.Automation; @@ -48,6 +49,17 @@ public class FindJobTemplateCommand : FindCommandBase public string[]? Name { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "job_type", "inventory", "project", + "playbook", "scm_branch", "forks", "limit", "verbosity", "job_tags", "force_handlers", + "skip_tags", "start_at_task", "timeout", "use_fact_cache", "organization", "last_job_run", + "last_job_failed", "next_job_run", "status", "execution_environment", "ask_scm_branch_on_launch", + "ask_diff_mode_on_launch", "ask_variables_on_launch", "ask_limit_on_launch", "ask_tags_on_launch", + "ask_skip_tags_on_launch", "ask_job_type_on_launch", "ask_verbosity_on_launch", + "ask_inventory_on_launch", "ask_credential_on_launch", "ask_execution_environment_on_launch", + "ask_labels_on_launch", "ask_forks_on_launch", "ask_job_slice_count_on_launch", + "ask_timeout_on_launch", "ask_instance_groups_on_launch", "survey_enabled", "become_enabled", + "diff_mode", "allow_simultaneous", "custom_virtualenv", "job_slice_count", "webhook_service", + "webhook_credential", "prevent_instance_group_fallback"])] public override string[] OrderBy { get; set; } = ["!id"]; protected override void BeginProcessing() From 0b8dbca5da0266a250edb7dc7330ea52453a4805 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 8 Nov 2024 22:09:14 +0900 Subject: [PATCH 22/84] :sparkles: Set OrderBy completer for `Find-Label` --- src/Jagabata/Cmdlets/LabelCommand.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Jagabata/Cmdlets/LabelCommand.cs b/src/Jagabata/Cmdlets/LabelCommand.cs index 2887f57..f213ac2 100644 --- a/src/Jagabata/Cmdlets/LabelCommand.cs +++ b/src/Jagabata/Cmdlets/LabelCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -51,6 +52,7 @@ public class FindLabelCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "organization"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 4e7b71db84ce1a4d801503c365d3a9d8c375e2b3 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 8 Nov 2024 22:13:14 +0900 Subject: [PATCH 23/84] :sparkles: Set OrderBy completer for `Find-Notification` --- src/Jagabata/Cmdlets/NotificationCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/NotificationCommand.cs b/src/Jagabata/Cmdlets/NotificationCommand.cs index b90ba07..eaf3f49 100644 --- a/src/Jagabata/Cmdlets/NotificationCommand.cs +++ b/src/Jagabata/Cmdlets/NotificationCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -50,6 +51,8 @@ public class FindNotificationCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "notification_template", "error", "status", + "notifications_sent", "notification_type", "recipients", "subject", "body"])] public override string[] OrderBy { get; set; } = ["!id"]; protected override void BeginProcessing() From 8d238d00a1f942ac35e5c4d9593755ef77240230 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 8 Nov 2024 22:16:11 +0900 Subject: [PATCH 24/84] :sparkles: Set OrderBy completer for `Find-NotificationTemplate` and `Find-NotificationTemplateFor***` --- src/Jagabata/Cmdlets/NotificationTemplateCommand.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Jagabata/Cmdlets/NotificationTemplateCommand.cs b/src/Jagabata/Cmdlets/NotificationTemplateCommand.cs index dd0f61f..0175d1c 100644 --- a/src/Jagabata/Cmdlets/NotificationTemplateCommand.cs +++ b/src/Jagabata/Cmdlets/NotificationTemplateCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Collections; using System.Management.Automation; @@ -30,6 +31,8 @@ public class FindNotificationTemplateCommand : FindCommandBase public ulong Organization { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "organization", + "notification_type", "messages"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() @@ -66,6 +69,8 @@ public class FindNotificationTemplateForApprovalCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "organization", + "notification_type", "messages"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() @@ -118,6 +123,8 @@ public class FindNotificationTemplateForErrorCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "organization", + "notification_type", "messages"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() @@ -174,6 +181,8 @@ public class FindNotificationTemplateForStartedCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "organization", + "notification_type", "messages"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() @@ -219,6 +228,8 @@ public class FindNotificationTemplateForSuccessCommand : FindCommandBase public ulong Id { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "organization", + "notification_type", "messages"])] public override string[] OrderBy { get; set; } = ["id"]; [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] From 7e65f5c4c0e51adafcce91d42426f115cb50afe0 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 8 Nov 2024 22:28:13 +0900 Subject: [PATCH 25/84] :sparkles: Set OrderBy completer for `Find-Organization` --- src/Jagabata/Cmdlets/OrganizationCommand.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Jagabata/Cmdlets/OrganizationCommand.cs b/src/Jagabata/Cmdlets/OrganizationCommand.cs index 1edaae9..8ea7a9b 100644 --- a/src/Jagabata/Cmdlets/OrganizationCommand.cs +++ b/src/Jagabata/Cmdlets/OrganizationCommand.cs @@ -1,5 +1,6 @@ using System.Management.Automation; using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; namespace Jagabata.Cmdlets @@ -35,6 +36,8 @@ public class FindOrganizationCommand : FindCommandBase public string[]? Name { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", + "max_hosts", "default_environment"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() @@ -96,7 +99,7 @@ protected override void ProcessRecord() } } } - + [Cmdlet(VerbsData.Update, "Organization", SupportsShouldProcess = true)] [OutputType(typeof(Organization))] public class UpdateOrganizationCommand : UpdateCommandBase From d2d6c28dacf8e89123717244d491039fabebfa3b Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 8 Nov 2024 22:34:36 +0900 Subject: [PATCH 26/84] :sparkles: Set OrderBy completer for `Find-Project` --- src/Jagabata/Cmdlets/ProjectCommand.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Jagabata/Cmdlets/ProjectCommand.cs b/src/Jagabata/Cmdlets/ProjectCommand.cs index 41dba22..20feea9 100644 --- a/src/Jagabata/Cmdlets/ProjectCommand.cs +++ b/src/Jagabata/Cmdlets/ProjectCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -42,6 +43,12 @@ public class FindProjectCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "local_path", "scm_type", + "scm_url", "scm_branch", "scm_refspec", "scm_clean", "scm_track_submodules", + "scm_delete_on_update", "credential", "timeout", "scm_revision", "last_job_run", + "last_job_failed", "next_job_run", "status", "organization", "scm_update_on_launch", + "scm_update_cache_timeout", "allow_override", "default_environment", + "signature_validation_credential", "last_update_failed", "last_updated"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 72fcba312f48295352348a75636fd24afa758f3b Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 8 Nov 2024 22:53:19 +0900 Subject: [PATCH 27/84] :sparkles: Set OrderBy completer for `Find-ProjectUpdateJob` --- src/Jagabata/Cmdlets/ProjectUpdateCommand.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Jagabata/Cmdlets/ProjectUpdateCommand.cs b/src/Jagabata/Cmdlets/ProjectUpdateCommand.cs index 7aaa375..44c8edb 100644 --- a/src/Jagabata/Cmdlets/ProjectUpdateCommand.cs +++ b/src/Jagabata/Cmdlets/ProjectUpdateCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -32,6 +33,11 @@ public class FindProjectUpdateJobCommand : FindCommandBase public string[]? Status { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "launch_type", "status", + "execution_environment", "failed", "started", "finished", "canceled_on", "elapsed", + "job_explanation", "execution_node", "work_unit_id", "local_path", "scm_type", + "scm_url", "scm_branch", "scm_refspec", "scm_clean", "scm_track_submodules", + "scm_delete_on_update", "credential", "timeout", "scm_revision", "project"])] public override string[] OrderBy { get; set; } = ["!id"]; From 2645df9578d233f3fa51a1ee2236d746a3e293f3 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 8 Nov 2024 23:13:03 +0900 Subject: [PATCH 28/84] :sparkles: Set OrderBy completer for `Find-Role`, `Find-ObjectRole` --- src/Jagabata/Cmdlets/RoleCommand.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Jagabata/Cmdlets/RoleCommand.cs b/src/Jagabata/Cmdlets/RoleCommand.cs index 31a8a8b..7e23a51 100644 --- a/src/Jagabata/Cmdlets/RoleCommand.cs +++ b/src/Jagabata/Cmdlets/RoleCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -40,6 +41,8 @@ public class FindRoleCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "name", "description", "parents", "parents", "content_type", + "ancestors", "descendents", "children"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() @@ -96,6 +99,8 @@ public class FindObjectRoleCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "name", "description", "parents", "parents", "content_type", + "ancestors", "descendents", "children"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 2f45780506ddecda8281fe95e964acda76627509 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 21:26:19 +0900 Subject: [PATCH 29/84] :sparkles: Set OrderBy completer for `Find-Schedule` --- src/Jagabata/Cmdlets/ScheduleCommand.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Jagabata/Cmdlets/ScheduleCommand.cs b/src/Jagabata/Cmdlets/ScheduleCommand.cs index 315b23c..00b449d 100644 --- a/src/Jagabata/Cmdlets/ScheduleCommand.cs +++ b/src/Jagabata/Cmdlets/ScheduleCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -46,6 +47,10 @@ public class FindScheduleCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["rrule", "id", "created", "modified", "name", "description", "extra_data", + "inventory", "execution_environment", "unified_job_template", "enabled", + "dtstart", "dtend", "next_run", "created_by", "modified_by", "credentials", + "instance_groups", "labels"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 2d689ffc2c578aa3069cca0b172e5f8a36750ea2 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 21:39:41 +0900 Subject: [PATCH 30/84] :sparkles: Set OrderBy completer for `Find-SystemJob` --- src/Jagabata/Cmdlets/SystemJobCommand.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Jagabata/Cmdlets/SystemJobCommand.cs b/src/Jagabata/Cmdlets/SystemJobCommand.cs index e4ebc0b..ac74bda 100644 --- a/src/Jagabata/Cmdlets/SystemJobCommand.cs +++ b/src/Jagabata/Cmdlets/SystemJobCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -29,6 +30,11 @@ public class FindSystemJobCommand : FindCommandBase public string[]? Status { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "unified_job_template", + "launch_type", "status", "execution_environment", "failed", "started", "finished", + "canceled_on", "elapsed", "job_explanation", "execution_node", "work_unit_id", + "system_job_template", "job_type", "schedule", "notifications", "created_by", + "modified_by", "dependent_jobs", "labels", "instance_group"])] public override string[] OrderBy { get; set; } = ["!id"]; From 67d8d287e40413a3f6f9f3dfb9c69f0a68afc99a Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 21:40:10 +0900 Subject: [PATCH 31/84] :sparkles: Set OrderBy completer for `Find-SystemJobTemplate` --- src/Jagabata/Cmdlets/SystemJobTemplateCommand.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Jagabata/Cmdlets/SystemJobTemplateCommand.cs b/src/Jagabata/Cmdlets/SystemJobTemplateCommand.cs index a331b88..c4d8aa7 100644 --- a/src/Jagabata/Cmdlets/SystemJobTemplateCommand.cs +++ b/src/Jagabata/Cmdlets/SystemJobTemplateCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Collections; using System.Management.Automation; @@ -27,6 +28,12 @@ protected override void EndProcessing() public class FindSystemJobTemplateCommand : FindCommandBase { [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "last_job_run", + "last_job_failed", "next_job_run", "status", "execution_environment", + "job_type", "notification_templates_error", "notification_templates_success", + "notification_templates_started", "unifiedjob_unified_jobs", "last_job", + "organization", "schedules", "jobs", "created_by", "credentials", "current_job", + "modified_by", "instance_groups", "labels", "next_schedule"])] public override string[] OrderBy { get; set; } = ["id"]; From d7ad326e1e00e1051b5c3fa17e2a20f2b17e138e Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 21:43:25 +0900 Subject: [PATCH 32/84] :sparkles: Set OrderBy completer for `Find-Team` --- src/Jagabata/Cmdlets/TeamCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/TeamCommand.cs b/src/Jagabata/Cmdlets/TeamCommand.cs index 2908c47..dc3394d 100644 --- a/src/Jagabata/Cmdlets/TeamCommand.cs +++ b/src/Jagabata/Cmdlets/TeamCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -46,6 +47,8 @@ public class FindTeamCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "organization", + "created_by", "modified_by"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From a3fce0ea57b9f04396c1aa205af1383c9df984fd Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 21:45:43 +0900 Subject: [PATCH 33/84] :sparkles: Set OrderBy completer for `Find-Token` --- src/Jagabata/Cmdlets/TokenCommand.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jagabata/Cmdlets/TokenCommand.cs b/src/Jagabata/Cmdlets/TokenCommand.cs index 28a2440..b77d4f5 100644 --- a/src/Jagabata/Cmdlets/TokenCommand.cs +++ b/src/Jagabata/Cmdlets/TokenCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -48,6 +49,8 @@ public class FindTokenCommand : FindCommandBase public ETokenType TokenType { get; set; } = ETokenType.Both; [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "description", "user", + "application", "expires", "scope"])] public override string[] OrderBy { get; set; } = ["id"]; public enum ETokenType From cfa7587cdf61ef6c95680b6c4a67c5782b770d51 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 21:51:22 +0900 Subject: [PATCH 34/84] :sparkles: Set OrderBy completer for `Find-UnifiedJob` --- src/Jagabata/Cmdlets/UnifiedJobCommand.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Jagabata/Cmdlets/UnifiedJobCommand.cs b/src/Jagabata/Cmdlets/UnifiedJobCommand.cs index 7f32f90..9064d73 100644 --- a/src/Jagabata/Cmdlets/UnifiedJobCommand.cs +++ b/src/Jagabata/Cmdlets/UnifiedJobCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Cmdlets.Utilities; using Jagabata.Resources; using System.Collections.Specialized; @@ -44,6 +45,11 @@ public class FindUnifiedJobCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "unified_job_template", + "launch_type", "status", "execution_environment", "failed", "started", "finished", + "canceled_on", "elapsed", "job_explanation", "execution_node", "controller_node", + "work_unit_id", "notifications", "organization", "schedule", "created_by", + "modified_by", "credentials", "instance_group", "labels"])] public override string[] OrderBy { get; set; } = ["!id"]; private IEnumerable GetResultSet(string path, From e7b998c3f21c54fd68c5dabc88792ee1a1489249 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 21:56:24 +0900 Subject: [PATCH 35/84] :sparkles: Set OrderBy completer for `Find-UnifiedJobTemplate` --- src/Jagabata/Cmdlets/UnifiedJobTemplateCommand.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Jagabata/Cmdlets/UnifiedJobTemplateCommand.cs b/src/Jagabata/Cmdlets/UnifiedJobTemplateCommand.cs index 99f407c..39a98cb 100644 --- a/src/Jagabata/Cmdlets/UnifiedJobTemplateCommand.cs +++ b/src/Jagabata/Cmdlets/UnifiedJobTemplateCommand.cs @@ -1,3 +1,4 @@ +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Collections.Specialized; using System.Management.Automation; @@ -9,6 +10,11 @@ namespace Jagabata.Cmdlets public class FindUnifiedJobTemplateCommand : FindCommandBase { [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "last_job_run", "last_job_failed", + "next_job_run", "status", "execution_environment", "notification_templates_error", + "notification_templates_success", "notification_templates_started", "last_job", + "organization", "schedules", "labels", "created_by", "modified_by", "credentials", + "instance_groups", "next_schedule"])] public override string[] OrderBy { get; set; } = ["id"]; private IEnumerable GetResultSet(string path, From d1361b14823a4bc0e1a11c904b7f431c66b8f066 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 22:02:43 +0900 Subject: [PATCH 36/84] :sparkles: Set OrderBy completer for `Find-User` & `Find-AccessList` --- src/Jagabata/Cmdlets/UserCommand.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Jagabata/Cmdlets/UserCommand.cs b/src/Jagabata/Cmdlets/UserCommand.cs index 0576a02..adbbac3 100644 --- a/src/Jagabata/Cmdlets/UserCommand.cs +++ b/src/Jagabata/Cmdlets/UserCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Cmdlets.Utilities; using Jagabata.Resources; using System.Management.Automation; @@ -66,6 +67,9 @@ public class FindUserCommand : FindCommandBase public string[]? Email { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "username", "first_name", "last_name", "email", "is_superuser", "last_login", + "enterprise_auth", "social_auth", "main_oauth2application", "activity_stream", + "roles", "profile"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() @@ -133,6 +137,9 @@ public class FindAccessListCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "username", "first_name", "last_name", "email", "is_superuser", "last_login", + "enterprise_auth", "social_auth", "main_oauth2application", "activity_stream", + "roles", "profile"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() @@ -207,7 +214,7 @@ private void GatherUserAndPassword() _user = Credential.UserName; _password = Credential.Password; } - else + else { _user = UserName; if (Password is not null) From 7f782dbdf10ff45a2e2240d95e6702794b8651f5 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 22:08:12 +0900 Subject: [PATCH 37/84] :sparkles: Set OrderBy completer for `Find-WorkflowApprovalRequest` --- src/Jagabata/Cmdlets/WorkflowApprovalCommand.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Jagabata/Cmdlets/WorkflowApprovalCommand.cs b/src/Jagabata/Cmdlets/WorkflowApprovalCommand.cs index 8db2672..e98283a 100644 --- a/src/Jagabata/Cmdlets/WorkflowApprovalCommand.cs +++ b/src/Jagabata/Cmdlets/WorkflowApprovalCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; using System.Web; @@ -30,6 +31,11 @@ public class FindWorkflowApprovalRequestCommand : FindCommandBase public JobStatus[]? Status { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "unified_job_template", + "launch_type", "status", "execution_environment", "failed", "started", "finished", + "canceled_on", "elapsed", "job_explanation", "work_unit_id", "timed_out", + "workflow_approval_template", "approved_or_denied_by", "schedule", "notifications", + "created_by", "modified_by", "instance_group", "organization", "labels"])] public override string[] OrderBy { get; set; } = ["!id"]; protected override void BeginProcessing() From c07ed18aecd1265d5e672679c2dd5cffa3470ab6 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 22:12:22 +0900 Subject: [PATCH 38/84] :sparkles: Set OrderBy completer for `Find-WorkflowJob` --- src/Jagabata/Cmdlets/WorkflowJobCommand.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Jagabata/Cmdlets/WorkflowJobCommand.cs b/src/Jagabata/Cmdlets/WorkflowJobCommand.cs index e1b87f9..767aa7f 100644 --- a/src/Jagabata/Cmdlets/WorkflowJobCommand.cs +++ b/src/Jagabata/Cmdlets/WorkflowJobCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -47,6 +48,13 @@ public class FindWorkflowJobCommand : FindCommandBase public string[]? LaunchType { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "unified_job_template", + "launch_type", "status", "failed", "started", "finished", "canceled_on", + "elapsed", "job_explanation", "work_unit_id", "workflow_job_template", + "allow_simultaneous", "job_template", "is_sliced_job", "inventory", + "webhook_service", "webhook_credential", "webhook_guid", "notifications", + "unified_job_node", "workflow_job_template", "organization", "schedule", + "created_by", "modified_by", "instance_group", "labels"])] public override string[] OrderBy { get; set; } = ["!id"]; protected override void BeginProcessing() From 67d3a286e47143fb3de3c325385290ce12689f09 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 22:21:57 +0900 Subject: [PATCH 39/84] :sparkles: Set OrderBy completer for `Find-WorkflowJobNode` --- src/Jagabata/Cmdlets/WorkflowJobNodeCommand.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Jagabata/Cmdlets/WorkflowJobNodeCommand.cs b/src/Jagabata/Cmdlets/WorkflowJobNodeCommand.cs index e7c254a..734b2f3 100644 --- a/src/Jagabata/Cmdlets/WorkflowJobNodeCommand.cs +++ b/src/Jagabata/Cmdlets/WorkflowJobNodeCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Management.Automation; @@ -36,6 +37,9 @@ public class FindWorkflowJobNodeCommand : FindCommandBase public WorkflowJobNodeLinkState Linked { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "extra_data", "inventory", "execution_environment", + "job", "workflow_job", "unified_job_template", "success_nodes", "failure_nodes", + "always_nodes", "all_parents_must_converge", "do_not_run", "identifier", "labels"])] public override string[] OrderBy { get; set; } = ["!id"]; protected override void BeginProcessing() From 70c5e783b7be0fce6022de20f98c35f2612c1b78 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 22:31:10 +0900 Subject: [PATCH 40/84] :sparkles: Set OrderBy completer for `Find-WorkflowJobTemplate` --- src/Jagabata/Cmdlets/WorkflowJobTemplateCommand.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Jagabata/Cmdlets/WorkflowJobTemplateCommand.cs b/src/Jagabata/Cmdlets/WorkflowJobTemplateCommand.cs index cd496ea..bc84b35 100644 --- a/src/Jagabata/Cmdlets/WorkflowJobTemplateCommand.cs +++ b/src/Jagabata/Cmdlets/WorkflowJobTemplateCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Cmdlets.Utilities; using Jagabata.Resources; using System.Management.Automation; @@ -32,6 +33,15 @@ public class FindWorkflowJobTemplateCommand : FindCommandBase public ulong Organization { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "name", "description", "last_job_run", + "last_job_failed", "next_job_run", "status", "organization", "survey_enabled", + "allow_simultaneous", "ask_variables_on_launch", "inventory", + "ask_inventory_on_launch", "ask_scm_branch_on_launch", "ask_limit_on_launch", + "webhook_service", "webhook_credential", "ask_labels_on_launch", + "ask_skip_tags_on_launch", "ask_tags_on_launch", "notification_templates_error", + "notification_templates_success", "notification_templates_approvals", + "notification_templates_started", "inventory", "organization", "last_job", + "schedules", "created_by", "modified_by", "labels", "next_schedule"])] public override string[] OrderBy { get; set; } = ["id"]; protected override void BeginProcessing() From 1e6ba958e3112d850284384830491f02d18aee17 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 9 Nov 2024 22:45:15 +0900 Subject: [PATCH 41/84] :sparkles: Set OrderBy completer for `Find-WorkflowJobTemplateNode` --- src/Jagabata/Cmdlets/WorkflowJobTemplateNodeCommand.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Jagabata/Cmdlets/WorkflowJobTemplateNodeCommand.cs b/src/Jagabata/Cmdlets/WorkflowJobTemplateNodeCommand.cs index c04c238..9fa08e7 100644 --- a/src/Jagabata/Cmdlets/WorkflowJobTemplateNodeCommand.cs +++ b/src/Jagabata/Cmdlets/WorkflowJobTemplateNodeCommand.cs @@ -1,4 +1,5 @@ using Jagabata.Cmdlets.ArgumentTransformation; +using Jagabata.Cmdlets.Completer; using Jagabata.Resources; using System.Diagnostics.CodeAnalysis; using System.Management.Automation; @@ -37,6 +38,9 @@ public class FindWorkflowJobTemplateNodeCommand : FindCommandBase public WorkflowJobNodeLinkState Linked { get; set; } [Parameter()] + [OrderByCompletion(Keys = ["id", "created", "modified", "extra_data", "inventory", "execution_environment", + "workflow_job_template", "unified_job_template", "success_nodes", "failure_nodes", + "always_nodes", "all_parents_must_converge", "identifier", "instance_groups", "labels"])] public override string[] OrderBy { get; set; } = ["!id"]; protected override void BeginProcessing() From 448ed73d9514dcee8dad693cc67b837f5f72d3ce Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 11 Nov 2024 22:26:53 +0900 Subject: [PATCH 42/84] Rename parameter `Kind` to `CredentialTypeNamespace` for Find-Credential - rename: `Kind` to `CredentialTypeNamespace` - enable to specify multiple (convert type to Array) - add `ArgumentCompletions` attribute --- docs/en-US/cmdlets/Find-AnsibleCredential.md | 68 ++++++++++---------- src/Jagabata/Cmdlets/CredentialCommand.cs | 12 +++- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/docs/en-US/cmdlets/Find-AnsibleCredential.md b/docs/en-US/cmdlets/Find-AnsibleCredential.md index 63f3dd1..b38f58d 100644 --- a/docs/en-US/cmdlets/Find-AnsibleCredential.md +++ b/docs/en-US/cmdlets/Find-AnsibleCredential.md @@ -14,22 +14,23 @@ Retrieve Credentials. ### All (Default) ``` -Find-AnsibleCredential [-Kind ] [-Galaxy] [-OrderBy ] [-Search ] - [-Filter ] [-Count ] [-Page ] [-All] [] +Find-AnsibleCredential [-CredentialTypeNamespace ] [-Galaxy] [-OrderBy ] + [-Search ] [-Filter ] [-Count ] [-Page ] [-All] + [] ``` ### AssociatedWith ``` -Find-AnsibleCredential [-Type] [-Id] [-Kind ] [-Galaxy] [-OrderBy ] - [-Search ] [-Filter ] [-Count ] [-Page ] [-All] - [] +Find-AnsibleCredential [-Type] [-Id] [-CredentialTypeNamespace ] [-Galaxy] + [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] + [-All] [] ``` ### PipelineInput ``` -Find-AnsibleCredential [-Resource] [-Kind ] [-Galaxy] [-OrderBy ] - [-Search ] [-Filter ] [-Count ] [-Page ] [-All] - [] +Find-AnsibleCredential [-Resource] [-CredentialTypeNamespace ] [-Galaxy] + [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] + [-All] [] ``` ## DESCRIPTION @@ -107,6 +108,32 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -CredentialTypeNamespace +Filter with `kind` field. +This parameter is the same as `-Filter credential_type__namespace__in=...`. + +Examples.) +`ssh`, `scm`, `vault`, `net`, `awx`, `openstack`, `vmware`, `satellite6`, `gce`, `azure_rm`, +`github_token`, `gitlab_token`, `insights`, `rhv`, `controller`, `kubernetes_bearer_token`, +`registry`, `galaxy_api_token`, `gpg_public_key`, `aim`, `aws_secretsmanager_credential`, +`azure_kv`, `centrify_vault_kv`, `conjur`, `hashivault_kv`, `hashivault_ssh`, `thycotic_dsv`, +`thycotic_tss` + +> [!NOTE] +> The `kind` field of a Credential corresponds to `namespace` field of a CredentialType. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: Namespace + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Filter Filtering various fields. @@ -161,31 +188,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Kind -Filter with `kind` field. - -Examples.) -`ssh`, `scm`, `vault`, `net`, `awx`, `openstack`, `vmware`, `satellite6`, `gce`, `azure_rm`, -`github_token`, `gitlab_token`, `insights`, `rhv`, `controller`, `kubernetes_bearer_token`, -`registry`, `galaxy_api_token`, `gpg_public_key`, `aim`, `aws_secretsmanager_credential`, -`azure_kv`, `centrify_vault_kv`, `conjur`, `hashivault_kv`, `hashivault_ssh`, `thycotic_dsv`, -`thycotic_tss` - -> [!NOTE] -> The `kind` field of a Credential corresponds to `namespace` field of a CredentialType. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -OrderBy Retrieve list in the specified orders. Use `!` prefix to sort in reverse. diff --git a/src/Jagabata/Cmdlets/CredentialCommand.cs b/src/Jagabata/Cmdlets/CredentialCommand.cs index da29bfd..0040178 100644 --- a/src/Jagabata/Cmdlets/CredentialCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialCommand.cs @@ -59,7 +59,13 @@ public class FindCredentialCommand : FindCommandBase public IResource? Resource { get; set; } [Parameter()] - public string? Kind { get; set; } + [ArgumentCompletions("aim", "aws", "aws_secretsmanager_credential", "azure_kv", "azure_rm", "centrify_vault_kv", + "conjur", "controller", "galaxy_api_token", "gce", "github_token", "gitlab_token", + "gpg_public_key", "hashivault_kv", "hashivault_ssh", "insights", "kubernetes_bearer_token", + "net", "openstack", "registry", "rhv", "satellite6", "scm", "ssh", "thycotic_dsv", + "thycotic_tss", "vault", "vmware")] + [Alias("Namespace")] + public string[]? CredentialTypeNamespace { get; set; } /// /// Only affected for an Organization @@ -74,9 +80,9 @@ public class FindCredentialCommand : FindCommandBase protected override void BeginProcessing() { - if (Kind is not null) + if (CredentialTypeNamespace is not null) { - Query.Add("chain__credential_type__namespace__icontains", Kind); + Query.Add("credential_type__namespace__in", string.Join(',', CredentialTypeNamespace)); } SetupCommonQuery(); } From df933f5b615df21cc7c024a0f56799e821fdf1ba Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 11 Nov 2024 22:42:58 +0900 Subject: [PATCH 43/84] :sparkles: Add `CredentialTypeKind` parameter to Find-Credential --- docs/en-US/cmdlets/Find-AnsibleCredential.md | 35 +++++++++++++++----- src/Jagabata/Cmdlets/CredentialCommand.cs | 8 +++++ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/docs/en-US/cmdlets/Find-AnsibleCredential.md b/docs/en-US/cmdlets/Find-AnsibleCredential.md index b38f58d..f9557d9 100644 --- a/docs/en-US/cmdlets/Find-AnsibleCredential.md +++ b/docs/en-US/cmdlets/Find-AnsibleCredential.md @@ -14,23 +14,23 @@ Retrieve Credentials. ### All (Default) ``` -Find-AnsibleCredential [-CredentialTypeNamespace ] [-Galaxy] [-OrderBy ] - [-Search ] [-Filter ] [-Count ] [-Page ] [-All] - [] +Find-AnsibleCredential [-CredentialTypeKind ] [-CredentialTypeNamespace ] + [-Galaxy] [-OrderBy ] [-Search ] [-Filter ] [-Count ] + [-Page ] [-All] [] ``` ### AssociatedWith ``` -Find-AnsibleCredential [-Type] [-Id] [-CredentialTypeNamespace ] [-Galaxy] - [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] - [-All] [] +Find-AnsibleCredential [-Type] [-Id] [-CredentialTypeKind ] + [-CredentialTypeNamespace ] [-Galaxy] [-OrderBy ] [-Search ] + [-Filter ] [-Count ] [-Page ] [-All] [] ``` ### PipelineInput ``` -Find-AnsibleCredential [-Resource] [-CredentialTypeNamespace ] [-Galaxy] - [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] - [-All] [] +Find-AnsibleCredential [-Resource] [-CredentialTypeKind ] + [-CredentialTypeNamespace ] [-Galaxy] [-OrderBy ] [-Search ] + [-Filter ] [-Count ] [-Page ] [-All] [] ``` ## DESCRIPTION @@ -108,6 +108,23 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -CredentialTypeKind +Filter with CredentialType's `kind` field. +This parameter is the same as `-Filter credential_type__kind__in=...`. + +```yaml +Type: CredentialTypeKind[] +Parameter Sets: (All) +Aliases: Kind +Accepted values: ssh, vault, net, scm, cloud, registry, token, insights, external, kubernetes, galaxy, cryptography + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -CredentialTypeNamespace Filter with `kind` field. This parameter is the same as `-Filter credential_type__namespace__in=...`. diff --git a/src/Jagabata/Cmdlets/CredentialCommand.cs b/src/Jagabata/Cmdlets/CredentialCommand.cs index 0040178..03d743a 100644 --- a/src/Jagabata/Cmdlets/CredentialCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialCommand.cs @@ -58,6 +58,10 @@ public class FindCredentialCommand : FindCommandBase ])] public IResource? Resource { get; set; } + [Parameter()] + [Alias("Kind")] + public CredentialTypeKind[]? CredentialTypeKind { get; set; } + [Parameter()] [ArgumentCompletions("aim", "aws", "aws_secretsmanager_credential", "azure_kv", "azure_rm", "centrify_vault_kv", "conjur", "controller", "galaxy_api_token", "gce", "github_token", "gitlab_token", @@ -80,6 +84,10 @@ public class FindCredentialCommand : FindCommandBase protected override void BeginProcessing() { + if (CredentialTypeKind is not null) + { + Query.Add("credential_type__kind__in", string.Join(',', CredentialTypeKind)); + } if (CredentialTypeNamespace is not null) { Query.Add("credential_type__namespace__in", string.Join(',', CredentialTypeNamespace)); From 78cfc5a7a4ff2ec27628b974b319af6d679ef878 Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 11 Nov 2024 23:34:18 +0900 Subject: [PATCH 44/84] fix: return type `IList` to `List TransformList(IList list) + private List TransformList(IList list) { var arr = new List(); foreach (var inputItem in list) @@ -30,7 +30,9 @@ private IList TransformList(IList list) private ulong TransformToId(object inputData) { if (inputData is PSObject pso) + { inputData = pso.BaseObject; + } switch (inputData) { @@ -94,7 +96,9 @@ protected IList TransformToList(IList list) protected IResource TransformToResource(object inputData) { if (inputData is PSObject pso && pso.BaseObject is not PSCustomObject) + { inputData = pso.BaseObject; + } (ResourceType Type, ulong Id) resourceData = (ResourceType.None, 0); @@ -105,8 +109,11 @@ protected IResource TransformToResource(object inputData) case IDictionary dict: foreach (var key in dict.Keys) { - var strKey = key as string; - if (strKey is null) continue; + if (key is not string strKey) + { + continue; + } + switch (strKey.ToLowerInvariant()) { case "type": @@ -123,7 +130,9 @@ protected IResource TransformToResource(object inputData) break; } if (resourceData.Id > 0 && resourceData.Type > 0) + { break; + } } break; case PSObject ps: @@ -145,7 +154,9 @@ protected IResource TransformToResource(object inputData) break; } if (resourceData.Id > 0 && resourceData.Type > 0) + { break; + } } break; default: @@ -172,7 +183,9 @@ protected IResource TransformToResource(object inputData) break; } if (resourceData.Id > 0 && resourceData.Type > 0) + { break; + } } } break; From b5a494cd3087e21b27d412bb0d16defb9c55438a Mon Sep 17 00:00:00 2001 From: teramako Date: Tue, 12 Nov 2024 21:29:55 +0900 Subject: [PATCH 45/84] Fixes #95: Remove position attribute from `-Resource` parameter. --- src/Jagabata/Cmdlets/ActivityStreamCommand.cs | 2 +- src/Jagabata/Cmdlets/AdHocCommandCommand.cs | 2 +- src/Jagabata/Cmdlets/ApplicationCommand.cs | 2 +- src/Jagabata/Cmdlets/CredentialCommand.cs | 2 +- src/Jagabata/Cmdlets/GroupCommand.cs | 2 +- src/Jagabata/Cmdlets/HostCommand.cs | 2 +- src/Jagabata/Cmdlets/InstanceGroupCommand.cs | 2 +- src/Jagabata/Cmdlets/InventoryCommand.cs | 2 +- src/Jagabata/Cmdlets/InventorySourceCommand.cs | 2 +- src/Jagabata/Cmdlets/InventoryUpdateCommand.cs | 2 +- src/Jagabata/Cmdlets/JobEventCommand.cs | 2 +- src/Jagabata/Cmdlets/JobHostSummaryCommand.cs | 2 +- src/Jagabata/Cmdlets/JobTemplateCommand.cs | 2 +- src/Jagabata/Cmdlets/LabelCommand.cs | 2 +- src/Jagabata/Cmdlets/NotificationCommand.cs | 2 +- src/Jagabata/Cmdlets/NotificationTemplateCommand.cs | 6 +++--- src/Jagabata/Cmdlets/ProjectCommand.cs | 2 +- src/Jagabata/Cmdlets/RoleCommand.cs | 4 ++-- src/Jagabata/Cmdlets/ScheduleCommand.cs | 2 +- src/Jagabata/Cmdlets/TeamCommand.cs | 2 +- src/Jagabata/Cmdlets/TokenCommand.cs | 2 +- src/Jagabata/Cmdlets/UnifiedJobCommand.cs | 2 +- src/Jagabata/Cmdlets/UserCommand.cs | 4 ++-- src/Jagabata/Cmdlets/WorkflowJobCommand.cs | 2 +- 24 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Jagabata/Cmdlets/ActivityStreamCommand.cs b/src/Jagabata/Cmdlets/ActivityStreamCommand.cs index 483280c..82f700a 100644 --- a/src/Jagabata/Cmdlets/ActivityStreamCommand.cs +++ b/src/Jagabata/Cmdlets/ActivityStreamCommand.cs @@ -48,7 +48,7 @@ public class FindActivityStreamCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.OAuth2Application, ResourceType.OAuth2AccessToken, diff --git a/src/Jagabata/Cmdlets/AdHocCommandCommand.cs b/src/Jagabata/Cmdlets/AdHocCommandCommand.cs index 9404093..4c1783c 100644 --- a/src/Jagabata/Cmdlets/AdHocCommandCommand.cs +++ b/src/Jagabata/Cmdlets/AdHocCommandCommand.cs @@ -31,7 +31,7 @@ public class FindAdHocCommandJobCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Inventory, ResourceType.Host, diff --git a/src/Jagabata/Cmdlets/ApplicationCommand.cs b/src/Jagabata/Cmdlets/ApplicationCommand.cs index 2e0bfeb..ead5f72 100644 --- a/src/Jagabata/Cmdlets/ApplicationCommand.cs +++ b/src/Jagabata/Cmdlets/ApplicationCommand.cs @@ -31,7 +31,7 @@ public class FindApplicationCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Organization, ResourceType.User diff --git a/src/Jagabata/Cmdlets/CredentialCommand.cs b/src/Jagabata/Cmdlets/CredentialCommand.cs index 03d743a..03cd2dd 100644 --- a/src/Jagabata/Cmdlets/CredentialCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialCommand.cs @@ -42,7 +42,7 @@ public class FindCredentialCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Organization, ResourceType.User, diff --git a/src/Jagabata/Cmdlets/GroupCommand.cs b/src/Jagabata/Cmdlets/GroupCommand.cs index 1402256..eb75687 100644 --- a/src/Jagabata/Cmdlets/GroupCommand.cs +++ b/src/Jagabata/Cmdlets/GroupCommand.cs @@ -35,7 +35,7 @@ public class FindGroupCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceIdTransformation(AcceptableTypes = [ ResourceType.Inventory, ResourceType.Group, diff --git a/src/Jagabata/Cmdlets/HostCommand.cs b/src/Jagabata/Cmdlets/HostCommand.cs index b43e289..5e6d489 100644 --- a/src/Jagabata/Cmdlets/HostCommand.cs +++ b/src/Jagabata/Cmdlets/HostCommand.cs @@ -34,7 +34,7 @@ public class FindHostCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Inventory, ResourceType.InventorySource, diff --git a/src/Jagabata/Cmdlets/InstanceGroupCommand.cs b/src/Jagabata/Cmdlets/InstanceGroupCommand.cs index 5b47026..6ca632b 100644 --- a/src/Jagabata/Cmdlets/InstanceGroupCommand.cs +++ b/src/Jagabata/Cmdlets/InstanceGroupCommand.cs @@ -37,7 +37,7 @@ public class FindInstanceGroupCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Instance, ResourceType.Organization, diff --git a/src/Jagabata/Cmdlets/InventoryCommand.cs b/src/Jagabata/Cmdlets/InventoryCommand.cs index 8312cde..3a3b2a6 100644 --- a/src/Jagabata/Cmdlets/InventoryCommand.cs +++ b/src/Jagabata/Cmdlets/InventoryCommand.cs @@ -34,7 +34,7 @@ public class FindInventoryCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Organization, ResourceType.Inventory, diff --git a/src/Jagabata/Cmdlets/InventorySourceCommand.cs b/src/Jagabata/Cmdlets/InventorySourceCommand.cs index c7f1bf8..bfa1c54 100644 --- a/src/Jagabata/Cmdlets/InventorySourceCommand.cs +++ b/src/Jagabata/Cmdlets/InventorySourceCommand.cs @@ -34,7 +34,7 @@ public class FindInventorySourceCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineVariable", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineVariable", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Project, ResourceType.Inventory, diff --git a/src/Jagabata/Cmdlets/InventoryUpdateCommand.cs b/src/Jagabata/Cmdlets/InventoryUpdateCommand.cs index 1fdbc3b..55512e1 100644 --- a/src/Jagabata/Cmdlets/InventoryUpdateCommand.cs +++ b/src/Jagabata/Cmdlets/InventoryUpdateCommand.cs @@ -29,7 +29,7 @@ public class FindInventoryUpdateJobCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineVariable", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineVariable", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.ProjectUpdate, ResourceType.InventorySource diff --git a/src/Jagabata/Cmdlets/JobEventCommand.cs b/src/Jagabata/Cmdlets/JobEventCommand.cs index 6f7b00d..4fe731a 100644 --- a/src/Jagabata/Cmdlets/JobEventCommand.cs +++ b/src/Jagabata/Cmdlets/JobEventCommand.cs @@ -22,7 +22,7 @@ public class FindJobEventCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } = 0; - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Job, ResourceType.ProjectUpdate, diff --git a/src/Jagabata/Cmdlets/JobHostSummaryCommand.cs b/src/Jagabata/Cmdlets/JobHostSummaryCommand.cs index 49655cd..3821768 100644 --- a/src/Jagabata/Cmdlets/JobHostSummaryCommand.cs +++ b/src/Jagabata/Cmdlets/JobHostSummaryCommand.cs @@ -30,7 +30,7 @@ public class FindJobHostSummaryCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput")] [ResourceTransformation(AcceptableTypes = [ ResourceType.Job, ResourceType.Host, diff --git a/src/Jagabata/Cmdlets/JobTemplateCommand.cs b/src/Jagabata/Cmdlets/JobTemplateCommand.cs index e267007..adc029b 100644 --- a/src/Jagabata/Cmdlets/JobTemplateCommand.cs +++ b/src/Jagabata/Cmdlets/JobTemplateCommand.cs @@ -38,7 +38,7 @@ public class FindJobTemplateCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Organization, ResourceType.Inventory diff --git a/src/Jagabata/Cmdlets/LabelCommand.cs b/src/Jagabata/Cmdlets/LabelCommand.cs index f213ac2..01bcc09 100644 --- a/src/Jagabata/Cmdlets/LabelCommand.cs +++ b/src/Jagabata/Cmdlets/LabelCommand.cs @@ -38,7 +38,7 @@ public class FindLabelCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Inventory, ResourceType.JobTemplate, diff --git a/src/Jagabata/Cmdlets/NotificationCommand.cs b/src/Jagabata/Cmdlets/NotificationCommand.cs index eaf3f49..4dd4e15 100644 --- a/src/Jagabata/Cmdlets/NotificationCommand.cs +++ b/src/Jagabata/Cmdlets/NotificationCommand.cs @@ -38,7 +38,7 @@ public class FindNotificationCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineVariable", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineVariable", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.NotificationTemplate, ResourceType.Job, diff --git a/src/Jagabata/Cmdlets/NotificationTemplateCommand.cs b/src/Jagabata/Cmdlets/NotificationTemplateCommand.cs index 0175d1c..a68e1bb 100644 --- a/src/Jagabata/Cmdlets/NotificationTemplateCommand.cs +++ b/src/Jagabata/Cmdlets/NotificationTemplateCommand.cs @@ -111,7 +111,7 @@ public class FindNotificationTemplateForErrorCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Organization, ResourceType.Project, @@ -169,7 +169,7 @@ public class FindNotificationTemplateForStartedCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Organization, ResourceType.Project, @@ -232,7 +232,7 @@ public class FindNotificationTemplateForSuccessCommand : FindCommandBase "notification_type", "messages"])] public override string[] OrderBy { get; set; } = ["id"]; - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Organization, ResourceType.Project, diff --git a/src/Jagabata/Cmdlets/ProjectCommand.cs b/src/Jagabata/Cmdlets/ProjectCommand.cs index 20feea9..c74a311 100644 --- a/src/Jagabata/Cmdlets/ProjectCommand.cs +++ b/src/Jagabata/Cmdlets/ProjectCommand.cs @@ -34,7 +34,7 @@ public class FindProjectCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineVariable", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineVariable", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Organization, ResourceType.User, diff --git a/src/Jagabata/Cmdlets/RoleCommand.cs b/src/Jagabata/Cmdlets/RoleCommand.cs index 7e23a51..5080877 100644 --- a/src/Jagabata/Cmdlets/RoleCommand.cs +++ b/src/Jagabata/Cmdlets/RoleCommand.cs @@ -33,7 +33,7 @@ public class FindRoleCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput")] [ResourceTransformation(AcceptableTypes = [ ResourceType.User, ResourceType.Team @@ -85,7 +85,7 @@ public class FindObjectRoleCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput")] [ResourceTransformation(AcceptableTypes = [ ResourceType.InstanceGroup, ResourceType.Organization, diff --git a/src/Jagabata/Cmdlets/ScheduleCommand.cs b/src/Jagabata/Cmdlets/ScheduleCommand.cs index 00b449d..4ce58f4 100644 --- a/src/Jagabata/Cmdlets/ScheduleCommand.cs +++ b/src/Jagabata/Cmdlets/ScheduleCommand.cs @@ -36,7 +36,7 @@ public class FindScheduleCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Project, ResourceType.InventorySource, diff --git a/src/Jagabata/Cmdlets/TeamCommand.cs b/src/Jagabata/Cmdlets/TeamCommand.cs index dc3394d..ffc25f1 100644 --- a/src/Jagabata/Cmdlets/TeamCommand.cs +++ b/src/Jagabata/Cmdlets/TeamCommand.cs @@ -36,7 +36,7 @@ public class FindTeamCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Organization, ResourceType.User, diff --git a/src/Jagabata/Cmdlets/TokenCommand.cs b/src/Jagabata/Cmdlets/TokenCommand.cs index b77d4f5..ae76e1b 100644 --- a/src/Jagabata/Cmdlets/TokenCommand.cs +++ b/src/Jagabata/Cmdlets/TokenCommand.cs @@ -33,7 +33,7 @@ public class FindTokenCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.OAuth2Application, ResourceType.User diff --git a/src/Jagabata/Cmdlets/UnifiedJobCommand.cs b/src/Jagabata/Cmdlets/UnifiedJobCommand.cs index 9064d73..80dccc3 100644 --- a/src/Jagabata/Cmdlets/UnifiedJobCommand.cs +++ b/src/Jagabata/Cmdlets/UnifiedJobCommand.cs @@ -28,7 +28,7 @@ public class FindUnifiedJobCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.JobTemplate, ResourceType.WorkflowJobTemplate, diff --git a/src/Jagabata/Cmdlets/UserCommand.cs b/src/Jagabata/Cmdlets/UserCommand.cs index adbbac3..2992beb 100644 --- a/src/Jagabata/Cmdlets/UserCommand.cs +++ b/src/Jagabata/Cmdlets/UserCommand.cs @@ -51,7 +51,7 @@ public class FindUserCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.Organization, ResourceType.Team, @@ -122,7 +122,7 @@ public class FindAccessListCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.InstanceGroup, ResourceType.Organization, diff --git a/src/Jagabata/Cmdlets/WorkflowJobCommand.cs b/src/Jagabata/Cmdlets/WorkflowJobCommand.cs index 767aa7f..d92504b 100644 --- a/src/Jagabata/Cmdlets/WorkflowJobCommand.cs +++ b/src/Jagabata/Cmdlets/WorkflowJobCommand.cs @@ -29,7 +29,7 @@ public class FindWorkflowJobCommand : FindCommandBase [Parameter(Mandatory = true, ParameterSetName = "AssociatedWith", Position = 1)] public ulong Id { get; set; } - [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true, Position = 0)] + [Parameter(Mandatory = true, ParameterSetName = "PipelineInput", ValueFromPipeline = true)] [ResourceTransformation(AcceptableTypes = [ ResourceType.JobTemplate, ResourceType.WorkflowApprovalTemplate From a2c53b9683689b5be729b9ce7192c0203e8bf85b Mon Sep 17 00:00:00 2001 From: teramako Date: Wed, 13 Nov 2024 22:17:38 +0900 Subject: [PATCH 46/84] :sparkles: Serialize/Deserialize `ask_at_runtime` for CredentialStringInputField --- src/Jagabata/Resources/CredentialType.cs | 25 ++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Jagabata/Resources/CredentialType.cs b/src/Jagabata/Resources/CredentialType.cs index 3180d4d..02f087c 100644 --- a/src/Jagabata/Resources/CredentialType.cs +++ b/src/Jagabata/Resources/CredentialType.cs @@ -189,7 +189,8 @@ public record CredentialStringInputField(string Id, string? Format, bool Secret = false, bool Multiline = false, - string? Default = null) + string? Default = null, + bool AskAtRuntime = false) : CredentialInputField(Id, Label, Type, HelpText) { public override string ToString() @@ -204,6 +205,7 @@ public override string ToString() if (Format is not null) sb.Append($", Format = {Format}"); if (Secret) sb.Append(", Secret = True"); if (Multiline) sb.Append(", Multiline = True"); + if (AskAtRuntime) sb.Append(", AskAtRuntime = True"); if (HelpText is not null) sb.Append($", HelpText = {HelpText}"); sb.Append(" }"); return sb.ToString(); @@ -212,10 +214,14 @@ public override string ToString() internal class CredentialInputFieldConverter : JsonConverter { - public override CredentialInputField? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override CredentialInputField? Read(ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options) { - (string id, string label, string? help_text, string[]? choices, string? format, string type, bool secret, bool multiline) = - ("", "", null, null, null, "string", false, false); + ( + string id, string label, string? help_text, string[]? choices, string? format, + string type, bool secret, bool multiline, bool askAtRuntime + ) = ("", "", null, null, null, "string", false, false, false); string? defaultString = null; bool? defaultBool = null; while (reader.Read()) @@ -228,8 +234,8 @@ internal class CredentialInputFieldConverter : JsonConverter Date: Thu, 14 Nov 2024 23:27:57 +0900 Subject: [PATCH 47/84] :art: Add format for Jagabata.Resource.CredentialInputField --- src/formats.ps1xml | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/formats.ps1xml b/src/formats.ps1xml index cbe37a8..de87e4e 100644 --- a/src/formats.ps1xml +++ b/src/formats.ps1xml @@ -917,6 +917,73 @@ + + CredentialInputField + + Jagabata.Resources.CredentialStringInputField + Jagabata.Resources.CredentialBoolInputField + + + + + + + Right + + + + + Right + + + Right + + + + + Right + + + + + + true + + + Id + + + Type + + + Label + + + Format + + + Secret + + + Multiline + + + Default + + + Choices + + + AskAtRuntime + + + HelpText + + + + + + Inventory From b8d6c7e4b85f669a582c5a21c3b3220dc2493696 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 16 Nov 2024 23:55:33 +0900 Subject: [PATCH 48/84] :recycle: fix format --- src/Jagabata/Resources/Survey.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Jagabata/Resources/Survey.cs b/src/Jagabata/Resources/Survey.cs index a10455f..2ee01ce 100644 --- a/src/Jagabata/Resources/Survey.cs +++ b/src/Jagabata/Resources/Survey.cs @@ -81,16 +81,22 @@ internal class SurveySpecConverter : JsonConverter { case "max": if (reader.TryGetInt32(out int max)) + { spec.Max = max; + } break; case "min": if (reader.TryGetInt32(out int min)) + { spec.Min = min; + } break; case "type": var typeName = reader.GetString(); if (Enum.TryParse(typeName, true, out var type)) + { spec.Type = type; + } break; case "choices": switch (reader.TokenType) @@ -110,9 +116,13 @@ internal class SurveySpecConverter : JsonConverter { case JsonTokenType.Number: if (reader.TryGetInt32(out var defaultInt)) + { spec.Default = defaultInt; + } else if (reader.TryGetSingle(out var defaultFloat)) + { spec.Default = defaultFloat; + } break; case JsonTokenType.String: default: @@ -164,7 +174,10 @@ public override void Write(Utf8JsonWriter writer, SurveySpec value, JsonSerializ { writer.WritePropertyName("choices"); writer.WriteStartArray(); - foreach (var item in list) writer.WriteStringValue(item.ToString()); + foreach (var item in list) + { + writer.WriteStringValue(item.ToString()); + } writer.WriteEndArray(); } else From 91c7fe6b6746c2dd21b6feacc0b18d8f45f12c89 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 16 Nov 2024 23:56:15 +0900 Subject: [PATCH 49/84] :recycle: Remove the unnecessary assignment. --- src/Jagabata/Resources/Survey.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Jagabata/Resources/Survey.cs b/src/Jagabata/Resources/Survey.cs index 2ee01ce..fccaa56 100644 --- a/src/Jagabata/Resources/Survey.cs +++ b/src/Jagabata/Resources/Survey.cs @@ -46,11 +46,11 @@ public SurveySpec(SurveySpecType type, string name, string variableName) : this( public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public SurveySpecType Type { get; internal set; } - public bool Required { get; set; } = false; + public bool Required { get; set; } public string Variable { get; set; } = string.Empty; public virtual object? Default { get; set; } public virtual object Choices { get; set; } = string.Empty; - public int Min { get; set; } = 0; + public int Min { get; set; } public int Max { get; set; } = 1024; public bool NewQuestion { get; set; } From ba974d6356ced67ef028bdbad167811add998004 Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 17 Nov 2024 11:17:29 +0900 Subject: [PATCH 50/84] :bug: fix RelatedResourceConverter (#98) Crash the powershell process when try to serialize a Resource object, because of a bug for `Jagabata.Json+RelatedResourceConverter.Write()` --- src/Jagabata/Json.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Jagabata/Json.cs b/src/Jagabata/Json.cs index da22567..d89e2ee 100644 --- a/src/Jagabata/Json.cs +++ b/src/Jagabata/Json.cs @@ -173,7 +173,25 @@ public class RelatedResourceConverter : JsonConverter public override void Write(Utf8JsonWriter writer, RelatedDictionary value, JsonSerializerOptions options) { - JsonSerializer.Serialize(writer, value, options); + writer.WriteStartObject(); + foreach (var kv in value) + { + writer.WritePropertyName(kv.Key); + if (kv.Value is IList list) + { + writer.WriteStartArray(); + foreach (var item in list) + { + writer.WriteStringValue($"{item}"); + } + writer.WriteEndArray(); + } + else + { + writer.WriteStringValue($"{kv.Value}"); + } + } + writer.WriteEndObject(); } } /// From 78c613036382434d5e7eb888d8b381089aed6a46 Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 18 Nov 2024 22:04:09 +0900 Subject: [PATCH 51/84] :+1: New namespace `Jagabata.CredentialType` and classes --- src/Jagabata/CredentialType/BoolField.cs | 57 +++++ src/Jagabata/CredentialType/ChoiceField.cs | 59 +++++ src/Jagabata/CredentialType/FieldBase.cs | 93 ++++++++ src/Jagabata/CredentialType/FieldFormat.cs | 11 + src/Jagabata/CredentialType/FieldList.cs | 10 + .../CredentialType/FieldListConverter.cs | 202 ++++++++++++++++++ src/Jagabata/CredentialType/FieldType.cs | 11 + src/Jagabata/CredentialType/SecretField.cs | 16 ++ .../CredentialType/SshPrivateKeyField.cs | 20 ++ src/Jagabata/CredentialType/StringField.cs | 88 ++++++++ src/Jagabata/CredentialType/UrlField.cs | 16 ++ 11 files changed, 583 insertions(+) create mode 100644 src/Jagabata/CredentialType/BoolField.cs create mode 100644 src/Jagabata/CredentialType/ChoiceField.cs create mode 100644 src/Jagabata/CredentialType/FieldBase.cs create mode 100644 src/Jagabata/CredentialType/FieldFormat.cs create mode 100644 src/Jagabata/CredentialType/FieldList.cs create mode 100644 src/Jagabata/CredentialType/FieldListConverter.cs create mode 100644 src/Jagabata/CredentialType/FieldType.cs create mode 100644 src/Jagabata/CredentialType/SecretField.cs create mode 100644 src/Jagabata/CredentialType/SshPrivateKeyField.cs create mode 100644 src/Jagabata/CredentialType/StringField.cs create mode 100644 src/Jagabata/CredentialType/UrlField.cs diff --git a/src/Jagabata/CredentialType/BoolField.cs b/src/Jagabata/CredentialType/BoolField.cs new file mode 100644 index 0000000..08c8697 --- /dev/null +++ b/src/Jagabata/CredentialType/BoolField.cs @@ -0,0 +1,57 @@ +using System.Globalization; +using System.Text; +using System.Text.Json.Serialization; + +namespace Jagabata.CredentialType; + +/// +/// Checkbox field +/// +public sealed class BoolField : FieldBase +{ + public BoolField() : base(FieldType.Boolean) + { } + public BoolField(string id, string label) : base(FieldType.Boolean, id, label) + { } + + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public override object? Default + { + get => _default; + set => _default = value switch + { + null => null, + bool boolValue => boolValue, + _ => throw new InvalidCastException($"value should be boolean type: {value.GetType()}"), + }; + } + private bool? _default; + + public override string ToString() + { + var iv = CultureInfo.InvariantCulture; + var sb = new StringBuilder(); + sb.Append('{'); + sb.Append(iv, $" Id = {Id}"); + sb.Append(iv, $", Label = {Label}"); + sb.Append(iv, $", Type = {Type}"); + if (Required is not null) + { + sb.Append(iv, $", Required = {Required}"); + } + if (Default is not null) + { + sb.Append(iv, $", Default = {Default}"); + } + if (AskAtRuntime is not null) + { + sb.Append(iv, $", AskAtRuntime = {AskAtRuntime}"); + } + if (HelpText is not null) + { + sb.Append(iv, $", HelpText = {HelpText}"); + } + sb.Append(" }"); + return sb.ToString(); + } +} diff --git a/src/Jagabata/CredentialType/ChoiceField.cs b/src/Jagabata/CredentialType/ChoiceField.cs new file mode 100644 index 0000000..a143c72 --- /dev/null +++ b/src/Jagabata/CredentialType/ChoiceField.cs @@ -0,0 +1,59 @@ +using System.Globalization; +using System.Text; +using System.Text.Json.Serialization; + +namespace Jagabata.CredentialType; + +/// +/// Selectbox field +/// +public sealed class ChoiceField : FieldBase +{ + public ChoiceField() : base(FieldType.String) + { } + public ChoiceField(string id, string label) : base(FieldType.String, id, label) + { } + + public string[] Choices { get; set; } = []; + + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public override object? Default + { + get => _default; + set => _default = value switch + { + null => null, + string str => str, + _ => throw new InvalidCastException($"value should be string type: {value.GetType()}"), + }; + } + private string? _default; + + public override string ToString() + { + var iv = CultureInfo.InvariantCulture; + var sb = new StringBuilder(); + sb.Append('{'); + sb.Append(iv, $" Id = {Id}"); + sb.Append(iv, $", Label = {Label}"); + sb.Append(iv, $", Type = {Type}"); + if (_default is not null) + { + sb.Append(iv, $", Default = {_default}"); + } + if (Choices is not null) + { + sb.Append(iv, $", Choices = [{string.Join(", ", Choices)}]"); + } + if (AskAtRuntime is not null) + { + sb.Append(iv, $", AskAtRuntime = {AskAtRuntime}"); + } + if (HelpText is not null) + { + sb.Append(iv, $", HelpText = {HelpText}"); + } + sb.Append(" }"); + return sb.ToString(); + } +} diff --git a/src/Jagabata/CredentialType/FieldBase.cs b/src/Jagabata/CredentialType/FieldBase.cs new file mode 100644 index 0000000..aa805cd --- /dev/null +++ b/src/Jagabata/CredentialType/FieldBase.cs @@ -0,0 +1,93 @@ +using System.Text.Json.Serialization; +using System.Text.RegularExpressions; + +namespace Jagabata.CredentialType; + +public abstract partial class FieldBase : IEquatable +{ + public FieldBase(FieldType type) + { + Type = type; + } + public FieldBase(FieldType type, string id) + { + Type = type; + Id = id; + } + public FieldBase(FieldType type, string id, string label) + { + Type = type; + Id = id; + Label = label; + } + + [GeneratedRegex(@"^[a-zA-Z_]+[a-zA-Z0-9_]*$")] + private static partial Regex idPattern(); + + /// + /// A unique name used to reference the field value + /// + [JsonPropertyOrder(1)] + public string Id + { + get => _id; + init + { + if (!idPattern().IsMatch(value)) + { + throw new InvalidDataException("Id must be '^[a-zA-Z_]+[a-zA-Z0-9]*$'"); + } + _id = value; + } + } + private string _id = string.Empty; + + /// + /// A unique label for the field + /// + [JsonPropertyOrder(2)] + public string Label { get; set; } = string.Empty; + + /// + /// Field type: "String" or "Boolean" (default: "String") + /// + [JsonPropertyOrder(3)] + public FieldType Type { get; } = FieldType.String; + + /// + /// User-facing short text describing the field. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? HelpText { get; set; } + + [JsonIgnore] + public bool? Required { get; set; } + + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public virtual object? Default { get; set; } + + /// + /// If true, this field is given a checkbox that can be used to prompt for input on startup. + /// + /// + /// For only managed CredentialType. + /// (Not supported for custom CredentialType) + /// + [JsonIgnore] + public bool? AskAtRuntime { get; internal set; } + + public bool Equals(FieldBase? other) + { + return other is not null && string.Equals(Id, other.Id, StringComparison.Ordinal); + } + + public override bool Equals(object? obj) + { + return obj is FieldBase field && Equals(field); + } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } +} diff --git a/src/Jagabata/CredentialType/FieldFormat.cs b/src/Jagabata/CredentialType/FieldFormat.cs new file mode 100644 index 0000000..745f986 --- /dev/null +++ b/src/Jagabata/CredentialType/FieldFormat.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +namespace Jagabata.CredentialType; + +[JsonConverter(typeof(Json.EnumUpperCamelCaseStringConverter))] +public enum FieldFormat +{ + SshPrivateKey, + VaultId, + Url +} diff --git a/src/Jagabata/CredentialType/FieldList.cs b/src/Jagabata/CredentialType/FieldList.cs new file mode 100644 index 0000000..aca455f --- /dev/null +++ b/src/Jagabata/CredentialType/FieldList.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace Jagabata.CredentialType; + +[JsonConverter(typeof(FieldListConverter))] +public class FieldList : List +{ + public Dictionary? Dependencies { get; internal set; } + public Dictionary[]? Metadata { get; internal set; } +} diff --git a/src/Jagabata/CredentialType/FieldListConverter.cs b/src/Jagabata/CredentialType/FieldListConverter.cs new file mode 100644 index 0000000..af503d5 --- /dev/null +++ b/src/Jagabata/CredentialType/FieldListConverter.cs @@ -0,0 +1,202 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Jagabata.CredentialType; + +internal class FieldListConverter : JsonConverter +{ + private static FieldBase? ReadField(ref Utf8JsonReader reader, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartObject) + { + throw new JsonException(); + } + + (string Id, string Label, string? HelpText, string[]? Choices, FieldFormat? Format, FieldType Type, + bool? Secret, bool? Multiline, string? DefaultString, bool? DefaultBool, bool? AskAtRuntime) field = + (string.Empty, string.Empty, null, null, null, FieldType.String, null, null, null, null, null); + + while (reader.Read()) + { + switch (reader.TokenType) + { + case JsonTokenType.EndObject: + return field.Type switch + { + FieldType.Boolean => new BoolField(field.Id, field.Label) + { + Default = field.DefaultBool, + HelpText = field.HelpText, + AskAtRuntime = field.AskAtRuntime + }, + FieldType.String => field.Choices is null + ? new StringField(field.Id, field.Label) + { + Format = field.Format, + Secret = field.Secret, + Multiline = field.Multiline, + Default = field.DefaultString, + HelpText = field.HelpText, + AskAtRuntime = field.AskAtRuntime + } + : new ChoiceField(field.Id, field.Label) + { + Choices = field.Choices, + Default = field.DefaultString, + HelpText = field.HelpText, + AskAtRuntime = field.AskAtRuntime + }, + _ => throw new JsonException($"Unknown field type: {field.Type}"), + }; + case JsonTokenType.PropertyName: + string fieldPropertyName = reader.GetString() ?? throw new JsonException("PropertyName is null"); + reader.Read(); + switch (fieldPropertyName) + { + case "id": + field.Id = reader.GetString() ?? ""; + break; + case "label": + field.Label = reader.GetString() ?? ""; + break; + case "help_text": + field.HelpText = reader.GetString(); + break; + case "choices": + field.Choices = JsonSerializer.Deserialize(ref reader, options); + break; + case "format": + field.Format = JsonSerializer.Deserialize(ref reader, options); + break; + case "secret": + field.Secret = reader.GetBoolean(); + break; + case "multiline": + field.Multiline = reader.GetBoolean(); + break; + case "type": + field.Type = JsonSerializer.Deserialize(ref reader, options); + break; + case "ask_at_runtime": + field.AskAtRuntime = reader.GetBoolean(); + break; + case "default": + switch (reader.TokenType) + { + case JsonTokenType.String: + field.DefaultString = reader.GetString() ?? ""; + break; + case JsonTokenType.True: + case JsonTokenType.False: + field.DefaultBool = reader.GetBoolean(); + break; + } + break; + } + continue; + } + } + throw new JsonException(); + } + + public override FieldList? Read(ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options) + { + var container = new FieldList(); + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + { + return container; + } + if (reader.TokenType != JsonTokenType.PropertyName) + { + throw new JsonException($"TokenType is not PropertyName: {reader.TokenType}"); + } + string propertyName = reader.GetString() ?? throw new JsonException("PropertyName is null"); + reader.Read(); + switch (propertyName) + { + case "fields": + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndArray) + { + break; + } + + var field = ReadField(ref reader, options); + if (field is not null) + { + container.Add(field); + } + } + break; + case "required": + var requiredFields = JsonSerializer.Deserialize(ref reader, options); + if (requiredFields is not null) + { + foreach (var id in requiredFields) + { + var field = container.FirstOrDefault(item => string.Equals(item.Id, id, StringComparison.Ordinal)); + if (field is not null) + { + field.Required = true; + } + } + } + break; + case "dependencies": + container.Dependencies = JsonSerializer.Deserialize>(ref reader, options); + break; + case "metadata": + container.Metadata = JsonSerializer.Deserialize[]>(ref reader, options); + break; + } + } + throw new JsonException(); + } + + public override void Write(Utf8JsonWriter writer, + FieldList value, + JsonSerializerOptions options) + { + var requiredFields = new List(); + + writer.WriteStartObject(); + + writer.WriteStartArray("fields"); + foreach (var field in value) + { + if (field.Required is not null && (bool)field.Required) + { + requiredFields.Add(field.Id); + } + JsonSerializer.Serialize(writer, field, field.GetType(), options); + } + writer.WriteEndArray(); + + if (value.Metadata is not null) + { + writer.WriteStartArray("metadata"); + JsonSerializer.Serialize(writer, value.Metadata, options); + writer.WriteEndArray(); + } + + if (value.Dependencies is not null) + { + writer.WriteStartArray("dependencies"); + JsonSerializer.Serialize(writer, value.Dependencies, options); + writer.WriteEndArray(); + } + + writer.WriteStartArray("required"); + foreach (var id in requiredFields) + { + writer.WriteStringValue(id); + } + writer.WriteEndArray(); + writer.WriteEndObject(); + } +} diff --git a/src/Jagabata/CredentialType/FieldType.cs b/src/Jagabata/CredentialType/FieldType.cs new file mode 100644 index 0000000..1459fe2 --- /dev/null +++ b/src/Jagabata/CredentialType/FieldType.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +namespace Jagabata.CredentialType; + +[JsonConverter(typeof(Json.EnumUpperCamelCaseStringConverter))] +public enum FieldType +{ + String, + Boolean +} + diff --git a/src/Jagabata/CredentialType/SecretField.cs b/src/Jagabata/CredentialType/SecretField.cs new file mode 100644 index 0000000..4c0c399 --- /dev/null +++ b/src/Jagabata/CredentialType/SecretField.cs @@ -0,0 +1,16 @@ +namespace Jagabata.CredentialType; + +/// +/// Secret Input field +/// +public class SecretField : StringField +{ + public SecretField() : base() + { + Secret = true; + } + public SecretField(string id, string label) : base(id, label) + { + Secret = true; + } +} diff --git a/src/Jagabata/CredentialType/SshPrivateKeyField.cs b/src/Jagabata/CredentialType/SshPrivateKeyField.cs new file mode 100644 index 0000000..a4535bb --- /dev/null +++ b/src/Jagabata/CredentialType/SshPrivateKeyField.cs @@ -0,0 +1,20 @@ +namespace Jagabata.CredentialType; + +/// +/// SSH Provate Key field +/// +public sealed class SshPrivateKeyField : StringField +{ + public SshPrivateKeyField() : base() + { + Secret = true; + Format = FieldFormat.SshPrivateKey; + Multiline = true; + } + public SshPrivateKeyField(string id, string label) : base(id, label) + { + Secret = true; + Format = FieldFormat.SshPrivateKey; + Multiline = true; + } +} diff --git a/src/Jagabata/CredentialType/StringField.cs b/src/Jagabata/CredentialType/StringField.cs new file mode 100644 index 0000000..a0f7991 --- /dev/null +++ b/src/Jagabata/CredentialType/StringField.cs @@ -0,0 +1,88 @@ +using System.Globalization; +using System.Text; +using System.Text.Json.Serialization; + +namespace Jagabata.CredentialType; + +/// +/// Normal Input field +/// +public class StringField : FieldBase +{ + public StringField() : base(FieldType.String) + { } + public StringField(string id, string label) : base(FieldType.String, id, label) + { } + + /// + /// Optional, can be used to enforce data format validity for SSH private key data + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public FieldFormat? Format { get; internal set; } + + /// + /// Optional, can be used to provide a default value if the field is left empty; + /// when creating a credential of this type, credential forms will use this value + /// as a prefill when making credentials of this type + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public override object? Default + { + get => _default; + set => _default = value switch + { + null => null, + string str => str, + _ => throw new InvalidCastException($"value should be string type: {value.GetType()}"), + }; + } + private string? _default; + + /// + /// If true, the field value will be encrypted + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public bool? Secret { get; internal set; } + + /// + /// If true, the field should be rendered as multi-line for input entry + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public bool? Multiline { get; set; } + + public override string ToString() + { + var iv = CultureInfo.InvariantCulture; + var sb = new StringBuilder(); + sb.Append('{'); + sb.Append(iv, $" Id = {Id}"); + sb.Append(iv, $", Label = {Label}"); + sb.Append(iv, $", Type = {Type}"); + if (Secret is not null) + { + sb.Append(iv, $", Secret = {Secret}"); + } + if (_default is not null) + { + sb.Append(iv, $", Default = {_default}"); + } + if (Format is not null) + { + sb.Append(iv, $", Format = {Format}"); + } + if (Multiline is not null) + { + sb.Append(iv, $", Multiline = {Multiline}"); + } + if (AskAtRuntime is not null) + { + sb.Append(iv, $", AskAtRuntime = {AskAtRuntime}"); + } + if (HelpText is not null) + { + sb.Append(iv, $", HelpText = {HelpText}"); + } + sb.Append(" }"); + return sb.ToString(); + } +} diff --git a/src/Jagabata/CredentialType/UrlField.cs b/src/Jagabata/CredentialType/UrlField.cs new file mode 100644 index 0000000..a3cd9b8 --- /dev/null +++ b/src/Jagabata/CredentialType/UrlField.cs @@ -0,0 +1,16 @@ +namespace Jagabata.CredentialType; + +/// +/// Url Input field +/// +public sealed class UrlField : StringField +{ + public UrlField() : base() + { + Format = FieldFormat.Url; + } + public UrlField(string id, string label) : base(id, label) + { + Format = FieldFormat.Url; + } +} From 7c9ad35d26293b2900005b735125ca8022362a1b Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 18 Nov 2024 22:05:43 +0900 Subject: [PATCH 52/84] Fix path of Jagabata.Resources.CredentialType --- src/Jagabata/Cmdlets/ActivityStreamCommand.cs | 2 +- src/Jagabata/Cmdlets/CredentialCommand.cs | 4 ++-- src/Jagabata/Cmdlets/CredentialTypeCommand.cs | 20 ++++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Jagabata/Cmdlets/ActivityStreamCommand.cs b/src/Jagabata/Cmdlets/ActivityStreamCommand.cs index 82f700a..b061d94 100644 --- a/src/Jagabata/Cmdlets/ActivityStreamCommand.cs +++ b/src/Jagabata/Cmdlets/ActivityStreamCommand.cs @@ -96,7 +96,7 @@ protected override void ProcessRecord() ResourceType.Project => $"{Project.PATH}{Id}/activity_stream/", ResourceType.Team => $"{Team.PATH}{Id}/activity_stream/", ResourceType.Credential => $"{Credential.PATH}{Id}/activity_stream/", - ResourceType.CredentialType => $"{CredentialType.PATH}{Id}/activity_stream/", + ResourceType.CredentialType => $"{Resources.CredentialType.PATH}{Id}/activity_stream/", ResourceType.Inventory => $"{Inventory.PATH}{Id}/activity_stream/", ResourceType.InventorySource => $"{InventorySource.PATH}{Id}/activity_stream/", ResourceType.Group => $"{Group.PATH}{Id}/activity_stream/", diff --git a/src/Jagabata/Cmdlets/CredentialCommand.cs b/src/Jagabata/Cmdlets/CredentialCommand.cs index 03cd2dd..9da621b 100644 --- a/src/Jagabata/Cmdlets/CredentialCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialCommand.cs @@ -107,7 +107,7 @@ protected override void ProcessRecord() ResourceType.Organization => $"{Organization.PATH}{Id}/" + (Galaxy ? "galaxy_credentials/" : "credentials/"), ResourceType.User => $"{User.PATH}{Id}/credentials/", ResourceType.Team => $"{Team.PATH}{Id}/credentials/", - ResourceType.CredentialType => $"{CredentialType.PATH}{Id}/credentials/", + ResourceType.CredentialType => $"{Resources.CredentialType.PATH}{Id}/credentials/", ResourceType.InventorySource => $"{InventorySource.PATH}{Id}/credentials/", ResourceType.InventoryUpdate => $"{InventoryUpdateJob.PATH}{Id}/credentials/", ResourceType.JobTemplate => $"{JobTemplate.PATH}{Id}/credentials/", @@ -208,7 +208,7 @@ public class RegisterCredentialCommand : RegistrationCommandBase ResourceType.Schedule, ResourceType.WorkflowJobTemplateNode ])] - public IResource To { get; set; } = new Resource(0 ,0); + public IResource To { get; set; } = new Resource(0, 0); protected override void ProcessRecord() { diff --git a/src/Jagabata/Cmdlets/CredentialTypeCommand.cs b/src/Jagabata/Cmdlets/CredentialTypeCommand.cs index d423069..e7618bc 100644 --- a/src/Jagabata/Cmdlets/CredentialTypeCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialTypeCommand.cs @@ -7,8 +7,8 @@ namespace Jagabata.Cmdlets { [Cmdlet(VerbsCommon.Get, "CredentialType")] - [OutputType(typeof(CredentialType))] - public class GetCredentialTypeCommand : GetCommandBase + [OutputType(typeof(Resources.CredentialType))] + public class GetCredentialTypeCommand : GetCommandBase { protected override ResourceType AcceptType => ResourceType.CredentialType; @@ -23,7 +23,7 @@ protected override void EndProcessing() } [Cmdlet(VerbsCommon.Find, "CredentialType")] - [OutputType(typeof(CredentialType))] + [OutputType(typeof(Resources.CredentialType))] public class FindCredentialTypeCommand : FindCommandBase { [Parameter()] @@ -44,13 +44,13 @@ protected override void BeginProcessing() } protected override void ProcessRecord() { - Find(CredentialType.PATH); + Find(Resources.CredentialType.PATH); } } [Cmdlet(VerbsCommon.New, "CredentialType", SupportsShouldProcess = true)] - [OutputType(typeof(CredentialType))] - public class NewCredentialTypeCommand : NewCommandBase + [OutputType(typeof(Resources.CredentialType))] + public class NewCredentialTypeCommand : NewCommandBase { [Parameter(Mandatory = true, Position = 0)] public string Name { get; set; } = string.Empty; @@ -79,7 +79,9 @@ protected override Dictionary CreateSendData() { "injectors", Injectors } }; if (Description is not null) + { sendData.Add("description", Description); + } return sendData; } @@ -95,7 +97,7 @@ protected override void ProcessRecord() [Cmdlet(VerbsCommon.Remove, "CredentialType", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)] [OutputType(typeof(void))] - public class RemoveCredentialTypeCommand : RemoveCommandBase + public class RemoveCredentialTypeCommand : RemoveCommandBase { [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0)] [ResourceIdTransformation(AcceptableTypes = [ResourceType.CredentialType])] @@ -108,8 +110,8 @@ protected override void ProcessRecord() } [Cmdlet(VerbsData.Update, "CredentialType", SupportsShouldProcess = true)] - [OutputType(typeof(CredentialType))] - public class UpdateCredentialTypeCommand : UpdateCommandBase + [OutputType(typeof(Resources.CredentialType))] + public class UpdateCredentialTypeCommand : UpdateCommandBase { [Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0)] [ResourceIdTransformation(AcceptableTypes = [ResourceType.CredentialType])] From 9f915d4900c23c2a2e0e372d843bf543bd7f00ef Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 18 Nov 2024 22:09:08 +0900 Subject: [PATCH 53/84] Change type of `Inputs` property in CredentialType --- src/Jagabata/Resources/CredentialType.cs | 212 +---------------------- 1 file changed, 4 insertions(+), 208 deletions(-) diff --git a/src/Jagabata/Resources/CredentialType.cs b/src/Jagabata/Resources/CredentialType.cs index 02f087c..fb46bcd 100644 --- a/src/Jagabata/Resources/CredentialType.cs +++ b/src/Jagabata/Resources/CredentialType.cs @@ -1,7 +1,6 @@ using System.Collections.Specialized; -using System.Text; -using System.Text.Json; using System.Text.Json.Serialization; +using Jagabata.CredentialType; namespace Jagabata.Resources { @@ -69,7 +68,7 @@ public interface ICredentialType /// string Description { get; } CredentialTypeKind Kind { get; } - CredentialTypeInputs Inputs { get; } + FieldList Inputs { get; } Dictionary> Injectors { get; } } @@ -85,7 +84,7 @@ public class CredentialType(ulong id, CredentialTypeKind kind, string nameSpace, bool managed, - CredentialTypeInputs inputs, + FieldList inputs, Dictionary> injectors) : ICredentialType, IResource { @@ -134,210 +133,7 @@ public record Summary(Capability UserCapabilities); public CredentialTypeKind Kind { get; } = kind; public string Namespace { get; } = nameSpace; public bool Managed { get; } = managed; - public CredentialTypeInputs Inputs { get; } = inputs; + public FieldList Inputs { get; } = inputs; public Dictionary> Injectors { get; } = injectors; } - - public record CredentialTypeInputs(CredentialInputField[] Fields, string[]? Required) - { - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("{ "); - sb.Append("Fields = ["); - if (Fields.Length > 0) sb.Append($" {string.Join(", ", Fields.Select(field => field.Id))} "); - sb.Append(']'); - if (Required is not null) - { - sb.Append(", Required = ["); - if (Required.Length > 0) sb.Append($" {string.Join(", ", Required)} "); - sb.Append(']'); - } - sb.Append(" }"); - return sb.ToString(); - } - } - - [JsonConverter(typeof(CredentialInputFieldConverter))] - public abstract record CredentialInputField(string Id, string Label, string Type, string? HelpText); - - public record CredentialBoolInputField(string Id, - string Label, - string Type, - string? HelpText, - bool? Default) - : CredentialInputField(Id, Label, Type, HelpText) - { - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append('{'); - sb.Append($" Id = {Id}"); - sb.Append($", Label = {Label}"); - sb.Append($", Type = {Type}"); - if (Default is not null) sb.Append($", Default = {Default}"); - if (HelpText is not null) sb.Append($", HelpText = {HelpText}"); - sb.Append(" }"); - return sb.ToString(); - } - } - public record CredentialStringInputField(string Id, - string Label, - string Type, - string? HelpText, - string[]? Choices, - string? Format, - bool Secret = false, - bool Multiline = false, - string? Default = null, - bool AskAtRuntime = false) - : CredentialInputField(Id, Label, Type, HelpText) - { - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append('{'); - sb.Append($" Id = {Id}"); - sb.Append($", Label = {Label}"); - sb.Append($", Type = {Type}"); - if (Default is not null) sb.Append($", Default = {Default}"); - if (Choices is not null) sb.Append($", Choices = [{string.Join(", ", Choices)}]"); - if (Format is not null) sb.Append($", Format = {Format}"); - if (Secret) sb.Append(", Secret = True"); - if (Multiline) sb.Append(", Multiline = True"); - if (AskAtRuntime) sb.Append(", AskAtRuntime = True"); - if (HelpText is not null) sb.Append($", HelpText = {HelpText}"); - sb.Append(" }"); - return sb.ToString(); - } - } - - internal class CredentialInputFieldConverter : JsonConverter - { - public override CredentialInputField? Read(ref Utf8JsonReader reader, - Type typeToConvert, - JsonSerializerOptions options) - { - ( - string id, string label, string? help_text, string[]? choices, string? format, - string type, bool secret, bool multiline, bool askAtRuntime - ) = ("", "", null, null, null, "string", false, false, false); - string? defaultString = null; - bool? defaultBool = null; - while (reader.Read()) - { - if (reader.TokenType == JsonTokenType.EndObject) - { - switch (type) - { - case "boolean": - return new CredentialBoolInputField(id, label, type, help_text, defaultBool); - case "string": - default: - return new CredentialStringInputField(id, label, type, help_text, choices, format, secret, - multiline, defaultString, askAtRuntime); - } - } - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException($"TokenType is not PropertyName: {reader.TokenType}"); - } - string propertyName = reader.GetString() ?? throw new JsonException("PropertyName is null"); - reader.Read(); - switch (propertyName) - { - case "id": - id = reader.GetString() ?? ""; - break; - case "label": - label = reader.GetString() ?? ""; - break; - case "help_text": - help_text = reader.GetString(); - break; - case "choices": - choices = JsonSerializer.Deserialize(ref reader, options); - break; - case "format": - format = reader.GetString(); - break; - case "secret": - secret = reader.GetBoolean(); - break; - case "multiline": - multiline = reader.GetBoolean(); - break; - case "type": - type = reader.GetString() ?? "string"; - break; - case "ask_at_runtime": - askAtRuntime = reader.GetBoolean(); - break; - case "default": - switch (reader.TokenType) - { - case JsonTokenType.String: - defaultString = reader.GetString() ?? ""; - break; - case JsonTokenType.True: - case JsonTokenType.False: - defaultBool = reader.GetBoolean(); - break; - } - break; - } - } - throw new JsonException(); - } - - public override void Write(Utf8JsonWriter writer, CredentialInputField value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - writer.WriteString("id", value.Id); - writer.WriteString("label", value.Label); - writer.WriteString("type", value.Type); - if (value.HelpText is not null) - { - writer.WriteString("help_text", value.HelpText); - } - switch (value) - { - case CredentialBoolInputField boolField: - if (boolField.Default is not null) - { - writer.WriteBoolean("default", (bool)boolField.Default); - } - break; - case CredentialStringInputField strField: - if (strField.Choices is not null) - { - writer.WritePropertyName("choices"); - JsonSerializer.Serialize(writer, strField.Choices, options); - } - if (strField.Default is not null) - { - writer.WriteString("default", strField.Default); - } - if (strField.Format is not null) - { - writer.WriteString("format", strField.Format); - } - if (strField.Secret) - { - writer.WriteBoolean("secret", strField.Secret); - } - if (strField.Multiline) - { - writer.WriteBoolean("multiline", strField.Multiline); - } - if (strField.AskAtRuntime) - { - writer.WriteBoolean("ask_at_runtime", strField.AskAtRuntime); - } - break; - } - writer.WriteEndObject(); - } - } } - From f76b4743f59bd047a7c754ac557e19fdaf46c8a6 Mon Sep 17 00:00:00 2001 From: teramako Date: Tue, 19 Nov 2024 21:12:12 +0900 Subject: [PATCH 54/84] fix formats --- src/formats.ps1xml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/formats.ps1xml b/src/formats.ps1xml index de87e4e..e273ea8 100644 --- a/src/formats.ps1xml +++ b/src/formats.ps1xml @@ -918,10 +918,11 @@ - CredentialInputField + CredentialTypeInputs - Jagabata.Resources.CredentialStringInputField - Jagabata.Resources.CredentialBoolInputField + Jagabata.CredentialType.StringField + Jagabata.CredentialType.BoolField + Jagabata.CredentialType.ChoiceField @@ -932,6 +933,9 @@ + + Right + Right @@ -961,6 +965,9 @@ Format + + Required + Secret From c4699ac3425ee8d9c1f8bae9c7e1ea35ea783fac Mon Sep 17 00:00:00 2001 From: teramako Date: Tue, 19 Nov 2024 22:18:43 +0900 Subject: [PATCH 55/84] :sparkles: Add `FieldList` parameter for New/Update-CredentialType --- src/Jagabata/Cmdlets/CredentialTypeCommand.cs | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Jagabata/Cmdlets/CredentialTypeCommand.cs b/src/Jagabata/Cmdlets/CredentialTypeCommand.cs index e7618bc..8b6eea2 100644 --- a/src/Jagabata/Cmdlets/CredentialTypeCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialTypeCommand.cs @@ -1,5 +1,6 @@ using Jagabata.Cmdlets.ArgumentTransformation; using Jagabata.Cmdlets.Completer; +using Jagabata.CredentialType; using Jagabata.Resources; using System.Collections; using System.Management.Automation; @@ -63,8 +64,11 @@ public class NewCredentialTypeCommand : NewCommandBase [ValidateSet("net", "cloud")] public string Kind { get; set; } = string.Empty; - [Parameter()] - public IDictionary Inputs { get; set; } = new Hashtable(); + [Parameter(Mandatory = true, ParameterSetName = "InputsDict")] + public IDictionary? Inputs { get; set; } + + [Parameter(Mandatory = true, ParameterSetName = "FieldList")] + public FieldList? FieldList { get; set; } [Parameter()] public IDictionary Injectors { get; set; } = new Hashtable(); @@ -75,9 +79,17 @@ protected override Dictionary CreateSendData() { { "name", Name }, { "kind", Kind }, - { "inputs", Inputs }, { "injectors", Injectors } }; + if (FieldList is not null) + { + sendData.Add("inputs", FieldList); + } + else if (Inputs is not null) + { + sendData.Add("inputs", Inputs); + } + if (Description is not null) { sendData.Add("description", Description); @@ -128,9 +140,12 @@ public class UpdateCredentialTypeCommand : UpdateCommandBase Date: Tue, 19 Nov 2024 22:25:22 +0900 Subject: [PATCH 56/84] :books: Update documents for New/Update-CredentialType --- .../cmdlets/New-AnsibleCredentialType.md | 28 +++++++++++++++++-- .../cmdlets/Update-AnsibleCredentialType.md | 28 +++++++++++++++++-- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/docs/en-US/cmdlets/New-AnsibleCredentialType.md b/docs/en-US/cmdlets/New-AnsibleCredentialType.md index 65abe27..71de281 100644 --- a/docs/en-US/cmdlets/New-AnsibleCredentialType.md +++ b/docs/en-US/cmdlets/New-AnsibleCredentialType.md @@ -12,8 +12,15 @@ Create a CredentialType. ## SYNTAX +### InputsDict ``` -New-AnsibleCredentialType [-Name] [-Description ] [-Kind] [-Inputs ] +New-AnsibleCredentialType [-Name] [-Description ] [-Kind] -Inputs + [-Injectors ] [-WhatIf] [-Confirm] [] +``` + +### FieldList +``` +New-AnsibleCredentialType [-Name] [-Description ] [-Kind] -FieldList [-Injectors ] [-WhatIf] [-Confirm] [] ``` @@ -49,6 +56,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -FieldList +Custom `inputs` of CredentialType which defined by `Jagabata.CredentialType.FieldList` + +```yaml +Type: FieldList +Parameter Sets: FieldList +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Injectors ```yaml @@ -67,10 +89,10 @@ Accept wildcard characters: False ```yaml Type: IDictionary -Parameter Sets: (All) +Parameter Sets: InputsDict Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False diff --git a/docs/en-US/cmdlets/Update-AnsibleCredentialType.md b/docs/en-US/cmdlets/Update-AnsibleCredentialType.md index 2f34323..d8f2e98 100644 --- a/docs/en-US/cmdlets/Update-AnsibleCredentialType.md +++ b/docs/en-US/cmdlets/Update-AnsibleCredentialType.md @@ -12,9 +12,16 @@ Update a CredentialType. ## SYNTAX +### InputsDict ``` Update-AnsibleCredentialType [-Id] [-Name ] [-Description ] [-Kind ] - [-Inputs ] [-Injectors ] [-WhatIf] [-Confirm] [] + -Inputs [-Injectors ] [-WhatIf] [-Confirm] [] +``` + +### FieldList +``` +Update-AnsibleCredentialType [-Id] [-Name ] [-Description ] [-Kind ] + -FieldList [-Injectors ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -47,6 +54,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -FieldList +Custom `inputs` of CredentialType which defined by `Jagabata.CredentialType.FieldList` + +```yaml +Type: FieldList +Parameter Sets: FieldList +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Id CredentialType ID to be updated. @@ -80,10 +102,10 @@ Accept wildcard characters: False ```yaml Type: IDictionary -Parameter Sets: (All) +Parameter Sets: InputsDict Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False From 8f854e7d64a50a2514a84ce0cb7d2ab7f5f7d8f0 Mon Sep 17 00:00:00 2001 From: teramako Date: Tue, 19 Nov 2024 22:31:09 +0900 Subject: [PATCH 57/84] :books: Update document for #96 Commit: b5a494cd3087e21b27d412bb0d16defb9c55438a --- docs/en-US/cmdlets/Find-AnsibleAccessList.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleActivityStream.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleAdHocCommandJob.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleApplication.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleCredential.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleGroup.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleHost.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleInstanceGroup.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleInventory.md | 7 +++---- docs/en-US/cmdlets/Find-AnsibleInventorySource.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleInventoryUpdateJob.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleJobEvent.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleJobHostSummary.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleJobTemplate.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleLabel.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleNotification.md | 4 ++-- .../cmdlets/Find-AnsibleNotificationTemplateForError.md | 4 ++-- .../cmdlets/Find-AnsibleNotificationTemplateForStarted.md | 4 ++-- .../cmdlets/Find-AnsibleNotificationTemplateForSuccess.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleObjectRole.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleProject.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleRole.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleSchedule.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleTeam.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleToken.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleUnifiedJob.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleUser.md | 4 ++-- docs/en-US/cmdlets/Find-AnsibleWorkflowJob.md | 8 ++++---- 28 files changed, 59 insertions(+), 60 deletions(-) diff --git a/docs/en-US/cmdlets/Find-AnsibleAccessList.md b/docs/en-US/cmdlets/Find-AnsibleAccessList.md index 1267063..72e1cde 100644 --- a/docs/en-US/cmdlets/Find-AnsibleAccessList.md +++ b/docs/en-US/cmdlets/Find-AnsibleAccessList.md @@ -20,7 +20,7 @@ Find-AnsibleAccessList [-Type] [-Id] [-OrderBy [-OrderBy ] [-Search ] +Find-AnsibleAccessList -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -176,7 +176,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleActivityStream.md b/docs/en-US/cmdlets/Find-AnsibleActivityStream.md index 02bbf98..e5dcfb9 100644 --- a/docs/en-US/cmdlets/Find-AnsibleActivityStream.md +++ b/docs/en-US/cmdlets/Find-AnsibleActivityStream.md @@ -26,7 +26,7 @@ Find-AnsibleActivityStream [-Type] [-Id] [-OrderBy [-OrderBy ] [-Search ] +Find-AnsibleActivityStream -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -207,7 +207,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleAdHocCommandJob.md b/docs/en-US/cmdlets/Find-AnsibleAdHocCommandJob.md index 81694f2..5096922 100644 --- a/docs/en-US/cmdlets/Find-AnsibleAdHocCommandJob.md +++ b/docs/en-US/cmdlets/Find-AnsibleAdHocCommandJob.md @@ -26,7 +26,7 @@ Find-AnsibleAdHocCommandJob [-Type] [-Id] [-OrderBy [-OrderBy ] [-Search ] +Find-AnsibleAdHocCommandJob -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -174,7 +174,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleApplication.md b/docs/en-US/cmdlets/Find-AnsibleApplication.md index b8e4907..5b1555a 100644 --- a/docs/en-US/cmdlets/Find-AnsibleApplication.md +++ b/docs/en-US/cmdlets/Find-AnsibleApplication.md @@ -26,7 +26,7 @@ Find-AnsibleApplication [-Type] [-Id] [-OrderBy [-OrderBy ] [-Search ] +Find-AnsibleApplication -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -173,7 +173,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleCredential.md b/docs/en-US/cmdlets/Find-AnsibleCredential.md index f9557d9..276f9cd 100644 --- a/docs/en-US/cmdlets/Find-AnsibleCredential.md +++ b/docs/en-US/cmdlets/Find-AnsibleCredential.md @@ -28,7 +28,7 @@ Find-AnsibleCredential [-Type] [-Id] [-CredentialTypeKin ### PipelineInput ``` -Find-AnsibleCredential [-Resource] [-CredentialTypeKind ] +Find-AnsibleCredential -Resource [-CredentialTypeKind ] [-CredentialTypeNamespace ] [-Galaxy] [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -261,7 +261,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleGroup.md b/docs/en-US/cmdlets/Find-AnsibleGroup.md index ef60b62..38ea46f 100644 --- a/docs/en-US/cmdlets/Find-AnsibleGroup.md +++ b/docs/en-US/cmdlets/Find-AnsibleGroup.md @@ -27,7 +27,7 @@ Find-AnsibleGroup [-Type] [-Id] [-OnlyRoot] [-OnlyParnet ### PipelineInput ``` -Find-AnsibleGroup [-Resource] [-OnlyRoot] [-OnlyParnets] [-OrderBy ] [-Search ] +Find-AnsibleGroup -Resource [-OnlyRoot] [-OnlyParnets] [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -227,7 +227,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleHost.md b/docs/en-US/cmdlets/Find-AnsibleHost.md index ccbbdcc..e7958da 100644 --- a/docs/en-US/cmdlets/Find-AnsibleHost.md +++ b/docs/en-US/cmdlets/Find-AnsibleHost.md @@ -27,7 +27,7 @@ Find-AnsibleHost [-Type] [-Id] [-OnlyChildren] [-OrderBy ### PipelineInput ``` -Find-AnsibleHost [-Resource] [-OnlyChildren] [-OrderBy ] [-Search ] +Find-AnsibleHost -Resource [-OnlyChildren] [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -201,7 +201,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleInstanceGroup.md b/docs/en-US/cmdlets/Find-AnsibleInstanceGroup.md index acb9c5c..8f3a3f4 100644 --- a/docs/en-US/cmdlets/Find-AnsibleInstanceGroup.md +++ b/docs/en-US/cmdlets/Find-AnsibleInstanceGroup.md @@ -26,7 +26,7 @@ Find-AnsibleInstanceGroup [-Type] [-Id] [-OrderBy [-OrderBy ] [-Search ] +Find-AnsibleInstanceGroup -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -179,7 +179,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleInventory.md b/docs/en-US/cmdlets/Find-AnsibleInventory.md index fdd51f8..90abd0a 100644 --- a/docs/en-US/cmdlets/Find-AnsibleInventory.md +++ b/docs/en-US/cmdlets/Find-AnsibleInventory.md @@ -27,9 +27,8 @@ Find-AnsibleInventory [-Type] [-Id] [-Kind [-Kind ] [-OrderBy ] - [-Search ] [-Filter ] [-Count ] [-Page ] [-All] - [] +Find-AnsibleInventory -Resource [-Kind ] [-OrderBy ] [-Search ] + [-Filter ] [-Count ] [-Page ] [-All] [] ``` ## DESCRIPTION @@ -189,7 +188,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleInventorySource.md b/docs/en-US/cmdlets/Find-AnsibleInventorySource.md index 594b939..c3b3e31 100644 --- a/docs/en-US/cmdlets/Find-AnsibleInventorySource.md +++ b/docs/en-US/cmdlets/Find-AnsibleInventorySource.md @@ -26,7 +26,7 @@ Find-AnsibleInventorySource [-Type] [-Id] [-OrderBy [-OrderBy ] [-Search ] +Find-AnsibleInventorySource -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -173,7 +173,7 @@ Parameter Sets: PipelineVariable Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleInventoryUpdateJob.md b/docs/en-US/cmdlets/Find-AnsibleInventoryUpdateJob.md index 79364c4..e5b480a 100644 --- a/docs/en-US/cmdlets/Find-AnsibleInventoryUpdateJob.md +++ b/docs/en-US/cmdlets/Find-AnsibleInventoryUpdateJob.md @@ -26,7 +26,7 @@ Find-AnsibleInventoryUpdateJob [-Type] [-Id] [-OrderBy < ### PipelineVariable ``` -Find-AnsibleInventoryUpdateJob [-Resource] [-OrderBy ] [-Search ] +Find-AnsibleInventoryUpdateJob -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -169,7 +169,7 @@ Parameter Sets: PipelineVariable Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleJobEvent.md b/docs/en-US/cmdlets/Find-AnsibleJobEvent.md index ab82362..d11a8e5 100644 --- a/docs/en-US/cmdlets/Find-AnsibleJobEvent.md +++ b/docs/en-US/cmdlets/Find-AnsibleJobEvent.md @@ -21,7 +21,7 @@ Find-AnsibleJobEvent [-Type] [-Id] [-AdHocCommandEvent] ### PipelineInput ``` -Find-AnsibleJobEvent [-Resource] [-AdHocCommandEvent] [-OrderBy ] [-Search ] +Find-AnsibleJobEvent -Resource [-AdHocCommandEvent] [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -193,7 +193,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleJobHostSummary.md b/docs/en-US/cmdlets/Find-AnsibleJobHostSummary.md index 82f8486..2524de7 100644 --- a/docs/en-US/cmdlets/Find-AnsibleJobHostSummary.md +++ b/docs/en-US/cmdlets/Find-AnsibleJobHostSummary.md @@ -20,7 +20,7 @@ Find-AnsibleJobHostSummary [-Type] [-Id] [-OrderBy [-OrderBy ] [-Search ] +Find-AnsibleJobHostSummary -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -166,7 +166,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleJobTemplate.md b/docs/en-US/cmdlets/Find-AnsibleJobTemplate.md index 524be07..5a4cdc5 100644 --- a/docs/en-US/cmdlets/Find-AnsibleJobTemplate.md +++ b/docs/en-US/cmdlets/Find-AnsibleJobTemplate.md @@ -27,7 +27,7 @@ Find-AnsibleJobTemplate [-Type] [-Id] [[-Name] [[-Name] ] [-OrderBy ] [-Search ] +Find-AnsibleJobTemplate -Resource [[-Name] ] [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -189,7 +189,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleLabel.md b/docs/en-US/cmdlets/Find-AnsibleLabel.md index dd79ae0..bd2d70b 100644 --- a/docs/en-US/cmdlets/Find-AnsibleLabel.md +++ b/docs/en-US/cmdlets/Find-AnsibleLabel.md @@ -26,7 +26,7 @@ Find-AnsibleLabel [-Type] [-Id] [-OrderBy ] [- ### PipelineInput ``` -Find-AnsibleLabel [-Resource] [-OrderBy ] [-Search ] +Find-AnsibleLabel -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -174,7 +174,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleNotification.md b/docs/en-US/cmdlets/Find-AnsibleNotification.md index 1a2b8f4..0c5fa15 100644 --- a/docs/en-US/cmdlets/Find-AnsibleNotification.md +++ b/docs/en-US/cmdlets/Find-AnsibleNotification.md @@ -26,7 +26,7 @@ Find-AnsibleNotification [-Type] [-Id] [-OrderBy [-OrderBy ] [-Search ] +Find-AnsibleNotification -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -179,7 +179,7 @@ Parameter Sets: PipelineVariable Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForError.md b/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForError.md index 7e44a11..7003926 100644 --- a/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForError.md +++ b/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForError.md @@ -21,7 +21,7 @@ Find-AnsibleNotificationTemplateForError [-Type] [-Id] [ ### PipelineInput ``` -Find-AnsibleNotificationTemplateForError [-Resource] [-OrderBy ] [-Search ] +Find-AnsibleNotificationTemplateForError -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -167,7 +167,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForStarted.md b/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForStarted.md index 86fce59..055d3a9 100644 --- a/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForStarted.md +++ b/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForStarted.md @@ -21,7 +21,7 @@ Find-AnsibleNotificationTemplateForStarted [-Type] [-Id] ### PipelineInput ``` -Find-AnsibleNotificationTemplateForStarted [-Resource] [-OrderBy ] [-Search ] +Find-AnsibleNotificationTemplateForStarted -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -167,7 +167,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForSuccess.md b/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForSuccess.md index cb272aa..da354da 100644 --- a/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForSuccess.md +++ b/docs/en-US/cmdlets/Find-AnsibleNotificationTemplateForSuccess.md @@ -21,7 +21,7 @@ Find-AnsibleNotificationTemplateForSuccess [-Type] [-Id] ### PipelineInput ``` -Find-AnsibleNotificationTemplateForSuccess [-OrderBy ] [-Resource] [-Search ] +Find-AnsibleNotificationTemplateForSuccess [-OrderBy ] -Resource [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -167,7 +167,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleObjectRole.md b/docs/en-US/cmdlets/Find-AnsibleObjectRole.md index c9560fa..1bc2ab7 100644 --- a/docs/en-US/cmdlets/Find-AnsibleObjectRole.md +++ b/docs/en-US/cmdlets/Find-AnsibleObjectRole.md @@ -20,7 +20,7 @@ Find-AnsibleObjectRole [-Type] [-Id] [-OrderBy [-OrderBy ] [-Search ] +Find-AnsibleObjectRole -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -169,7 +169,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleProject.md b/docs/en-US/cmdlets/Find-AnsibleProject.md index 9720904..4cfff4f 100644 --- a/docs/en-US/cmdlets/Find-AnsibleProject.md +++ b/docs/en-US/cmdlets/Find-AnsibleProject.md @@ -26,7 +26,7 @@ Find-AnsibleProject [-Type] [-Id] [-OrderBy ] ### PipelineVariable ``` -Find-AnsibleProject [-Resource] [-OrderBy ] [-Search ] +Find-AnsibleProject -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -171,7 +171,7 @@ Parameter Sets: PipelineVariable Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleRole.md b/docs/en-US/cmdlets/Find-AnsibleRole.md index 773d4c3..acf4d88 100644 --- a/docs/en-US/cmdlets/Find-AnsibleRole.md +++ b/docs/en-US/cmdlets/Find-AnsibleRole.md @@ -26,7 +26,7 @@ Find-AnsibleRole [-Type] [-Id] [-OrderBy ] [-S ### PipelineInput ``` -Find-AnsibleRole [-Resource] [-OrderBy ] [-Search ] +Find-AnsibleRole -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -169,7 +169,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleSchedule.md b/docs/en-US/cmdlets/Find-AnsibleSchedule.md index 7675950..8f2c928 100644 --- a/docs/en-US/cmdlets/Find-AnsibleSchedule.md +++ b/docs/en-US/cmdlets/Find-AnsibleSchedule.md @@ -26,7 +26,7 @@ Find-AnsibleSchedule [-Type] [-Id] [-OrderBy ] ### PipelineInput ``` -Find-AnsibleSchedule [-Resource] [-OrderBy ] [-Search ] +Find-AnsibleSchedule -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -175,7 +175,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleTeam.md b/docs/en-US/cmdlets/Find-AnsibleTeam.md index 3a45006..cea9f8d 100644 --- a/docs/en-US/cmdlets/Find-AnsibleTeam.md +++ b/docs/en-US/cmdlets/Find-AnsibleTeam.md @@ -26,7 +26,7 @@ Find-AnsibleTeam [-Type] [-Id] [-OrderBy ] [-S ### PipelineInput ``` -Find-AnsibleTeam [-Resource] [-OrderBy ] [-Search ] +Find-AnsibleTeam -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -175,7 +175,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleToken.md b/docs/en-US/cmdlets/Find-AnsibleToken.md index 71344d1..74dbe34 100644 --- a/docs/en-US/cmdlets/Find-AnsibleToken.md +++ b/docs/en-US/cmdlets/Find-AnsibleToken.md @@ -27,7 +27,7 @@ Find-AnsibleToken [-Type] [-Id] [-TokenType ### PipelineInput ``` -Find-AnsibleToken [-Resource] [-TokenType ] [-OrderBy ] [-Search ] +Find-AnsibleToken -Resource [-TokenType ] [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -170,7 +170,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleUnifiedJob.md b/docs/en-US/cmdlets/Find-AnsibleUnifiedJob.md index 22de60c..6759925 100644 --- a/docs/en-US/cmdlets/Find-AnsibleUnifiedJob.md +++ b/docs/en-US/cmdlets/Find-AnsibleUnifiedJob.md @@ -26,7 +26,7 @@ Find-AnsibleUnifiedJob [-Type] [-Id] [-OrderBy [-OrderBy ] [-Search ] +Find-AnsibleUnifiedJob -Resource [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -181,7 +181,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleUser.md b/docs/en-US/cmdlets/Find-AnsibleUser.md index 831fcb3..1349a76 100644 --- a/docs/en-US/cmdlets/Find-AnsibleUser.md +++ b/docs/en-US/cmdlets/Find-AnsibleUser.md @@ -27,7 +27,7 @@ Find-AnsibleUser [-Type] [-Id] [[-UserName] ] ### PipelineInput ``` -Find-AnsibleUser [-Resource] [[-UserName] ] [[-Email] ] [-OrderBy ] +Find-AnsibleUser -Resource [[-UserName] ] [[-Email] ] [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] [-All] [] ``` @@ -192,7 +192,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False diff --git a/docs/en-US/cmdlets/Find-AnsibleWorkflowJob.md b/docs/en-US/cmdlets/Find-AnsibleWorkflowJob.md index c1effd5..0f6a7ac 100644 --- a/docs/en-US/cmdlets/Find-AnsibleWorkflowJob.md +++ b/docs/en-US/cmdlets/Find-AnsibleWorkflowJob.md @@ -28,9 +28,9 @@ Find-AnsibleWorkflowJob [-Type] [-Id] [-Name ] ### PipelineInput ``` -Find-AnsibleWorkflowJob [-Resource] [-Name ] [-Status ] - [-LaunchType ] [-OrderBy ] [-Search ] [-Filter ] - [-Count ] [-Page ] [-All] [] +Find-AnsibleWorkflowJob -Resource [-Name ] [-Status ] [-LaunchType ] + [-OrderBy ] [-Search ] [-Filter ] [-Count ] [-Page ] + [-All] [] ``` ## DESCRIPTION @@ -206,7 +206,7 @@ Parameter Sets: PipelineInput Aliases: Required: True -Position: 0 +Position: Named Default value: None Accept pipeline input: True (ByValue) Accept wildcard characters: False From ddbffab6bc896c58d31a901ac68746f2416e9d24 Mon Sep 17 00:00:00 2001 From: teramako Date: Wed, 20 Nov 2024 22:08:20 +0900 Subject: [PATCH 58/84] :books: Add document for creating CredentialType --- docs/en-US/CredentialType.md | 171 +++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 docs/en-US/CredentialType.md diff --git a/docs/en-US/CredentialType.md b/docs/en-US/CredentialType.md new file mode 100644 index 0000000..7af6e39 --- /dev/null +++ b/docs/en-US/CredentialType.md @@ -0,0 +1,171 @@ +# Creating CredentialType + +To create CredentialType, we need to define `inputs` data. + +## Custom Credential Type Inputs + +The specification: https://github.com/ansible/awx/blob/devel/docs/credentials/custom_credential_types.md#defining-custom-credential-type-inputs + +> A `Credential Type` specifies an `inputs` schema which defines a set of ordered fields for that type: +> ```yaml +> "inputs": { +> "fields": [{ +> "id": "api_token", # required - a unique name used to +> # reference the field value +> +> "label": "API Token", # required - a unique label for the +> # field +> +> "help_text": "User-facing short text describing the field.", +> +> "type": ("string" | "boolean") # defaults to 'string' +> +> "format": "ssh_private_key" # optional, can be used to enforce data +> # format validity for SSH private key +> # data (only applicable to `type=string`) +> +> "secret": true, # if true, the field value will be encrypted +> +> "multiline": false # if true, the field should be rendered +> # as multi-line for input entry +> # (only applicable to `type=string`) +> +> "default": "default value" # optional, can be used to provide a +> # default value if the field is left empty; +> # when creating a credential of this type, +> # credential forms will use this value +> # as a prefill when making credentials of +> # this type +> },{ +> # field 2... +> },{ +> # field 3... +> }] +> "required": ["api_token"] # optional; one or more fields can be marked as required +> }, +> ``` +> When `type=string`, fields can optionally specify multiple choice options: +> ```yaml +> "inputs": { +> "fields": [{ +> "id": "api_token", # required - a unique name used to reference the field value +> "label": "API Token", # required - a unique label for the field +> "type": "string", +> "choices": ["A", "B", "C"] +> }] +> }, +> ``` + +There are helper classes that make the generation of these `fields` and `required` properties a little easier. + +### Classes +Namespace: `Jagabata.CredentialType`: +- `Jagabata.CredentialType.FieldList`: container for `fields` and `required` properties +- `Jagabata.CredentialType.BoolField`: boolean field (rendered as Checkbox) +- `Jagabata.CredentialType.StringField`: string input field (rendered as Input box) + - `Jagabata.CredentialType.SecretField`: confidential information input field (`secret=true`) + - `Jagabata.CredentialType.UrlField`: URL input field (`format=url`) + - `Jagabata.CredentialType.SshPrivateKeyField`: input field for SSH key (`secret=true`, `multiline=true`, `format=ssh_private_key`) +- `Jagabata.CredentialType.ChoiceField`: multiple choice field (rendered as Select box) + +### Example +```powershell +$list = [Jagabata.CredentialType.FieldList]::new(); + +# Add normal input field +$list.Add([Jagabata.CredentialType.StringField]@{ Id = "username"; Label = "User Name"; Required = $true }) + +# Add password input field +$list.Add([Jagabata.CredentialType.SecretField]@{ Id = "password"; Label = "Password"; Required = $true }) + +New-AnsibleCredentialType -Name "Demo-1" -Kind cloud -FieldList $list -WhatIf +``` + +```Output +What if: Performing the operation "New-AnsibleCredentialType" on target "{ + "name": "Demo 1", + "kind": "cloud", + "injectors": {}, + "inputs": { + "fields": [ + { + "id": "username", + "label": "User Name", + "type": "string" + }, + { + "secret": true, + "id": "password", + "label": "Password", + "type": "string" + } + ], + "required": [ + "username", + "password" + ] + } +}". +``` + +### Class Diagram + +```mermaid +classDiagram + FieldList -- FieldListConverter + FieldList o-- "*" FieldBase + FieldBase <|-- StringField + FieldBase <|-- ChoiceField + FieldBase <|-- BoolField + + StringField <|-- SecretField + StringField <|-- UrlField + StringField <|-- SshPrivateKeyField + + class FieldListConverter { + <> + ~read() + ~write() + } + class FieldList { + <> + +this[i] + } + class FieldBase { + <> + +string Id + +string Label + +FieldType Type = "string" + +string HelpText + +bool Required + } + class StringField { + +FieldType Type = "string" + +string? Default + +FieldFormat? Format + +bool? Secret + +bool? Multiline + } + class SecretField { + +bool Secret = true + } + class UrlField { + +FieldFormat? Format = "Url" + } + class SshPrivateKeyField { + +FieldFormat Format = "SshPrivateKey" + +bool Secret = true + +bool Multiline = true + } + class ChoiceField { + +FieldType Type = "string" + +string? Default + +string[] Choices + } + class BoolField { + +FieldType Type = "boolean" + +bool? Default + } + +``` +This is only an overview diagram and differs from the actual class diagram. From f9cebdb2c0d7fa032aa06d1d4b9b0e35f10661cf Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 22 Nov 2024 23:25:17 +0900 Subject: [PATCH 59/84] :+1: Implement Injectors class for generating CredentialType --- src/Jagabata/CredentialType/Injectors.cs | 74 ++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/Jagabata/CredentialType/Injectors.cs diff --git a/src/Jagabata/CredentialType/Injectors.cs b/src/Jagabata/CredentialType/Injectors.cs new file mode 100644 index 0000000..12ad89c --- /dev/null +++ b/src/Jagabata/CredentialType/Injectors.cs @@ -0,0 +1,74 @@ +using System.Collections; +using System.Text.Json.Serialization; + +namespace Jagabata.CredentialType; + +public class Injectors(StringDictionary? env = null, + ObjectDictionary? extraVars = null, + StringDictionary? file = null) +{ + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public StringDictionary? Env { get; set; } = env; + + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public ObjectDictionary? ExtraVars { get; set; } = extraVars; + + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public StringDictionary? File { get; set; } = file; +} + +public class StringDictionary : Dictionary +{ + public StringDictionary() + { } + public StringDictionary(IDictionary dict) + { + foreach (var entry in dict.Cast()) + { + this[$"{entry.Key}"] = $"{entry.Value}"; + } + } +} + +public class ObjectDictionary : Dictionary +{ + public ObjectDictionary() + { } + public ObjectDictionary(IDictionary dict) + { + foreach (var entry in dict.Cast()) + { + this[$"{entry.Key}"] = entry.Value switch + { + IDictionary subDict => ConvertDict(subDict), + IList list => ConvertList(list), + _ => entry.Value + }; + } + } + private static Dictionary ConvertDict(IDictionary dict) + { + return dict.Cast().ToDictionary( + d => $"{d.Key}", + d => d.Value switch + { + IDictionary subDict => ConvertDict(subDict), + IList list => ConvertList(list), + _ => d.Value + }); + } + private static ArrayList ConvertList(IList list) + { + var result = new ArrayList(); + foreach (var item in list) + { + result.Add(item switch + { + IDictionary subDict => ConvertDict(subDict), + IList subList => ConvertList(subList), + _ => item + }); + } + return result; + } +} From c2014edb21725aabc7f010f4e1f7b2707cad63b8 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 23 Nov 2024 14:39:35 +0900 Subject: [PATCH 60/84] :sparkles: use `Injectors` class for deserializing --- src/Jagabata/Resources/CredentialType.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Jagabata/Resources/CredentialType.cs b/src/Jagabata/Resources/CredentialType.cs index fb46bcd..d80e6df 100644 --- a/src/Jagabata/Resources/CredentialType.cs +++ b/src/Jagabata/Resources/CredentialType.cs @@ -69,7 +69,7 @@ public interface ICredentialType string Description { get; } CredentialTypeKind Kind { get; } FieldList Inputs { get; } - Dictionary> Injectors { get; } + Injectors Injectors { get; } } public class CredentialType(ulong id, @@ -85,7 +85,7 @@ public class CredentialType(ulong id, string nameSpace, bool managed, FieldList inputs, - Dictionary> injectors) + Injectors injectors) : ICredentialType, IResource { public const string PATH = "/api/v2/credential_types/"; @@ -134,6 +134,6 @@ public record Summary(Capability UserCapabilities); public string Namespace { get; } = nameSpace; public bool Managed { get; } = managed; public FieldList Inputs { get; } = inputs; - public Dictionary> Injectors { get; } = injectors; + public Injectors Injectors { get; } = injectors; } } From 6d31ed5c80a0512f44c2327a51b4c87705e28875 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 23 Nov 2024 18:57:36 +0900 Subject: [PATCH 61/84] :+1: Implement DictionaryTransformationAttribute --- .../DictionaryTransformation.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/Jagabata/Cmdlets/ArgumentTransformation/DictionaryTransformation.cs diff --git a/src/Jagabata/Cmdlets/ArgumentTransformation/DictionaryTransformation.cs b/src/Jagabata/Cmdlets/ArgumentTransformation/DictionaryTransformation.cs new file mode 100644 index 0000000..fd35dc0 --- /dev/null +++ b/src/Jagabata/Cmdlets/ArgumentTransformation/DictionaryTransformation.cs @@ -0,0 +1,38 @@ +using System.Collections; +using System.Management.Automation; +using System.Text.Json; + +namespace Jagabata.Cmdlets.ArgumentTransformation; + +internal class DictionaryTransformation : ArgumentTransformationAttribute +{ + public DictionaryTransformation(params Type[] types) + { + Types = types; + } + + protected Type[] Types { get; init; } + + public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) + { + if (inputData is PSObject pso && pso.BaseObject is not null) + { + inputData = pso.BaseObject; + } + if (inputData is IDictionary dict) + { + return dict; + } + foreach (var t in Types) + { + if (inputData.GetType() != t) + { + continue; + } + var jsonElm = JsonSerializer.SerializeToElement(inputData, t, Json.SerializeOptions); + return JsonSerializer.Deserialize>(jsonElm, Json.DeserializeOptions) + ?? throw new ArgumentException("result is null"); + } + throw new ArgumentException($"{nameof(inputData)} should be one of [IDictionary, {string.Join(", ", Types.Select(t => t.Name))}]"); + } +} From 500fcdc48754cc139742cb2cc8673a0745a57a5a Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 23 Nov 2024 18:59:03 +0900 Subject: [PATCH 62/84] :sparkles: set DictionaryTransformation for CredentialType's Inputs parameter fixies https://github.com/teramako/Jagabata.psm/pull/99 --- src/Jagabata/Cmdlets/CredentialTypeCommand.cs | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/Jagabata/Cmdlets/CredentialTypeCommand.cs b/src/Jagabata/Cmdlets/CredentialTypeCommand.cs index 8b6eea2..664b4ed 100644 --- a/src/Jagabata/Cmdlets/CredentialTypeCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialTypeCommand.cs @@ -64,11 +64,9 @@ public class NewCredentialTypeCommand : NewCommandBase [ValidateSet("net", "cloud")] public string Kind { get; set; } = string.Empty; - [Parameter(Mandatory = true, ParameterSetName = "InputsDict")] - public IDictionary? Inputs { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = "FieldList")] - public FieldList? FieldList { get; set; } + [Parameter()] + [DictionaryTransformation(typeof(FieldList))] + public IDictionary Inputs { get; set; } = new Hashtable(); [Parameter()] public IDictionary Injectors { get; set; } = new Hashtable(); @@ -79,16 +77,9 @@ protected override Dictionary CreateSendData() { { "name", Name }, { "kind", Kind }, + { "inputs", Inputs }, { "injectors", Injectors } }; - if (FieldList is not null) - { - sendData.Add("inputs", FieldList); - } - else if (Inputs is not null) - { - sendData.Add("inputs", Inputs); - } if (Description is not null) { @@ -140,12 +131,10 @@ public class UpdateCredentialTypeCommand : UpdateCommandBase Date: Sat, 23 Nov 2024 19:16:36 +0900 Subject: [PATCH 63/84] :books: Update `-Input` parameter --- docs/en-US/CredentialType.md | 2 +- .../cmdlets/New-AnsibleCredentialType.md | 31 ++++--------------- .../cmdlets/Update-AnsibleCredentialType.md | 31 ++++--------------- 3 files changed, 13 insertions(+), 51 deletions(-) diff --git a/docs/en-US/CredentialType.md b/docs/en-US/CredentialType.md index 7af6e39..80a952e 100644 --- a/docs/en-US/CredentialType.md +++ b/docs/en-US/CredentialType.md @@ -78,7 +78,7 @@ $list.Add([Jagabata.CredentialType.StringField]@{ Id = "username"; Label = "User # Add password input field $list.Add([Jagabata.CredentialType.SecretField]@{ Id = "password"; Label = "Password"; Required = $true }) -New-AnsibleCredentialType -Name "Demo-1" -Kind cloud -FieldList $list -WhatIf +New-AnsibleCredentialType -Name "Demo-1" -Kind cloud -Inputs $list -WhatIf ``` ```Output diff --git a/docs/en-US/cmdlets/New-AnsibleCredentialType.md b/docs/en-US/cmdlets/New-AnsibleCredentialType.md index 71de281..34a771e 100644 --- a/docs/en-US/cmdlets/New-AnsibleCredentialType.md +++ b/docs/en-US/cmdlets/New-AnsibleCredentialType.md @@ -12,15 +12,8 @@ Create a CredentialType. ## SYNTAX -### InputsDict ``` -New-AnsibleCredentialType [-Name] [-Description ] [-Kind] -Inputs - [-Injectors ] [-WhatIf] [-Confirm] [] -``` - -### FieldList -``` -New-AnsibleCredentialType [-Name] [-Description ] [-Kind] -FieldList +New-AnsibleCredentialType [-Name] [-Description ] [-Kind] [-Inputs ] [-Injectors ] [-WhatIf] [-Confirm] [] ``` @@ -56,21 +49,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -FieldList -Custom `inputs` of CredentialType which defined by `Jagabata.CredentialType.FieldList` - -```yaml -Type: FieldList -Parameter Sets: FieldList -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Injectors ```yaml @@ -86,13 +64,16 @@ Accept wildcard characters: False ``` ### -Inputs +Custom Credential Type Inputs object which raw Dictionary or `Jagabata.CredentialType.FieldList`. + +See: https://github.com/teramako/Jagabata.psm/blob/develop/docs/en-US/CredentialType.md ```yaml Type: IDictionary -Parameter Sets: InputsDict +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/docs/en-US/cmdlets/Update-AnsibleCredentialType.md b/docs/en-US/cmdlets/Update-AnsibleCredentialType.md index d8f2e98..aaf0fb8 100644 --- a/docs/en-US/cmdlets/Update-AnsibleCredentialType.md +++ b/docs/en-US/cmdlets/Update-AnsibleCredentialType.md @@ -12,16 +12,9 @@ Update a CredentialType. ## SYNTAX -### InputsDict ``` Update-AnsibleCredentialType [-Id] [-Name ] [-Description ] [-Kind ] - -Inputs [-Injectors ] [-WhatIf] [-Confirm] [] -``` - -### FieldList -``` -Update-AnsibleCredentialType [-Id] [-Name ] [-Description ] [-Kind ] - -FieldList [-Injectors ] [-WhatIf] [-Confirm] [] + [-Inputs ] [-Injectors ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -54,21 +47,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -FieldList -Custom `inputs` of CredentialType which defined by `Jagabata.CredentialType.FieldList` - -```yaml -Type: FieldList -Parameter Sets: FieldList -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Id CredentialType ID to be updated. @@ -99,13 +77,16 @@ Accept wildcard characters: False ``` ### -Inputs +Custom Credential Type Inputs object which raw Dictionary or `Jagabata.CredentialType.FieldList`. + +See: https://github.com/teramako/Jagabata.psm/blob/develop/docs/en-US/CredentialType.md ```yaml Type: IDictionary -Parameter Sets: InputsDict +Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False From 54ee147bac439767512191695db0edd37ca04d3a Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 24 Nov 2024 22:34:49 +0900 Subject: [PATCH 64/84] :sparkles: Set DictionaryTransformation for CredentialType's -Injectors parameter --- src/Jagabata/Cmdlets/CredentialTypeCommand.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Jagabata/Cmdlets/CredentialTypeCommand.cs b/src/Jagabata/Cmdlets/CredentialTypeCommand.cs index 664b4ed..75c951c 100644 --- a/src/Jagabata/Cmdlets/CredentialTypeCommand.cs +++ b/src/Jagabata/Cmdlets/CredentialTypeCommand.cs @@ -69,6 +69,7 @@ public class NewCredentialTypeCommand : NewCommandBase public IDictionary Inputs { get; set; } = new Hashtable(); [Parameter()] + [DictionaryTransformation(typeof(Injectors))] public IDictionary Injectors { get; set; } = new Hashtable(); protected override Dictionary CreateSendData() @@ -136,6 +137,7 @@ public class UpdateCredentialTypeCommand : UpdateCommandBase CreateSendData() From 62f62fbec1bcfc0b93af3021eb13acfc3b12d6e4 Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 24 Nov 2024 22:35:35 +0900 Subject: [PATCH 65/84] :books: Update documents for `-Injectors` parameter --- docs/en-US/cmdlets/New-AnsibleCredentialType.md | 3 +++ docs/en-US/cmdlets/Update-AnsibleCredentialType.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/docs/en-US/cmdlets/New-AnsibleCredentialType.md b/docs/en-US/cmdlets/New-AnsibleCredentialType.md index 34a771e..78073ef 100644 --- a/docs/en-US/cmdlets/New-AnsibleCredentialType.md +++ b/docs/en-US/cmdlets/New-AnsibleCredentialType.md @@ -50,6 +50,9 @@ Accept wildcard characters: False ``` ### -Injectors +Custom Credential Type Injectors object which raw Dictionary or `Jagabata.CredentialType.Injectors`. + +See: https://github.com/teramako/Jagabata.psm/blob/develop/docs/en-US/CredentialType.md ```yaml Type: IDictionary diff --git a/docs/en-US/cmdlets/Update-AnsibleCredentialType.md b/docs/en-US/cmdlets/Update-AnsibleCredentialType.md index aaf0fb8..6f01a1b 100644 --- a/docs/en-US/cmdlets/Update-AnsibleCredentialType.md +++ b/docs/en-US/cmdlets/Update-AnsibleCredentialType.md @@ -63,6 +63,9 @@ Accept wildcard characters: False ``` ### -Injectors +Custom Credential Type Injectors object which raw Dictionary or `Jagabata.CredentialType.Injectors`. + +See: https://github.com/teramako/Jagabata.psm/blob/develop/docs/en-US/CredentialType.md ```yaml Type: IDictionary From 2c3740a1ca38134eb18247339d236bf11b0733aa Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 24 Nov 2024 22:39:09 +0900 Subject: [PATCH 66/84] :books: Add document about `injectors` --- docs/en-US/CredentialType.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/en-US/CredentialType.md b/docs/en-US/CredentialType.md index 80a952e..e13c2e9 100644 --- a/docs/en-US/CredentialType.md +++ b/docs/en-US/CredentialType.md @@ -1,6 +1,6 @@ # Creating CredentialType -To create CredentialType, we need to define `inputs` data. +To create CredentialType, we need to define `inputs` and `injectors` data. ## Custom Credential Type Inputs @@ -169,3 +169,33 @@ classDiagram ``` This is only an overview diagram and differs from the actual class diagram. + +## Custom Credential Type Injectors + +The specification: https://github.com/ansible/awx/blob/devel/docs/credentials/custom_credential_types.md#defining-custom-credential-type-injectors + +### Classes + +Namespace: `Jagabata.CredentialType`: +- `Jagabata.CredentialType.Injectors`: container for `env`, `extra_vars` or `file` properties + +```powershell +$injectors = [Jagabata.CredentialType.Injectors]::new(); +$injectors.Env = @{ + MY_CLOUD_INI_FILE = "{{ tower.filename }}" +} +$injectors.File = @{ + template = @( + "[mycloud]", + "token={{ api_token }}" + ) -join "`n" +} +$injectors.ExtraVars = @{ + some_extra_var = "{{ username }}:{{ password }}"; + auth = @{ + username = "{{ username }}"; + password = "{{ password }}"; + } +} +``` + From ec231fe92684c90c0be7f89ff74ab984d88d3572 Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 24 Nov 2024 22:42:50 +0900 Subject: [PATCH 67/84] :bug: Fix DictionaryTransformationAttribute - Add `Attribute` suffix to the class name - Change to the static anonymous function --- .../ArgumentTransformation/DictionaryTransformation.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Jagabata/Cmdlets/ArgumentTransformation/DictionaryTransformation.cs b/src/Jagabata/Cmdlets/ArgumentTransformation/DictionaryTransformation.cs index fd35dc0..c0d96e5 100644 --- a/src/Jagabata/Cmdlets/ArgumentTransformation/DictionaryTransformation.cs +++ b/src/Jagabata/Cmdlets/ArgumentTransformation/DictionaryTransformation.cs @@ -4,9 +4,9 @@ namespace Jagabata.Cmdlets.ArgumentTransformation; -internal class DictionaryTransformation : ArgumentTransformationAttribute +internal class DictionaryTransformationAttribute : ArgumentTransformationAttribute { - public DictionaryTransformation(params Type[] types) + public DictionaryTransformationAttribute(params Type[] types) { Types = types; } @@ -33,6 +33,6 @@ public override object Transform(EngineIntrinsics engineIntrinsics, object input return JsonSerializer.Deserialize>(jsonElm, Json.DeserializeOptions) ?? throw new ArgumentException("result is null"); } - throw new ArgumentException($"{nameof(inputData)} should be one of [IDictionary, {string.Join(", ", Types.Select(t => t.Name))}]"); + throw new ArgumentException($"{nameof(inputData)} should be one of [IDictionary, {string.Join(", ", Types.Select(static t => t.Name))}]"); } } From 06e07d2a635280500e52f5a199a43749ab57e6cf Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 24 Nov 2024 23:03:09 +0900 Subject: [PATCH 68/84] :recycle: Change accessibility to internal --- .../ArgumentTransformation/ExtraVarsArgumentTransformation.cs | 2 +- .../ArgumentTransformation/FilterArgumentTransformation.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Jagabata/Cmdlets/ArgumentTransformation/ExtraVarsArgumentTransformation.cs b/src/Jagabata/Cmdlets/ArgumentTransformation/ExtraVarsArgumentTransformation.cs index 8249aff..ade6efd 100644 --- a/src/Jagabata/Cmdlets/ArgumentTransformation/ExtraVarsArgumentTransformation.cs +++ b/src/Jagabata/Cmdlets/ArgumentTransformation/ExtraVarsArgumentTransformation.cs @@ -4,7 +4,7 @@ namespace Jagabata.Cmdlets.ArgumentTransformation { - public class ExtraVarsArgumentTransformationAttribute : ArgumentTransformationAttribute + internal class ExtraVarsArgumentTransformationAttribute : ArgumentTransformationAttribute { public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) { diff --git a/src/Jagabata/Cmdlets/ArgumentTransformation/FilterArgumentTransformation.cs b/src/Jagabata/Cmdlets/ArgumentTransformation/FilterArgumentTransformation.cs index 0aad60a..5e5e7c2 100644 --- a/src/Jagabata/Cmdlets/ArgumentTransformation/FilterArgumentTransformation.cs +++ b/src/Jagabata/Cmdlets/ArgumentTransformation/FilterArgumentTransformation.cs @@ -40,7 +40,7 @@ namespace Jagabata.Cmdlets.ArgumentTransformation /// /// /// - public class FilterArgumentTransformationAttribute : ArgumentTransformationAttribute + internal class FilterArgumentTransformationAttribute : ArgumentTransformationAttribute { public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) { From 0af8c7d31c209b6683aef5d1c4ec2314bb79cc02 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 29 Nov 2024 23:32:08 +0900 Subject: [PATCH 69/84] :memo: fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fa4bb7..36d10e3 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ All commands of Jagabata.psm are added "Ansible" prefix by default, like `Get-Ho > ```powershell > Import-Module Jagabata.psm -Prefix Awx > ``` -> All commands of Jagabata.psm will be added "Awx" prefix instead of "Ansibl", like `Get-Host` -> `Get-AwxHost`. +> All commands of Jagabata.psm will be added "Awx" prefix instead of "Ansible", like `Get-Host` -> `Get-AwxHost`. ### 3. Get Poersonal Access Token From d30b5efd73987452af1e04871298ae5e38fcb0b1 Mon Sep 17 00:00:00 2001 From: teramako Date: Sat, 30 Nov 2024 23:43:25 +0900 Subject: [PATCH 70/84] :bug: Fix: prevent `+` character is converted to white space fixes #102 --- .../ArgumentTransformation/FilterArgumentTransformation.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Jagabata/Cmdlets/ArgumentTransformation/FilterArgumentTransformation.cs b/src/Jagabata/Cmdlets/ArgumentTransformation/FilterArgumentTransformation.cs index 5e5e7c2..7c1637c 100644 --- a/src/Jagabata/Cmdlets/ArgumentTransformation/FilterArgumentTransformation.cs +++ b/src/Jagabata/Cmdlets/ArgumentTransformation/FilterArgumentTransformation.cs @@ -66,9 +66,10 @@ public override object Transform(EngineIntrinsics engineIntrinsics, object input } continue; case string str: - foreach (var f in GetQueries(HttpUtility.ParseQueryString(str))) + foreach (var kv in str.Split('&')) { - queries.Add(f.GetKey(), f.GetValue()); + var filter = Filter.Parse(kv); + queries.Add(filter.GetKey(), filter.GetValue()); } continue; default: From 584da99b15549e21217bb0cc30df35f7059ab5fb Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 1 Dec 2024 03:22:59 +0900 Subject: [PATCH 71/84] :bug: fix HTML job log is not written for a long time since 95223d4aa697ac6fa945db4e0c125db7cc73fe4d --- src/Jagabata/Cmdlets/JobLogCommand.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Jagabata/Cmdlets/JobLogCommand.cs b/src/Jagabata/Cmdlets/JobLogCommand.cs index 9403710..19c06fb 100644 --- a/src/Jagabata/Cmdlets/JobLogCommand.cs +++ b/src/Jagabata/Cmdlets/JobLogCommand.cs @@ -313,6 +313,18 @@ private FileInfo WriteLogAsHtml(DirectoryInfo dir, IUnifiedJob unifiedJob) // Write Log to a fileStream as HTML using StreamWriter ws = new(fileStream, Encoding.UTF8); + if (htmlLog is not null) + { + int bodyTagStart = htmlLog.IndexOf(" 0) + { + int bodyTagEnd = htmlLog.IndexOf('>', bodyTagStart) + 1; + ws.WriteLine(htmlLog[..bodyTagEnd].Replace("Type", $"{title}")); + ws.WriteLine(jobInfo.ToString()); + ws.WriteLine(htmlLog[bodyTagEnd..]); + return fileInfo; + } + } ws.WriteLine(""); ws.WriteLine($"{title}"); ws.WriteLine(""); From c2d5fff792037f729ee3aa48f73ab433be3efc92 Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 1 Dec 2024 04:05:35 +0900 Subject: [PATCH 72/84] :recycle: to static anonymous function --- src/Jagabata/Cmdlets/JobLogCommand.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Jagabata/Cmdlets/JobLogCommand.cs b/src/Jagabata/Cmdlets/JobLogCommand.cs index 19c06fb..9c53337 100644 --- a/src/Jagabata/Cmdlets/JobLogCommand.cs +++ b/src/Jagabata/Cmdlets/JobLogCommand.cs @@ -218,7 +218,7 @@ private IEnumerable StdoutLogs(IEnumerable jobs) } private IEnumerable DownloadLogs(DirectoryInfo dir) { - var unifiedJobsTask = UnifiedJob.Get(_jobs.Select(job => job.Id).ToArray()); + var unifiedJobsTask = UnifiedJob.Get(_jobs.Select(static job => job.Id).ToArray()); unifiedJobsTask.Wait(); foreach (var unifiedJob in unifiedJobsTask.Result) { @@ -262,7 +262,7 @@ private FileInfo WriteSystemLog(DirectoryInfo dir, ISystemJob systemJob) ws.WriteLine("-----"); var props = typeof(ISystemJob).GetProperties(BindingFlags.Public); - var maxLength = props.Select(p => p.Name.Length).Max(); + var maxLength = props.Select(static p => p.Name.Length).Max(); var format = $"{{0,{maxLength}}}: {{1}}"; foreach (var prop in props) { @@ -282,7 +282,7 @@ private FileInfo WriteLogAsText(DirectoryInfo dir, IUnifiedJob unifiedJob) ws.WriteLine("-----"); var props = GetJobProperties(unifiedJob).ToArray(); - var maxLength = props.Select(tuple => tuple.Key.Length).Max(); + var maxLength = props.Select(static tuple => tuple.Key.Length).Max(); var format = $"{{0,{maxLength}}}: {{1}}"; foreach (var (key, value) in props) { From ccc0f2d581763e927165f76e94b25d2cf726fc89 Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 1 Dec 2024 04:31:48 +0900 Subject: [PATCH 73/84] Open file as `CreateNew` mode if not exists; otherwise as `Truncate` mode --- src/Jagabata/Cmdlets/JobLogCommand.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Jagabata/Cmdlets/JobLogCommand.cs b/src/Jagabata/Cmdlets/JobLogCommand.cs index 9c53337..a49284a 100644 --- a/src/Jagabata/Cmdlets/JobLogCommand.cs +++ b/src/Jagabata/Cmdlets/JobLogCommand.cs @@ -256,7 +256,8 @@ private FileInfo WriteLogAsJson(DirectoryInfo dir, IUnifiedJob unifiedJob) private FileInfo WriteSystemLog(DirectoryInfo dir, ISystemJob systemJob) { FileInfo fileInfo = new(Path.Combine(dir.FullName, $"{systemJob.Id}.txt")); - using FileStream fileStream = fileInfo.OpenWrite(); + using FileStream fileStream = fileInfo.Open(fileInfo.Exists ? FileMode.Truncate : FileMode.CreateNew, + FileAccess.Write); var txtLog = systemJob.ResultStdout; using var ws = new StreamWriter(fileStream, Encoding.UTF8); @@ -275,7 +276,8 @@ private FileInfo WriteSystemLog(DirectoryInfo dir, ISystemJob systemJob) private FileInfo WriteLogAsText(DirectoryInfo dir, IUnifiedJob unifiedJob) { FileInfo fileInfo = new(Path.Combine(dir.FullName, $"{unifiedJob.Id}.txt")); - using FileStream fileStream = fileInfo.OpenWrite(); + using FileStream fileStream = fileInfo.Open(fileInfo.Exists ? FileMode.Truncate : FileMode.CreateNew, + FileAccess.Write); var path = GetStdoutPath(unifiedJob.Id, unifiedJob.Type); var txtLog = GetResource($"{path}?{Query}", AcceptType.Text); using var ws = new StreamWriter(fileStream, Encoding.UTF8); @@ -295,7 +297,8 @@ private FileInfo WriteLogAsText(DirectoryInfo dir, IUnifiedJob unifiedJob) private FileInfo WriteLogAsHtml(DirectoryInfo dir, IUnifiedJob unifiedJob) { FileInfo fileInfo = new(Path.Combine(dir.FullName, $"{unifiedJob.Id}.html")); - using FileStream fileStream = fileInfo.OpenWrite(); + using FileStream fileStream = fileInfo.Open(fileInfo.Exists ? FileMode.Truncate : FileMode.CreateNew, + FileAccess.Write); var path = GetStdoutPath(unifiedJob.Id, unifiedJob.Type); var htmlLog = GetResource($"{path}?{Query}", AcceptType.Html); var title = $"{unifiedJob.Id} - {HttpUtility.HtmlEncode(unifiedJob.Name)}"; From 802bb97c8456600793e94c1e1b1ef07d43aeb1a9 Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 1 Dec 2024 04:34:20 +0900 Subject: [PATCH 74/84] Close WriteStream explicitly --- src/Jagabata/Cmdlets/JobLogCommand.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Jagabata/Cmdlets/JobLogCommand.cs b/src/Jagabata/Cmdlets/JobLogCommand.cs index a49284a..3b65d95 100644 --- a/src/Jagabata/Cmdlets/JobLogCommand.cs +++ b/src/Jagabata/Cmdlets/JobLogCommand.cs @@ -271,6 +271,7 @@ private FileInfo WriteSystemLog(DirectoryInfo dir, ISystemJob systemJob) } ws.WriteLine("-----"); ws.WriteLine(txtLog); + ws.Close(); return fileInfo; } private FileInfo WriteLogAsText(DirectoryInfo dir, IUnifiedJob unifiedJob) @@ -292,6 +293,7 @@ private FileInfo WriteLogAsText(DirectoryInfo dir, IUnifiedJob unifiedJob) } ws.WriteLine("-----"); ws.WriteLine(txtLog); + ws.Close(); return fileInfo; } private FileInfo WriteLogAsHtml(DirectoryInfo dir, IUnifiedJob unifiedJob) @@ -325,6 +327,7 @@ private FileInfo WriteLogAsHtml(DirectoryInfo dir, IUnifiedJob unifiedJob) ws.WriteLine(htmlLog[..bodyTagEnd].Replace("Type", $"{title}")); ws.WriteLine(jobInfo.ToString()); ws.WriteLine(htmlLog[bodyTagEnd..]); + ws.Close(); return fileInfo; } } @@ -334,6 +337,7 @@ private FileInfo WriteLogAsHtml(DirectoryInfo dir, IUnifiedJob unifiedJob) ws.WriteLine(jobInfo.ToString()); ws.WriteLine("

Ooops, Missing log data :(

"); ws.WriteLine(""); + ws.Close(); return fileInfo; } private static IEnumerable<(string Key, object? Value)> GetJobProperties(IUnifiedJob job) From 1ddb9166a6adc689b4cbc2ed394959d3cde44e5e Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 1 Dec 2024 04:35:27 +0900 Subject: [PATCH 75/84] :sparkles: Write as JSON serialized string if the value is IList or IDictionary --- src/Jagabata/Cmdlets/JobLogCommand.cs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Jagabata/Cmdlets/JobLogCommand.cs b/src/Jagabata/Cmdlets/JobLogCommand.cs index 3b65d95..3fe3b56 100644 --- a/src/Jagabata/Cmdlets/JobLogCommand.cs +++ b/src/Jagabata/Cmdlets/JobLogCommand.cs @@ -1,6 +1,8 @@ using Jagabata.Cmdlets.ArgumentTransformation; using Jagabata.Resources; +using System.Collections; using System.Collections.Specialized; +using System.Globalization; using System.Management.Automation; using System.Reflection; using System.Text; @@ -267,7 +269,13 @@ private FileInfo WriteSystemLog(DirectoryInfo dir, ISystemJob systemJob) var format = $"{{0,{maxLength}}}: {{1}}"; foreach (var prop in props) { - ws.WriteLine(format, prop.Name, prop.GetValue(systemJob)); + var value = prop.GetValue(systemJob); + var val = value switch + { + IList or IDictionary => Json.Stringify(value), + _ => value + }; + ws.WriteLine(format, prop.Name, val); } ws.WriteLine("-----"); ws.WriteLine(txtLog); @@ -289,7 +297,12 @@ private FileInfo WriteLogAsText(DirectoryInfo dir, IUnifiedJob unifiedJob) var format = $"{{0,{maxLength}}}: {{1}}"; foreach (var (key, value) in props) { - ws.WriteLine(format, key, value); + var val = value switch + { + IList or IDictionary => Json.Stringify(value), + _ => value + }; + ws.WriteLine(format, key, val); } ws.WriteLine("-----"); ws.WriteLine(txtLog); @@ -312,7 +325,13 @@ private FileInfo WriteLogAsHtml(DirectoryInfo dir, IUnifiedJob unifiedJob) jobInfo.AppendLine(""); foreach ((string key, object? value) in GetJobProperties(unifiedJob)) { - jobInfo.AppendLine(string.Format(format, key, value)); + var val = value switch + { + IList or IDictionary => Json.Stringify(value), + _ => value + }; + jobInfo.AppendFormat(CultureInfo.CurrentCulture, format, key, HttpUtility.HtmlEncode(val)) + .AppendLine(); } jobInfo.AppendLine("
Job Info
"); From 8c2c3db2b366dbc5ce44552817915008381c0906 Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 1 Dec 2024 04:44:01 +0900 Subject: [PATCH 76/84] :recycle: fix format --- src/Jagabata/Cmdlets/JobLogCommand.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Jagabata/Cmdlets/JobLogCommand.cs b/src/Jagabata/Cmdlets/JobLogCommand.cs index 3fe3b56..f27f55f 100644 --- a/src/Jagabata/Cmdlets/JobLogCommand.cs +++ b/src/Jagabata/Cmdlets/JobLogCommand.cs @@ -109,14 +109,18 @@ private void GetJobsFromWorkflowJob(ulong id) protected override void BeginProcessing() { if (Id > 0 && Type > 0) + { Job = new Resource(Type, Id); + } if (Download is null) { if (CommandRuntime.Host?.UI.SupportsVirtualTerminal ?? false) { if (Format == JobLogFormat.NotSpecified) + { Format = JobLogFormat.ansi; + } } else if (Format == JobLogFormat.ansi) { @@ -143,12 +147,14 @@ protected override void BeginProcessing() } } Query.Add("format", $"{Format}"); - Query.Add("dark", (Dark ? "1" : "0")); + Query.Add("dark", Dark ? "1" : "0"); } protected override void ProcessRecord() { if (Job.Id == 0) + { return; + } switch (Job.Type) { From 75e83feea73592dd0740ea7e2fb269cebe95f7d2 Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 1 Dec 2024 04:44:32 +0900 Subject: [PATCH 77/84] fix: don't use `Exception` --- src/Jagabata/Cmdlets/JobLogCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Jagabata/Cmdlets/JobLogCommand.cs b/src/Jagabata/Cmdlets/JobLogCommand.cs index f27f55f..734c9af 100644 --- a/src/Jagabata/Cmdlets/JobLogCommand.cs +++ b/src/Jagabata/Cmdlets/JobLogCommand.cs @@ -248,7 +248,7 @@ private IEnumerable DownloadLogs(DirectoryInfo dir) yield return WriteLogAsHtml(dir, unifiedJob); break; default: - throw new Exception($"Unkown format: {Format}"); + throw new InvalidOperationException($"Unkown format: {Format}"); } } } From 8b55171d0ab269f24c654a924eff96ea102ee168 Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 2 Dec 2024 23:02:15 +0900 Subject: [PATCH 78/84] :bug: Fix don't do nothing when `type` is null ( --- src/Jagabata/Cmdlets/JobLogCommand.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Jagabata/Cmdlets/JobLogCommand.cs b/src/Jagabata/Cmdlets/JobLogCommand.cs index 734c9af..8da7e5c 100644 --- a/src/Jagabata/Cmdlets/JobLogCommand.cs +++ b/src/Jagabata/Cmdlets/JobLogCommand.cs @@ -377,8 +377,12 @@ private FileInfo WriteLogAsHtml(DirectoryInfo dir, IUnifiedJob unifiedJob) IProjectUpdateJob => typeof(IProjectUpdateJob), IInventoryUpdateJob => typeof(IInventoryUpdateJob), ISystemJob => typeof(ISystemJob), - _ => throw new NotFiniteNumberException() + _ => null }; + if (type is null) + { + yield break; + } foreach (var prop in type.GetProperties()) { yield return (prop.Name, prop.GetValue(job)); From 08939eb196045300a06df6bae8038452b34f3afb Mon Sep 17 00:00:00 2001 From: teramako Date: Mon, 2 Dec 2024 23:06:38 +0900 Subject: [PATCH 79/84] :sparkles: Allow `AdHocCommand` properties to be output as a list. --- src/Jagabata/Cmdlets/JobLogCommand.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Jagabata/Cmdlets/JobLogCommand.cs b/src/Jagabata/Cmdlets/JobLogCommand.cs index 8da7e5c..b42d88d 100644 --- a/src/Jagabata/Cmdlets/JobLogCommand.cs +++ b/src/Jagabata/Cmdlets/JobLogCommand.cs @@ -377,6 +377,7 @@ private FileInfo WriteLogAsHtml(DirectoryInfo dir, IUnifiedJob unifiedJob) IProjectUpdateJob => typeof(IProjectUpdateJob), IInventoryUpdateJob => typeof(IInventoryUpdateJob), ISystemJob => typeof(ISystemJob), + IAdHocCommand => typeof(IAdHocCommand), _ => null }; if (type is null) From 1522ab570cc671f09e8f92062657ad770d8f9889 Mon Sep 17 00:00:00 2001 From: teramako Date: Tue, 3 Dec 2024 23:38:57 +0900 Subject: [PATCH 80/84] :+1: Implement IParsable for `Resource` --- src/Jagabata/Resources/ResourceBase.cs | 34 +++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Jagabata/Resources/ResourceBase.cs b/src/Jagabata/Resources/ResourceBase.cs index 902d4fe..2b64b98 100644 --- a/src/Jagabata/Resources/ResourceBase.cs +++ b/src/Jagabata/Resources/ResourceBase.cs @@ -1,3 +1,5 @@ +using System.Diagnostics.CodeAnalysis; + namespace Jagabata.Resources { public interface IResource @@ -12,7 +14,37 @@ public interface IResource ResourceType Type { get; } } - public record struct Resource(ResourceType Type, ulong Id) : IResource; + public record struct Resource(ResourceType Type, ulong Id) : IResource, IParsable + { + public static Resource Parse(string s, IFormatProvider? provider = null) + { + return TryParse(s, provider, out var result) + ? result + : throw new FormatException($"Resource format should be '{{Type}}:{{Id}}': {s}"); + } + + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Resource result) + { + result = default; + if (s is null) + { + return false; + } + var list = s.Split([':', '#'], StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); + if (list.Length > 1 + && Enum.TryParse(list[0], true, out var resourceType) + && ulong.TryParse(list[1], System.Globalization.NumberStyles.Integer, provider, out var id)) + { + result = new Resource(resourceType, id); + return true; + } + return false; + } + public override readonly string ToString() + { + return $"{Type}:{Id}"; + } + } public interface IResource : IResource { From 285e3dcabe58f979a7366c339e41feb800b6d579 Mon Sep 17 00:00:00 2001 From: teramako Date: Wed, 4 Dec 2024 21:36:50 +0900 Subject: [PATCH 81/84] :+1: Enable to convert to `Resource` from string --- .../ArgumentTransformation/ResourceTransformation.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Jagabata/Cmdlets/ArgumentTransformation/ResourceTransformation.cs b/src/Jagabata/Cmdlets/ArgumentTransformation/ResourceTransformation.cs index 860be22..f236394 100644 --- a/src/Jagabata/Cmdlets/ArgumentTransformation/ResourceTransformation.cs +++ b/src/Jagabata/Cmdlets/ArgumentTransformation/ResourceTransformation.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Globalization; using System.Management.Automation; using Jagabata.Resources; @@ -38,13 +39,10 @@ private ulong TransformToId(object inputData) { case int: case long: - if (ulong.TryParse($"{inputData}", out var id)) - return id; - throw new ArgumentException(); + return ulong.Parse($"{inputData}", CultureInfo.InvariantCulture); case uint: case ulong: - id = (ulong)inputData; - return id; + return (ulong)inputData; } var resource = TransformToResource(inputData); @@ -104,6 +102,8 @@ protected IResource TransformToResource(object inputData) switch (inputData) { + case string str: + return Resource.Parse(str, CultureInfo.InvariantCulture); case IResource resource: return Validate(resource); case IDictionary dict: From 4891d62d7d323ab92e1a0eb7fcf85576538d53c9 Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 5 Dec 2024 23:32:51 +0900 Subject: [PATCH 82/84] :recycle: Remove unnecessary code --- src/Jagabata/Cmdlets/UserCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Jagabata/Cmdlets/UserCommand.cs b/src/Jagabata/Cmdlets/UserCommand.cs index 2992beb..9c8e932 100644 --- a/src/Jagabata/Cmdlets/UserCommand.cs +++ b/src/Jagabata/Cmdlets/UserCommand.cs @@ -205,7 +205,7 @@ public class NewUserCommand : NewCommandBase private string? _user; private SecureString? _password; - private bool _passwordInputedFromPrompt = false; + private bool _passwordInputedFromPrompt; private void GatherUserAndPassword() { From a548e6f658870a7c37dba57f765b9f3648aa838e Mon Sep 17 00:00:00 2001 From: teramako Date: Thu, 5 Dec 2024 23:54:13 +0900 Subject: [PATCH 83/84] :recycle: Remove unnecessary code and --- src/Jagabata/Cmdlets/UserCommand.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Jagabata/Cmdlets/UserCommand.cs b/src/Jagabata/Cmdlets/UserCommand.cs index 9c8e932..faae167 100644 --- a/src/Jagabata/Cmdlets/UserCommand.cs +++ b/src/Jagabata/Cmdlets/UserCommand.cs @@ -3,7 +3,6 @@ using Jagabata.Cmdlets.Utilities; using Jagabata.Resources; using System.Management.Automation; -using System.Runtime.InteropServices; using System.Security; namespace Jagabata.Cmdlets @@ -327,7 +326,6 @@ public class UpdateUserCommand : UpdateCommandBase protected override Dictionary CreateSendData() { var sendData = new Dictionary(); - string dataDescription = string.Empty; if (!string.IsNullOrEmpty(UserName)) sendData.Add("username", UserName); if (FirstName is not null) @@ -342,14 +340,7 @@ public class UpdateUserCommand : UpdateCommandBase sendData.Add("is_system_auditor", IsSystemAuditor); if (Password is not null) { - var passwordString = Marshal.PtrToStringUni(Marshal.SecureStringToGlobalAllocUnicode(Password)); - Password.Dispose(); - if (!string.IsNullOrEmpty(passwordString)) - { - sendData.Add("password", "***"); // dummy - dataDescription = Json.Stringify(sendData, pretty: true); - sendData["password"] = passwordString; - } + sendData.Add("password", Password); } return sendData; From 6d9ce415805aa83079cac0bccfe3b967741f599f Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 8 Dec 2024 20:15:12 +0900 Subject: [PATCH 84/84] :gear: Bump up version to v2.2.0 --- src/Jagabata/Jagabata.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Jagabata/Jagabata.csproj b/src/Jagabata/Jagabata.csproj index d56c9ce..290cb16 100644 --- a/src/Jagabata/Jagabata.csproj +++ b/src/Jagabata/Jagabata.csproj @@ -6,7 +6,7 @@ enable Jagabata.psm Jagabata - 2.1.0 + 2.2.0 true