refactor!(scoping): mandate explicit -ProjectId/-Environment; add -Type/-IncludeRoles to Get-InfisicalProject
BREAKING CHANGES
- Connect-Infisical no longer accepts -ProjectId, -Environment, or -SecretPath.
- InfisicalConnection no longer carries ProjectId, Environment, or DefaultSecretPath.
- Every cmdlet that previously inherited those fields now requires -ProjectId
and/or -Environment as Mandatory=true. -SecretPath / -Path remain optional
and default to "/" at the client layer.
- INFISICAL_PROJECT_ID, INFISICAL_ENVIRONMENT, INFISICAL_SECRET_PATH env-var
scanning removed from Connect-Infisical.
- Resolve{ProjectId,Environment,SecretPath} helpers removed from
InfisicalCmdletBase. ResolveOrganizationId retained.
ADDED
- Get-InfisicalProject -Type <enum> filters the list by product surface
(secret-manager, cert-manager, kms, ssh, secret-scanning, pam, ai) with
IntelliSense via ValidateSet.
- Get-InfisicalProject -IncludeRoles switch maps to includeRoles=true/false
query parameter (always sent).
RATIONALE
- Implicit connection scoping caused 400 Bad Request when the active
connection's ProjectId belonged to a different product surface than the
cmdlet's target (e.g. secret-manager project id passed to /cert-manager/*).
- Explicit parameters make scope unambiguous and make scripts portable
across projects.
- The new -Type filter on Get-InfisicalProject lets callers discover the
correct project id for each subsequent CRUD invocation without needing
connection-level inheritance.
INTERNAL
- All client classes (Secrets / Folders / Environments / Tags / Projects /
Pki) now receive scoping as explicit arguments rather than reading the
InfisicalConnection object.
- Client-layer SecretPath / Path defaulting to "/" is preserved via
FirstNonEmpty(...).
- Help XML updated to remove all "session-pinned" / "active connection"
phrasing; OrderedDictionary splatting examples now include the mandatory
parameters.
- 216/216 unit tests passing.
This commit is contained in:
@@ -5,7 +5,6 @@ using System.Reflection;
|
||||
using PSInfisicalAPI.Cmdlets;
|
||||
using PSInfisicalAPI.Connections;
|
||||
using PSInfisicalAPI.Logging;
|
||||
using PSInfisicalAPI.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace PSInfisicalAPI.Tests
|
||||
@@ -26,21 +25,6 @@ namespace PSInfisicalAPI.Tests
|
||||
[Cmdlet(VerbsCommon.Get, "TestCmdlet")]
|
||||
private sealed class TestCmdlet : InfisicalCmdletBase
|
||||
{
|
||||
public string CallResolveProjectId(InfisicalConnection connection, string explicitValue)
|
||||
{
|
||||
return ResolveProjectId(connection, explicitValue);
|
||||
}
|
||||
|
||||
public string CallResolveEnvironment(InfisicalConnection connection, string explicitValue)
|
||||
{
|
||||
return ResolveEnvironment(connection, explicitValue);
|
||||
}
|
||||
|
||||
public string CallResolveSecretPath(InfisicalConnection connection, string explicitValue)
|
||||
{
|
||||
return ResolveSecretPath(connection, explicitValue);
|
||||
}
|
||||
|
||||
public string CallResolveApiVersion(InfisicalConnection connection, string explicitValue)
|
||||
{
|
||||
return ResolveApiVersion(connection, explicitValue);
|
||||
@@ -65,60 +49,11 @@ namespace PSInfisicalAPI.Tests
|
||||
return new InfisicalConnection
|
||||
{
|
||||
BaseUri = new Uri("https://app.example.com"),
|
||||
ProjectId = "proj-conn",
|
||||
Environment = "prod-conn",
|
||||
DefaultSecretPath = "/db",
|
||||
OrganizationId = "org-conn",
|
||||
PinnedApiVersion = "v3"
|
||||
};
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Explicit_Value_Overrides_Connection_And_Does_Not_Log()
|
||||
{
|
||||
RecordingLogger logger = new RecordingLogger();
|
||||
TestCmdlet cmdlet = CreateCmdletWith(logger);
|
||||
|
||||
string resolved = cmdlet.CallResolveProjectId(ConnectionWithDefaults(), "explicit-proj");
|
||||
Assert.Equal("explicit-proj", resolved);
|
||||
Assert.Empty(logger.VerboseEntries);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Missing_Value_Inherits_From_Connection_And_Logs()
|
||||
{
|
||||
RecordingLogger logger = new RecordingLogger();
|
||||
TestCmdlet cmdlet = CreateCmdletWith(logger);
|
||||
|
||||
string resolved = cmdlet.CallResolveProjectId(ConnectionWithDefaults(), null);
|
||||
Assert.Equal("proj-conn", resolved);
|
||||
Assert.Single(logger.VerboseEntries);
|
||||
Assert.Contains("Inherited ProjectId", logger.VerboseEntries[0]);
|
||||
Assert.Contains("proj-conn", logger.VerboseEntries[0]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveSecretPath_Defaults_To_Root_When_Connection_Has_No_Default()
|
||||
{
|
||||
RecordingLogger logger = new RecordingLogger();
|
||||
TestCmdlet cmdlet = CreateCmdletWith(logger);
|
||||
|
||||
InfisicalConnection bareConnection = new InfisicalConnection { BaseUri = new Uri("https://app.example.com") };
|
||||
string resolved = cmdlet.CallResolveSecretPath(bareConnection, null);
|
||||
Assert.Equal("/", resolved);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveSecretPath_Inherits_From_Connection_When_Set()
|
||||
{
|
||||
RecordingLogger logger = new RecordingLogger();
|
||||
TestCmdlet cmdlet = CreateCmdletWith(logger);
|
||||
|
||||
string resolved = cmdlet.CallResolveSecretPath(ConnectionWithDefaults(), null);
|
||||
Assert.Equal("/db", resolved);
|
||||
Assert.Contains(logger.VerboseEntries, v => v.Contains("SecretPath") && v.Contains("/db"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveApiVersion_Prefers_PinnedApiVersion_From_Connection()
|
||||
{
|
||||
@@ -130,14 +65,24 @@ namespace PSInfisicalAPI.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveEnvironment_And_ResolveOrganizationId_Inherit()
|
||||
public void ResolveOrganizationId_Inherits_From_Connection_And_Logs()
|
||||
{
|
||||
RecordingLogger logger = new RecordingLogger();
|
||||
TestCmdlet cmdlet = CreateCmdletWith(logger);
|
||||
|
||||
Assert.Equal("prod-conn", cmdlet.CallResolveEnvironment(ConnectionWithDefaults(), null));
|
||||
Assert.Equal("org-conn", cmdlet.CallResolveOrganizationId(ConnectionWithDefaults(), null));
|
||||
Assert.Equal(2, logger.VerboseEntries.Count);
|
||||
Assert.Single(logger.VerboseEntries);
|
||||
Assert.Contains("OrganizationId", logger.VerboseEntries[0]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveOrganizationId_Explicit_Value_Wins_And_Does_Not_Log()
|
||||
{
|
||||
RecordingLogger logger = new RecordingLogger();
|
||||
TestCmdlet cmdlet = CreateCmdletWith(logger);
|
||||
|
||||
Assert.Equal("explicit-org", cmdlet.CallResolveOrganizationId(ConnectionWithDefaults(), "explicit-org"));
|
||||
Assert.Empty(logger.VerboseEntries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,26 +26,6 @@ namespace PSInfisicalAPI.Tests
|
||||
Assert.True(MatchesAny(name, InfisicalEnvironmentResolver.OrganizationIdPatterns), "Expected match for " + name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("INFISICAL_PROJECT_ID")]
|
||||
[InlineData("INFISICAL_WORKSPACE_ID")]
|
||||
[InlineData("CLOUDINIT_INFISICAL_PROJECTID")]
|
||||
public void ProjectIdPatterns_Match_Expected_Names(string name)
|
||||
{
|
||||
Assert.True(MatchesAny(name, InfisicalEnvironmentResolver.ProjectIdPatterns), "Expected match for " + name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("INFISICAL_ENVIRONMENT")]
|
||||
[InlineData("INFISICAL_ENVIRONMENT_NAME")]
|
||||
[InlineData("INFISICAL_ENV")]
|
||||
[InlineData("INFISICAL_ENV_SLUG")]
|
||||
[InlineData("CLOUDINIT_INFISICAL_ENVIRONMENT")]
|
||||
public void EnvironmentPatterns_Match_Expected_Names(string name)
|
||||
{
|
||||
Assert.True(MatchesAny(name, InfisicalEnvironmentResolver.EnvironmentPatterns), "Expected match for " + name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("INFISICAL_CLIENT_ID")]
|
||||
[InlineData("INFISICAL_UNIVERSAL_AUTH_CLIENT_ID")]
|
||||
@@ -78,15 +58,6 @@ namespace PSInfisicalAPI.Tests
|
||||
Assert.True(MatchesAny(name, InfisicalEnvironmentResolver.AccessTokenPatterns), "Expected match for " + name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("INFISICAL_SECRET_PATH")]
|
||||
[InlineData("INFISICAL_DEFAULT_SECRET_PATH")]
|
||||
[InlineData("CLOUDINIT_INFISICAL_SECRETPATH")]
|
||||
public void SecretPathPatterns_Match_Expected_Names(string name)
|
||||
{
|
||||
Assert.True(MatchesAny(name, InfisicalEnvironmentResolver.SecretPathPatterns), "Expected match for " + name);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("INFISICAL_SECRET_PATH")]
|
||||
[InlineData("INFISICAL_DEFAULT_SECRET_PATH")]
|
||||
@@ -108,9 +79,6 @@ namespace PSInfisicalAPI.Tests
|
||||
Assert.False(MatchesAny(name, InfisicalEnvironmentResolver.AccessTokenPatterns));
|
||||
Assert.False(MatchesAny(name, InfisicalEnvironmentResolver.BaseUriPatterns));
|
||||
Assert.False(MatchesAny(name, InfisicalEnvironmentResolver.OrganizationIdPatterns));
|
||||
Assert.False(MatchesAny(name, InfisicalEnvironmentResolver.ProjectIdPatterns));
|
||||
Assert.False(MatchesAny(name, InfisicalEnvironmentResolver.EnvironmentPatterns));
|
||||
Assert.False(MatchesAny(name, InfisicalEnvironmentResolver.SecretPathPatterns));
|
||||
Assert.False(MatchesAny(name, InfisicalEnvironmentResolver.ApiVersionPatterns));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,18 +33,6 @@ namespace PSInfisicalAPI.Authentication
|
||||
new Regex(@".*INFISICAL.*ORG(ANIZATION)?.*ID.*", DefaultRegexOptions)
|
||||
};
|
||||
|
||||
public static readonly Regex[] ProjectIdPatterns = new[]
|
||||
{
|
||||
new Regex(@".*INFISICAL.*(PROJECT|WORKSPACE).*ID.*", DefaultRegexOptions)
|
||||
};
|
||||
|
||||
public static readonly Regex[] EnvironmentPatterns = new[]
|
||||
{
|
||||
new Regex(@".*INFISICAL.*ENV(IRONMENT)?.*NAME.*", DefaultRegexOptions),
|
||||
new Regex(@".*INFISICAL.*ENV(IRONMENT)?.*SLUG.*", DefaultRegexOptions),
|
||||
new Regex(@".*INFISICAL.*ENV(IRONMENT)?.*", DefaultRegexOptions)
|
||||
};
|
||||
|
||||
public static readonly Regex[] ClientIdPatterns = new[]
|
||||
{
|
||||
new Regex(@".*INFISICAL.*CLIENT.*ID.*", DefaultRegexOptions),
|
||||
@@ -64,12 +52,6 @@ namespace PSInfisicalAPI.Authentication
|
||||
new Regex(@".*INFISICAL.*TOKEN.*", DefaultRegexOptions)
|
||||
};
|
||||
|
||||
public static readonly Regex[] SecretPathPatterns = new[]
|
||||
{
|
||||
new Regex(@".*INFISICAL.*SECRET.*PATH.*", DefaultRegexOptions),
|
||||
new Regex(@".*INFISICAL.*DEFAULT.*PATH.*", DefaultRegexOptions)
|
||||
};
|
||||
|
||||
public static readonly Regex[] ApiVersionPatterns = new[]
|
||||
{
|
||||
new Regex(@".*INFISICAL.*API.*VERSION.*", DefaultRegexOptions)
|
||||
|
||||
@@ -28,12 +28,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Parameter]
|
||||
public string OrganizationId { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string ProjectId { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Environment { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = ParameterSetUniversalAuth)]
|
||||
public string ClientId { get; set; }
|
||||
|
||||
@@ -62,9 +56,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Parameter(Mandatory = true, ParameterSetName = ParameterSetLdap)]
|
||||
public SecureString Password { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string SecretPath { get; set; } = "/";
|
||||
|
||||
[Parameter]
|
||||
public string ApiVersion { get; set; } = "v4";
|
||||
|
||||
@@ -185,9 +176,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
PinnedApiVersion = apiVersionExplicitlyBound ? ApiVersion : null,
|
||||
AuthType = authType,
|
||||
OrganizationId = OrganizationId,
|
||||
ProjectId = ProjectId,
|
||||
Environment = Environment,
|
||||
DefaultSecretPath = string.IsNullOrEmpty(SecretPath) ? "/" : SecretPath,
|
||||
ConnectedAtUtc = DateTimeOffset.UtcNow,
|
||||
ExpiresAtUtc = authResult.ExpiresAtUtc,
|
||||
IsConnected = true,
|
||||
@@ -215,8 +203,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
bool needsScan =
|
||||
BaseUri == null ||
|
||||
string.IsNullOrWhiteSpace(OrganizationId) ||
|
||||
string.IsNullOrWhiteSpace(ProjectId) ||
|
||||
string.IsNullOrWhiteSpace(Environment) ||
|
||||
(tokenSet && (AccessToken == null || AccessToken.Length == 0)) ||
|
||||
(universalSet && string.IsNullOrWhiteSpace(ClientId)) ||
|
||||
(universalSet && (ClientSecret == null || ClientSecret.Length == 0));
|
||||
@@ -242,8 +228,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
OrganizationId = InfisicalEnvironmentResolver.ResolveString("OrganizationId", InfisicalEnvironmentResolver.OrganizationIdPatterns, OrganizationId, Logger);
|
||||
ProjectId = InfisicalEnvironmentResolver.ResolveString("ProjectId", InfisicalEnvironmentResolver.ProjectIdPatterns, ProjectId, Logger);
|
||||
Environment = InfisicalEnvironmentResolver.ResolveString("Environment", InfisicalEnvironmentResolver.EnvironmentPatterns, Environment, Logger);
|
||||
|
||||
if (tokenSet)
|
||||
{
|
||||
@@ -255,15 +239,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
ClientSecret = InfisicalEnvironmentResolver.ResolveSecureString("ClientSecret", InfisicalEnvironmentResolver.ClientSecretPatterns, ClientSecret, Logger);
|
||||
}
|
||||
|
||||
if (!MyInvocation.BoundParameters.ContainsKey("SecretPath"))
|
||||
{
|
||||
string resolvedPath = InfisicalEnvironmentResolver.ResolveString("SecretPath", InfisicalEnvironmentResolver.SecretPathPatterns, null, Logger);
|
||||
if (!string.IsNullOrWhiteSpace(resolvedPath))
|
||||
{
|
||||
SecretPath = resolvedPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (!MyInvocation.BoundParameters.ContainsKey("ApiVersion"))
|
||||
{
|
||||
string resolvedVersion = InfisicalEnvironmentResolver.ResolveString("ApiVersion", InfisicalEnvironmentResolver.ApiVersionPatterns, null, Logger);
|
||||
@@ -280,8 +255,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
|
||||
if (BaseUri == null) { missing.Add("BaseUri"); }
|
||||
if (string.IsNullOrWhiteSpace(OrganizationId)) { missing.Add("OrganizationId"); }
|
||||
if (string.IsNullOrWhiteSpace(ProjectId)) { missing.Add("ProjectId"); }
|
||||
if (string.IsNullOrWhiteSpace(Environment)) { missing.Add("Environment"); }
|
||||
|
||||
if (string.Equals(ParameterSetName, ParameterSetToken, StringComparison.Ordinal))
|
||||
{
|
||||
|
||||
@@ -18,9 +18,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
public string DestinationEnvironment { get; set; }
|
||||
|
||||
[Parameter] public string DestinationSecretPath { get; set; }
|
||||
[Parameter] public string SourceEnvironment { get; set; }
|
||||
[Parameter(Mandatory = true)] public string SourceEnvironment { get; set; }
|
||||
[Parameter] public string SourceSecretPath { get; set; }
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter] public string ApiVersion { get; set; }
|
||||
[Parameter] public SwitchParameter OverwriteExisting { get; set; }
|
||||
[Parameter] public SwitchParameter CopySecretValue { get; set; }
|
||||
@@ -35,9 +35,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
if (SecretId == null || SecretId.Length == 0) { return; }
|
||||
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
string resolvedSourceEnv = ResolveEnvironment(connection, SourceEnvironment);
|
||||
string resolvedSourcePath = ResolveSecretPath(connection, SourceSecretPath);
|
||||
string resolvedApiVersion = ResolveApiVersion(connection, ApiVersion);
|
||||
|
||||
string target = string.Concat(SecretId.Length, " secret(s) -> ", DestinationEnvironment);
|
||||
@@ -45,10 +42,10 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
|
||||
InfisicalDuplicateSecretsRequest request = new InfisicalDuplicateSecretsRequest
|
||||
{
|
||||
ProjectId = resolvedProjectId,
|
||||
SourceEnvironment = resolvedSourceEnv,
|
||||
ProjectId = ProjectId,
|
||||
SourceEnvironment = SourceEnvironment,
|
||||
DestinationEnvironment = DestinationEnvironment,
|
||||
SourceSecretPath = resolvedSourcePath,
|
||||
SourceSecretPath = SourceSecretPath,
|
||||
DestinationSecretPath = DestinationSecretPath,
|
||||
SecretIds = SecretId,
|
||||
ApiVersion = resolvedApiVersion,
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Name")]
|
||||
public string ApplicationName { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = "List")] public int? Limit { get; set; }
|
||||
|
||||
@@ -30,23 +30,22 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
InfisicalPkiClient client = new InfisicalPkiClient(HttpClient, Logger);
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
|
||||
if (string.Equals(ParameterSetName, "ById", StringComparison.Ordinal))
|
||||
{
|
||||
InfisicalCertificateApplication app = client.GetCertificateApplication(connection, Id, resolvedProjectId);
|
||||
InfisicalCertificateApplication app = client.GetCertificateApplication(connection, Id, ProjectId);
|
||||
if (app != null) { WriteObject(app); }
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.Equals(ParameterSetName, "ByName", StringComparison.Ordinal))
|
||||
{
|
||||
InfisicalCertificateApplication app = client.GetCertificateApplicationByName(connection, ApplicationName, resolvedProjectId);
|
||||
InfisicalCertificateApplication app = client.GetCertificateApplicationByName(connection, ApplicationName, ProjectId);
|
||||
if (app != null) { WriteObject(app); }
|
||||
return;
|
||||
}
|
||||
|
||||
InfisicalCertificateApplication[] all = client.ListCertificateApplications(connection, resolvedProjectId, Limit, Offset);
|
||||
InfisicalCertificateApplication[] all = client.ListCertificateApplications(connection, ProjectId, Limit, Offset);
|
||||
foreach (InfisicalCertificateApplication app in all)
|
||||
{
|
||||
WriteObject(app);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("CertificateProfileId")]
|
||||
public string ProfileId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
@@ -26,9 +26,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
InfisicalPkiClient client = new InfisicalPkiClient(HttpClient, Logger);
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
|
||||
InfisicalCertificateApplicationEnrollment enrollment = client.GetCertificateApplicationEnrollment(connection, ApplicationId, ProfileId, resolvedProjectId);
|
||||
InfisicalCertificateApplicationEnrollment enrollment = client.GetCertificateApplicationEnrollment(connection, ApplicationId, ProfileId, ProjectId);
|
||||
if (enrollment != null)
|
||||
{
|
||||
WriteObject(enrollment);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Id")]
|
||||
public string CaId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = "List")]
|
||||
[ValidateSet("Internal", "Acme", "Any")]
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
public string SerialNumber { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = "List")] public SwitchParameter List { get; set; }
|
||||
[Parameter(ParameterSetName = "List")] public string ProjectId { get; set; }
|
||||
[Parameter(ParameterSetName = "List", Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter(ParameterSetName = "List")] public string CommonName { get; set; }
|
||||
[Parameter(ParameterSetName = "List")] public string FriendlyName { get; set; }
|
||||
[Parameter(ParameterSetName = "List")] public string Status { get; set; }
|
||||
@@ -42,11 +42,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
return;
|
||||
}
|
||||
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
|
||||
InfisicalCertificateSearchQuery query = new InfisicalCertificateSearchQuery
|
||||
{
|
||||
ProjectId = resolvedProjectId,
|
||||
ProjectId = ProjectId,
|
||||
CommonName = CommonName,
|
||||
FriendlyName = FriendlyName,
|
||||
Status = Status,
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Id", "CertificatePolicyId")]
|
||||
public string PolicyId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = "List")] public int? Limit { get; set; }
|
||||
|
||||
@@ -26,11 +26,10 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
InfisicalPkiClient client = new InfisicalPkiClient(HttpClient, Logger);
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
|
||||
if (string.Equals(ParameterSetName, "ById", StringComparison.Ordinal))
|
||||
{
|
||||
InfisicalCertificatePolicy policy = client.GetCertificatePolicy(connection, PolicyId, resolvedProjectId);
|
||||
InfisicalCertificatePolicy policy = client.GetCertificatePolicy(connection, PolicyId, ProjectId);
|
||||
if (policy != null)
|
||||
{
|
||||
WriteObject(policy);
|
||||
@@ -39,7 +38,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
return;
|
||||
}
|
||||
|
||||
InfisicalCertificatePolicy[] all = client.ListCertificatePolicies(connection, resolvedProjectId, Limit, Offset);
|
||||
InfisicalCertificatePolicy[] all = client.ListCertificatePolicies(connection, ProjectId, Limit, Offset);
|
||||
foreach (InfisicalCertificatePolicy policy in all)
|
||||
{
|
||||
WriteObject(policy);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Id", "CertificateProfileId")]
|
||||
public string ProfileId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = "List")] public int? Limit { get; set; }
|
||||
|
||||
@@ -28,11 +28,10 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
InfisicalPkiClient client = new InfisicalPkiClient(HttpClient, Logger);
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
|
||||
if (string.Equals(ParameterSetName, "ById", StringComparison.Ordinal))
|
||||
{
|
||||
InfisicalCertificateProfile profile = client.GetCertificateProfile(connection, ProfileId, resolvedProjectId);
|
||||
InfisicalCertificateProfile profile = client.GetCertificateProfile(connection, ProfileId, ProjectId);
|
||||
if (profile != null)
|
||||
{
|
||||
WriteObject(profile);
|
||||
@@ -42,7 +41,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
bool? includeConfigs = MyInvocation.BoundParameters.ContainsKey("IncludeConfigs") ? (bool?)IncludeConfigs.IsPresent : null;
|
||||
InfisicalCertificateProfile[] all = client.ListCertificateProfiles(connection, resolvedProjectId, Limit, Offset, includeConfigs);
|
||||
InfisicalCertificateProfile[] all = client.ListCertificateProfiles(connection, ProjectId, Limit, Offset, includeConfigs);
|
||||
foreach (InfisicalCertificateProfile profile in all)
|
||||
{
|
||||
WriteObject(profile);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Slug", "Id", "Environment")]
|
||||
public string EnvironmentSlugOrId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = "List")] public SwitchParameter List { get; set; }
|
||||
|
||||
@@ -23,12 +23,11 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
try
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
InfisicalEnvironmentClient client = new InfisicalEnvironmentClient(HttpClient, Logger);
|
||||
|
||||
if (string.Equals(ParameterSetName, "Single", StringComparison.Ordinal))
|
||||
{
|
||||
InfisicalEnvironment env = client.Retrieve(connection, resolvedProjectId, EnvironmentSlugOrId);
|
||||
InfisicalEnvironment env = client.Retrieve(connection, ProjectId, EnvironmentSlugOrId);
|
||||
if (env != null)
|
||||
{
|
||||
WriteObject(env);
|
||||
@@ -37,7 +36,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
return;
|
||||
}
|
||||
|
||||
InfisicalEnvironment[] envs = client.List(connection, resolvedProjectId);
|
||||
InfisicalEnvironment[] envs = client.List(connection, ProjectId);
|
||||
foreach (InfisicalEnvironment env in envs)
|
||||
{
|
||||
WriteObject(env);
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Name", "Id")]
|
||||
public string FolderNameOrId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter] public string Environment { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string Environment { get; set; }
|
||||
[Parameter] public string Path { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = "List")] public SwitchParameter List { get; set; }
|
||||
@@ -25,14 +25,11 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
try
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
string resolvedEnvironment = ResolveEnvironment(connection, Environment);
|
||||
string resolvedPath = ResolveSecretPath(connection, Path);
|
||||
InfisicalFolderClient client = new InfisicalFolderClient(HttpClient, Logger);
|
||||
|
||||
if (string.Equals(ParameterSetName, "Single", StringComparison.Ordinal))
|
||||
{
|
||||
InfisicalFolder folder = client.Retrieve(connection, resolvedProjectId, resolvedEnvironment, resolvedPath, FolderNameOrId);
|
||||
InfisicalFolder folder = client.Retrieve(connection, ProjectId, Environment, Path, FolderNameOrId);
|
||||
if (folder != null)
|
||||
{
|
||||
WriteObject(folder);
|
||||
@@ -41,7 +38,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
return;
|
||||
}
|
||||
|
||||
InfisicalFolder[] folders = client.List(connection, resolvedProjectId, resolvedEnvironment, resolvedPath);
|
||||
InfisicalFolder[] folders = client.List(connection, ProjectId, Environment, Path);
|
||||
foreach (InfisicalFolder folder in folders)
|
||||
{
|
||||
WriteObject(folder);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("SubscriberName", "Slug")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
@@ -22,11 +22,10 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
InfisicalPkiClient client = new InfisicalPkiClient(HttpClient, Logger);
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
|
||||
if (string.Equals(ParameterSetName, "ByName", StringComparison.Ordinal))
|
||||
{
|
||||
InfisicalPkiSubscriber subscriber = client.GetPkiSubscriber(connection, Name, resolvedProjectId);
|
||||
InfisicalPkiSubscriber subscriber = client.GetPkiSubscriber(connection, Name, ProjectId);
|
||||
if (subscriber != null)
|
||||
{
|
||||
WriteObject(subscriber);
|
||||
@@ -35,7 +34,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
return;
|
||||
}
|
||||
|
||||
InfisicalPkiSubscriber[] all = client.ListPkiSubscribers(connection, resolvedProjectId);
|
||||
InfisicalPkiSubscriber[] all = client.ListPkiSubscribers(connection, ProjectId);
|
||||
foreach (InfisicalPkiSubscriber subscriber in all)
|
||||
{
|
||||
WriteObject(subscriber);
|
||||
|
||||
@@ -16,6 +16,12 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
|
||||
[Parameter(ParameterSetName = "List")] public SwitchParameter List { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = "List")]
|
||||
[ValidateSet("secret-manager", "cert-manager", "kms", "ssh", "secret-scanning", "pam", "ai")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = "List")] public SwitchParameter IncludeRoles { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
try
|
||||
@@ -25,8 +31,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
|
||||
if (string.Equals(ParameterSetName, "Single", StringComparison.Ordinal))
|
||||
{
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
InfisicalProject project = client.Retrieve(connection, resolvedProjectId);
|
||||
InfisicalProject project = client.Retrieve(connection, ProjectId);
|
||||
if (project != null)
|
||||
{
|
||||
WriteObject(project);
|
||||
@@ -35,7 +40,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
return;
|
||||
}
|
||||
|
||||
InfisicalProject[] projects = client.List(connection);
|
||||
InfisicalProject[] projects = client.List(connection, Type, IncludeRoles.IsPresent);
|
||||
foreach (InfisicalProject project in projects)
|
||||
{
|
||||
WriteObject(project);
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Parameter(ParameterSetName = "Single", Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 0)]
|
||||
public string SecretName { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter] public string Environment { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string Environment { get; set; }
|
||||
[Parameter] public string SecretPath { get; set; }
|
||||
[Parameter] public string ApiVersion { get; set; }
|
||||
[Parameter] public SwitchParameter ViewSecretValue { get; set; } = SwitchParameter.Present;
|
||||
@@ -44,9 +44,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
InfisicalRetrieveSecretQuery query = new InfisicalRetrieveSecretQuery
|
||||
{
|
||||
SecretName = SecretName,
|
||||
ProjectId = ResolveProjectId(connection, ProjectId),
|
||||
Environment = ResolveEnvironment(connection, Environment),
|
||||
SecretPath = ResolveSecretPath(connection, SecretPath),
|
||||
ProjectId = ProjectId,
|
||||
Environment = Environment,
|
||||
SecretPath = SecretPath,
|
||||
ApiVersion = ResolveApiVersion(connection, ApiVersion),
|
||||
Version = Version,
|
||||
Type = Type.ToString(),
|
||||
@@ -66,9 +66,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
|
||||
InfisicalListSecretsQuery listQuery = new InfisicalListSecretsQuery
|
||||
{
|
||||
ProjectId = ResolveProjectId(connection, ProjectId),
|
||||
Environment = ResolveEnvironment(connection, Environment),
|
||||
SecretPath = ResolveSecretPath(connection, SecretPath),
|
||||
ProjectId = ProjectId,
|
||||
Environment = Environment,
|
||||
SecretPath = SecretPath,
|
||||
ApiVersion = ResolveApiVersion(connection, ApiVersion),
|
||||
Recursive = Recursive.IsPresent,
|
||||
IncludeImports = IncludeImports.IsPresent,
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Slug", "Id")]
|
||||
public string TagSlugOrId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
|
||||
[Parameter(ParameterSetName = "List")] public SwitchParameter List { get; set; }
|
||||
|
||||
@@ -23,12 +23,11 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
try
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
InfisicalTagClient client = new InfisicalTagClient(HttpClient, Logger);
|
||||
|
||||
if (string.Equals(ParameterSetName, "Single", StringComparison.Ordinal))
|
||||
{
|
||||
InfisicalTag tag = client.Retrieve(connection, resolvedProjectId, TagSlugOrId);
|
||||
InfisicalTag tag = client.Retrieve(connection, ProjectId, TagSlugOrId);
|
||||
if (tag != null)
|
||||
{
|
||||
WriteObject(tag);
|
||||
@@ -37,7 +36,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
return;
|
||||
}
|
||||
|
||||
InfisicalTag[] tags = client.List(connection, resolvedProjectId);
|
||||
InfisicalTag[] tags = client.List(connection, ProjectId);
|
||||
foreach (InfisicalTag tag in tags)
|
||||
{
|
||||
WriteObject(tag);
|
||||
|
||||
@@ -46,21 +46,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
ThrowTerminatingError(record);
|
||||
}
|
||||
|
||||
protected string ResolveProjectId(InfisicalConnection connection, string explicitValue)
|
||||
{
|
||||
return ResolveValue("ProjectId", explicitValue, connection != null ? connection.ProjectId : null, null);
|
||||
}
|
||||
|
||||
protected string ResolveEnvironment(InfisicalConnection connection, string explicitValue)
|
||||
{
|
||||
return ResolveValue("Environment", explicitValue, connection != null ? connection.Environment : null, null);
|
||||
}
|
||||
|
||||
protected string ResolveSecretPath(InfisicalConnection connection, string explicitValue)
|
||||
{
|
||||
return ResolveValue("SecretPath", explicitValue, connection != null ? connection.DefaultSecretPath : null, "/");
|
||||
}
|
||||
|
||||
protected string ResolveApiVersion(InfisicalConnection connection, string explicitValue)
|
||||
{
|
||||
string fromConnection = connection != null ? (!string.IsNullOrEmpty(connection.PinnedApiVersion) ? connection.PinnedApiVersion : connection.ApiVersion) : null;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
{
|
||||
[Parameter(Mandatory = true, Position = 0)] public string Name { get; set; }
|
||||
[Parameter(Mandatory = true, Position = 1)] public string Slug { get; set; }
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter] public int? Position { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
@@ -25,9 +25,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
InfisicalEnvironmentClient client = new InfisicalEnvironmentClient(HttpClient, Logger);
|
||||
InfisicalEnvironment env = client.Create(connection, resolvedProjectId, Name, Slug, Position);
|
||||
InfisicalEnvironment env = client.Create(connection, ProjectId, Name, Slug, Position);
|
||||
if (env != null)
|
||||
{
|
||||
WriteObject(env);
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
public sealed class NewInfisicalFolderCmdlet : InfisicalCmdletBase
|
||||
{
|
||||
[Parameter(Mandatory = true, Position = 0)] public string Name { get; set; }
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter] public string Environment { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string Environment { get; set; }
|
||||
[Parameter] public string Path { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
@@ -25,11 +25,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
string resolvedEnvironment = ResolveEnvironment(connection, Environment);
|
||||
string resolvedPath = ResolveSecretPath(connection, Path);
|
||||
InfisicalFolderClient client = new InfisicalFolderClient(HttpClient, Logger);
|
||||
InfisicalFolder folder = client.Create(connection, resolvedProjectId, resolvedEnvironment, Name, resolvedPath);
|
||||
InfisicalFolder folder = client.Create(connection, ProjectId, Environment, Name, Path);
|
||||
if (folder != null)
|
||||
{
|
||||
WriteObject(folder);
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
public IDictionary<string, string>[] Secrets { get; set; }
|
||||
|
||||
[Parameter] public string SecretComment { get; set; }
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter] public string Environment { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string Environment { get; set; }
|
||||
[Parameter] public string SecretPath { get; set; }
|
||||
[Parameter] public string ApiVersion { get; set; }
|
||||
[Parameter] public InfisicalSecretType Type { get; set; } = InfisicalSecretType.Shared;
|
||||
@@ -41,9 +41,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
try
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
string resolvedEnvironment = ResolveEnvironment(connection, Environment);
|
||||
string resolvedSecretPath = ResolveSecretPath(connection, SecretPath);
|
||||
string resolvedApiVersion = ResolveApiVersion(connection, ApiVersion);
|
||||
|
||||
if (string.Equals(ParameterSetName, "Bulk", StringComparison.Ordinal))
|
||||
@@ -54,9 +51,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
|
||||
InfisicalBulkCreateSecretsRequest bulk = new InfisicalBulkCreateSecretsRequest
|
||||
{
|
||||
ProjectId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = resolvedSecretPath,
|
||||
ProjectId = ProjectId,
|
||||
Environment = Environment,
|
||||
SecretPath = SecretPath,
|
||||
ApiVersion = resolvedApiVersion,
|
||||
Secrets = InfisicalBulkSecretConverter.ToCreateItems(Secrets)
|
||||
};
|
||||
@@ -82,9 +79,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
SecretName = SecretName,
|
||||
SecretValue = plainValue,
|
||||
SecretComment = SecretComment,
|
||||
ProjectId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = resolvedSecretPath,
|
||||
ProjectId = ProjectId,
|
||||
Environment = Environment,
|
||||
SecretPath = SecretPath,
|
||||
Type = Type.ToString(),
|
||||
ApiVersion = resolvedApiVersion,
|
||||
SkipMultilineEncoding = SkipMultilineEncoding.IsPresent ? (bool?)true : null,
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Parameter(Mandatory = true, Position = 0)] public string Slug { get; set; }
|
||||
[Parameter] public string Name { get; set; }
|
||||
[Parameter] public string Color { get; set; }
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
@@ -25,9 +25,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
InfisicalTagClient client = new InfisicalTagClient(HttpClient, Logger);
|
||||
InfisicalTag tag = client.Create(connection, resolvedProjectId, Slug, Name, Color);
|
||||
InfisicalTag tag = client.Create(connection, ProjectId, Slug, Name, Color);
|
||||
if (tag != null)
|
||||
{
|
||||
WriteObject(tag);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Id")]
|
||||
public string EnvironmentId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter] public SwitchParameter PassThru { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
@@ -25,9 +25,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
InfisicalEnvironmentClient client = new InfisicalEnvironmentClient(HttpClient, Logger);
|
||||
client.Delete(connection, resolvedProjectId, EnvironmentId);
|
||||
client.Delete(connection, ProjectId, EnvironmentId);
|
||||
|
||||
if (PassThru.IsPresent)
|
||||
{
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Id")]
|
||||
public string FolderId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter] public string Environment { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string Environment { get; set; }
|
||||
[Parameter] public string Path { get; set; }
|
||||
[Parameter] public SwitchParameter PassThru { get; set; }
|
||||
|
||||
@@ -27,11 +27,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
string resolvedEnvironment = ResolveEnvironment(connection, Environment);
|
||||
string resolvedPath = ResolveSecretPath(connection, Path);
|
||||
InfisicalFolderClient client = new InfisicalFolderClient(HttpClient, Logger);
|
||||
client.Delete(connection, resolvedProjectId, resolvedEnvironment, FolderId, resolvedPath);
|
||||
client.Delete(connection, ProjectId, Environment, FolderId, Path);
|
||||
|
||||
if (PassThru.IsPresent)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Cmdlet(VerbsCommon.Remove, "InfisicalProject", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
|
||||
public sealed class RemoveInfisicalProjectCmdlet : InfisicalCmdletBase
|
||||
{
|
||||
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0)]
|
||||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 0)]
|
||||
[Alias("Id")]
|
||||
public string ProjectId { get; set; }
|
||||
|
||||
@@ -19,19 +19,18 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
try
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
|
||||
if (!ShouldProcess(resolvedProjectId, "Remove Infisical project"))
|
||||
if (!ShouldProcess(ProjectId, "Remove Infisical project"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InfisicalProjectClient client = new InfisicalProjectClient(HttpClient, Logger);
|
||||
client.Delete(connection, resolvedProjectId);
|
||||
client.Delete(connection, ProjectId);
|
||||
|
||||
if (PassThru.IsPresent)
|
||||
{
|
||||
WriteObject(resolvedProjectId);
|
||||
WriteObject(ProjectId);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Names", "SecretKeys")]
|
||||
public string[] SecretNames { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter] public string Environment { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string Environment { get; set; }
|
||||
[Parameter] public string SecretPath { get; set; }
|
||||
[Parameter] public string ApiVersion { get; set; }
|
||||
[Parameter] public InfisicalSecretType Type { get; set; } = InfisicalSecretType.Shared;
|
||||
@@ -28,9 +28,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
try
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
string resolvedEnvironment = ResolveEnvironment(connection, Environment);
|
||||
string resolvedSecretPath = ResolveSecretPath(connection, SecretPath);
|
||||
string resolvedApiVersion = ResolveApiVersion(connection, ApiVersion);
|
||||
|
||||
InfisicalSecretsClient client = new InfisicalSecretsClient(HttpClient, Logger);
|
||||
@@ -43,9 +40,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
|
||||
InfisicalBulkDeleteSecretsRequest bulk = new InfisicalBulkDeleteSecretsRequest
|
||||
{
|
||||
ProjectId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = resolvedSecretPath,
|
||||
ProjectId = ProjectId,
|
||||
Environment = Environment,
|
||||
SecretPath = SecretPath,
|
||||
ApiVersion = resolvedApiVersion,
|
||||
SecretNames = SecretNames
|
||||
};
|
||||
@@ -65,9 +62,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
InfisicalDeleteSecretRequest request = new InfisicalDeleteSecretRequest
|
||||
{
|
||||
SecretName = SecretName,
|
||||
ProjectId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = resolvedSecretPath,
|
||||
ProjectId = ProjectId,
|
||||
Environment = Environment,
|
||||
SecretPath = SecretPath,
|
||||
Type = Type.ToString(),
|
||||
ApiVersion = resolvedApiVersion
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Id")]
|
||||
public string TagId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter] public SwitchParameter PassThru { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
@@ -25,9 +25,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
InfisicalTagClient client = new InfisicalTagClient(HttpClient, Logger);
|
||||
client.Delete(connection, resolvedProjectId, TagId);
|
||||
client.Delete(connection, ProjectId, TagId);
|
||||
|
||||
if (PassThru.IsPresent)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("ProfileId")]
|
||||
public string CertificateProfileId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter] public IDictionary Subject { get; set; }
|
||||
[Parameter] public string CommonName { get; set; }
|
||||
[Parameter] public string Country { get; set; }
|
||||
@@ -77,14 +77,13 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
InfisicalPkiClient client = new InfisicalPkiClient(HttpClient, Logger);
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
|
||||
InfisicalCsrSubject csrSubject = InfisicalCertificateRequestHelpers.MergeSubject(Subject, CommonName, Country, State, Locality, Organization, OrganizationalUnit, EmailAddress);
|
||||
List<string> dnsNames = BuildDnsNames(csrSubject);
|
||||
if (string.IsNullOrEmpty(csrSubject.CommonName) && dnsNames.Count > 0) { csrSubject.CommonName = dnsNames[0]; }
|
||||
if (string.IsNullOrEmpty(csrSubject.CommonName)) { throw new InvalidOperationException("Subject CommonName could not be determined and no DnsName was provided."); }
|
||||
|
||||
X509Certificate2 existing = TryFindExisting(client, connection, resolvedProjectId, csrSubject.CommonName);
|
||||
X509Certificate2 existing = TryFindExisting(client, connection, ProjectId, csrSubject.CommonName);
|
||||
if (existing != null && !Force.IsPresent && !(AllowRenewal.IsPresent && InfisicalLocalCertificateLookup.IsRenewable(existing, RenewalThresholdDays)))
|
||||
{
|
||||
Logger.Information(Component, string.Concat("Reusing existing certificate (Thumbprint=", existing.Thumbprint, ", NotAfter=", existing.NotAfter.ToString("u"), ")."));
|
||||
@@ -118,7 +117,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
|
||||
InfisicalCsrOptions csrOptions = new InfisicalCsrOptions { KeyAlgorithm = KeyAlgorithm, RsaKeySize = KeySize, EcCurve = Curve };
|
||||
InfisicalCsrResult csr = InfisicalCsrBuilder.Build(csrSubject, dnsNames, IpAddress, csrOptions);
|
||||
InfisicalSignedCertificate signed = SignCertificate(client, connection, resolvedProjectId, csr.CsrPem);
|
||||
InfisicalSignedCertificate signed = SignCertificate(client, connection, ProjectId, csr.CsrPem);
|
||||
signed.PrivateKeyPem = csr.PrivateKeyPem;
|
||||
|
||||
if (string.IsNullOrEmpty(signed.CertificatePem))
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[OutputType(typeof(InfisicalCertificate))]
|
||||
public sealed class SearchInfisicalCertificateCmdlet : InfisicalCmdletBase
|
||||
{
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter] public string FriendlyName { get; set; }
|
||||
[Parameter] public string CommonName { get; set; }
|
||||
[Parameter] public string Search { get; set; }
|
||||
@@ -39,10 +39,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
try
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
InfisicalPkiClient client = new InfisicalPkiClient(HttpClient, Logger);
|
||||
|
||||
InfisicalCertificateSearchQuery query = BuildQuery(resolvedProjectId);
|
||||
InfisicalCertificateSearchQuery query = BuildQuery(ProjectId);
|
||||
int requestedLimit = query.Limit ?? 100;
|
||||
query.Limit = requestedLimit;
|
||||
query.Offset = query.Offset ?? 0;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Alias("Id")]
|
||||
public string EnvironmentId { get; set; }
|
||||
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter] public string Name { get; set; }
|
||||
[Parameter] public string Slug { get; set; }
|
||||
[Parameter] public int? Position { get; set; }
|
||||
@@ -29,9 +29,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
InfisicalEnvironmentClient client = new InfisicalEnvironmentClient(HttpClient, Logger);
|
||||
InfisicalEnvironment env = client.Update(connection, resolvedProjectId, EnvironmentId, Name, Slug, Position);
|
||||
InfisicalEnvironment env = client.Update(connection, ProjectId, EnvironmentId, Name, Slug, Position);
|
||||
if (env != null)
|
||||
{
|
||||
WriteObject(env);
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
public string FolderId { get; set; }
|
||||
|
||||
[Parameter(Mandatory = true, Position = 1)] public string Name { get; set; }
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter] public string Environment { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string Environment { get; set; }
|
||||
[Parameter] public string Path { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
@@ -29,11 +29,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
string resolvedEnvironment = ResolveEnvironment(connection, Environment);
|
||||
string resolvedPath = ResolveSecretPath(connection, Path);
|
||||
InfisicalFolderClient client = new InfisicalFolderClient(HttpClient, Logger);
|
||||
InfisicalFolder folder = client.Update(connection, resolvedProjectId, resolvedEnvironment, FolderId, Name, resolvedPath);
|
||||
InfisicalFolder folder = client.Update(connection, ProjectId, Environment, FolderId, Name, Path);
|
||||
if (folder != null)
|
||||
{
|
||||
WriteObject(folder);
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[OutputType(typeof(InfisicalProject))]
|
||||
public sealed class UpdateInfisicalProjectCmdlet : InfisicalCmdletBase
|
||||
{
|
||||
[Parameter(ValueFromPipelineByPropertyName = true, Position = 0)]
|
||||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 0)]
|
||||
[Alias("Id")]
|
||||
public string ProjectId { get; set; }
|
||||
|
||||
@@ -23,15 +23,14 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
try
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
|
||||
if (!ShouldProcess(resolvedProjectId, "Update Infisical project"))
|
||||
if (!ShouldProcess(ProjectId, "Update Infisical project"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InfisicalProjectClient client = new InfisicalProjectClient(HttpClient, Logger);
|
||||
InfisicalProject project = client.Update(connection, resolvedProjectId, Name, Description, AutoCapitalization);
|
||||
InfisicalProject project = client.Update(connection, ProjectId, Name, Description, AutoCapitalization);
|
||||
if (project != null)
|
||||
{
|
||||
WriteObject(project);
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
|
||||
[Parameter] public string NewSecretName { get; set; }
|
||||
[Parameter] public string SecretComment { get; set; }
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter] public string Environment { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string Environment { get; set; }
|
||||
[Parameter] public string SecretPath { get; set; }
|
||||
[Parameter] public string ApiVersion { get; set; }
|
||||
[Parameter] public InfisicalSecretType Type { get; set; } = InfisicalSecretType.Shared;
|
||||
@@ -39,9 +39,6 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
try
|
||||
{
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
string resolvedEnvironment = ResolveEnvironment(connection, Environment);
|
||||
string resolvedSecretPath = ResolveSecretPath(connection, SecretPath);
|
||||
string resolvedApiVersion = ResolveApiVersion(connection, ApiVersion);
|
||||
|
||||
if (string.Equals(ParameterSetName, "Bulk", StringComparison.Ordinal))
|
||||
@@ -52,9 +49,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
|
||||
InfisicalBulkUpdateSecretsRequest bulk = new InfisicalBulkUpdateSecretsRequest
|
||||
{
|
||||
ProjectId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = resolvedSecretPath,
|
||||
ProjectId = ProjectId,
|
||||
Environment = Environment,
|
||||
SecretPath = SecretPath,
|
||||
ApiVersion = resolvedApiVersion,
|
||||
Secrets = InfisicalBulkSecretConverter.ToUpdateItems(Secrets)
|
||||
};
|
||||
@@ -81,9 +78,9 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
NewSecretName = NewSecretName,
|
||||
SecretValue = plainValue,
|
||||
SecretComment = SecretComment,
|
||||
ProjectId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = resolvedSecretPath,
|
||||
ProjectId = ProjectId,
|
||||
Environment = Environment,
|
||||
SecretPath = SecretPath,
|
||||
Type = Type.ToString(),
|
||||
ApiVersion = resolvedApiVersion,
|
||||
SkipMultilineEncoding = SkipMultilineEncoding.IsPresent ? (bool?)true : null,
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
[Parameter] public string Slug { get; set; }
|
||||
[Parameter] public string Name { get; set; }
|
||||
[Parameter] public string Color { get; set; }
|
||||
[Parameter] public string ProjectId { get; set; }
|
||||
[Parameter(Mandatory = true)] public string ProjectId { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
@@ -29,9 +29,8 @@ namespace PSInfisicalAPI.Cmdlets
|
||||
}
|
||||
|
||||
InfisicalConnection connection = InfisicalSessionManager.RequireCurrent();
|
||||
string resolvedProjectId = ResolveProjectId(connection, ProjectId);
|
||||
InfisicalTagClient client = new InfisicalTagClient(HttpClient, Logger);
|
||||
InfisicalTag tag = client.Update(connection, resolvedProjectId, TagId, Slug, Name, Color);
|
||||
InfisicalTag tag = client.Update(connection, ProjectId, TagId, Slug, Name, Color);
|
||||
if (tag != null)
|
||||
{
|
||||
WriteObject(tag);
|
||||
|
||||
@@ -12,9 +12,6 @@ namespace PSInfisicalAPI.Connections
|
||||
public string PinnedApiVersion { get; set; }
|
||||
public InfisicalAuthType AuthType { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string ProjectId { get; set; }
|
||||
public string Environment { get; set; }
|
||||
public string DefaultSecretPath { get; set; }
|
||||
public DateTimeOffset ConnectedAtUtc { get; set; }
|
||||
public DateTimeOffset? ExpiresAtUtc { get; set; }
|
||||
public bool IsConnected { get; set; }
|
||||
@@ -26,8 +23,8 @@ namespace PSInfisicalAPI.Connections
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Concat(
|
||||
"Project=", ProjectId ?? "",
|
||||
" Environment=", Environment ?? "",
|
||||
"BaseUri=", BaseUri != null ? BaseUri.ToString() : "",
|
||||
" AuthType=", AuthType.ToString(),
|
||||
" Connected=", IsConnected ? "true" : "false");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,9 @@ namespace PSInfisicalAPI.Environments
|
||||
public InfisicalEnvironment[] List(InfisicalConnection connection, string projectId)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", resolvedProjectId } };
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", projectId } };
|
||||
|
||||
try
|
||||
{
|
||||
@@ -43,7 +42,7 @@ namespace PSInfisicalAPI.Environments
|
||||
|
||||
InfisicalEnvironmentWorkspaceDto workspace = dto != null ? (dto.Workspace ?? dto.Project) : null;
|
||||
List<InfisicalEnvironmentResponseDto> envs = workspace != null ? workspace.Environments : null;
|
||||
InfisicalEnvironment[] mapped = InfisicalEnvironmentMapper.MapMany(envs, resolvedProjectId);
|
||||
InfisicalEnvironment[] mapped = InfisicalEnvironmentMapper.MapMany(envs, projectId);
|
||||
_logger.Information(Component, "Infisical environment list retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -57,11 +56,10 @@ namespace PSInfisicalAPI.Environments
|
||||
public InfisicalEnvironment Retrieve(InfisicalConnection connection, string projectId, string environmentSlugOrId)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(environmentSlugOrId)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
|
||||
InfisicalEnvironment[] all = List(connection, resolvedProjectId);
|
||||
InfisicalEnvironment[] all = List(connection, projectId);
|
||||
foreach (InfisicalEnvironment env in all)
|
||||
{
|
||||
if (string.Equals(env.Id, environmentSlugOrId, StringComparison.OrdinalIgnoreCase) ||
|
||||
@@ -77,12 +75,11 @@ namespace PSInfisicalAPI.Environments
|
||||
public InfisicalEnvironment Create(InfisicalConnection connection, string projectId, string name, string slug, int? position)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(name)) { throw new InfisicalConfigurationException("Name is required."); }
|
||||
if (string.IsNullOrEmpty(slug)) { throw new InfisicalConfigurationException("Slug is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", resolvedProjectId } };
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", projectId } };
|
||||
InfisicalEnvironmentCreateRequestDto request = new InfisicalEnvironmentCreateRequestDto { Name = name, Slug = slug, Position = position };
|
||||
string body = _serializer.Serialize(request);
|
||||
|
||||
@@ -93,7 +90,7 @@ namespace PSInfisicalAPI.Environments
|
||||
InfisicalEnvironmentSingleResponseDto dto = _serializer.Deserialize<InfisicalEnvironmentSingleResponseDto>(response.Body);
|
||||
response.Clear();
|
||||
|
||||
InfisicalEnvironment mapped = InfisicalEnvironmentMapper.Map(dto != null ? dto.Environment : null, resolvedProjectId);
|
||||
InfisicalEnvironment mapped = InfisicalEnvironmentMapper.Map(dto != null ? dto.Environment : null, projectId);
|
||||
_logger.Information(Component, "Infisical environment creation was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -107,11 +104,10 @@ namespace PSInfisicalAPI.Environments
|
||||
public InfisicalEnvironment Update(InfisicalConnection connection, string projectId, string environmentId, string name, string slug, int? position)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(environmentId)) { throw new InfisicalConfigurationException("EnvironmentId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", resolvedProjectId }, { "environmentId", environmentId } };
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", projectId }, { "environmentId", environmentId } };
|
||||
InfisicalEnvironmentUpdateRequestDto request = new InfisicalEnvironmentUpdateRequestDto { Name = name, Slug = slug, Position = position };
|
||||
string body = _serializer.Serialize(request);
|
||||
|
||||
@@ -122,7 +118,7 @@ namespace PSInfisicalAPI.Environments
|
||||
InfisicalEnvironmentSingleResponseDto dto = _serializer.Deserialize<InfisicalEnvironmentSingleResponseDto>(response.Body);
|
||||
response.Clear();
|
||||
|
||||
InfisicalEnvironment mapped = InfisicalEnvironmentMapper.Map(dto != null ? dto.Environment : null, resolvedProjectId);
|
||||
InfisicalEnvironment mapped = InfisicalEnvironmentMapper.Map(dto != null ? dto.Environment : null, projectId);
|
||||
_logger.Information(Component, "Infisical environment update was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -136,11 +132,10 @@ namespace PSInfisicalAPI.Environments
|
||||
public void Delete(InfisicalConnection connection, string projectId, string environmentId)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(environmentId)) { throw new InfisicalConfigurationException("EnvironmentId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", resolvedProjectId }, { "environmentId", environmentId } };
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", projectId }, { "environmentId", environmentId } };
|
||||
|
||||
try
|
||||
{
|
||||
@@ -156,11 +151,5 @@ namespace PSInfisicalAPI.Environments
|
||||
}
|
||||
}
|
||||
|
||||
private static string FirstNonEmpty(params string[] values)
|
||||
{
|
||||
if (values == null) { return null; }
|
||||
foreach (string value in values) { if (!string.IsNullOrEmpty(value)) { return value; } }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,16 +29,14 @@ namespace PSInfisicalAPI.Folders
|
||||
public InfisicalFolder[] List(InfisicalConnection connection, string projectId, string environment, string path)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
string resolvedEnvironment = FirstNonEmpty(environment, connection.Environment);
|
||||
string resolvedPath = FirstNonEmpty(path, connection.DefaultSecretPath, "/");
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedEnvironment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(environment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
string resolvedPath = FirstNonEmpty(path, "/");
|
||||
|
||||
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("workspaceId", resolvedProjectId),
|
||||
new KeyValuePair<string, string>("environment", resolvedEnvironment),
|
||||
new KeyValuePair<string, string>("workspaceId", projectId),
|
||||
new KeyValuePair<string, string>("environment", environment),
|
||||
new KeyValuePair<string, string>("path", resolvedPath)
|
||||
};
|
||||
|
||||
@@ -49,7 +47,7 @@ namespace PSInfisicalAPI.Folders
|
||||
InfisicalFolderListResponseDto dto = _serializer.Deserialize<InfisicalFolderListResponseDto>(response.Body);
|
||||
response.Clear();
|
||||
|
||||
InfisicalFolder[] mapped = InfisicalFolderMapper.MapMany(dto != null ? dto.Folders : null, resolvedProjectId, resolvedEnvironment);
|
||||
InfisicalFolder[] mapped = InfisicalFolderMapper.MapMany(dto != null ? dto.Folders : null, projectId, environment);
|
||||
_logger.Information(Component, "Infisical folder list retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -80,17 +78,15 @@ namespace PSInfisicalAPI.Folders
|
||||
public InfisicalFolder Create(InfisicalConnection connection, string projectId, string environment, string name, string path)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
string resolvedEnvironment = FirstNonEmpty(environment, connection.Environment);
|
||||
string resolvedPath = FirstNonEmpty(path, connection.DefaultSecretPath, "/");
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedEnvironment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(environment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(name)) { throw new InfisicalConfigurationException("Name is required."); }
|
||||
string resolvedPath = FirstNonEmpty(path, "/");
|
||||
|
||||
InfisicalFolderCreateRequestDto request = new InfisicalFolderCreateRequestDto
|
||||
{
|
||||
WorkspaceId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
WorkspaceId = projectId,
|
||||
Environment = environment,
|
||||
Name = name,
|
||||
Path = resolvedPath
|
||||
};
|
||||
@@ -103,7 +99,7 @@ namespace PSInfisicalAPI.Folders
|
||||
InfisicalFolderSingleResponseDto dto = _serializer.Deserialize<InfisicalFolderSingleResponseDto>(response.Body);
|
||||
response.Clear();
|
||||
|
||||
InfisicalFolder mapped = InfisicalFolderMapper.Map(dto != null ? dto.Folder : null, resolvedProjectId, resolvedEnvironment);
|
||||
InfisicalFolder mapped = InfisicalFolderMapper.Map(dto != null ? dto.Folder : null, projectId, environment);
|
||||
_logger.Information(Component, "Infisical folder creation was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -117,19 +113,17 @@ namespace PSInfisicalAPI.Folders
|
||||
public InfisicalFolder Update(InfisicalConnection connection, string projectId, string environment, string folderId, string name, string path)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
string resolvedEnvironment = FirstNonEmpty(environment, connection.Environment);
|
||||
string resolvedPath = FirstNonEmpty(path, connection.DefaultSecretPath, "/");
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedEnvironment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(environment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(folderId)) { throw new InfisicalConfigurationException("FolderId is required."); }
|
||||
string resolvedPath = FirstNonEmpty(path, "/");
|
||||
if (string.IsNullOrEmpty(name)) { throw new InfisicalConfigurationException("Name is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "folderId", folderId } };
|
||||
InfisicalFolderUpdateRequestDto request = new InfisicalFolderUpdateRequestDto
|
||||
{
|
||||
WorkspaceId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
WorkspaceId = projectId,
|
||||
Environment = environment,
|
||||
Name = name,
|
||||
Path = resolvedPath
|
||||
};
|
||||
@@ -142,7 +136,7 @@ namespace PSInfisicalAPI.Folders
|
||||
InfisicalFolderSingleResponseDto dto = _serializer.Deserialize<InfisicalFolderSingleResponseDto>(response.Body);
|
||||
response.Clear();
|
||||
|
||||
InfisicalFolder mapped = InfisicalFolderMapper.Map(dto != null ? dto.Folder : null, resolvedProjectId, resolvedEnvironment);
|
||||
InfisicalFolder mapped = InfisicalFolderMapper.Map(dto != null ? dto.Folder : null, projectId, environment);
|
||||
_logger.Information(Component, "Infisical folder update was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -156,18 +150,16 @@ namespace PSInfisicalAPI.Folders
|
||||
public void Delete(InfisicalConnection connection, string projectId, string environment, string folderId, string path)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
string resolvedEnvironment = FirstNonEmpty(environment, connection.Environment);
|
||||
string resolvedPath = FirstNonEmpty(path, connection.DefaultSecretPath, "/");
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedEnvironment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(environment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(folderId)) { throw new InfisicalConfigurationException("FolderId is required."); }
|
||||
string resolvedPath = FirstNonEmpty(path, "/");
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "folderId", folderId } };
|
||||
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("workspaceId", resolvedProjectId),
|
||||
new KeyValuePair<string, string>("environment", resolvedEnvironment),
|
||||
new KeyValuePair<string, string>("workspaceId", projectId),
|
||||
new KeyValuePair<string, string>("environment", environment),
|
||||
new KeyValuePair<string, string>("path", resolvedPath)
|
||||
};
|
||||
|
||||
|
||||
@@ -47,8 +47,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
List<InfisicalInternalCaResponseDto> source = ParseCaListBody(body);
|
||||
string fallbackProjectId = !string.IsNullOrEmpty(projectId) ? projectId : connection.ProjectId;
|
||||
InfisicalCertificateAuthority[] mapped = InfisicalCaMapper.MapMany(source, fallbackProjectId);
|
||||
InfisicalCertificateAuthority[] mapped = InfisicalCaMapper.MapMany(source, projectId);
|
||||
_logger.Information(Component, "Infisical internal certificate authority list retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -79,8 +78,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
InfisicalInternalCaResponseDto inner = ParseCaSingleBody(body);
|
||||
string fallbackProjectId = !string.IsNullOrEmpty(projectId) ? projectId : connection.ProjectId;
|
||||
InfisicalCertificateAuthority mapped = InfisicalCaMapper.Map(inner, fallbackProjectId);
|
||||
InfisicalCertificateAuthority mapped = InfisicalCaMapper.Map(inner, projectId);
|
||||
_logger.Information(Component, "Infisical internal certificate authority retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -94,12 +92,11 @@ namespace PSInfisicalAPI.Pki
|
||||
public InfisicalCertificateAuthority[] ListAllCertificateAuthorities(InfisicalConnection connection, string projectId)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
List<KeyValuePair<string, string>> query = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("projectId", resolvedProjectId)
|
||||
new KeyValuePair<string, string>("projectId", projectId)
|
||||
};
|
||||
|
||||
try
|
||||
@@ -110,7 +107,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
List<InfisicalInternalCaResponseDto> source = ParseCaListBody(body);
|
||||
InfisicalCertificateAuthority[] mapped = InfisicalCaMapper.MapMany(source, resolvedProjectId);
|
||||
InfisicalCertificateAuthority[] mapped = InfisicalCaMapper.MapMany(source, projectId);
|
||||
_logger.Information(Component, "Infisical certificate authority list retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -136,7 +133,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
InfisicalCertificateResponseDto inner = ParseCertificateSingleBody(body);
|
||||
InfisicalCertificate mapped = InfisicalCertificateMapper.Map(inner, connection.ProjectId);
|
||||
InfisicalCertificate mapped = InfisicalCertificateMapper.Map(inner, null);
|
||||
_logger.Information(Component, "Infisical certificate retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -187,10 +184,9 @@ namespace PSInfisicalAPI.Pki
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
if (query == null) { throw new ArgumentNullException(nameof(query)); }
|
||||
string resolvedProjectId = FirstNonEmpty(query.ProjectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(query.ProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", resolvedProjectId } };
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", query.ProjectId } };
|
||||
InfisicalCertificateSearchRequestDto request = BuildSearchRequest(query);
|
||||
string body = _serializer.Serialize(request);
|
||||
|
||||
@@ -201,7 +197,7 @@ namespace PSInfisicalAPI.Pki
|
||||
InfisicalCertificateSearchResponseDto dto = _serializer.Deserialize<InfisicalCertificateSearchResponseDto>(response.Body);
|
||||
response.Clear();
|
||||
|
||||
InfisicalCertificate[] mapped = InfisicalCertificateMapper.MapMany(dto != null ? dto.Certificates : null, resolvedProjectId);
|
||||
InfisicalCertificate[] mapped = InfisicalCertificateMapper.MapMany(dto != null ? dto.Certificates : null, query.ProjectId);
|
||||
int total = dto != null ? dto.TotalCount : mapped.Length;
|
||||
_logger.Information(Component, "Infisical certificate search was successful.");
|
||||
return new InfisicalCertificateSearchResult { Certificates = mapped, TotalCount = total };
|
||||
@@ -218,13 +214,12 @@ namespace PSInfisicalAPI.Pki
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
if (string.IsNullOrEmpty(subscriberName)) { throw new InfisicalConfigurationException("SubscriberName is required."); }
|
||||
if (string.IsNullOrEmpty(csrPem)) { throw new InfisicalConfigurationException("CSR is required."); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "subscriberName", subscriberName } };
|
||||
InfisicalSignCertificateBySubscriberRequestDto request = new InfisicalSignCertificateBySubscriberRequestDto
|
||||
{
|
||||
ProjectId = resolvedProjectId,
|
||||
ProjectId = projectId,
|
||||
Csr = csrPem
|
||||
};
|
||||
string body = _serializer.Serialize(request);
|
||||
@@ -373,10 +368,9 @@ namespace PSInfisicalAPI.Pki
|
||||
public InfisicalPkiSubscriber[] ListPkiSubscribers(InfisicalConnection connection, string projectId)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", resolvedProjectId } };
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", projectId } };
|
||||
|
||||
try
|
||||
{
|
||||
@@ -386,7 +380,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
List<InfisicalPkiSubscriberResponseDto> source = ParsePkiSubscriberListBody(body);
|
||||
InfisicalPkiSubscriber[] mapped = InfisicalPkiSubscriberMapper.MapMany(source, resolvedProjectId);
|
||||
InfisicalPkiSubscriber[] mapped = InfisicalPkiSubscriberMapper.MapMany(source, projectId);
|
||||
_logger.Information(Component, "Infisical PKI subscriber list retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -401,11 +395,10 @@ namespace PSInfisicalAPI.Pki
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
if (string.IsNullOrEmpty(subscriberName)) { throw new InfisicalConfigurationException("SubscriberName is required."); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "subscriberName", subscriberName } };
|
||||
List<KeyValuePair<string, string>> query = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("projectId", resolvedProjectId) };
|
||||
List<KeyValuePair<string, string>> query = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("projectId", projectId) };
|
||||
|
||||
try
|
||||
{
|
||||
@@ -414,7 +407,7 @@ namespace PSInfisicalAPI.Pki
|
||||
InfisicalPkiSubscriberResponseDto dto = _serializer.Deserialize<InfisicalPkiSubscriberResponseDto>(response.Body);
|
||||
response.Clear();
|
||||
|
||||
InfisicalPkiSubscriber mapped = InfisicalPkiSubscriberMapper.Map(dto, resolvedProjectId);
|
||||
InfisicalPkiSubscriber mapped = InfisicalPkiSubscriberMapper.Map(dto, projectId);
|
||||
_logger.Information(Component, "Infisical PKI subscriber retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -441,12 +434,11 @@ namespace PSInfisicalAPI.Pki
|
||||
public InfisicalCertificateProfile[] ListCertificateProfiles(InfisicalConnection connection, string projectId, int? limit, int? offset, bool? includeConfigs)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
List<KeyValuePair<string, string>> query = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("projectId", resolvedProjectId)
|
||||
new KeyValuePair<string, string>("projectId", projectId)
|
||||
};
|
||||
if (limit.HasValue) { query.Add(new KeyValuePair<string, string>("limit", limit.Value.ToString(CultureInfo.InvariantCulture))); }
|
||||
if (offset.HasValue) { query.Add(new KeyValuePair<string, string>("offset", offset.Value.ToString(CultureInfo.InvariantCulture))); }
|
||||
@@ -460,7 +452,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
List<InfisicalCertificateProfileResponseDto> source = ParseCertificateProfileListBody(body);
|
||||
InfisicalCertificateProfile[] mapped = InfisicalCertificateProfileMapper.MapMany(source, resolvedProjectId);
|
||||
InfisicalCertificateProfile[] mapped = InfisicalCertificateProfileMapper.MapMany(source, projectId);
|
||||
_logger.Information(Component, "Infisical certificate profile list retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -491,8 +483,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
InfisicalCertificateProfileResponseDto inner = ParseCertificateProfileSingleBody(body);
|
||||
string fallbackProjectId = !string.IsNullOrEmpty(projectId) ? projectId : connection.ProjectId;
|
||||
InfisicalCertificateProfile mapped = InfisicalCertificateProfileMapper.Map(inner, fallbackProjectId);
|
||||
InfisicalCertificateProfile mapped = InfisicalCertificateProfileMapper.Map(inner, projectId);
|
||||
_logger.Information(Component, "Infisical certificate profile retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -530,12 +521,11 @@ namespace PSInfisicalAPI.Pki
|
||||
public InfisicalCertificatePolicy[] ListCertificatePolicies(InfisicalConnection connection, string projectId, int? limit, int? offset)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
List<KeyValuePair<string, string>> query = new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("projectId", resolvedProjectId)
|
||||
new KeyValuePair<string, string>("projectId", projectId)
|
||||
};
|
||||
if (limit.HasValue) { query.Add(new KeyValuePair<string, string>("limit", limit.Value.ToString(CultureInfo.InvariantCulture))); }
|
||||
if (offset.HasValue) { query.Add(new KeyValuePair<string, string>("offset", offset.Value.ToString(CultureInfo.InvariantCulture))); }
|
||||
@@ -548,7 +538,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
List<InfisicalCertificatePolicyResponseDto> source = ParseCertificatePolicyListBody(body);
|
||||
InfisicalCertificatePolicy[] mapped = InfisicalCertificatePolicyMapper.MapMany(source, resolvedProjectId);
|
||||
InfisicalCertificatePolicy[] mapped = InfisicalCertificatePolicyMapper.MapMany(source, projectId);
|
||||
_logger.Information(Component, "Infisical certificate policy list retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -579,8 +569,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
InfisicalCertificatePolicyResponseDto inner = ParseCertificatePolicySingleBody(body);
|
||||
string fallbackProjectId = !string.IsNullOrEmpty(projectId) ? projectId : connection.ProjectId;
|
||||
InfisicalCertificatePolicy mapped = InfisicalCertificatePolicyMapper.Map(inner, fallbackProjectId);
|
||||
InfisicalCertificatePolicy mapped = InfisicalCertificatePolicyMapper.Map(inner, projectId);
|
||||
_logger.Information(Component, "Infisical certificate policy retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -643,14 +632,13 @@ namespace PSInfisicalAPI.Pki
|
||||
public InfisicalCertificateApplication[] ListCertificateApplications(InfisicalConnection connection, string projectId, int? limit, int? offset)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
List<KeyValuePair<string, string>> query = new List<KeyValuePair<string, string>>();
|
||||
if (limit.HasValue) { query.Add(new KeyValuePair<string, string>("limit", limit.Value.ToString(CultureInfo.InvariantCulture))); }
|
||||
if (offset.HasValue) { query.Add(new KeyValuePair<string, string>("offset", offset.Value.ToString(CultureInfo.InvariantCulture))); }
|
||||
|
||||
Dictionary<string, string> headers = BuildProjectHeader(resolvedProjectId);
|
||||
Dictionary<string, string> headers = BuildProjectHeader(projectId);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -660,7 +648,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
List<InfisicalCertificateApplicationResponseDto> source = ParseApplicationListBody(body);
|
||||
InfisicalCertificateApplication[] mapped = InfisicalCertificateApplicationMapper.MapMany(source, resolvedProjectId);
|
||||
InfisicalCertificateApplication[] mapped = InfisicalCertificateApplicationMapper.MapMany(source, projectId);
|
||||
_logger.Information(Component, "Infisical certificate application list retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -677,8 +665,7 @@ namespace PSInfisicalAPI.Pki
|
||||
if (string.IsNullOrEmpty(applicationId)) { throw new InfisicalConfigurationException("ApplicationId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "applicationId", applicationId } };
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
Dictionary<string, string> headers = !string.IsNullOrEmpty(resolvedProjectId) ? BuildProjectHeader(resolvedProjectId) : null;
|
||||
Dictionary<string, string> headers = !string.IsNullOrEmpty(projectId) ? BuildProjectHeader(projectId) : null;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -688,7 +675,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
InfisicalCertificateApplicationResponseDto inner = ParseApplicationSingleBody(body);
|
||||
InfisicalCertificateApplication mapped = InfisicalCertificateApplicationMapper.Map(inner, resolvedProjectId);
|
||||
InfisicalCertificateApplication mapped = InfisicalCertificateApplicationMapper.Map(inner, projectId);
|
||||
_logger.Information(Component, "Infisical certificate application retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -703,11 +690,10 @@ namespace PSInfisicalAPI.Pki
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
if (string.IsNullOrEmpty(name)) { throw new InfisicalConfigurationException("ApplicationName is required."); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "name", name } };
|
||||
Dictionary<string, string> headers = BuildProjectHeader(resolvedProjectId);
|
||||
Dictionary<string, string> headers = BuildProjectHeader(projectId);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -717,7 +703,7 @@ namespace PSInfisicalAPI.Pki
|
||||
response.Clear();
|
||||
|
||||
InfisicalCertificateApplicationResponseDto inner = ParseApplicationSingleBody(body);
|
||||
InfisicalCertificateApplication mapped = InfisicalCertificateApplicationMapper.Map(inner, resolvedProjectId);
|
||||
InfisicalCertificateApplication mapped = InfisicalCertificateApplicationMapper.Map(inner, projectId);
|
||||
_logger.Information(Component, "Infisical certificate application (by name) retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -734,8 +720,7 @@ namespace PSInfisicalAPI.Pki
|
||||
if (string.IsNullOrEmpty(applicationId)) { throw new InfisicalConfigurationException("ApplicationId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "applicationId", applicationId } };
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
Dictionary<string, string> headers = !string.IsNullOrEmpty(resolvedProjectId) ? BuildProjectHeader(resolvedProjectId) : null;
|
||||
Dictionary<string, string> headers = !string.IsNullOrEmpty(projectId) ? BuildProjectHeader(projectId) : null;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -767,8 +752,7 @@ namespace PSInfisicalAPI.Pki
|
||||
{ "applicationId", applicationId },
|
||||
{ "profileId", profileId }
|
||||
};
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
Dictionary<string, string> headers = !string.IsNullOrEmpty(resolvedProjectId) ? BuildProjectHeader(resolvedProjectId) : null;
|
||||
Dictionary<string, string> headers = !string.IsNullOrEmpty(projectId) ? BuildProjectHeader(projectId) : null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -27,13 +27,25 @@ namespace PSInfisicalAPI.Projects
|
||||
}
|
||||
|
||||
public InfisicalProject[] List(InfisicalConnection connection)
|
||||
{
|
||||
return List(connection, null, false);
|
||||
}
|
||||
|
||||
public InfisicalProject[] List(InfisicalConnection connection, string type, bool includeRoles)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
|
||||
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
|
||||
queryParameters.Add(new KeyValuePair<string, string>("includeRoles", includeRoles ? "true" : "false"));
|
||||
if (!string.IsNullOrEmpty(type))
|
||||
{
|
||||
queryParameters.Add(new KeyValuePair<string, string>("type", type));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_logger.Information(Component, "Attempting to list Infisical projects. Please Wait...");
|
||||
InfisicalHttpResponse response = _invoker.Invoke(connection, InfisicalEndpointNames.ListProjects, "ListProjects", null, null, null);
|
||||
InfisicalHttpResponse response = _invoker.Invoke(connection, InfisicalEndpointNames.ListProjects, "ListProjects", null, queryParameters, null);
|
||||
InfisicalProjectListResponseDto dto = _serializer.Deserialize<InfisicalProjectListResponseDto>(response.Body);
|
||||
response.Clear();
|
||||
|
||||
|
||||
@@ -32,13 +32,11 @@ namespace PSInfisicalAPI.Secrets
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
if (query == null) { throw new ArgumentNullException(nameof(query)); }
|
||||
|
||||
string resolvedProjectId = FirstNonEmpty(query.ProjectId, connection.ProjectId);
|
||||
|
||||
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
|
||||
AddIfNotNull(queryParameters, "workspaceId", resolvedProjectId);
|
||||
AddIfNotNull(queryParameters, "projectId", resolvedProjectId);
|
||||
AddIfNotNull(queryParameters, "environment", FirstNonEmpty(query.Environment, connection.Environment));
|
||||
AddIfNotNull(queryParameters, "secretPath", FirstNonEmpty(query.SecretPath, connection.DefaultSecretPath, "/"));
|
||||
AddIfNotNull(queryParameters, "workspaceId", query.ProjectId);
|
||||
AddIfNotNull(queryParameters, "projectId", query.ProjectId);
|
||||
AddIfNotNull(queryParameters, "environment", query.Environment);
|
||||
AddIfNotNull(queryParameters, "secretPath", FirstNonEmpty(query.SecretPath, "/"));
|
||||
queryParameters.Add(new KeyValuePair<string, string>("recursive", query.Recursive ? "true" : "false"));
|
||||
if (query.IncludeImports.HasValue) { queryParameters.Add(new KeyValuePair<string, string>("includeImports", query.IncludeImports.Value ? "true" : "false")); }
|
||||
if (query.IncludePersonalOverrides) { queryParameters.Add(new KeyValuePair<string, string>("includePersonalOverrides", "true")); }
|
||||
@@ -96,13 +94,11 @@ namespace PSInfisicalAPI.Secrets
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "secretName", query.SecretName } };
|
||||
|
||||
string resolvedProjectId = FirstNonEmpty(query.ProjectId, connection.ProjectId);
|
||||
|
||||
List<KeyValuePair<string, string>> queryParameters = new List<KeyValuePair<string, string>>();
|
||||
AddIfNotNull(queryParameters, "workspaceId", resolvedProjectId);
|
||||
AddIfNotNull(queryParameters, "projectId", resolvedProjectId);
|
||||
AddIfNotNull(queryParameters, "environment", FirstNonEmpty(query.Environment, connection.Environment));
|
||||
AddIfNotNull(queryParameters, "secretPath", FirstNonEmpty(query.SecretPath, connection.DefaultSecretPath, "/"));
|
||||
AddIfNotNull(queryParameters, "workspaceId", query.ProjectId);
|
||||
AddIfNotNull(queryParameters, "projectId", query.ProjectId);
|
||||
AddIfNotNull(queryParameters, "environment", query.Environment);
|
||||
AddIfNotNull(queryParameters, "secretPath", FirstNonEmpty(query.SecretPath, "/"));
|
||||
AddIfNotNull(queryParameters, "type", string.IsNullOrEmpty(query.Type) ? "shared" : query.Type.ToLowerInvariant());
|
||||
if (query.Version.HasValue) { queryParameters.Add(new KeyValuePair<string, string>("version", query.Version.Value.ToString(CultureInfo.InvariantCulture))); }
|
||||
if (query.ViewSecretValue.HasValue) { queryParameters.Add(new KeyValuePair<string, string>("viewSecretValue", query.ViewSecretValue.Value ? "true" : "false")); }
|
||||
@@ -143,17 +139,15 @@ namespace PSInfisicalAPI.Secrets
|
||||
if (string.IsNullOrEmpty(request.SecretName)) { throw new InfisicalConfigurationException("SecretName is required."); }
|
||||
if (request.SecretValue == null) { throw new InfisicalConfigurationException("SecretValue is required."); }
|
||||
|
||||
string resolvedProjectId = FirstNonEmpty(request.ProjectId, connection.ProjectId);
|
||||
string resolvedEnvironment = FirstNonEmpty(request.Environment, connection.Environment);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedEnvironment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(request.Environment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "secretName", request.SecretName } };
|
||||
InfisicalSecretCreateRequestDto dtoRequest = new InfisicalSecretCreateRequestDto
|
||||
{
|
||||
WorkspaceId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, connection.DefaultSecretPath, "/"),
|
||||
WorkspaceId = request.ProjectId,
|
||||
Environment = request.Environment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, "/"),
|
||||
Type = string.IsNullOrEmpty(request.Type) ? "shared" : request.Type.ToLowerInvariant(),
|
||||
SecretValue = request.SecretValue,
|
||||
SecretComment = request.SecretComment,
|
||||
@@ -186,17 +180,15 @@ namespace PSInfisicalAPI.Secrets
|
||||
if (request == null) { throw new ArgumentNullException(nameof(request)); }
|
||||
if (string.IsNullOrEmpty(request.SecretName)) { throw new InfisicalConfigurationException("SecretName is required."); }
|
||||
|
||||
string resolvedProjectId = FirstNonEmpty(request.ProjectId, connection.ProjectId);
|
||||
string resolvedEnvironment = FirstNonEmpty(request.Environment, connection.Environment);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedEnvironment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(request.Environment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "secretName", request.SecretName } };
|
||||
InfisicalSecretUpdateRequestDto dtoRequest = new InfisicalSecretUpdateRequestDto
|
||||
{
|
||||
WorkspaceId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, connection.DefaultSecretPath, "/"),
|
||||
WorkspaceId = request.ProjectId,
|
||||
Environment = request.Environment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, "/"),
|
||||
Type = string.IsNullOrEmpty(request.Type) ? "shared" : request.Type.ToLowerInvariant(),
|
||||
SecretValue = request.SecretValue,
|
||||
SecretComment = request.SecretComment,
|
||||
@@ -230,10 +222,8 @@ namespace PSInfisicalAPI.Secrets
|
||||
if (request == null) { throw new ArgumentNullException(nameof(request)); }
|
||||
if (request.Secrets == null || request.Secrets.Length == 0) { throw new InfisicalConfigurationException("At least one secret is required."); }
|
||||
|
||||
string resolvedProjectId = FirstNonEmpty(request.ProjectId, connection.ProjectId);
|
||||
string resolvedEnvironment = FirstNonEmpty(request.Environment, connection.Environment);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedEnvironment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(request.Environment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
|
||||
List<InfisicalSecretBatchCreateItemDto> items = new List<InfisicalSecretBatchCreateItemDto>(request.Secrets.Length);
|
||||
foreach (InfisicalBulkCreateSecretItem item in request.Secrets)
|
||||
@@ -253,10 +243,10 @@ namespace PSInfisicalAPI.Secrets
|
||||
|
||||
InfisicalSecretBatchCreateRequestDto dtoRequest = new InfisicalSecretBatchCreateRequestDto
|
||||
{
|
||||
WorkspaceId = resolvedProjectId,
|
||||
ProjectId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, connection.DefaultSecretPath, "/"),
|
||||
WorkspaceId = request.ProjectId,
|
||||
ProjectId = request.ProjectId,
|
||||
Environment = request.Environment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, "/"),
|
||||
Secrets = items
|
||||
};
|
||||
string body = _serializer.Serialize(dtoRequest);
|
||||
@@ -285,10 +275,8 @@ namespace PSInfisicalAPI.Secrets
|
||||
if (request == null) { throw new ArgumentNullException(nameof(request)); }
|
||||
if (request.Secrets == null || request.Secrets.Length == 0) { throw new InfisicalConfigurationException("At least one secret is required."); }
|
||||
|
||||
string resolvedProjectId = FirstNonEmpty(request.ProjectId, connection.ProjectId);
|
||||
string resolvedEnvironment = FirstNonEmpty(request.Environment, connection.Environment);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedEnvironment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(request.Environment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
|
||||
List<InfisicalSecretBatchUpdateItemDto> items = new List<InfisicalSecretBatchUpdateItemDto>(request.Secrets.Length);
|
||||
foreach (InfisicalBulkUpdateSecretItem item in request.Secrets)
|
||||
@@ -309,10 +297,10 @@ namespace PSInfisicalAPI.Secrets
|
||||
|
||||
InfisicalSecretBatchUpdateRequestDto dtoRequest = new InfisicalSecretBatchUpdateRequestDto
|
||||
{
|
||||
WorkspaceId = resolvedProjectId,
|
||||
ProjectId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, connection.DefaultSecretPath, "/"),
|
||||
WorkspaceId = request.ProjectId,
|
||||
ProjectId = request.ProjectId,
|
||||
Environment = request.Environment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, "/"),
|
||||
Mode = request.Mode,
|
||||
Secrets = items
|
||||
};
|
||||
@@ -342,10 +330,8 @@ namespace PSInfisicalAPI.Secrets
|
||||
if (request == null) { throw new ArgumentNullException(nameof(request)); }
|
||||
if (request.SecretNames == null || request.SecretNames.Length == 0) { throw new InfisicalConfigurationException("At least one secret name is required."); }
|
||||
|
||||
string resolvedProjectId = FirstNonEmpty(request.ProjectId, connection.ProjectId);
|
||||
string resolvedEnvironment = FirstNonEmpty(request.Environment, connection.Environment);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedEnvironment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(request.Environment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
|
||||
List<InfisicalSecretBatchDeleteItemDto> items = new List<InfisicalSecretBatchDeleteItemDto>(request.SecretNames.Length);
|
||||
foreach (string name in request.SecretNames)
|
||||
@@ -356,10 +342,10 @@ namespace PSInfisicalAPI.Secrets
|
||||
|
||||
InfisicalSecretBatchDeleteRequestDto dtoRequest = new InfisicalSecretBatchDeleteRequestDto
|
||||
{
|
||||
WorkspaceId = resolvedProjectId,
|
||||
ProjectId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, connection.DefaultSecretPath, "/"),
|
||||
WorkspaceId = request.ProjectId,
|
||||
ProjectId = request.ProjectId,
|
||||
Environment = request.Environment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, "/"),
|
||||
Secrets = items
|
||||
};
|
||||
string body = _serializer.Serialize(dtoRequest);
|
||||
@@ -384,13 +370,11 @@ namespace PSInfisicalAPI.Secrets
|
||||
if (request == null) { throw new ArgumentNullException(nameof(request)); }
|
||||
if (request.SecretIds == null || request.SecretIds.Length == 0) { throw new InfisicalConfigurationException("At least one SecretId is required."); }
|
||||
|
||||
string resolvedProjectId = FirstNonEmpty(request.ProjectId, connection.ProjectId);
|
||||
string resolvedSourceEnv = FirstNonEmpty(request.SourceEnvironment, connection.Environment);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedSourceEnv)) { throw new InfisicalConfigurationException("SourceEnvironment is required."); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(request.SourceEnvironment)) { throw new InfisicalConfigurationException("SourceEnvironment is required."); }
|
||||
if (string.IsNullOrEmpty(request.DestinationEnvironment)) { throw new InfisicalConfigurationException("DestinationEnvironment is required."); }
|
||||
|
||||
string resolvedSourcePath = FirstNonEmpty(request.SourceSecretPath, connection.DefaultSecretPath, "/");
|
||||
string resolvedSourcePath = FirstNonEmpty(request.SourceSecretPath, "/");
|
||||
string resolvedDestPath = FirstNonEmpty(request.DestinationSecretPath, resolvedSourcePath);
|
||||
|
||||
InfisicalSecretDuplicateAttributesDto attributes = null;
|
||||
@@ -407,8 +391,8 @@ namespace PSInfisicalAPI.Secrets
|
||||
|
||||
InfisicalSecretDuplicateRequestDto dtoRequest = new InfisicalSecretDuplicateRequestDto
|
||||
{
|
||||
ProjectId = resolvedProjectId,
|
||||
SourceEnvironment = resolvedSourceEnv,
|
||||
ProjectId = request.ProjectId,
|
||||
SourceEnvironment = request.SourceEnvironment,
|
||||
DestinationEnvironment = request.DestinationEnvironment,
|
||||
SourceSecretPath = resolvedSourcePath,
|
||||
DestinationSecretPath = resolvedDestPath,
|
||||
@@ -454,17 +438,15 @@ namespace PSInfisicalAPI.Secrets
|
||||
if (request == null) { throw new ArgumentNullException(nameof(request)); }
|
||||
if (string.IsNullOrEmpty(request.SecretName)) { throw new InfisicalConfigurationException("SecretName is required."); }
|
||||
|
||||
string resolvedProjectId = FirstNonEmpty(request.ProjectId, connection.ProjectId);
|
||||
string resolvedEnvironment = FirstNonEmpty(request.Environment, connection.Environment);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(resolvedEnvironment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(request.Environment)) { throw new InfisicalConfigurationException("Environment is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "secretName", request.SecretName } };
|
||||
InfisicalSecretDeleteRequestDto dtoRequest = new InfisicalSecretDeleteRequestDto
|
||||
{
|
||||
WorkspaceId = resolvedProjectId,
|
||||
Environment = resolvedEnvironment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, connection.DefaultSecretPath, "/"),
|
||||
WorkspaceId = request.ProjectId,
|
||||
Environment = request.Environment,
|
||||
SecretPath = FirstNonEmpty(request.SecretPath, "/"),
|
||||
Type = string.IsNullOrEmpty(request.Type) ? "shared" : request.Type.ToLowerInvariant()
|
||||
};
|
||||
string body = _serializer.Serialize(dtoRequest);
|
||||
|
||||
@@ -29,10 +29,9 @@ namespace PSInfisicalAPI.Tags
|
||||
public InfisicalTag[] List(InfisicalConnection connection, string projectId)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", resolvedProjectId } };
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", projectId } };
|
||||
|
||||
try
|
||||
{
|
||||
@@ -42,7 +41,7 @@ namespace PSInfisicalAPI.Tags
|
||||
response.Clear();
|
||||
|
||||
List<InfisicalTagResponseDto> source = dto != null ? (dto.WorkspaceTags ?? dto.Tags) : null;
|
||||
InfisicalTag[] mapped = InfisicalTagMapper.MapMany(source, resolvedProjectId);
|
||||
InfisicalTag[] mapped = InfisicalTagMapper.MapMany(source, projectId);
|
||||
_logger.Information(Component, "Infisical tag list retrieval was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -56,11 +55,10 @@ namespace PSInfisicalAPI.Tags
|
||||
public InfisicalTag Retrieve(InfisicalConnection connection, string projectId, string tagSlugOrId)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(tagSlugOrId)) { throw new InfisicalConfigurationException("Tag slug or id is required."); }
|
||||
|
||||
InfisicalTag[] all = List(connection, resolvedProjectId);
|
||||
InfisicalTag[] all = List(connection, projectId);
|
||||
foreach (InfisicalTag tag in all)
|
||||
{
|
||||
if (string.Equals(tag.Id, tagSlugOrId, StringComparison.OrdinalIgnoreCase) ||
|
||||
@@ -76,11 +74,10 @@ namespace PSInfisicalAPI.Tags
|
||||
public InfisicalTag Create(InfisicalConnection connection, string projectId, string slug, string name, string color)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(slug)) { throw new InfisicalConfigurationException("Slug is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", resolvedProjectId } };
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", projectId } };
|
||||
InfisicalTagCreateRequestDto request = new InfisicalTagCreateRequestDto { Slug = slug, Name = name, Color = color };
|
||||
string body = _serializer.Serialize(request);
|
||||
|
||||
@@ -92,7 +89,7 @@ namespace PSInfisicalAPI.Tags
|
||||
response.Clear();
|
||||
|
||||
InfisicalTagResponseDto inner = dto != null ? (dto.WorkspaceTag ?? dto.Tag) : null;
|
||||
InfisicalTag mapped = InfisicalTagMapper.Map(inner, resolvedProjectId);
|
||||
InfisicalTag mapped = InfisicalTagMapper.Map(inner, projectId);
|
||||
_logger.Information(Component, "Infisical tag creation was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -106,11 +103,10 @@ namespace PSInfisicalAPI.Tags
|
||||
public InfisicalTag Update(InfisicalConnection connection, string projectId, string tagId, string slug, string name, string color)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(tagId)) { throw new InfisicalConfigurationException("TagId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", resolvedProjectId }, { "tagId", tagId } };
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", projectId }, { "tagId", tagId } };
|
||||
InfisicalTagUpdateRequestDto request = new InfisicalTagUpdateRequestDto { Slug = slug, Name = name, Color = color };
|
||||
string body = _serializer.Serialize(request);
|
||||
|
||||
@@ -122,7 +118,7 @@ namespace PSInfisicalAPI.Tags
|
||||
response.Clear();
|
||||
|
||||
InfisicalTagResponseDto inner = dto != null ? (dto.WorkspaceTag ?? dto.Tag) : null;
|
||||
InfisicalTag mapped = InfisicalTagMapper.Map(inner, resolvedProjectId);
|
||||
InfisicalTag mapped = InfisicalTagMapper.Map(inner, projectId);
|
||||
_logger.Information(Component, "Infisical tag update was successful.");
|
||||
return mapped;
|
||||
}
|
||||
@@ -136,11 +132,10 @@ namespace PSInfisicalAPI.Tags
|
||||
public void Delete(InfisicalConnection connection, string projectId, string tagId)
|
||||
{
|
||||
if (connection == null) { throw new ArgumentNullException(nameof(connection)); }
|
||||
string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
|
||||
if (string.IsNullOrEmpty(resolvedProjectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(projectId)) { throw new InfisicalConfigurationException("ProjectId is required."); }
|
||||
if (string.IsNullOrEmpty(tagId)) { throw new InfisicalConfigurationException("TagId is required."); }
|
||||
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", resolvedProjectId }, { "tagId", tagId } };
|
||||
Dictionary<string, string> pathParameters = new Dictionary<string, string> { { "projectId", projectId }, { "tagId", tagId } };
|
||||
|
||||
try
|
||||
{
|
||||
@@ -156,11 +151,5 @@ namespace PSInfisicalAPI.Tags
|
||||
}
|
||||
}
|
||||
|
||||
private static string FirstNonEmpty(params string[] values)
|
||||
{
|
||||
if (values == null) { return null; }
|
||||
foreach (string value in values) { if (!string.IsNullOrEmpty(value)) { return value; } }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user