Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 2 deletions verkadaModule/Private/Invoke-VerkadaFormCall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ function Invoke-VerkadaFormCall
[Parameter(Mandatory = $true, Position = 0)]
[String]$url,
#The UUID of the organization the user belongs to
[Parameter(Mandatory = $true, Position = 1)]
[Parameter(Mandatory = $true, ParameterSetName = 'UnPwd', Position = 1)]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')]
[String]$org_id,
#Object to pass form parameters to forms
[Parameter(Mandatory = $true,Position = 2)]
[Parameter(Mandatory = $true, ParameterSetName = 'Default', Position = 1)]
[Parameter(Mandatory = $true, ParameterSetName = 'UnPwd',Position = 2)]
[Object]$form_params,
#Object containing the query parameters need that will be put into the query string of the uri
[Parameter()]
Expand Down
22 changes: 11 additions & 11 deletions verkadaModule/Private/Invoke-VerkadaRestMethod.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,21 @@ function Invoke-VerkadaRestMethod
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = 'UnPwd')]
[String]$url,
#The UUID of the organization the user belongs to
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'Default')]
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'Pagination')]
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'UnPwd')]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')]
[String]$org_id,
#The public API token obatined via the Login endpoint to be used for calls that hit the public API gateway
[Parameter(Mandatory = $true, Position = 2, ParameterSetName = 'Default')]
[Parameter(Mandatory = $true, Position = 2, ParameterSetName = 'Pagination')]
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'Default')]
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'Pagination')]
[String]$x_verkada_auth_api,
#Object containing the query parameters need that will be put into the query string of the uri
[Parameter(Position = 3, ParameterSetName = 'Default')]
[Parameter(Position = 3, ParameterSetName = 'Pagination')]
[Parameter(Position = 2, ParameterSetName = 'Default')]
[Parameter(Position = 2, ParameterSetName = 'Pagination')]
[Object]$query_params,
#The body of the REST call
[Parameter(Position = 4, ParameterSetName = 'Default')]
[Parameter(Position = 4, ParameterSetName = 'Pagination')]
[Parameter(Position = 3, ParameterSetName = 'Default')]
[Parameter(Position = 3, ParameterSetName = 'Pagination')]
[Parameter(Position = 2, ParameterSetName = 'UnPwd')]
[Object]$body_params,
#HTTP method required
Expand Down Expand Up @@ -71,7 +69,9 @@ function Invoke-VerkadaRestMethod

