Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
1e35053
feat(tools): resolve array-of-references projections to their outer w…
juemerson-at-purestorage Jul 28, 2026
4e10a13
chore(reports): regenerate field-cmdlet map and drift report
juemerson-at-purestorage Jul 28, 2026
f061e3c
feat(admin): add typed body params to Update-PfbAdmin (#31)
juemerson-at-purestorage Jul 27, 2026
eeffce9
feat(admin): add typed body params to Update-PfbApiClient (#31)
juemerson-at-purestorage Jul 27, 2026
ddb5228
feat(admin): add typed body params to Update-PfbManagementAccessPolic…
juemerson-at-purestorage Jul 27, 2026
9c3b9c4
feat(admin): add typed body params to Update-PfbOidcIdp (#31)
juemerson-at-purestorage Jul 27, 2026
c1b5ff3
feat(admin): add typed body params to Update-PfbSaml2Idp (#31)
juemerson-at-purestorage Jul 27, 2026
dfcb4e1
feat(admin): add typed body params to New-PfbApiToken (#31)
juemerson-at-purestorage Jul 28, 2026
4a38864
fix(admin): ContainsKey guards + rename to -NewName (#31 review fixes…
juemerson-at-purestorage Jul 28, 2026
49cbf31
docs(admin): widen guard comment; test explicit -Timeout 0 (#31 revie…
juemerson-at-purestorage Jul 28, 2026
fee613e
fix(admin): correct canonical help and close its constraint-test gap …
juemerson-at-purestorage Jul 28, 2026
797958d
feat(policy): add typed body params to Update-PfbQosPolicy (#31)
juemerson-at-purestorage Jul 28, 2026
d5df269
feat(objectstore): add typed body params to Update-PfbObjectStoreAcco…
juemerson-at-purestorage Jul 28, 2026
b1c2426
feat(hardware): add typed body params to Update-PfbHardware (#31)
juemerson-at-purestorage Jul 28, 2026
c56a80f
feat(policy): add typed body params to Update-PfbSshCaPolicy (#31)
juemerson-at-purestorage Jul 28, 2026
b217129
feat(misc): add typed query params to New-PfbLegalHoldEntity (#31)
juemerson-at-purestorage Jul 28, 2026
10bec48
feat(objectstore): add typed body params to Update-PfbObjectStoreRemo…
juemerson-at-purestorage Jul 28, 2026
1ffcd16
feat(certificate): add typed body params to Update-PfbCertificate (#31)
juemerson-at-purestorage Jul 28, 2026
339f19d
feat(hardware): add typed body params to Update-PfbHardwareConnector …
juemerson-at-purestorage Jul 28, 2026
35f58b2
feat(misc): add typed query params to Update-PfbLegalHoldEntity (#31)
juemerson-at-purestorage Jul 28, 2026
7246a04
feat(policy): add typed body params to Update-PfbStorageClassTieringP…
juemerson-at-purestorage Jul 28, 2026
f40dfd2
feat(policy): add typed body params to New-PfbNetworkAccessRule (#31)
juemerson-at-purestorage Jul 28, 2026
13d1b82
feat(certificate): add typed query params to New-PfbCertificateCertif…
juemerson-at-purestorage Jul 28, 2026
4889966
feat(directoryservice): add typed body params to Update-PfbActiveDire…
juemerson-at-purestorage Jul 28, 2026
0a72f19
feat(objectstore): add typed body params to Update-PfbObjectStoreRole…
juemerson-at-purestorage Jul 28, 2026
4893887
feat(monitoring): add typed body params to Update-PfbAsyncLog (#31)
juemerson-at-purestorage Jul 28, 2026
d59f954
feat(misc): add typed body params to Update-PfbKmip (#31)
juemerson-at-purestorage Jul 28, 2026
6694ffb
feat(policy): add typed body params to Update-PfbTlsPolicy (#31)
juemerson-at-purestorage Jul 28, 2026
82233ce
feat(bucket): add typed body params to Update-PfbBucketAuditFilter (#31)
juemerson-at-purestorage Jul 28, 2026
87abc91
feat(directoryservice): add typed body params to Update-PfbDirectoryS…
juemerson-at-purestorage Jul 28, 2026
968debd
feat(objectstore): add typed body params to Update-PfbObjectStoreVirt…
juemerson-at-purestorage Jul 28, 2026
11cd457
feat(monitoring): add typed body params to Update-PfbLogTargetFileSys…
juemerson-at-purestorage Jul 28, 2026
1edfde8
feat(policy): add typed body params to New-PfbNfsExportRule (#31)
juemerson-at-purestorage Jul 28, 2026
e8a25f1
feat(network): add typed body params to New-PfbNetworkInterfaceTlsPol…
juemerson-at-purestorage Jul 28, 2026
cb4686a
feat(misc): add typed body params to Update-PfbLag (#31)
juemerson-at-purestorage Jul 28, 2026
1f79edd
feat(monitoring): add typed body params to Update-PfbLogTargetObjectS…
juemerson-at-purestorage Jul 28, 2026
e36784c
feat(policy): add typed body params to Update-PfbWormPolicy (#31)
juemerson-at-purestorage Jul 28, 2026
983b35e
feat(filesystem): add typed body params to Update-PfbFileSystemExport…
juemerson-at-purestorage Jul 28, 2026
5b3617f
fix(policy): correct wire query keys on New-PfbPolicyFileSystemReplic…
juemerson-at-purestorage Jul 28, 2026
f93f23f
feat(network): add typed body params to Update-PfbDns (#31)
juemerson-at-purestorage Jul 28, 2026
01b35b5
feat(misc): add typed body params to Update-PfbLegalHold (#31)
juemerson-at-purestorage Jul 28, 2026
ca8824f
feat(replication): add typed body params to New-PfbArrayConnection (#31)
juemerson-at-purestorage Jul 28, 2026
df0aad7
feat(monitoring): add typed body params to Update-PfbSnmpManager (#31)
juemerson-at-purestorage Jul 28, 2026
67a25e4
feat(policy): add typed query params to New-PfbQosPolicyMember (#31)
juemerson-at-purestorage Jul 28, 2026
bec94ae
feat(realm): add typed body params to Update-PfbRealmDefaults (#31)
juemerson-at-purestorage Jul 28, 2026
64b8615
feat(network): add typed body params to Update-PfbNetworkInterface (#31)
juemerson-at-purestorage Jul 28, 2026
9d8ada7
feat(misc): add typed body and query params to Update-PfbLifecycleRul…
juemerson-at-purestorage Jul 28, 2026
ed613a8
feat(monitoring): add typed body params to Update-PfbSyslogServer (#31)
juemerson-at-purestorage Jul 28, 2026
8181e69
feat(replication): add typed body params to Update-PfbArrayConnection…
juemerson-at-purestorage Jul 28, 2026
d00d1db
feat(policy): add typed body/query params to New-PfbS3ExportRule (#31)
juemerson-at-purestorage Jul 28, 2026
7087603
feat(network): add typed body params to Update-PfbNetworkInterfaceCon…
juemerson-at-purestorage Jul 28, 2026
2d349cf
feat(replication): add typed body params to Update-PfbFleet (#31)
juemerson-at-purestorage Jul 28, 2026
237bd1e
feat(network): add typed body params to Update-PfbSubnet (#31)
juemerson-at-purestorage Jul 28, 2026
fd9833b
feat(policy): add typed body params to New-PfbSmbClientRule (#31)
juemerson-at-purestorage Jul 28, 2026
44ce30c
feat(replication): add typed body params to Update-PfbTarget (#31)
juemerson-at-purestorage Jul 28, 2026
1549141
fix(node): correct wire keys and add typed query params to New-PfbNod…
juemerson-at-purestorage Jul 28, 2026
9a01812
feat(policy): add typed body params to New-PfbSmbShareRule (#31)
juemerson-at-purestorage Jul 28, 2026
e5125c7
fix(replication): correct member_names bug and add query params to Ne…
juemerson-at-purestorage Jul 28, 2026
5cc9fd7
feat(node): add typed body params to Update-PfbNode (#31)
juemerson-at-purestorage Jul 28, 2026
4fa33d4
fix(replication): correct wire contract and add typed params to New-P…
juemerson-at-purestorage Jul 28, 2026
8f76966
feat(node): add typed body params to Update-PfbNodeGroup (#31)
juemerson-at-purestorage Jul 28, 2026
8a842ff
Merge Task 4 (Hardware+Monitoring) into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
3a6dad4
fix(objectstore): replace vacuous sensitive-field test, add verbose-l…
juemerson-at-purestorage Jul 28, 2026
1d60ffd
fix(query-string): serialize booleans as lowercase true/false (#31)
juemerson-at-purestorage Jul 28, 2026
34871ca
fix(query-string): serialize booleans as lowercase true/false (#31)
juemerson-at-purestorage Jul 28, 2026
cf0ce22
fix(query-string): serialize booleans as lowercase true/false (#31)
juemerson-at-purestorage Jul 28, 2026
e1dd191
fix(query-string): serialize booleans as lowercase true/false (#31)
juemerson-at-purestorage Jul 28, 2026
fd3c828
fix(query-string): serialize booleans as lowercase true/false (#31)
juemerson-at-purestorage Jul 28, 2026
6bbe314
fix(query-string): serialize booleans as lowercase true/false (#31)
juemerson-at-purestorage Jul 28, 2026
2e80a7a
fix(query-string): serialize booleans as lowercase true/false (#31)
juemerson-at-purestorage Jul 28, 2026
35cffef
fix(query-string): serialize booleans as lowercase true/false (#31)
juemerson-at-purestorage Jul 28, 2026
8976630
fix(query-string): serialize booleans as lowercase true/false (#31)
juemerson-at-purestorage Jul 28, 2026
fe0a8f3
fix(certificate): preserve positional binding for pre-existing params…
juemerson-at-purestorage Jul 28, 2026
d407f90
fix(network,node): preserve positional binding for pre-existing param…
juemerson-at-purestorage Jul 28, 2026
0cf66d8
fix(replication): preserve positional binding for pre-existing params…
juemerson-at-purestorage Jul 28, 2026
bc90e6e
fix(directoryservice): drop unreachable -RoleIds/-RoleNames, add miss…
juemerson-at-purestorage Jul 28, 2026
0eee367
test(policy): add missing Constraint 2/18 falsy-value coverage (#31 r…
juemerson-at-purestorage Jul 28, 2026
069e184
test(replication): add missing -Members @() coverage (#31 review)
juemerson-at-purestorage Jul 28, 2026
10a31fb
fix(policy): restore -MemberId, member_ids is a real spec parameter (…
juemerson-at-purestorage Jul 28, 2026
2adfb45
fix(bucket): fail fast when -MemberId is used without a filter name (…
juemerson-at-purestorage Jul 28, 2026
48a5146
test(network): add missing Constraint 2 zero-value coverage (#31 review)
juemerson-at-purestorage Jul 28, 2026
df6961e
Merge Task 2 into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
3e20ede
Merge Task 3 into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
e12c9e1
Merge Task 5 into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
b5cc660
Merge Task 6 into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
3c02848
Merge Task 7 into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
3a635d0
Merge Task 8 into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
9a378ef
Merge Task 9 into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
58e29b1
Merge Task 10 into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
3de324a
fix(replication): restore positional binding on New-PfbArrayConnectio…
juemerson-at-purestorage Jul 28, 2026
623d22f
fix(network): restore positional binding on Update-PfbDns (#31 whole-…
juemerson-at-purestorage Jul 28, 2026
b65faca
fix(misc): remove dead -HoldName/-MemberName wire keys (#31 whole-bra…
juemerson-at-purestorage Jul 28, 2026
f1aa647
fix(policy): alias -LocalFileSystemName to -MemberName for consistenc…
juemerson-at-purestorage Jul 28, 2026
7d39467
Merge Task 5 whole-branch-review fixes into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
ae3ed81
Merge Task 6 whole-branch-review fixes into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
953db2e
Merge Task 8 whole-branch-review fixes into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
6c7b8ce
Merge Task 10 whole-branch-review fixes into issue #31 branch
juemerson-at-purestorage Jul 28, 2026
2e3a775
test: guard in-scope cmdlets against drift-confidence regression (#31)
juemerson-at-purestorage Jul 28, 2026
31b60b5
docs: regenerate API drift report after issue #31 (#31, Task 12 step 3)
juemerson-at-purestorage Jul 28, 2026
c581fec
fix(test): skip the drift-confidence guard on PowerShell < 7 (#31, Ta…
juemerson-at-purestorage Jul 28, 2026
148a9a2
test: re-pin drift-tooling acceptance figures after issue #31 (#31, T…
juemerson-at-purestorage Jul 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Private/ConvertTo-PfbQueryString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ function ConvertTo-PfbQueryString {
continue
}

if ($value -is [array]) {
if ($value -is [bool]) {
$value = $value.ToString().ToLowerInvariant()
}
elseif ($value -is [array]) {
$value = $value -join ','
}

Expand Down
41 changes: 30 additions & 11 deletions Public/Admin/New-PfbApiToken.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,33 @@ function New-PfbApiToken {
Creates a new API token for a FlashBlade administrator.
.DESCRIPTION
The New-PfbApiToken cmdlet generates a new API token for an administrator account on the
connected Pure Storage FlashBlade. The administrator is identified by name or ID. Optional
attributes can be provided to configure token properties. Supports ShouldProcess for
confirmation prompts.
connected Everpure FlashBlade. The administrator is identified by name or ID. Supports
ShouldProcess for confirmation prompts.

Note that `POST /admins/api-tokens` takes no request body at all -- every field this
endpoint accepts is a query parameter.
.PARAMETER Name
The name of the administrator account for which to create an API token.
The name of the administrator account for which to create an API token. Sent as the
`admin_names` query parameter. Also accepts the alias -AdminNames.
.PARAMETER Id
The ID of the administrator account for which to create an API token.
The ID of the administrator account for which to create an API token. Sent as the
`admin_ids` query parameter. Also accepts the alias -AdminIds.
.PARAMETER Timeout
The duration of API token validity, in milliseconds.
.PARAMETER Attributes
A hashtable of token attributes to set (e.g., timeout duration).
Retained for backward compatibility only. `POST /admins/api-tokens` accepts no request
body, so nothing supplied here is sent to the array. Use -Timeout to set the token's
validity period.
.PARAMETER Array
The FlashBlade connection object. If not specified, the default connection is used.
.EXAMPLE
New-PfbApiToken -Name "pureuser"

Creates a new API token for the administrator named "pureuser".
.EXAMPLE
New-PfbApiToken -Name "ops-admin" -Attributes @{ timeout = 86400000 }
New-PfbApiToken -Name "ops-admin" -Timeout 86400000

Creates a new API token with a custom timeout for the specified administrator.
Creates a new API token for "ops-admin" that is valid for 24 hours.
.EXAMPLE
New-PfbApiToken -Id "10314f42-020d-7080-8013-000ddt400012"

Expand All @@ -31,8 +39,14 @@ function New-PfbApiToken {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
param(
[Parameter(ParameterSetName = 'ByName', ValueFromPipelineByPropertyName)]
[Alias('AdminNames')]
[string]$Name,
[Parameter(ParameterSetName = 'ById')] [string]$Id,

[Parameter(ParameterSetName = 'ById')]
[Alias('AdminIds')]
[string]$Id,

[Parameter()] [long]$Timeout,
[Parameter()] [hashtable]$Attributes,
[Parameter()] [PSCustomObject]$Array
)
Expand All @@ -42,9 +56,14 @@ function New-PfbApiToken {
}

process {
# POST /admins/api-tokens accepts admin_names/admin_ids, NOT names/ids. The cmdlet
# previously sent names/ids, which the array silently ignored, so -Name and -Id had
# no effect at all.
$queryParams = @{}
if ($Name) { $queryParams['names'] = $Name }
if ($Id) { $queryParams['ids'] = $Id }
if ($Name) { $queryParams['admin_names'] = $Name }
if ($Id) { $queryParams['admin_ids'] = $Id }
if ($PSBoundParameters.ContainsKey('Timeout')) { $queryParams['timeout'] = $Timeout }

$target = if ($Name) { $Name } else { $Id }
$body = if ($Attributes) { $Attributes } else { @{} }

Expand Down
119 changes: 106 additions & 13 deletions Public/Admin/Update-PfbAdmin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,92 @@ function Update-PfbAdmin {
Updates a FlashBlade administrator account.
.DESCRIPTION
The Update-PfbAdmin cmdlet modifies attributes of an existing administrator account
on the connected Pure Storage FlashBlade. The target administrator can be identified
by name or ID. Common updates include role changes and password resets. Supports
pipeline input and ShouldProcess for confirmation prompts.
on the connected Everpure FlashBlade. The target administrator can be identified
by name or ID. Common updates include password resets and access-policy changes.
Supports pipeline input and ShouldProcess for confirmation prompts.

The individual typed parameters and the raw -Attributes hashtable are mutually
exclusive: they live in separate parameter sets, so PowerShell rejects a mixed
invocation at bind time rather than letting -Attributes silently override an
explicitly supplied value.
.PARAMETER Name
The name of the administrator account to update. Accepts pipeline input by property name.
.PARAMETER Id
The ID of the administrator account to update.
.PARAMETER AuthorizationModel
The location for access policies mapping.
.PARAMETER Locked
If set to $false, the specified user is unlocked.
.PARAMETER ManagementAccessPolicies
Names of the management access policies associated with the statically-authorized
administrator.
.PARAMETER OldPassword
Old user password.
.PARAMETER Password
New user password.
.PARAMETER PublicKey
Public key for SSH access.
.PARAMETER Attributes
A hashtable of administrator attributes to modify (e.g., role, password).
A hashtable of administrator attributes to modify. Mutually exclusive with the
individual typed parameters above.
.PARAMETER Array
The FlashBlade connection object. If not specified, the default connection is used.
.EXAMPLE
Update-PfbAdmin -Name "pureuser" -Attributes @{ role = @{ name = "array_admin" } }
Update-PfbAdmin -Name "ops-admin" -Password "N3wP@ssw0rd!" -Locked $false

Resets the password for "ops-admin" and unlocks the account using typed parameters.
.EXAMPLE
Update-PfbAdmin -Name "ops-admin" -ManagementAccessPolicies "array-admin","readonly"

Assigns the array_admin role to the administrator account named "pureuser".
Assigns two management access policies to the administrator named "ops-admin".
.EXAMPLE
Update-PfbAdmin -Name "ops-admin" -Attributes @{ password = "N3wP@ssw0rd!" }

Updates the password for the administrator account named "ops-admin".
.EXAMPLE
Update-PfbAdmin -Id "10314f42-020d-7080-8013-000ddt400012" -Attributes @{ role = @{ name = "readonly" } }
Update-PfbAdmin -Id "10314f42-020d-7080-8013-000ddt400012" -Attributes @{ locked = $false }

Changes the role of the administrator identified by ID to readonly.
Unlocks the administrator identified by ID.
#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium',
DefaultParameterSetName = 'ByNameIndividual')]
param(
[Parameter(ParameterSetName = 'ByName', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName = 'ByNameIndividual', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName = 'ByNameAttributes', Mandatory, ValueFromPipelineByPropertyName)]
[string]$Name,
[Parameter(ParameterSetName = 'ById', Mandatory)] [string]$Id,
[Parameter(Mandatory)] [hashtable]$Attributes,

[Parameter(ParameterSetName = 'ByIdIndividual', Mandatory)]
[Parameter(ParameterSetName = 'ByIdAttributes', Mandatory)]
[string]$Id,

[Parameter(ParameterSetName = 'ByNameIndividual')]
[Parameter(ParameterSetName = 'ByIdIndividual')]
[string]$AuthorizationModel,

[Parameter(ParameterSetName = 'ByNameIndividual')]
[Parameter(ParameterSetName = 'ByIdIndividual')]
[Nullable[bool]]$Locked,

[Parameter(ParameterSetName = 'ByNameIndividual')]
[Parameter(ParameterSetName = 'ByIdIndividual')]
[string[]]$ManagementAccessPolicies,

[Parameter(ParameterSetName = 'ByNameIndividual')]
[Parameter(ParameterSetName = 'ByIdIndividual')]
[string]$OldPassword,

[Parameter(ParameterSetName = 'ByNameIndividual')]
[Parameter(ParameterSetName = 'ByIdIndividual')]
[string]$Password,

[Parameter(ParameterSetName = 'ByNameIndividual')]
[Parameter(ParameterSetName = 'ByIdIndividual')]
[string]$PublicKey,

[Parameter(ParameterSetName = 'ByNameAttributes', Mandatory)]
[Parameter(ParameterSetName = 'ByIdAttributes', Mandatory)]
[hashtable]$Attributes,

[Parameter()] [PSCustomObject]$Array
)
begin {
Expand All @@ -44,9 +100,46 @@ function Update-PfbAdmin {
$queryParams = @{}
if ($Name) { $queryParams['names'] = $Name }
if ($Id) { $queryParams['ids'] = $Id }

if ($PSCmdlet.ParameterSetName -like '*Attributes') {
$body = $Attributes
}
else {
# EVERY value-carrying parameter -- body OR query -- is guarded by
# $PSBoundParameters.ContainsKey, never by truthiness. `if ($X)` silently discards
# any legitimate falsy value the caller explicitly supplied: $false, 0, '' and an
# empty array all fail a truthiness test. So `-Locked $false` would never unlock,
# an integer field could never be set to a meaningful 0, and
# `-ManagementAccessPolicies @()` could never clear a list. ContainsKey asks the
# only correct question -- did the caller supply this parameter at all?
#
# The one exemption is a MANDATORY [string] selector like -Name/-Id above: the
# binder rejects '' for those before any guard runs, so their falsy branch is
# unreachable and `if ($Name)` is safe. That exemption is about mandatory-ness,
# not about being a query parameter -- an OPTIONAL query parameter still needs
# ContainsKey (see -Timeout in New-PfbApiToken.ps1).
#
# No [bool] cast on $Locked either: constraint 7 forbids it (it breaks the
# wire-name trace) and [Nullable[bool]] + ContainsKey already sends an explicit
# $false correctly.
$body = @{}
if ($PSBoundParameters.ContainsKey('AuthorizationModel')) { $body['authorization_model'] = $AuthorizationModel }
if ($PSBoundParameters.ContainsKey('Locked')) { $body['locked'] = $Locked }
if ($PSBoundParameters.ContainsKey('OldPassword')) { $body['old_password'] = $OldPassword }
if ($PSBoundParameters.ContainsKey('Password')) { $body['password'] = $Password }
if ($PSBoundParameters.ContainsKey('PublicKey')) { $body['public_key'] = $PublicKey }

# Constraint 8(b): management_access_policies is an ARRAY OF REFERENCES (item
# schema is {id, name, resource_type}), so the parameter is [string[]] and the
# projection is assigned INLINE -- constraint 7 forbids a $policyRefs local.
if ($PSBoundParameters.ContainsKey('ManagementAccessPolicies')) {
$body['management_access_policies'] = @($ManagementAccessPolicies | ForEach-Object { @{ name = $_ } })
}
}

$target = if ($Name) { $Name } else { $Id }
if ($PSCmdlet.ShouldProcess($target, 'Update admin')) {
Invoke-PfbApiRequest -Array $Array -Method PATCH -Endpoint 'admins' -Body $Attributes -QueryParams $queryParams
Invoke-PfbApiRequest -Array $Array -Method PATCH -Endpoint 'admins' -Body $body -QueryParams $queryParams
}
}
}
60 changes: 45 additions & 15 deletions Public/Admin/Update-PfbApiClient.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,58 @@ function Update-PfbApiClient {
Updates an API client on the FlashBlade.
.DESCRIPTION
The Update-PfbApiClient cmdlet modifies an existing API client on the connected
Pure Storage FlashBlade. Properties that can be updated include the public key,
maximum role, and enabled state.
Everpure FlashBlade.

Note that `PATCH /api-clients` reuses the full ApiClient resource schema. Of its nine
properties, seven are read-only and `max_role` is deprecated rather than read-only,
which leaves `enabled` as the only settable field this cmdlet exposes as a typed
parameter.

The individual typed parameters and the raw -Attributes hashtable are mutually
exclusive: they live in separate parameter sets, so PowerShell rejects a mixed
invocation at bind time rather than letting -Attributes silently override an
explicitly supplied value.
.PARAMETER Name
The name of the API client to update.
.PARAMETER Id
The ID of the API client to update.
.PARAMETER Enabled
If $true, the API client is permitted to exchange ID Tokens for access tokens.
.PARAMETER Attributes
A hashtable of properties to update on the API client.
A hashtable of properties to update on the API client. Mutually exclusive with the
individual typed parameters above.
.PARAMETER Array
The FlashBlade connection object. If not specified, the default connection is used.
.EXAMPLE
Update-PfbApiClient -Name 'automation-client' -Attributes @{ enabled = $true }
Update-PfbApiClient -Name 'automation-client' -Enabled $true

Enables the API client named 'automation-client'.
Enables the API client named 'automation-client' using a typed parameter.
.EXAMPLE
Update-PfbApiClient -Name 'automation-client' -Attributes @{ max_role = @{ name = 'readonly' } }
Update-PfbApiClient -Name 'automation-client' -Attributes @{ enabled = $true }

Changes the maximum role of the API client to read-only.
Enables the API client named 'automation-client'.
.EXAMPLE
Update-PfbApiClient -Id '12345678-abcd-efgh-ijkl-123456789012' -Attributes @{ public_key = $newKey }
Update-PfbApiClient -Id '12345678-abcd-efgh-ijkl-123456789012' -Enabled $false

Updates the public key of an API client by ID.
Disables an API client by ID.
#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium',
DefaultParameterSetName = 'ByNameIndividual')]
param(
[Parameter(ParameterSetName = 'ByName', Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName = 'ByNameIndividual', Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName = 'ByNameAttributes', Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[string]$Name,

[Parameter(ParameterSetName = 'ById', Mandatory)]
[Parameter(ParameterSetName = 'ByIdIndividual', Mandatory)]
[Parameter(ParameterSetName = 'ByIdAttributes', Mandatory)]
[string]$Id,

[Parameter(Mandatory)]
[Parameter(ParameterSetName = 'ByNameIndividual')]
[Parameter(ParameterSetName = 'ByIdIndividual')]
[Nullable[bool]]$Enabled,

[Parameter(ParameterSetName = 'ByNameAttributes', Mandatory)]
[Parameter(ParameterSetName = 'ByIdAttributes', Mandatory)]
[hashtable]$Attributes,

[Parameter()] [PSCustomObject]$Array
Expand All @@ -46,13 +66,23 @@ function Update-PfbApiClient {
}

process {
$target = if ($Name) { $Name } else { $Id }
$queryParams = @{}
if ($Name) { $queryParams['names'] = $Name }
if ($Id) { $queryParams['ids'] = $Id }

if ($PSCmdlet.ParameterSetName -like '*Attributes') {
$body = $Attributes
}
else {
# Every body parameter is guarded by ContainsKey, never by truthiness -- see the
# canonical explanation in Update-PfbAdmin.ps1.
$body = @{}
if ($PSBoundParameters.ContainsKey('Enabled')) { $body['enabled'] = $Enabled }
}

$target = if ($Name) { $Name } else { $Id }
if ($PSCmdlet.ShouldProcess($target, 'Update API client')) {
Invoke-PfbApiRequest -Array $Array -Method PATCH -Endpoint 'api-clients' -Body $Attributes -QueryParams $queryParams
Invoke-PfbApiRequest -Array $Array -Method PATCH -Endpoint 'api-clients' -Body $body -QueryParams $queryParams
}
}
}
Loading
Loading