diff --git a/Module/PSInfisicalAPI/en-US/PSInfisicalAPI.dll-Help.xml b/Module/PSInfisicalAPI/en-US/PSInfisicalAPI.dll-Help.xml
index c39f22b..5d82499 100644
--- a/Module/PSInfisicalAPI/en-US/PSInfisicalAPI.dll-Help.xml
+++ b/Module/PSInfisicalAPI/en-US/PSInfisicalAPI.dll-Help.xml
@@ -9,7 +9,7 @@
Infisical
- Authenticates against an Infisical instance using one of the supported auth providers (UniversalAuth, Token, JWT, OIDC, LDAP, Azure, GCP IAM) and stores the resulting connection in the module-level session manager. Subsequent cmdlets pick up the connection automatically. If parameters such as BaseUri, OrganizationId, ProjectId, Environment, ClientId, or ClientSecret are not supplied, the cmdlet attempts to resolve them from a curated list of environment-variable name patterns across Process, User, and Machine scopes.
+ Authenticates against an Infisical instance using one of the supported auth providers (UniversalAuth, Token, JWT, OIDC, LDAP, Azure, GCP IAM) and stores the resulting connection in the module-level session manager. Subsequent cmdlets pick up the connection automatically. If parameters such as BaseUri, OrganizationId, ClientId, or ClientSecret are not supplied, the cmdlet attempts to resolve them from a curated list of environment-variable name patterns across Process, User, and Machine scopes. The connection no longer carries a default ProjectId, Environment, or SecretPath; downstream cmdlets accept those as explicit (mandatory where applicable) parameters.
Notes
@@ -21,7 +21,7 @@
EXAMPLE 1
- Connect-Infisical -BaseUri 'https://app.infisical.com' -ClientId $ClientId -ClientSecret $ClientSecret -OrganizationId $OrgId -ProjectId $ProjectId -Environment 'dev'
+ Connect-Infisical -BaseUri 'https://app.infisical.com' -ClientId $ClientId -ClientSecret $ClientSecret -OrganizationId $OrgId
Performs a Universal-Auth machine-identity login and stores the resulting session for subsequent cmdlets.
@@ -29,11 +29,8 @@
$ConnectInfisicalParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$ConnectInfisicalParameters.BaseUri = 'https://app.infisical.com'
$ConnectInfisicalParameters.OrganizationId = $OrganizationId
-$ConnectInfisicalParameters.ProjectId = $ProjectId
-$ConnectInfisicalParameters.Environment = 'dev'
$ConnectInfisicalParameters.ClientId = $ClientId
$ConnectInfisicalParameters.ClientSecret = $ClientSecret
-$ConnectInfisicalParameters.SecretPath = '/'
$ConnectInfisicalParameters.ApiVersion = 'v4'
$ConnectInfisicalParameters.PassThru = $True
$ConnectInfisicalParameters.Verbose = $True
@@ -86,7 +83,7 @@ $DisconnectInfisicalResult = Disconnect-Infisical @DisconnectInfisicalParameters
InfisicalSecret
- Default (List parameter set) enumerates secrets under the active session's project and environment, optionally recursing through subfolders and filtering by metadata or tag slugs. When -SecretName is supplied (Single parameter set) the cmdlet returns one secret by name; -Version and -Type tune the single-record fetch. ProjectId, Environment, SecretPath, and ApiVersion default to the values pinned on the active InfisicalConnection in both modes.
+ Default (List parameter set) enumerates secrets under the supplied project and environment, optionally recursing through subfolders and filtering by metadata or tag slugs. When -SecretName is supplied (Single parameter set) the cmdlet returns one secret by name; -Version and -Type tune the single-record fetch. -ProjectId and -Environment are mandatory in both modes; -SecretPath defaults to '/' and -ApiVersion defaults to the value pinned on the active InfisicalConnection.
Notes
@@ -97,8 +94,8 @@ $DisconnectInfisicalResult = Disconnect-Infisical @DisconnectInfisicalParameters
EXAMPLE 1
- Get-InfisicalSecret -SecretPath '/Windows' -Recursive
- Lists every secret under /Windows in the active project and environment.
+ Get-InfisicalSecret -ProjectId $ProjectId -Environment 'dev' -SecretPath '/Windows' -Recursive
+ Lists every secret under /Windows in the dev environment of the specified project.
EXAMPLE 2
@@ -108,8 +105,8 @@ $DisconnectInfisicalResult = Disconnect-Infisical @DisconnectInfisicalParameters
EXAMPLE 3
$GetInfisicalSecretParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
-$GetInfisicalSecretParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
-$GetInfisicalSecretParameters.Environment = $ConnectInfisicalParameters.Environment
+$GetInfisicalSecretParameters.ProjectId = $ProjectId
+$GetInfisicalSecretParameters.Environment = 'dev'
$GetInfisicalSecretParameters.SecretPath = "/Windows/$($CallingScriptPath.BaseName)"
$GetInfisicalSecretParameters.Recursive = $True
$GetInfisicalSecretParameters.ExpandSecretReferences = $True
@@ -142,19 +139,19 @@ $GetInfisicalSecretResult = Get-InfisicalSecret @GetInfisicalSecretParameters
EXAMPLE 1
- New-InfisicalSecret -SecretName 'API_KEY' -SecretValue 'super-secret-value'
- Creates a single shared secret in the active project/environment.
+ New-InfisicalSecret -SecretName 'API_KEY' -SecretValue 'super-secret-value' -ProjectId $ProjectId -Environment 'dev'
+ Creates a single shared secret in the specified project/environment.
EXAMPLE 2
- $GetInfisicalTagResult = Get-InfisicalTag -ProjectId $ConnectInfisicalParameters.ProjectId
+ $GetInfisicalTagResult = Get-InfisicalTag -ProjectId $ProjectId
$NewInfisicalSecretParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$NewInfisicalSecretParameters.SecretName = 'API_KEY'
$NewInfisicalSecretParameters.SecretValue = 'super-secret-value'
$NewInfisicalSecretParameters.SecretComment = 'Issued by deployment pipeline'
-$NewInfisicalSecretParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
-$NewInfisicalSecretParameters.Environment = $ConnectInfisicalParameters.Environment
+$NewInfisicalSecretParameters.ProjectId = $ProjectId
+$NewInfisicalSecretParameters.Environment = 'dev'
$NewInfisicalSecretParameters.SecretPath = "/Windows/$($CallingScriptPath.BaseName)"
$NewInfisicalSecretParameters.TagIds = @($GetInfisicalTagResult[0].Id)
$NewInfisicalSecretParameters.Verbose = $True
@@ -184,8 +181,8 @@ $NewInfisicalSecretResult = New-InfisicalSecret @NewInfisicalSecretParameters
EXAMPLE 1
- Update-InfisicalSecret -SecretName 'API_KEY' -SecretValue 'rotated-value'
- Rotates the API_KEY secret in the active project/environment.
+ Update-InfisicalSecret -SecretName 'API_KEY' -SecretValue 'rotated-value' -ProjectId $ProjectId -Environment 'dev'
+ Rotates the API_KEY secret in the specified project/environment.
EXAMPLE 2
@@ -194,8 +191,8 @@ $UpdateInfisicalSecretParameters.SecretName = 'API_KEY'
$UpdateInfisicalSecretParameters.NewSecretName = 'API_KEY_V2'
$UpdateInfisicalSecretParameters.SecretValue = 'rotated-value'
$UpdateInfisicalSecretParameters.SecretComment = 'Rotated by scheduled job'
-$UpdateInfisicalSecretParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
-$UpdateInfisicalSecretParameters.Environment = $ConnectInfisicalParameters.Environment
+$UpdateInfisicalSecretParameters.ProjectId = $ProjectId
+$UpdateInfisicalSecretParameters.Environment = 'dev'
$UpdateInfisicalSecretParameters.SecretPath = "/Windows/$($CallingScriptPath.BaseName)"
$UpdateInfisicalSecretParameters.Verbose = $True
@@ -224,15 +221,15 @@ $UpdateInfisicalSecretResult = Update-InfisicalSecret @UpdateInfisicalSecretPara
EXAMPLE 1
- Remove-InfisicalSecret -SecretName 'API_KEY_V1' -Confirm:$False
+ Remove-InfisicalSecret -SecretName 'API_KEY_V1' -ProjectId $ProjectId -Environment 'dev' -Confirm:$False
Deletes a single secret without prompting.
EXAMPLE 2
$RemoveInfisicalSecretParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$RemoveInfisicalSecretParameters.SecretNames = @('LEGACY_KEY_1','LEGACY_KEY_2','LEGACY_KEY_3')
-$RemoveInfisicalSecretParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
-$RemoveInfisicalSecretParameters.Environment = $ConnectInfisicalParameters.Environment
+$RemoveInfisicalSecretParameters.ProjectId = $ProjectId
+$RemoveInfisicalSecretParameters.Environment = 'dev'
$RemoveInfisicalSecretParameters.SecretPath = "/Windows/$($CallingScriptPath.BaseName)"
$RemoveInfisicalSecretParameters.PassThru = $True
$RemoveInfisicalSecretParameters.Confirm = $False
@@ -263,17 +260,17 @@ $RemoveInfisicalSecretResult = Remove-InfisicalSecret @RemoveInfisicalSecretPara
EXAMPLE 1
- Get-InfisicalSecret | Select-Object -ExpandProperty Id | Copy-InfisicalSecret -DestinationEnvironment 'staging' -CopySecretValue
- Copies all secrets from the active environment into 'staging', including their values.
+ Get-InfisicalSecret -ProjectId $ProjectId -Environment 'dev' | Select-Object -ExpandProperty Id | Copy-InfisicalSecret -ProjectId $ProjectId -SourceEnvironment 'dev' -DestinationEnvironment 'staging' -CopySecretValue
+ Copies all secrets from dev into staging, including their values.
EXAMPLE 2
- $GetInfisicalSecretResult = Get-InfisicalSecret -SecretPath '/Windows' -Recursive
+ $GetInfisicalSecretResult = Get-InfisicalSecret -ProjectId $ProjectId -Environment 'dev' -SecretPath '/Windows' -Recursive
$CopyInfisicalSecretParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$CopyInfisicalSecretParameters.SecretId = $GetInfisicalSecretResult.Id
-$CopyInfisicalSecretParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
-$CopyInfisicalSecretParameters.SourceEnvironment = $ConnectInfisicalParameters.Environment
+$CopyInfisicalSecretParameters.ProjectId = $ProjectId
+$CopyInfisicalSecretParameters.SourceEnvironment = 'dev'
$CopyInfisicalSecretParameters.SourceSecretPath = '/Windows'
$CopyInfisicalSecretParameters.DestinationEnvironment = 'staging'
$CopyInfisicalSecretParameters.DestinationSecretPath = '/Windows'
@@ -285,7 +282,7 @@ $CopyInfisicalSecretParameters.CopyMetadata = $True
$CopyInfisicalSecretParameters.Verbose = $True
$CopyInfisicalSecretResult = Copy-InfisicalSecret @CopyInfisicalSecretParameters
- Promotes every Windows secret from the active environment into staging with full value/comment/tag/metadata propagation.
+ Promotes every Windows secret from dev into staging with full value/comment/tag/metadata propagation.
@@ -309,12 +306,12 @@ $CopyInfisicalSecretResult = Copy-InfisicalSecret @CopyInfisicalSecretParameters
EXAMPLE 1
- Get-InfisicalSecret | ConvertTo-InfisicalSecretDictionary -AsPlainText
- Builds a plain-text dictionary of every secret in the active environment.
+ Get-InfisicalSecret -ProjectId $ProjectId -Environment 'dev' | ConvertTo-InfisicalSecretDictionary -AsPlainText
+ Builds a plain-text dictionary of every secret in the dev environment of the specified project.
EXAMPLE 2
- $GetInfisicalSecretResult = Get-InfisicalSecret -SecretPath "/Windows/$($CallingScriptPath.BaseName)" -Recursive
+ $GetInfisicalSecretResult = Get-InfisicalSecret -ProjectId $ProjectId -Environment 'dev' -SecretPath "/Windows/$($CallingScriptPath.BaseName)" -Recursive
$ConvertToInfisicalSecretDictionaryParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$ConvertToInfisicalSecretDictionaryParameters.InputObject = $GetInfisicalSecretResult
@@ -347,12 +344,12 @@ $ConvertToInfisicalSecretDictionaryResult = ConvertTo-InfisicalSecretDictionary
EXAMPLE 1
- Get-InfisicalSecret | Export-InfisicalSecrets -Format DotEnv -Path '.\.env' -Force
- Writes the active environment's secrets to a .env file.
+ Get-InfisicalSecret -ProjectId $ProjectId -Environment 'dev' | Export-InfisicalSecrets -Format DotEnv -Path '.\.env' -Force
+ Writes the dev environment's secrets for the specified project to a .env file.
EXAMPLE 2
- $GetInfisicalSecretResult = Get-InfisicalSecret -SecretPath "/Windows/$($CallingScriptPath.BaseName)" -Recursive
+ $GetInfisicalSecretResult = Get-InfisicalSecret -ProjectId $ProjectId -Environment 'dev' -SecretPath "/Windows/$($CallingScriptPath.BaseName)" -Recursive
$ExportInfisicalSecretsParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$ExportInfisicalSecretsParameters.InputObject = $GetInfisicalSecretResult
@@ -375,7 +372,7 @@ $ExportInfisicalSecretsResult = Export-InfisicalSecrets @ExportInfisicalSecretsP
InfisicalProject
- Default (List parameter set) returns every project the active session can see; project visibility is governed by Infisical's role assignments. When -ProjectId is supplied (Single parameter set) the cmdlet returns the one matching record.
+ Default (List parameter set) returns every project the active session can see; project visibility is governed by Infisical's role assignments. -Type filters the list to a single product surface (secret-manager, cert-manager, kms, ssh, secret-scanning, pam, ai). -IncludeRoles asks the server to return the caller's role bindings on each project. When -ProjectId is supplied (Single parameter set) the cmdlet returns the one matching record.
Notes
@@ -391,19 +388,24 @@ $ExportInfisicalSecretsResult = Export-InfisicalSecrets @ExportInfisicalSecretsP
EXAMPLE 2
- Get-InfisicalProject -ProjectId $ConnectInfisicalParameters.ProjectId
- Retrieves the canonical record for the project pinned by the active session.
+ Get-InfisicalProject -ProjectId $ProjectId
+ Retrieves the canonical record for a single project by id.
EXAMPLE 3
- $GetInfisicalProjectListResult = Get-InfisicalProject | Where-Object { $_.Slug -ilike 'platform-*' }
+ Get-InfisicalProject -Type 'cert-manager' -IncludeRoles
+ Lists every Certificate Manager project visible to the session, including the caller's role bindings.
+
+
+ EXAMPLE 4
+ $GetInfisicalProjectListResult = Get-InfisicalProject -Type 'secret-manager' | Where-Object { $_.Slug -ilike 'platform-*' }
$GetInfisicalProjectParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$GetInfisicalProjectParameters.ProjectId = $GetInfisicalProjectListResult[0].Id
$GetInfisicalProjectParameters.Verbose = $True
$GetInfisicalProjectResult = Get-InfisicalProject @GetInfisicalProjectParameters
- Filters the project list to slugs that begin with 'platform-' and refetches the first match by id.
+ Filters Secret Manager projects to slugs that begin with 'platform-' and refetches the first match by id.
@@ -454,7 +456,7 @@ $NewInfisicalProjectResult = New-InfisicalProject @NewInfisicalProjectParameters
InfisicalProject
- Updates mutable attributes on a project. -ProjectId defaults to the pinned session project when omitted. Only parameters that are bound are sent to the server. Honors -WhatIf and -Confirm.
+ Updates mutable attributes on a project. -ProjectId is required. Only parameters that are bound are sent to the server. Honors -WhatIf and -Confirm.
Notes
@@ -466,7 +468,7 @@ $NewInfisicalProjectResult = New-InfisicalProject @NewInfisicalProjectParameters
EXAMPLE 1
Update-InfisicalProject -Name 'Platform Telemetry (v2)'
- Renames the session-pinned project.
+ Renames the supplied project.
EXAMPLE 2
@@ -493,7 +495,7 @@ $UpdateInfisicalProjectResult = Update-InfisicalProject @UpdateInfisicalProjectP
InfisicalProject
- Deletes a project by Id. Defaults to the session-pinned project when -ProjectId is omitted. High ConfirmImpact prompts unless -Confirm:$False is supplied. -PassThru emits the removed project id.
+ Deletes a project by Id. -ProjectId is required. High ConfirmImpact prompts unless -Confirm:$False is supplied. -PassThru emits the removed project id.
Notes
@@ -505,7 +507,7 @@ $UpdateInfisicalProjectResult = Update-InfisicalProject @UpdateInfisicalProjectP
EXAMPLE 1
Remove-InfisicalProject -Confirm:$False
- Deletes the session-pinned project without prompting.
+ Deletes the supplied project without prompting.
EXAMPLE 2
@@ -531,7 +533,7 @@ $RemoveInfisicalProjectResult = Remove-InfisicalProject @RemoveInfisicalProjectP
InfisicalEnvironment
- Default (List parameter set) returns every environment configured on the session-pinned project. When -EnvironmentSlugOrId is supplied (Single parameter set) the cmdlet returns one environment by slug or id. -ProjectId defaults to the session-pinned project in both modes.
+ Default (List parameter set) returns every environment configured on the supplied project. When -EnvironmentSlugOrId is supplied (Single parameter set) the cmdlet returns one environment by slug or id. -ProjectId is required in both modes.
Notes
@@ -543,12 +545,12 @@ $RemoveInfisicalProjectResult = Remove-InfisicalProject @RemoveInfisicalProjectP
EXAMPLE 1
Get-InfisicalEnvironment
- Lists every environment defined on the session-pinned project.
+ Lists every environment defined on the supplied project.
EXAMPLE 2
Get-InfisicalEnvironment -EnvironmentSlugOrId 'dev'
- Retrieves the 'dev' environment from the session-pinned project.
+ Retrieves the 'dev' environment from the supplied project.
EXAMPLE 3
@@ -573,7 +575,7 @@ $GetInfisicalEnvironmentResult = Get-InfisicalEnvironment @GetInfisicalEnvironme
InfisicalEnvironment
- Creates an environment with the supplied display name and slug, optionally setting its sort -Position. -ProjectId defaults to the session-pinned project when omitted. Honors -WhatIf and -Confirm.
+ Creates an environment with the supplied display name and slug, optionally setting its sort -Position. -ProjectId is required. Honors -WhatIf and -Confirm.
Notes
@@ -585,7 +587,7 @@ $GetInfisicalEnvironmentResult = Get-InfisicalEnvironment @GetInfisicalEnvironme
EXAMPLE 1
New-InfisicalEnvironment -Name 'Staging' -Slug 'staging'
- Adds a Staging environment to the session-pinned project.
+ Adds a Staging environment to the supplied project.
EXAMPLE 2
@@ -612,7 +614,7 @@ $NewInfisicalEnvironmentResult = New-InfisicalEnvironment @NewInfisicalEnvironme
InfisicalEnvironment
- Updates an environment identified by -EnvironmentId. -ProjectId defaults to the session-pinned project when omitted. Only bound parameters are sent to the server. Honors -WhatIf and -Confirm.
+ Updates an environment identified by -EnvironmentId. -ProjectId is required. Only bound parameters are sent to the server. Honors -WhatIf and -Confirm.
Notes
@@ -624,7 +626,7 @@ $NewInfisicalEnvironmentResult = New-InfisicalEnvironment @NewInfisicalEnvironme
EXAMPLE 1
Update-InfisicalEnvironment -EnvironmentId $EnvId -Name 'Pre-Production'
- Renames an environment in the session-pinned project.
+ Renames an environment in the supplied project.
EXAMPLE 2
@@ -632,7 +634,7 @@ $NewInfisicalEnvironmentResult = New-InfisicalEnvironment @NewInfisicalEnvironme
$UpdateInfisicalEnvironmentParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$UpdateInfisicalEnvironmentParameters.EnvironmentId = $GetInfisicalEnvironmentResult.Id
-$UpdateInfisicalEnvironmentParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
+$UpdateInfisicalEnvironmentParameters.ProjectId = $ProjectId
$UpdateInfisicalEnvironmentParameters.Name = 'Pre-Production'
$UpdateInfisicalEnvironmentParameters.Slug = 'preprod'
$UpdateInfisicalEnvironmentParameters.Position = 25
@@ -652,7 +654,7 @@ $UpdateInfisicalEnvironmentResult = Update-InfisicalEnvironment @UpdateInfisical
InfisicalEnvironment
- Removes an environment by Id. -ProjectId defaults to the session-pinned project when omitted. High ConfirmImpact prompts unless -Confirm:$False is supplied. -PassThru emits the removed environment id.
+ Removes an environment by Id. -ProjectId is required. High ConfirmImpact prompts unless -Confirm:$False is supplied. -PassThru emits the removed environment id.
Notes
@@ -672,7 +674,7 @@ $UpdateInfisicalEnvironmentResult = Update-InfisicalEnvironment @UpdateInfisical
$RemoveInfisicalEnvironmentParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$RemoveInfisicalEnvironmentParameters.EnvironmentId = $GetInfisicalEnvironmentResult.Id
-$RemoveInfisicalEnvironmentParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
+$RemoveInfisicalEnvironmentParameters.ProjectId = $ProjectId
$RemoveInfisicalEnvironmentParameters.PassThru = $True
$RemoveInfisicalEnvironmentParameters.Confirm = $False
$RemoveInfisicalEnvironmentParameters.Verbose = $True
@@ -691,7 +693,7 @@ $RemoveInfisicalEnvironmentResult = Remove-InfisicalEnvironment @RemoveInfisical
InfisicalFolder
- Default (List parameter set) enumerates folders directly under the supplied -Path within the active project and environment. When -FolderNameOrId is supplied (Single parameter set) the cmdlet returns one folder by name or id under -Path. -ProjectId, -Environment, and -Path default to the session-pinned values in both modes.
+ Default (List parameter set) enumerates folders directly under the supplied -Path within the project and environment. When -FolderNameOrId is supplied (Single parameter set) the cmdlet returns one folder by name or id under -Path. -ProjectId and -Environment are required in both modes; -Path defaults to '/'.
Notes
@@ -702,13 +704,13 @@ $RemoveInfisicalEnvironmentResult = Remove-InfisicalEnvironment @RemoveInfisical
EXAMPLE 1
- Get-InfisicalFolder -Path '/Windows'
- Lists every folder directly under /Windows in the active project and environment.
+ Get-InfisicalFolder -ProjectId $ProjectId -Environment 'dev' -Path '/Windows'
+ Lists every folder directly under /Windows in the supplied project and environment.
EXAMPLE 2
- Get-InfisicalFolder -FolderNameOrId 'Deployments' -Path '/Windows'
- Retrieves the Deployments folder under /Windows in the active project and environment.
+ Get-InfisicalFolder -FolderNameOrId 'Deployments' -ProjectId $ProjectId -Environment 'dev' -Path '/Windows'
+ Retrieves the Deployments folder under /Windows in the supplied project and environment.
EXAMPLE 3
@@ -716,8 +718,8 @@ $RemoveInfisicalEnvironmentResult = Remove-InfisicalEnvironment @RemoveInfisical
$GetInfisicalFolderParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$GetInfisicalFolderParameters.FolderNameOrId = $GetInfisicalFolderListResult.Id
-$GetInfisicalFolderParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
-$GetInfisicalFolderParameters.Environment = $ConnectInfisicalParameters.Environment
+$GetInfisicalFolderParameters.ProjectId = $ProjectId
+$GetInfisicalFolderParameters.Environment = 'dev'
$GetInfisicalFolderParameters.Path = '/Windows'
$GetInfisicalFolderParameters.Verbose = $True
@@ -735,7 +737,7 @@ $GetInfisicalFolderResult = Get-InfisicalFolder @GetInfisicalFolderParametersInfisicalFolder
- Creates a folder with the supplied -Name beneath the supplied -Path. -ProjectId, -Environment, and -Path default to the session-pinned values when omitted. Honors -WhatIf and -Confirm.
+ Creates a folder with the supplied -Name beneath the supplied -Path. -ProjectId and -Environment are required; -Path defaults to '/'. Honors -WhatIf and -Confirm.
Notes
@@ -746,20 +748,20 @@ $GetInfisicalFolderResult = Get-InfisicalFolder @GetInfisicalFolderParameters
EXAMPLE 1
- New-InfisicalFolder -Name 'Deployments' -Path '/Windows'
- Creates the Deployments folder under /Windows in the active project and environment.
+ New-InfisicalFolder -Name 'Deployments' -ProjectId $ProjectId -Environment 'dev' -Path '/Windows'
+ Creates the Deployments folder under /Windows in the supplied project and environment.
EXAMPLE 2
$NewInfisicalFolderParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$NewInfisicalFolderParameters.Name = $CallingScriptPath.BaseName
-$NewInfisicalFolderParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
-$NewInfisicalFolderParameters.Environment = $ConnectInfisicalParameters.Environment
+$NewInfisicalFolderParameters.ProjectId = $ProjectId
+$NewInfisicalFolderParameters.Environment = 'dev'
$NewInfisicalFolderParameters.Path = '/Windows'
$NewInfisicalFolderParameters.Verbose = $True
$NewInfisicalFolderResult = New-InfisicalFolder @NewInfisicalFolderParameters
- Creates a script-named folder under /Windows using the session-pinned project and environment.
+ Creates a script-named folder under /Windows in the supplied project and environment.
@@ -772,7 +774,7 @@ $NewInfisicalFolderResult = New-InfisicalFolder @NewInfisicalFolderParametersInfisicalFolder
- Renames a folder identified by -FolderId to the supplied -Name. -ProjectId, -Environment, and -Path default to the session-pinned values when omitted. Honors -WhatIf and -Confirm.
+ Renames a folder identified by -FolderId to the supplied -Name. -ProjectId and -Environment are required; -Path defaults to '/'. Honors -WhatIf and -Confirm.
Notes
@@ -784,7 +786,7 @@ $NewInfisicalFolderResult = New-InfisicalFolder @NewInfisicalFolderParameters
EXAMPLE 1
Update-InfisicalFolder -FolderId $FolderId -Name 'Deployments-Archive'
- Renames a folder in the session-pinned project/environment.
+ Renames a folder in the supplied project/environment.
EXAMPLE 2
@@ -793,8 +795,8 @@ $NewInfisicalFolderResult = New-InfisicalFolder @NewInfisicalFolderParametersInfisicalFolder
- Removes a folder by Id from the supplied -Path. -ProjectId, -Environment, and -Path default to the session-pinned values when omitted. High ConfirmImpact prompts unless -Confirm:$False is supplied. -PassThru emits the removed folder id.
+ Removes a folder by Id from the supplied -Path. -ProjectId and -Environment are required; -Path defaults to '/'. High ConfirmImpact prompts unless -Confirm:$False is supplied. -PassThru emits the removed folder id.
Notes
@@ -824,7 +826,7 @@ $UpdateInfisicalFolderResult = Update-InfisicalFolder @UpdateInfisicalFolderPara
EXAMPLE 1
Remove-InfisicalFolder -FolderId $FolderId -Confirm:$False
- Deletes a folder from the session-pinned project/environment without prompting.
+ Deletes a folder from the supplied project/environment without prompting.
EXAMPLE 2
@@ -832,8 +834,8 @@ $UpdateInfisicalFolderResult = Update-InfisicalFolder @UpdateInfisicalFolderPara
$RemoveInfisicalFolderParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$RemoveInfisicalFolderParameters.FolderId = $GetInfisicalFolderResult.Id
-$RemoveInfisicalFolderParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
-$RemoveInfisicalFolderParameters.Environment = $ConnectInfisicalParameters.Environment
+$RemoveInfisicalFolderParameters.ProjectId = $ProjectId
+$RemoveInfisicalFolderParameters.Environment = 'dev'
$RemoveInfisicalFolderParameters.Path = '/Windows'
$RemoveInfisicalFolderParameters.PassThru = $True
$RemoveInfisicalFolderParameters.Confirm = $False
@@ -853,7 +855,7 @@ $RemoveInfisicalFolderResult = Remove-InfisicalFolder @RemoveInfisicalFolderPara
InfisicalTag
- Default (List parameter set) returns every tag configured on the project. When -TagSlugOrId is supplied (Single parameter set) the cmdlet returns the one matching record. -ProjectId defaults to the session-pinned project in both modes.
+ Default (List parameter set) returns every tag configured on the project. When -TagSlugOrId is supplied (Single parameter set) the cmdlet returns the one matching record. -ProjectId is required in both modes.
Notes
@@ -865,12 +867,12 @@ $RemoveInfisicalFolderResult = Remove-InfisicalFolder @RemoveInfisicalFolderPara
EXAMPLE 1
Get-InfisicalTag
- Lists every tag defined on the session-pinned project.
+ Lists every tag defined on the supplied project.
EXAMPLE 2
Get-InfisicalTag -TagSlugOrId 'critical'
- Retrieves the 'critical' tag from the session-pinned project.
+ Retrieves the 'critical' tag from the supplied project.
EXAMPLE 3
@@ -895,7 +897,7 @@ $GetInfisicalTagResult = Get-InfisicalTag @GetInfisicalTagParameters
InfisicalTag
- Creates a tag with the supplied -Slug, optional -Name and -Color. -ProjectId defaults to the session-pinned project when omitted. Honors -WhatIf and -Confirm.
+ Creates a tag with the supplied -Slug, optional -Name and -Color. -ProjectId is required. Honors -WhatIf and -Confirm.
Notes
@@ -907,7 +909,7 @@ $GetInfisicalTagResult = Get-InfisicalTag @GetInfisicalTagParameters
EXAMPLE 1
New-InfisicalTag -Slug 'critical' -Name 'Critical' -Color '#FF0000'
- Creates a red Critical tag in the session-pinned project.
+ Creates a red Critical tag in the supplied project.
EXAMPLE 2
@@ -915,7 +917,7 @@ $GetInfisicalTagResult = Get-InfisicalTag @GetInfisicalTagParameters
$NewInfisicalTagParameters.Slug = 'critical'
$NewInfisicalTagParameters.Name = 'Critical'
$NewInfisicalTagParameters.Color = '#FF0000'
-$NewInfisicalTagParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
+$NewInfisicalTagParameters.ProjectId = $ProjectId
$NewInfisicalTagParameters.Verbose = $True
$NewInfisicalTagResult = New-InfisicalTag @NewInfisicalTagParameters
@@ -932,7 +934,7 @@ $NewInfisicalTagResult = New-InfisicalTag @NewInfisicalTagParameters
InfisicalTag
- Updates a tag identified by -TagId. -ProjectId defaults to the session-pinned project when omitted. Only bound parameters are sent to the server. Honors -WhatIf and -Confirm.
+ Updates a tag identified by -TagId. -ProjectId is required. Only bound parameters are sent to the server. Honors -WhatIf and -Confirm.
Notes
@@ -944,7 +946,7 @@ $NewInfisicalTagResult = New-InfisicalTag @NewInfisicalTagParameters
EXAMPLE 1
Update-InfisicalTag -TagId $TagId -Color '#FFA500'
- Changes the display color of a tag in the session-pinned project.
+ Changes the display color of a tag in the supplied project.
EXAMPLE 2
@@ -955,7 +957,7 @@ $UpdateInfisicalTagParameters.TagId = $GetInfisicalTagResult.Id
$UpdateInfisicalTagParameters.Slug = 'critical-v2'
$UpdateInfisicalTagParameters.Name = 'Critical (v2)'
$UpdateInfisicalTagParameters.Color = '#FFA500'
-$UpdateInfisicalTagParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
+$UpdateInfisicalTagParameters.ProjectId = $ProjectId
$UpdateInfisicalTagParameters.Verbose = $True
$UpdateInfisicalTagResult = Update-InfisicalTag @UpdateInfisicalTagParameters
@@ -972,7 +974,7 @@ $UpdateInfisicalTagResult = Update-InfisicalTag @UpdateInfisicalTagParametersInfisicalTag
- Removes a tag by Id. -ProjectId defaults to the session-pinned project when omitted. High ConfirmImpact prompts unless -Confirm:$False is supplied. -PassThru emits the removed tag id.
+ Removes a tag by Id. -ProjectId is required. High ConfirmImpact prompts unless -Confirm:$False is supplied. -PassThru emits the removed tag id.
Notes
@@ -984,7 +986,7 @@ $UpdateInfisicalTagResult = Update-InfisicalTag @UpdateInfisicalTagParameters
EXAMPLE 1
Remove-InfisicalTag -TagId $TagId -Confirm:$False
- Deletes a tag from the session-pinned project without prompting.
+ Deletes a tag from the supplied project without prompting.
EXAMPLE 2
@@ -992,7 +994,7 @@ $UpdateInfisicalTagResult = Update-InfisicalTag @UpdateInfisicalTagParametersInfisicalCertificateAuthority
- When -CaId is supplied (ById parameter set) returns a single internal CA. Otherwise (List parameter set) returns CAs scoped by -Kind: Internal (default, /api/v1/cert-manager/ca/internal), Any (/api/v1/cert-manager/ca returning both internal and ACME), or Acme (filters the generic endpoint to ACME issuers only). -ProjectId defaults to the session-pinned project when omitted.
+ When -CaId is supplied (ById parameter set) returns a single internal CA. Otherwise (List parameter set) returns CAs scoped by -Kind: Internal (default, /api/v1/cert-manager/ca/internal), Any (/api/v1/cert-manager/ca returning both internal and ACME), or Acme (filters the generic endpoint to ACME issuers only). -ProjectId is required.
Notes
@@ -1023,12 +1025,12 @@ $RemoveInfisicalTagResult = Remove-InfisicalTag @RemoveInfisicalTagParameters
EXAMPLE 1
Get-InfisicalCertificateAuthority
- Lists every internal CA visible in the session-pinned project.
+ Lists every internal CA visible in the supplied project.
EXAMPLE 2
Get-InfisicalCertificateAuthority -Kind Any
- Lists every CA (internal and ACME) visible in the session-pinned project; inspect the Type property to distinguish them.
+ Lists every CA (internal and ACME) visible in the supplied project; inspect the Type property to distinguish them.
EXAMPLE 3
@@ -1036,7 +1038,7 @@ $RemoveInfisicalTagResult = Remove-InfisicalTag @RemoveInfisicalTagParameters
@@ -1053,7 +1055,7 @@ $GetInfisicalCertificateAuthorityResult = Get-InfisicalCertificateAuthority @Get
InfisicalCertificate
- Default (List parameter set) enumerates certificates with optional filters for -CommonName, -FriendlyName, -Status, and -CaId; -Limit and -Offset drive a single page and pages are walked automatically until exhausted unless -NoAutoPage is supplied. When -SerialNumber is supplied (Single parameter set) the cmdlet returns one certificate record. -ProjectId defaults to the session-pinned project in both modes.
+ Default (List parameter set) enumerates certificates with optional filters for -CommonName, -FriendlyName, -Status, and -CaId; -Limit and -Offset drive a single page and pages are walked automatically until exhausted unless -NoAutoPage is supplied. When -SerialNumber is supplied (Single parameter set) the cmdlet returns one certificate record. -ProjectId is required in both modes.
Notes
@@ -1065,7 +1067,7 @@ $GetInfisicalCertificateAuthorityResult = Get-InfisicalCertificateAuthority @Get
EXAMPLE 1
Get-InfisicalCertificate -Status 'active'
- Lists every active certificate in the session-pinned project.
+ Lists every active certificate in the supplied project.
EXAMPLE 2
@@ -1077,7 +1079,7 @@ $GetInfisicalCertificateAuthorityResult = Get-InfisicalCertificateAuthority @Get
$GetInfisicalCertificateAuthorityListResult = Get-InfisicalCertificateAuthority | Where-Object { $_.FriendlyName -eq 'Issuing CA - Platform' }
$GetInfisicalCertificateParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
-$GetInfisicalCertificateParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
+$GetInfisicalCertificateParameters.ProjectId = $ProjectId
$GetInfisicalCertificateParameters.CommonName = $env:COMPUTERNAME
$GetInfisicalCertificateParameters.FriendlyName = 'web-tier'
$GetInfisicalCertificateParameters.Status = 'active'
@@ -1099,7 +1101,7 @@ $GetInfisicalCertificateListResult = Get-InfisicalCertificate @GetInfisicalCerti
InfisicalPkiSubscriber
- Default (List parameter set) returns every PKI subscriber configured on the project. When -Name is supplied (ByName parameter set) the cmdlet returns one subscriber by its slug. -ProjectId defaults to the session-pinned project in both modes.
+ Default (List parameter set) returns every PKI subscriber configured on the project. When -Name is supplied (ByName parameter set) the cmdlet returns one subscriber by its slug. -ProjectId is required in both modes.
Notes
@@ -1111,12 +1113,12 @@ $GetInfisicalCertificateListResult = Get-InfisicalCertificate @GetInfisicalCerti
EXAMPLE 1
Get-InfisicalPkiSubscriber
- Lists every PKI subscriber defined on the session-pinned project.
+ Lists every PKI subscriber defined on the supplied project.
EXAMPLE 2
Get-InfisicalPkiSubscriber -Name 'mecm'
- Retrieves the 'mecm' PKI subscriber from the session-pinned project.
+ Retrieves the 'mecm' PKI subscriber from the supplied project.
EXAMPLE 3
@@ -1124,7 +1126,7 @@ $GetInfisicalCertificateListResult = Get-InfisicalCertificate @GetInfisicalCerti
$GetInfisicalPkiSubscriberParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$GetInfisicalPkiSubscriberParameters.Name = $GetInfisicalPkiSubscriberListResult[0].Name
-$GetInfisicalPkiSubscriberParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
+$GetInfisicalPkiSubscriberParameters.ProjectId = $ProjectId
$GetInfisicalPkiSubscriberParameters.Verbose = $True
$GetInfisicalPkiSubscriberResult = Get-InfisicalPkiSubscriber @GetInfisicalPkiSubscriberParameters
@@ -1141,7 +1143,7 @@ $GetInfisicalPkiSubscriberResult = Get-InfisicalPkiSubscriber @GetInfisicalPkiSu
InfisicalCertificateProfile
- Default (List parameter set) returns every certificate profile configured on the project via /api/v1/cert-manager/certificate-profiles, with optional -Limit, -Offset, and -IncludeConfigs. When -ProfileId is supplied (ById parameter set) the cmdlet returns one profile by its id. -ProjectId defaults to the session-pinned project in both modes.
+ Default (List parameter set) returns every certificate profile configured on the project via /api/v1/cert-manager/certificate-profiles, with optional -Limit, -Offset, and -IncludeConfigs. When -ProfileId is supplied (ById parameter set) the cmdlet returns one profile by its id. -ProjectId is required in both modes.
Notes
@@ -1153,12 +1155,12 @@ $GetInfisicalPkiSubscriberResult = Get-InfisicalPkiSubscriber @GetInfisicalPkiSu
EXAMPLE 1
Get-InfisicalCertificateProfile
- Lists every certificate profile defined on the session-pinned project.
+ Lists every certificate profile defined on the supplied project.
EXAMPLE 2
Get-InfisicalCertificateProfile -ProfileId '8257641e-c808-454e-ac92-8dc920be865f'
- Retrieves a single certificate profile by id from the session-pinned project.
+ Retrieves a single certificate profile by id from the supplied project.
EXAMPLE 3
@@ -1166,7 +1168,7 @@ $GetInfisicalPkiSubscriberResult = Get-InfisicalPkiSubscriber @GetInfisicalPkiSu
$GetInfisicalCertificateProfileParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$GetInfisicalCertificateProfileParameters.ProfileId = $GetInfisicalCertificateProfileListResult[0].Id
-$GetInfisicalCertificateProfileParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
+$GetInfisicalCertificateProfileParameters.ProjectId = $ProjectId
$GetInfisicalCertificateProfileParameters.Verbose = $True
$GetInfisicalCertificateProfileResult = Get-InfisicalCertificateProfile @GetInfisicalCertificateProfileParameters
@@ -1183,7 +1185,7 @@ $GetInfisicalCertificateProfileResult = Get-InfisicalCertificateProfile @GetInfi
InfisicalCertificatePolicy
- Default (List parameter set) returns every certificate policy configured on the project via /api/v1/cert-manager/certificate-policies, with optional -Limit and -Offset. When -PolicyId is supplied (ById parameter set) the cmdlet returns one policy by its id. -ProjectId defaults to the session-pinned project in both modes.
+ Default (List parameter set) returns every certificate policy configured on the project via /api/v1/cert-manager/certificate-policies, with optional -Limit and -Offset. When -PolicyId is supplied (ById parameter set) the cmdlet returns one policy by its id. -ProjectId is required in both modes.
Notes
@@ -1195,12 +1197,12 @@ $GetInfisicalCertificateProfileResult = Get-InfisicalCertificateProfile @GetInfi
EXAMPLE 1
Get-InfisicalCertificatePolicy
- Lists every certificate policy defined on the session-pinned project.
+ Lists every certificate policy defined on the supplied project.
EXAMPLE 2
Get-InfisicalCertificatePolicy -PolicyId '3e69306a-e7c1-4fd2-a140-7fb300e53c43'
- Retrieves a single certificate policy by id from the session-pinned project.
+ Retrieves a single certificate policy by id from the supplied project.
EXAMPLE 3
@@ -1208,7 +1210,7 @@ $GetInfisicalCertificateProfileResult = Get-InfisicalCertificateProfile @GetInfi
$GetInfisicalCertificatePolicyParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$GetInfisicalCertificatePolicyParameters.PolicyId = $GetInfisicalCertificatePolicyListResult[0].Id
-$GetInfisicalCertificatePolicyParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
+$GetInfisicalCertificatePolicyParameters.ProjectId = $ProjectId
$GetInfisicalCertificatePolicyParameters.Verbose = $True
$GetInfisicalCertificatePolicyResult = Get-InfisicalCertificatePolicy @GetInfisicalCertificatePolicyParameters
@@ -1225,7 +1227,7 @@ $GetInfisicalCertificatePolicyResult = Get-InfisicalCertificatePolicy @GetInfisi
InfisicalCertificate
- Performs a server-side search across certificates with filters for friendly name, common name, free-text search, status, CA/profile/application/enrollment scope, key/signature algorithm, source, and validity window (-NotBeforeFrom/-NotBeforeTo/-NotAfterFrom/-NotAfterTo). Results are paged automatically unless -NoAutoPage is supplied. -ProjectId defaults to the session-pinned project when omitted.
+ Performs a server-side search across certificates with filters for friendly name, common name, free-text search, status, CA/profile/application/enrollment scope, key/signature algorithm, source, and validity window (-NotBeforeFrom/-NotBeforeTo/-NotAfterFrom/-NotAfterTo). Results are paged automatically unless -NoAutoPage is supplied. -ProjectId is required.
Notes
@@ -1244,7 +1246,7 @@ $GetInfisicalCertificatePolicyResult = Get-InfisicalCertificatePolicy @GetInfisi
$GetInfisicalCertificateAuthorityListResult = Get-InfisicalCertificateAuthority | Where-Object { $_.FriendlyName -eq 'Issuing CA - Platform' }
$SearchInfisicalCertificateParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
-$SearchInfisicalCertificateParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
+$SearchInfisicalCertificateParameters.ProjectId = $ProjectId
$SearchInfisicalCertificateParameters.CommonName = $env:COMPUTERNAME
$SearchInfisicalCertificateParameters.Status = 'active'
$SearchInfisicalCertificateParameters.CaId = @($GetInfisicalCertificateAuthorityListResult.Id)
@@ -1287,7 +1289,7 @@ $SearchInfisicalCertificateResult = Search-InfisicalCertificate @SearchInfisical
EXAMPLE 2
$RequestInfisicalCertificateParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' -ArgumentList ([System.StringComparer]::OrdinalIgnoreCase)
$RequestInfisicalCertificateParameters.PkiSubscriberSlug = 'web-tier'
-$RequestInfisicalCertificateParameters.ProjectId = $ConnectInfisicalParameters.ProjectId
+$RequestInfisicalCertificateParameters.ProjectId = $ProjectId
$RequestInfisicalCertificateParameters.CommonName = ([System.Net.Dns]::GetHostEntry($env:COMPUTERNAME)).HostName
$RequestInfisicalCertificateParameters.DnsName = @(([System.Net.Dns]::GetHostEntry($env:COMPUTERNAME)).HostName, $env:COMPUTERNAME)
$RequestInfisicalCertificateParameters.KeyAlgorithm = 'Rsa'
@@ -1480,22 +1482,22 @@ $UninstallInfisicalCertificateResult = Uninstall-InfisicalCertificate @Uninstall
Get-InfisicalCertificateApplication
- Lists or retrieves an Infisical Certificate Manager Application from the active project.
+ Lists or retrieves an Infisical Certificate Manager Application from the supplied project.
Get
InfisicalCertificateApplication
- Reads Infisical certificate-manager Applications (the join target used by EST/ACME/SCEP profile attachments) using the active connection's project scope. The List parameter set returns all applications visible to the caller; the ById and ByName sets return a single application. ProjectId falls back to the active connection when omitted.
+ Reads Infisical certificate-manager Applications (the join target used by EST/ACME/SCEP profile attachments) for the supplied project. The List parameter set returns all applications visible to the caller; the ById and ByName sets return a single application. -ProjectId is required.
EXAMPLE 1
- Get-InfisicalCertificateApplication
- Lists certificate-manager applications for the active project.
+ Get-InfisicalCertificateApplication -ProjectId $ProjectId
+ Lists certificate-manager applications for the supplied project.
EXAMPLE 2
- Get-InfisicalCertificateApplication -ApplicationName 'workstation-mdm'
+ Get-InfisicalCertificateApplication -ApplicationName 'workstation-mdm' -ProjectId $ProjectId
Retrieves a single application by name.
diff --git a/src/PSInfisicalAPI.Tests/CmdletBaseInheritanceTests.cs b/src/PSInfisicalAPI.Tests/CmdletBaseInheritanceTests.cs
index 6ae42cd..92840be 100644
--- a/src/PSInfisicalAPI.Tests/CmdletBaseInheritanceTests.cs
+++ b/src/PSInfisicalAPI.Tests/CmdletBaseInheritanceTests.cs
@@ -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);
}
}
}
diff --git a/src/PSInfisicalAPI.Tests/InfisicalEnvironmentPatternTests.cs b/src/PSInfisicalAPI.Tests/InfisicalEnvironmentPatternTests.cs
index 1bedc43..babd0f0 100644
--- a/src/PSInfisicalAPI.Tests/InfisicalEnvironmentPatternTests.cs
+++ b/src/PSInfisicalAPI.Tests/InfisicalEnvironmentPatternTests.cs
@@ -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));
}
diff --git a/src/PSInfisicalAPI/Authentication/InfisicalEnvironmentResolver.cs b/src/PSInfisicalAPI/Authentication/InfisicalEnvironmentResolver.cs
index dee5c0d..0e091c4 100644
--- a/src/PSInfisicalAPI/Authentication/InfisicalEnvironmentResolver.cs
+++ b/src/PSInfisicalAPI/Authentication/InfisicalEnvironmentResolver.cs
@@ -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)
diff --git a/src/PSInfisicalAPI/Cmdlets/ConnectInfisicalCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/ConnectInfisicalCmdlet.cs
index 08834df..d199fb9 100644
--- a/src/PSInfisicalAPI/Cmdlets/ConnectInfisicalCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/ConnectInfisicalCmdlet.cs
@@ -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))
{
diff --git a/src/PSInfisicalAPI/Cmdlets/CopyInfisicalSecretCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/CopyInfisicalSecretCmdlet.cs
index ce4baea..ea85a76 100644
--- a/src/PSInfisicalAPI/Cmdlets/CopyInfisicalSecretCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/CopyInfisicalSecretCmdlet.cs
@@ -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,
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateApplicationCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateApplicationCmdlet.cs
index 11bfb2e..9fa6433 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateApplicationCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateApplicationCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateApplicationEnrollmentCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateApplicationEnrollmentCmdlet.cs
index 426e1a2..6001970 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateApplicationEnrollmentCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateApplicationEnrollmentCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateAuthorityCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateAuthorityCmdlet.cs
index 3857d9a..d712ac4 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateAuthorityCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateAuthorityCmdlet.cs
@@ -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")]
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateCmdlet.cs
index 91a91e8..a9b98d7 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateCmdlet.cs
@@ -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,
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificatePolicyCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificatePolicyCmdlet.cs
index 01b59bb..0472507 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificatePolicyCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificatePolicyCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateProfileCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateProfileCmdlet.cs
index 7f20258..02cf1ae 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateProfileCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalCertificateProfileCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalEnvironmentCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalEnvironmentCmdlet.cs
index a871c16..c6b4013 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalEnvironmentCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalEnvironmentCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalFolderCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalFolderCmdlet.cs
index 8a1e644..2e877c6 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalFolderCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalFolderCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalPkiSubscriberCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalPkiSubscriberCmdlet.cs
index bcd2eab..5cfebda 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalPkiSubscriberCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalPkiSubscriberCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalProjectCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalProjectCmdlet.cs
index fa251fc..4ab1598 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalProjectCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalProjectCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalSecretCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalSecretCmdlet.cs
index 49eee51..724a4d3 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalSecretCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalSecretCmdlet.cs
@@ -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,
diff --git a/src/PSInfisicalAPI/Cmdlets/GetInfisicalTagCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/GetInfisicalTagCmdlet.cs
index 60ce541..eefe56d 100644
--- a/src/PSInfisicalAPI/Cmdlets/GetInfisicalTagCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/GetInfisicalTagCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/InfisicalCmdletBase.cs b/src/PSInfisicalAPI/Cmdlets/InfisicalCmdletBase.cs
index 4a3c37b..4e35b17 100644
--- a/src/PSInfisicalAPI/Cmdlets/InfisicalCmdletBase.cs
+++ b/src/PSInfisicalAPI/Cmdlets/InfisicalCmdletBase.cs
@@ -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;
diff --git a/src/PSInfisicalAPI/Cmdlets/NewInfisicalEnvironmentCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/NewInfisicalEnvironmentCmdlet.cs
index 6a00664..ad11bef 100644
--- a/src/PSInfisicalAPI/Cmdlets/NewInfisicalEnvironmentCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/NewInfisicalEnvironmentCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/NewInfisicalFolderCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/NewInfisicalFolderCmdlet.cs
index f31ff1d..46b6f97 100644
--- a/src/PSInfisicalAPI/Cmdlets/NewInfisicalFolderCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/NewInfisicalFolderCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/NewInfisicalSecretCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/NewInfisicalSecretCmdlet.cs
index 2d8962a..2b41f51 100644
--- a/src/PSInfisicalAPI/Cmdlets/NewInfisicalSecretCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/NewInfisicalSecretCmdlet.cs
@@ -28,8 +28,8 @@ namespace PSInfisicalAPI.Cmdlets
public IDictionary[] 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,
diff --git a/src/PSInfisicalAPI/Cmdlets/NewInfisicalTagCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/NewInfisicalTagCmdlet.cs
index bf26869..3014fcb 100644
--- a/src/PSInfisicalAPI/Cmdlets/NewInfisicalTagCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/NewInfisicalTagCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalEnvironmentCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalEnvironmentCmdlet.cs
index 2716bc4..48b3c24 100644
--- a/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalEnvironmentCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalEnvironmentCmdlet.cs
@@ -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)
{
diff --git a/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalFolderCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalFolderCmdlet.cs
index 7dde5d7..597defc 100644
--- a/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalFolderCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalFolderCmdlet.cs
@@ -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)
{
diff --git a/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalProjectCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalProjectCmdlet.cs
index fbab178..86bf47a 100644
--- a/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalProjectCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalProjectCmdlet.cs
@@ -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)
diff --git a/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalSecretCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalSecretCmdlet.cs
index d2154c7..e02d6ab 100644
--- a/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalSecretCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalSecretCmdlet.cs
@@ -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
};
diff --git a/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalTagCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalTagCmdlet.cs
index 96b3b7e..9280a22 100644
--- a/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalTagCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/RemoveInfisicalTagCmdlet.cs
@@ -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)
{
diff --git a/src/PSInfisicalAPI/Cmdlets/RequestInfisicalCertificateCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/RequestInfisicalCertificateCmdlet.cs
index 58eed3b..2a761de 100644
--- a/src/PSInfisicalAPI/Cmdlets/RequestInfisicalCertificateCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/RequestInfisicalCertificateCmdlet.cs
@@ -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 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))
diff --git a/src/PSInfisicalAPI/Cmdlets/SearchInfisicalCertificateCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/SearchInfisicalCertificateCmdlet.cs
index 4b3d3d7..1bd04b5 100644
--- a/src/PSInfisicalAPI/Cmdlets/SearchInfisicalCertificateCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/SearchInfisicalCertificateCmdlet.cs
@@ -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;
diff --git a/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalEnvironmentCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalEnvironmentCmdlet.cs
index 76de675..d042e01 100644
--- a/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalEnvironmentCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalEnvironmentCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalFolderCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalFolderCmdlet.cs
index bb5fe36..9305ae2 100644
--- a/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalFolderCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalFolderCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalProjectCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalProjectCmdlet.cs
index a76cb6b..3d929d0 100644
--- a/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalProjectCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalProjectCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalSecretCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalSecretCmdlet.cs
index 0449af7..30047b1 100644
--- a/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalSecretCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalSecretCmdlet.cs
@@ -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,
diff --git a/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalTagCmdlet.cs b/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalTagCmdlet.cs
index 15aefe6..7b5f01c 100644
--- a/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalTagCmdlet.cs
+++ b/src/PSInfisicalAPI/Cmdlets/UpdateInfisicalTagCmdlet.cs
@@ -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);
diff --git a/src/PSInfisicalAPI/Connections/InfisicalConnection.cs b/src/PSInfisicalAPI/Connections/InfisicalConnection.cs
index ef4d04c..7e6362d 100644
--- a/src/PSInfisicalAPI/Connections/InfisicalConnection.cs
+++ b/src/PSInfisicalAPI/Connections/InfisicalConnection.cs
@@ -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");
}
}
diff --git a/src/PSInfisicalAPI/Environments/InfisicalEnvironmentClient.cs b/src/PSInfisicalAPI/Environments/InfisicalEnvironmentClient.cs
index 3a917bc..455852c 100644
--- a/src/PSInfisicalAPI/Environments/InfisicalEnvironmentClient.cs
+++ b/src/PSInfisicalAPI/Environments/InfisicalEnvironmentClient.cs
@@ -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 pathParameters = new Dictionary { { "projectId", resolvedProjectId } };
+ Dictionary pathParameters = new Dictionary { { "projectId", projectId } };
try
{
@@ -43,7 +42,7 @@ namespace PSInfisicalAPI.Environments
InfisicalEnvironmentWorkspaceDto workspace = dto != null ? (dto.Workspace ?? dto.Project) : null;
List 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 pathParameters = new Dictionary { { "projectId", resolvedProjectId } };
+ Dictionary pathParameters = new Dictionary { { "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(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 pathParameters = new Dictionary { { "projectId", resolvedProjectId }, { "environmentId", environmentId } };
+ Dictionary pathParameters = new Dictionary { { "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(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 pathParameters = new Dictionary { { "projectId", resolvedProjectId }, { "environmentId", environmentId } };
+ Dictionary pathParameters = new Dictionary { { "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;
- }
}
}
diff --git a/src/PSInfisicalAPI/Folders/InfisicalFolderClient.cs b/src/PSInfisicalAPI/Folders/InfisicalFolderClient.cs
index 4722add..88f4d06 100644
--- a/src/PSInfisicalAPI/Folders/InfisicalFolderClient.cs
+++ b/src/PSInfisicalAPI/Folders/InfisicalFolderClient.cs
@@ -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> queryParameters = new List>
{
- new KeyValuePair("workspaceId", resolvedProjectId),
- new KeyValuePair("environment", resolvedEnvironment),
+ new KeyValuePair("workspaceId", projectId),
+ new KeyValuePair("environment", environment),
new KeyValuePair("path", resolvedPath)
};
@@ -49,7 +47,7 @@ namespace PSInfisicalAPI.Folders
InfisicalFolderListResponseDto dto = _serializer.Deserialize(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(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 pathParameters = new Dictionary { { "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(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 pathParameters = new Dictionary { { "folderId", folderId } };
List> queryParameters = new List>
{
- new KeyValuePair("workspaceId", resolvedProjectId),
- new KeyValuePair("environment", resolvedEnvironment),
+ new KeyValuePair("workspaceId", projectId),
+ new KeyValuePair("environment", environment),
new KeyValuePair("path", resolvedPath)
};
diff --git a/src/PSInfisicalAPI/Pki/InfisicalPkiClient.cs b/src/PSInfisicalAPI/Pki/InfisicalPkiClient.cs
index cda0afc..2735cd6 100644
--- a/src/PSInfisicalAPI/Pki/InfisicalPkiClient.cs
+++ b/src/PSInfisicalAPI/Pki/InfisicalPkiClient.cs
@@ -47,8 +47,7 @@ namespace PSInfisicalAPI.Pki
response.Clear();
List 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> query = new List>
{
- new KeyValuePair("projectId", resolvedProjectId)
+ new KeyValuePair("projectId", projectId)
};
try
@@ -110,7 +107,7 @@ namespace PSInfisicalAPI.Pki
response.Clear();
List 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 pathParameters = new Dictionary { { "projectId", resolvedProjectId } };
+ Dictionary pathParameters = new Dictionary { { "projectId", query.ProjectId } };
InfisicalCertificateSearchRequestDto request = BuildSearchRequest(query);
string body = _serializer.Serialize(request);
@@ -201,7 +197,7 @@ namespace PSInfisicalAPI.Pki
InfisicalCertificateSearchResponseDto dto = _serializer.Deserialize(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 pathParameters = new Dictionary { { "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 pathParameters = new Dictionary { { "projectId", resolvedProjectId } };
+ Dictionary pathParameters = new Dictionary { { "projectId", projectId } };
try
{
@@ -386,7 +380,7 @@ namespace PSInfisicalAPI.Pki
response.Clear();
List 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 pathParameters = new Dictionary { { "subscriberName", subscriberName } };
- List> query = new List> { new KeyValuePair("projectId", resolvedProjectId) };
+ List> query = new List> { new KeyValuePair("projectId", projectId) };
try
{
@@ -414,7 +407,7 @@ namespace PSInfisicalAPI.Pki
InfisicalPkiSubscriberResponseDto dto = _serializer.Deserialize(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> query = new List>
{
- new KeyValuePair("projectId", resolvedProjectId)
+ new KeyValuePair("projectId", projectId)
};
if (limit.HasValue) { query.Add(new KeyValuePair("limit", limit.Value.ToString(CultureInfo.InvariantCulture))); }
if (offset.HasValue) { query.Add(new KeyValuePair("offset", offset.Value.ToString(CultureInfo.InvariantCulture))); }
@@ -460,7 +452,7 @@ namespace PSInfisicalAPI.Pki
response.Clear();
List 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> query = new List>
{
- new KeyValuePair("projectId", resolvedProjectId)
+ new KeyValuePair("projectId", projectId)
};
if (limit.HasValue) { query.Add(new KeyValuePair("limit", limit.Value.ToString(CultureInfo.InvariantCulture))); }
if (offset.HasValue) { query.Add(new KeyValuePair("offset", offset.Value.ToString(CultureInfo.InvariantCulture))); }
@@ -548,7 +538,7 @@ namespace PSInfisicalAPI.Pki
response.Clear();
List 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> query = new List>();
if (limit.HasValue) { query.Add(new KeyValuePair("limit", limit.Value.ToString(CultureInfo.InvariantCulture))); }
if (offset.HasValue) { query.Add(new KeyValuePair("offset", offset.Value.ToString(CultureInfo.InvariantCulture))); }
- Dictionary headers = BuildProjectHeader(resolvedProjectId);
+ Dictionary headers = BuildProjectHeader(projectId);
try
{
@@ -660,7 +648,7 @@ namespace PSInfisicalAPI.Pki
response.Clear();
List 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 pathParameters = new Dictionary { { "applicationId", applicationId } };
- string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
- Dictionary headers = !string.IsNullOrEmpty(resolvedProjectId) ? BuildProjectHeader(resolvedProjectId) : null;
+ Dictionary 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 pathParameters = new Dictionary { { "name", name } };
- Dictionary headers = BuildProjectHeader(resolvedProjectId);
+ Dictionary 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 pathParameters = new Dictionary { { "applicationId", applicationId } };
- string resolvedProjectId = FirstNonEmpty(projectId, connection.ProjectId);
- Dictionary headers = !string.IsNullOrEmpty(resolvedProjectId) ? BuildProjectHeader(resolvedProjectId) : null;
+ Dictionary 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 headers = !string.IsNullOrEmpty(resolvedProjectId) ? BuildProjectHeader(resolvedProjectId) : null;
+ Dictionary headers = !string.IsNullOrEmpty(projectId) ? BuildProjectHeader(projectId) : null;
try
{
diff --git a/src/PSInfisicalAPI/Projects/InfisicalProjectClient.cs b/src/PSInfisicalAPI/Projects/InfisicalProjectClient.cs
index a0c5e28..900f29a 100644
--- a/src/PSInfisicalAPI/Projects/InfisicalProjectClient.cs
+++ b/src/PSInfisicalAPI/Projects/InfisicalProjectClient.cs
@@ -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> queryParameters = new List>();
+ queryParameters.Add(new KeyValuePair("includeRoles", includeRoles ? "true" : "false"));
+ if (!string.IsNullOrEmpty(type))
+ {
+ queryParameters.Add(new KeyValuePair("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(response.Body);
response.Clear();
diff --git a/src/PSInfisicalAPI/Secrets/InfisicalSecretsClient.cs b/src/PSInfisicalAPI/Secrets/InfisicalSecretsClient.cs
index fb386ac..f13bc53 100644
--- a/src/PSInfisicalAPI/Secrets/InfisicalSecretsClient.cs
+++ b/src/PSInfisicalAPI/Secrets/InfisicalSecretsClient.cs
@@ -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> queryParameters = new List>();
- 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("recursive", query.Recursive ? "true" : "false"));
if (query.IncludeImports.HasValue) { queryParameters.Add(new KeyValuePair("includeImports", query.IncludeImports.Value ? "true" : "false")); }
if (query.IncludePersonalOverrides) { queryParameters.Add(new KeyValuePair("includePersonalOverrides", "true")); }
@@ -96,13 +94,11 @@ namespace PSInfisicalAPI.Secrets
Dictionary pathParameters = new Dictionary { { "secretName", query.SecretName } };
- string resolvedProjectId = FirstNonEmpty(query.ProjectId, connection.ProjectId);
-
List> queryParameters = new List>();
- 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("version", query.Version.Value.ToString(CultureInfo.InvariantCulture))); }
if (query.ViewSecretValue.HasValue) { queryParameters.Add(new KeyValuePair("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 pathParameters = new Dictionary { { "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 pathParameters = new Dictionary { { "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 items = new List(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 items = new List(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 items = new List(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 pathParameters = new Dictionary { { "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);
diff --git a/src/PSInfisicalAPI/Tags/InfisicalTagClient.cs b/src/PSInfisicalAPI/Tags/InfisicalTagClient.cs
index 9430ae2..2eec1bf 100644
--- a/src/PSInfisicalAPI/Tags/InfisicalTagClient.cs
+++ b/src/PSInfisicalAPI/Tags/InfisicalTagClient.cs
@@ -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 pathParameters = new Dictionary { { "projectId", resolvedProjectId } };
+ Dictionary pathParameters = new Dictionary { { "projectId", projectId } };
try
{
@@ -42,7 +41,7 @@ namespace PSInfisicalAPI.Tags
response.Clear();
List 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 pathParameters = new Dictionary { { "projectId", resolvedProjectId } };
+ Dictionary pathParameters = new Dictionary { { "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 pathParameters = new Dictionary { { "projectId", resolvedProjectId }, { "tagId", tagId } };
+ Dictionary pathParameters = new Dictionary { { "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 pathParameters = new Dictionary { { "projectId", resolvedProjectId }, { "tagId", tagId } };
+ Dictionary pathParameters = new Dictionary { { "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;
- }
}
}