Process {
$query = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)
$query.add('org_id',$org_id)
if ($PSCmdlet.ParameterSetName -eq 'UnPwd'){
$query.add('org_id',$org_id)
}
if($query_params){
foreach ($qp in $query_params.GetEnumerator()) {$query.add("$($qp.name)", "$($qp.value)")}
}
Expand Down Expand Up @@ -147,7 +147,7 @@ function Invoke-VerkadaRestMethod
throw [VerkadaRestMethodException] "$res"
}
else {
Connect-Verkada -x_api_key $Global:verkadaConnection.x_api_key -org_id $Global:verkadaConnection.org_id -region $Global:verkadaConnection.region -noOutput
Connect-Verkada -x_api_key $Global:verkadaConnection.x_api_key -region $Global:verkadaConnection.region -noOutput
$headers.'x-verkada-auth' = $Global:verkadaConnection.x_verkada_auth_api
}
}
Expand Down Expand Up @@ -220,7 +220,7 @@ function Invoke-VerkadaRestMethod
throw [VerkadaRestMethodException] "$res"
}
else {
Connect-Verkada -x_api_key $Global:verkadaConnection.x_api_key -org_id $Global:verkadaConnection.org_id -region $Global:verkadaConnection.region -noOutput
Connect-Verkada -x_api_key $Global:verkadaConnection.x_api_key -region $Global:verkadaConnection.region -noOutput
$headers.'x-verkada-auth' = $Global:verkadaConnection.x_verkada_auth_api
}
}
Expand Down
16 changes: 5 additions & 11 deletions verkadaModule/Public/Add-VerkadaAccessGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ function Add-VerkadaAccessGroup{

.DESCRIPTION
Create an access group within the given organization using the given name. The name of the access group must be unique within the organization. This returns the Access Group Metadata Object for the created Access Group.
The org_id and reqired token can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands.
The reqired token can be directly submitted as a parameter, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands.

.LINK
https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessGroup.md

.EXAMPLE
Add-VerkadaAccessGroup -name 'Newgroup'
This will add the access group with the name "NewGroup". The org_id and tokens will be populated from the cached created by Connect-Verkada.
This will add the access group with the name "NewGroup". The token will be populated from the cache created by Connect-Verkada.

.EXAMPLE
Add-VerkadaAccessGroup -name 'NewGroup' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_auth_api 'sd78ds-uuid-of-verkada-token'
This will add the access group with the name "NewGroup". The org_id and tokens are submitted as parameters in the call.
Add-VerkadaAccessGroup -name 'NewGroup' -x_verkada_auth_api 'sd78ds-uuid-of-verkada-token'
This will add the access group with the name "NewGroup". The token is submitted as a parameter in the call.
#>
[CmdletBinding(PositionalBinding = $true)]
[Alias("Add-VrkdaAcGrp","a-VrkdaAcGrp")]
Expand All @@ -25,11 +25,6 @@ function Add-VerkadaAccessGroup{
[Parameter(ValueFromPipelineByPropertyName = $true)]
[Alias('group_name','groupName')]
[String]$name,
#The UUID of the organization the user belongs to
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')]
[String]$org_id = $Global:verkadaConnection.org_id,
#The public API token obatined via the Login endpoint to be used for calls that hit the public API gateway
[Parameter()]
[ValidateNotNullOrEmpty()]
Expand All @@ -46,7 +41,6 @@ function Add-VerkadaAccessGroup{
begin {
$url = "https://$($region).verkada.com/access/v1/access_groups/group"
#parameter validation
if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"}
if ([string]::IsNullOrEmpty($x_verkada_auth_api)) {throw "x_verkada_auth_api is missing but is required!"}
$myErrors = @()
} #end begin
Expand All @@ -64,7 +58,7 @@ function Add-VerkadaAccessGroup{
$query_params = @{}

try {
$response = Invoke-VerkadaRestMethod $url $org_id $x_verkada_auth_api $query_params -body_params $body_params -method POST
$response = Invoke-VerkadaRestMethod $url $x_verkada_auth_api $query_params -body_params $body_params -method POST
return $response
}
catch [Microsoft.PowerShell.Commands.HttpResponseException] {
Expand Down
18 changes: 6 additions & 12 deletions verkadaModule/Public/Add-VerkadaAccessUserCard.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ function Add-VerkadaAccessUserCard{
.DESCRIPTION
Create and add an access card for a specified user_id or external_id and org_id. Card object will be passed in the body of the request as a json.
We require facility code and card number OR card_number_hex OR card_number_base36. The successful repsonse will be the created credential information.
The org_id and reqired token can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands.
The reqired token can be directly submitted as a parameter, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands.

.LINK
https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUserCard.md

.EXAMPLE
Add-VerkadaAccessUserCard -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3' -type 'HID' -facilityCode 111 -cardNumber 55555
This will add a badge in the HID format with facility code 111 and card number 55555 to the user specified. The org_id and tokens will be populated from the cached created by Connect-Verkada.
This will add a badge in the HID format with facility code 111 and card number 55555 to the user specified. The token will be populated from the cache created by Connect-Verkada.

.EXAMPLE
Add-VerkadaAccessUserCard -externalId 'newUserUPN@contoso.com' -type 'HID' -facilityCode 111 -cardNumber 55555 -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_auth_api 'sd78ds-uuid-of-verkada-token'
This will add an Access credential in the HID format with facility code 111 and card number 55555 to the user specified. The org_id and tokens are submitted as parameters in the call.
Add-VerkadaAccessUserCard -externalId 'newUserUPN@contoso.com' -type 'HID' -facilityCode 111 -cardNumber 55555 -x_verkada_auth_api 'sd78ds-uuid-of-verkada-token'
This will add an Access credential in the HID format with facility code 111 and card number 55555 to the user specified. The token is submitted as a parameter in the call.

.EXAMPLE
Import-Csv ./myUserBadges.csv | Add-VerkadaAccessUserCard
This will add an Access credential for every row in the csv file which contains userId, type, cardNumber(or cardNumberHex or cardNumberBase36), and facilityCode(optional). The org_id and tokens will be populated from the cached created by Connect-Verkada.
This will add an Access credential for every row in the csv file which contains userId, type, cardNumber(or cardNumberHex or cardNumberBase36), and facilityCode(optional). The token will be populated from the cache created by Connect-Verkada.
#>
[CmdletBinding(PositionalBinding = $true, DefaultParameterSetName = 'cardNumber')]
[Alias("Add-VrkdaAcUsrCrd","a-VrkdaAcUsrCrd")]
Expand Down Expand Up @@ -60,11 +60,6 @@ function Add-VerkadaAccessUserCard{
#Bool value specifying if the credential is currently active. Default value is False.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[bool]$active=$true,
#The UUID of the organization the user belongs to
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')]
[String]$org_id = $Global:verkadaConnection.org_id,
#The public API token obatined via the Login endpoint to be used for calls that hit the public API gateway
[Parameter()]
[ValidateNotNullOrEmpty()]
Expand All @@ -81,7 +76,6 @@ function Add-VerkadaAccessUserCard{
begin {
$url = "https://$($region).verkada.com/access/v1/credentials/card"
#parameter validation
if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"}
if ([string]::IsNullOrEmpty($x_verkada_auth_api)) {throw "x_verkada_auth_api is missing but is required!"}
$myErrors = @()
} #end begin
Expand Down Expand Up @@ -113,7 +107,7 @@ function Add-VerkadaAccessUserCard{
}

try {
$response = Invoke-VerkadaRestMethod $url $org_id $x_verkada_auth_api $query_params -body_params $body_params -method POST
$response = Invoke-VerkadaRestMethod $url $x_verkada_auth_api $query_params -body_params $body_params -method POST
return $response
}
catch [Microsoft.PowerShell.Commands.HttpResponseException] {
Expand Down
16 changes: 5 additions & 11 deletions verkadaModule/Public/Add-VerkadaAccessUserLicensePlate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ function Add-VerkadaAccessUserLicensePlate{
.DESCRIPTION
Add a license plate credential to a user given a specified user_id or external_id and org_id. License plate object will be passed in the body of the request as a json.
We require a string of 6 alphanumeric values. The License Plate Object is returned.
The org_id and reqired token can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands.
The reqired token can be directly submitted as a parameter, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands.

.LINK
https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessUserLicensePlate.md

.EXAMPLE
Add-VerkadaAccessUserLicensePlate -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3' -licensePlateNumber 'ABC123'
This will add the license plate ABC123 to the Access user with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3 as a credential. The org_id and tokens will be populated from the cached created by Connect-Verkada.
This will add the license plate ABC123 to the Access user with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3 as a credential. The token will be populated from the cache created by Connect-Verkada.

.EXAMPLE
Add-VerkadaAccessUserLicensePlate -externalId 'newUserUPN@contoso.com' -licensePlateNumber 'ABC123' -name 'Users License Plate' -active $true -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a'
This will add the license plate ABC123 to the Access user with externalId newUserUPN@contoso.com as a credential and mark it active. The org_id and tokens are submitted as parameters in the call.
Add-VerkadaAccessUserLicensePlate -externalId 'newUserUPN@contoso.com' -licensePlateNumber 'ABC123' -name 'Users License Plate' -active $true -x_verkada_token 'a366ef47-2c20-4d35-a90a-10fd2aee113a'
This will add the license plate ABC123 to the Access user with externalId newUserUPN@contoso.com as a credential and mark it active. The token is submitted as a parameter in the call.
#>
[CmdletBinding(PositionalBinding = $true)]
[Alias("Add-VrkdaAcUsrLPR","a-VrkdaAcUsrLPR")]
Expand All @@ -43,11 +43,6 @@ function Add-VerkadaAccessUserLicensePlate{
#Bool value specifying if the license plate credential is currently active. Default value is False.
[Parameter(ValueFromPipelineByPropertyName = $true)]
[bool]$active=$true,
#The UUID of the organization the user belongs to
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')]
[String]$org_id = $Global:verkadaConnection.org_id,
#The public API token obatined via the Login endpoint to be used for calls that hit the public API gateway
[Parameter()]
[ValidateNotNullOrEmpty()]
Expand All @@ -64,7 +59,6 @@ function Add-VerkadaAccessUserLicensePlate{
begin {
$url = "https://$($region).verkada.com/access/v1/credentials/license_plate"
#parameter validation
if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"}
if ([string]::IsNullOrEmpty($x_verkada_auth_api)) {throw "x_verkada_auth_api is missing but is required!"}
$myErrors = @()
} #end begin
Expand Down Expand Up @@ -93,7 +87,7 @@ function Add-VerkadaAccessUserLicensePlate{
}

try {
$response = Invoke-VerkadaRestMethod $url $org_id $x_verkada_auth_api $query_params -body_params $body_params -method POST
$response = Invoke-VerkadaRestMethod $url $x_verkada_auth_api $query_params -body_params $body_params -method POST
return $response
}
catch [Microsoft.PowerShell.Commands.HttpResponseException] {
Expand Down
16 changes: 5 additions & 11 deletions verkadaModule/Public/Add-VerkadaAccessUserMfaCode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ function Add-VerkadaAccessUserMfaCode{

.DESCRIPTION
Adds a mfa code credential to a user given a specified user_id or external_id and org_id. MFA code object will be passed in the body of the request as a json.
The org_id and reqired token can be directly submitted as parameters, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands.
The reqired token can be directly submitted as a parameter, but is much easier to use Connect-Verkada to cache this information ahead of time and for subsequent commands.

.LINK
https://github.com/bepsoccer/verkadaModule/blob/master/docs/function-documentation/Add-VerkadaAccessMfaCode.md

.EXAMPLE
Add-VerkadaAccessUserMfaCode -mfaCode '9567' -userId '801c9551-b04c-4293-84ad-b0a6aa0588b3'
This adds the MFA code 9567 to the Access user's profile with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3. The org_id and token will be populated from the cached created by Connect-Verkada.
This adds the MFA code 9567 to the Access user's profile with userId 801c9551-b04c-4293-84ad-b0a6aa0588b3. The token will be populated from the cache created by Connect-Verkada.

.EXAMPLE
Add-VerkadaAccessUserMfaCode -mfaCode '9567' -externalId 'newUserUPN@contoso.com' -org_id '7cd47706-f51b-4419-8675-3b9f0ce7c12d' -x_verkada_auth_api 'sd78ds-uuid-of-verkada-token'
This adds the MFA code 9567 to the Access user's profile with externalId newUserUPN@contoso.com. The org_id and token are submitted as parameters in the call.
Add-VerkadaAccessUserMfaCode -mfaCode '9567' -externalId 'newUserUPN@contoso.com' -x_verkada_auth_api 'sd78ds-uuid-of-verkada-token'
This adds the MFA code 9567 to the Access user's profile with externalId newUserUPN@contoso.com. The token is submitted as a parameter in the call.
#>
[CmdletBinding(PositionalBinding = $true)]
[Alias("Add-VrkdaAcUsrMfaCd","a-VrkdaAcUsrMfaCd")]
Expand All @@ -36,11 +36,6 @@ function Add-VerkadaAccessUserMfaCode{
[ValidatePattern('^\d{4,16}$')]
[Alias('mfa_code','code')]
[string]$mfaCode,
#The UUID of the organization the user belongs to
[Parameter(ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$')]
[String]$org_id = $Global:verkadaConnection.org_id,
#The public API token obatined via the Login endpoint to be used for calls that hit the public API gateway
[Parameter()]
[ValidateNotNullOrEmpty()]
Expand All @@ -57,7 +52,6 @@ function Add-VerkadaAccessUserMfaCode{
begin {
$url = "https://$($region).verkada.com/access/v1/credentials/mfa_code"
#parameter validation
if ([string]::IsNullOrEmpty($org_id)) {throw "org_id is missing but is required!"}
if ([string]::IsNullOrEmpty($x_verkada_auth_api)) {throw "x_verkada_auth_api is missing but is required!"}
$myErrors = @()
} #end begin
Expand All @@ -83,7 +77,7 @@ function Add-VerkadaAccessUserMfaCode{
}

try {
$response = Invoke-VerkadaRestMethod $url $org_id $x_verkada_auth_api $query_params -body_params $body_params -method POST
$response = Invoke-VerkadaRestMethod $url $x_verkada_auth_api $query_params -body_params $body_params -method POST
return $response
}
catch [Microsoft.PowerShell.Commands.HttpResponseException] {
Expand Down
Loading