Skip to content

Commit

Permalink
Consistency cleanup
Browse files Browse the repository at this point in the history
Just some cleanup for consistency of code
  • Loading branch information
bepsoccer committed Feb 15, 2023
1 parent 0c85104 commit 066334f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
10 changes: 6 additions & 4 deletions Private/Invoke-VerkadaRestMethod.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ function Invoke-VerkadaRestMethod
)

Process {
$body = @{}
$body.org_id = $org_id
$body = @{
'org_id' = $org_id
}
if ($body_params){$body += $body_params}
$headers=@{}
$headers."x-api-key" = $x_api_key
$headers=@{
'x-api-key' = $x_api_key
}

if ($pagination){
$body.page_size = $page_size
Expand Down
13 changes: 8 additions & 5 deletions Public/Connect-Verkada.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ function Connect-Verkada
}

try {
$body = @{}
$body.org_id = $Global:verkadaConnection.org_id
$body.page_size = "1"
$headers=@{}
$headers."x-api-key" = $Global:verkadaConnection.token
$body = @{
'org_id' = $Global:verkadaConnection.org_id
'page_size' = "1"
}
$headers=@{
'x-api-key' = $Global:verkadaConnection.token
}

$response = Invoke-RestMethod -Uri 'https://api.verkada.com/cameras/v1/devices' -Body $body -Headers $headers -StatusCodeVariable responseCode
Write-Host -ForegroundColor green "$responseCode - Successfully connected to Verkada Command"
return
Expand Down
2 changes: 1 addition & 1 deletion Public/Get-VerkadaCameras.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Get-VerkadaCameras
$propertyName = 'cameras'
if (!($org_id)){Write-Warning 'Missing org_id which is required'; return}
if (!($x_api_key)){Write-Warning 'Missing API token which is required'; return}
}
} #end begin

Process {
Invoke-VerkadaRestMethod $uri $org_id $x_api_key -pagination -page_size $page_size -propertyName $propertyName
Expand Down
12 changes: 6 additions & 6 deletions Public/Get-VerkadaCloudBackupSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ function Get-VerkadaCloudBackupSettings
$response = @()
if (!($org_id)){Write-Warning 'missing org_id'; return}
if (!($x_api_key)){Write-Warning 'missing API token'; return}
#Write-Warning "Have you backed up your configs first? If not, consider halting and running Get-VerkadaCloudBackupSettings -backup" -WarningAction Inquire
}
} #end beging

Process {
$body_params = @{}
$body_params.camera_id = $camera_id
$body_params = @{
'camera_id' = $camera_id
}

$response += Invoke-VerkadaRestMethod $uri $org_id $x_api_key $body_params
}
} #end process

End {
if ($backup){
Expand All @@ -50,5 +50,5 @@ function Get-VerkadaCloudBackupSettings
}
}
return $response
}
} #end end
} #end function
8 changes: 4 additions & 4 deletions Public/Set-VerkadaCloudBackupSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Set-VerkadaCloudBackupSettings
if (!($org_id)){Write-Warning 'missing org_id'; return}
if (!($x_api_key)){Write-Warning 'missing API token'; return}
Write-Warning "Have you backed up your configs first? If not, consider halting and running Get-VerkadaCloudBackupSettings -backup" -WarningAction Inquire
}
} #end begin

Process {
$body_params = @{
Expand All @@ -55,9 +55,9 @@ function Set-VerkadaCloudBackupSettings
}

$response += Invoke-VerkadaRestMethod $uri $org_id $x_api_key $body_params -method post
}
} #end process

End {
return $response
}
}
} #end end
} #end function
4 changes: 2 additions & 2 deletions verkadaModule.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Brad Parker
#
# Generated on: 2/14/2023
# Generated on: 2/15/2023
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'verkadaModule.psm1'

# Version number of this module.
ModuleVersion = '0.0.1'
ModuleVersion = '0.0.2'

# Supported PSEditions
CompatiblePSEditions = 'Desktop', 'Core'
Expand Down

0 comments on commit 066334f

Please sign in to comment.