Skip to content

Commit

Permalink
Made internal commands unique to the module
Browse files Browse the repository at this point in the history
  • Loading branch information
Celerium committed Aug 3, 2023
1 parent 662a3fa commit a5412a9
Show file tree
Hide file tree
Showing 23 changed files with 171 additions and 171 deletions.
Binary file modified DattoAPI/DattoAPI.psd1
Binary file not shown.
40 changes: 20 additions & 20 deletions DattoAPI/Private/APICalls.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
function ConvertTo-QueryString {
function ConvertTo-DattoQueryString {
<#
.SYNOPSIS
Converts uri filter parameters
.DESCRIPTION
The Invoke-ApiRequest cmdlet converts & formats uri filter parameters
The Invoke-DattoRequest cmdlet converts & formats uri filter parameters
from a function which are later used to make the full resource uri for
an API call
This is an internal helper function the ties in directly with the
Invoke-ApiRequest & any public functions that define parameters
Invoke-DattoRequest & any public functions that define parameters
.PARAMETER uri_Filter
Hashtable of values to combine a functions parameters with
Expand All @@ -21,7 +21,7 @@ function ConvertTo-QueryString {
Defines the short resource uri (url) to use when creating the API call
.EXAMPLE
ConvertTo-QueryString -uri_Filter $uri_Filter -resource_Uri '/account'
ConvertTo-DattoQueryString -uri_Filter $uri_Filter -resource_Uri '/account'
Example: (From public function)
$uri_Filter = @{}
Expand All @@ -38,7 +38,7 @@ function ConvertTo-QueryString {
N\A
.LINK
https://celerium.github.io/Datto-PowerShellWrapper/site/Internal/ConvertTo-QueryString.html
https://celerium.github.io/Datto-PowerShellWrapper/site/Internal/ConvertTo-DattoQueryString.html
#>

Expand Down Expand Up @@ -98,13 +98,13 @@ param(



function Invoke-ApiRequest {
function Invoke-DattoRequest {
<#
.SYNOPSIS
Makes an API request
.DESCRIPTION
The Invoke-ApiRequest cmdlet invokes an API request to Datto API.
The Invoke-DattoRequest cmdlet invokes an API request to Datto API.
This is an internal function that is used by all public functions
Expand All @@ -120,13 +120,13 @@ function Invoke-ApiRequest {
Defines the resource uri (url) to use when creating the API call
.PARAMETER uri_Filter
Used with the internal function [ ConvertTo-QueryString ] to combine
Used with the internal function [ ConvertTo-DattoQueryString ] to combine
a functions parameters with the resource_Uri parameter.
This allows for the full uri query to occur
The full resource path is made with the following data
$Datto_Base_URI + $resource_Uri + ConvertTo-QueryString
$Datto_Base_URI + $resource_Uri + ConvertTo-DattoQueryString
.PARAMETER data
Place holder parameter to use when other methods are supported
Expand All @@ -139,7 +139,7 @@ function Invoke-ApiRequest {
parameters
.EXAMPLE
Invoke-ApiRequest -method GET -resource_Uri '/account' -uri_Filter $uri_Filter
Invoke-DattoRequest -method GET -resource_Uri '/account' -uri_Filter $uri_Filter
Invoke a rest method against the defined resource using any of the provided parameters
Expand All @@ -156,7 +156,7 @@ function Invoke-ApiRequest {
N\A
.LINK
https://celerium.github.io/Datto-PowerShellWrapper/site/Internal/Invoke-ApiRequest.html
https://celerium.github.io/Datto-PowerShellWrapper/site/Internal/Invoke-DattoRequest.html
#>

Expand Down Expand Up @@ -184,7 +184,7 @@ function Invoke-ApiRequest {

process{

$query_string = ConvertTo-QueryString -uri_Filter $uri_Filter -resource_Uri $resource_Uri
$query_string = ConvertTo-DattoQueryString -uri_Filter $uri_Filter -resource_Uri $resource_Uri

Set-Variable -Name 'Datto_queryString' -Value $query_string -Scope Global -Force

Expand Down Expand Up @@ -241,9 +241,9 @@ function Invoke-ApiRequest {
Write-Warning 'The [ Datto_invokeParameters, Datto_queryString, & Datto_CmdletNameParameters ] variables can provide extra details'

switch -Wildcard ($exceptionError) {
'*404*' { Write-Error "Invoke-ApiRequest : [ $resource_Uri ] not found!" }
'*429*' { Write-Error 'Invoke-ApiRequest : API rate limited' }
'*504*' { Write-Error "Invoke-ApiRequest : Gateway Timeout" }
'*404*' { Write-Error "Invoke-DattoRequest : [ $resource_Uri ] not found!" }
'*429*' { Write-Error 'Invoke-DattoRequest : API rate limited' }
'*504*' { Write-Error "Invoke-DattoRequest : Gateway Timeout" }
default { Write-Error $_ }
}

Expand Down Expand Up @@ -278,13 +278,13 @@ function Invoke-ApiRequest {



function Get-InvokeMetaData {
function Get-DattoMetaData {
<#
.SYNOPSIS
Gets various Api metadata values
.DESCRIPTION
The Get-InvokeMetaData cmdlet gets various Api metadata values from an
The Get-DattoMetaData cmdlet gets various Api metadata values from an
Invoke-WebRequest to assist in various troubleshooting scenarios such
as rate-limiting.
Expand All @@ -294,7 +294,7 @@ function Get-InvokeMetaData {
The default base URI is https://api.datto.com/v1
.EXAMPLE
Get-InvokeMetaData
Get-DattoMetaData
Gets various Api metadata values from an Invoke-WebRequest to assist
in various troubleshooting scenarios such as rate-limiting.
Expand All @@ -303,7 +303,7 @@ function Get-InvokeMetaData {
https://api.datto.com/v1
.EXAMPLE
Get-InvokeMetaData -base_uri http://myapi.gateway.example.com
Get-DattoMetaData -base_uri http://myapi.gateway.example.com
Gets various Api metadata values from an Invoke-WebRequest to assist
in various troubleshooting scenarios such as rate-limiting.
Expand All @@ -315,7 +315,7 @@ function Get-InvokeMetaData {
N\A
.LINK
https://celerium.github.io/Datto-PowerShellWrapper/site/Internal/Get-InvokeMetaData.html
https://celerium.github.io/Datto-PowerShellWrapper/site/Internal/Get-DattoMetaData.html
#>

[CmdletBinding()]
Expand Down
4 changes: 2 additions & 2 deletions DattoAPI/Public/BCDR_ActivityLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ function Get-DattoActivityLog {
Set-Variable -Name 'Datto_activityLogParameters' -Value $PSBoundParameters -Scope Global -Force

switch ($allPages) {
$true { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
$true { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
}

}
Expand Down
4 changes: 2 additions & 2 deletions DattoAPI/Public/BCDR_Agent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ function Get-DattoAgent {
Set-Variable -Name 'Datto_agentParameters' -Value $PSBoundParameters -Scope Global -Force

switch ($allPages) {
$true { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
$true { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
}

}
Expand Down
4 changes: 2 additions & 2 deletions DattoAPI/Public/BCDR_Alert.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ function Get-DattoAlert {
Set-Variable -Name 'Datto_alertParameters' -Value $PSBoundParameters -Scope Global -Force

switch ($allPages) {
$true { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
$true { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
}

}
Expand Down
4 changes: 2 additions & 2 deletions DattoAPI/Public/BCDR_Asset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ function Get-DattoAsset {
Set-Variable -Name 'Datto_assetParameters' -Value $PSBoundParameters -Scope Global -Force

switch ($allPages) {
$true { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
$true { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
}

}
Expand Down
4 changes: 2 additions & 2 deletions DattoAPI/Public/BCDR_BCDR.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ function Get-DattoBCDR {
Set-Variable -Name 'Datto_bcdrParameters' -Value $PSBoundParameters -Scope Global -Force

switch ($allPages) {
$true { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
$true { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
}

}
Expand Down
4 changes: 2 additions & 2 deletions DattoAPI/Public/BCDR_Device.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ function Get-DattoDevice {
Set-Variable -Name 'Datto_deviceParameters' -Value $PSBoundParameters -Scope Global -Force

switch ($allPages) {
$true { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
$true { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
}

}
Expand Down
4 changes: 2 additions & 2 deletions DattoAPI/Public/BCDR_Share.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ function Get-DattoShare {
Set-Variable -Name 'Datto_assetShareParameters' -Value $PSBoundParameters -Scope Global -Force

switch ($allPages) {
$true { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
$true { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -allPages }
$false { Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters }
}

}
Expand Down
2 changes: 1 addition & 1 deletion DattoAPI/Public/BCDR_Volume.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Get-DattoVolume {

Set-Variable -Name 'Datto_assetVolumeParameters' -Value $PSBoundParameters -Scope Global -Force

Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters
Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters

}

Expand Down
2 changes: 1 addition & 1 deletion DattoAPI/Public/SaaS_Application.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Get-DattoApplication {

Set-Variable -Name 'Datto_applicationParameters' -Value $PSBoundParameters -Scope Global -Force

Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters
Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters

}

Expand Down
2 changes: 1 addition & 1 deletion DattoAPI/Public/SaaS_Domain.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Get-DattoDomain {

Set-Variable -Name 'Datto_domainParameters' -Value $PSBoundParameters -Scope Global -Force

Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters
Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters

}

Expand Down
2 changes: 1 addition & 1 deletion DattoAPI/Public/SaaS_SaaS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function Get-DattoSaaS {

Set-Variable -Name 'Datto_bcdrParameters' -Value $PSBoundParameters -Scope Global -Force

Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters
Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters

}

Expand Down
2 changes: 1 addition & 1 deletion DattoAPI/Public/SaaS_Seat.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Get-DattoSeat {

Set-Variable -Name 'Datto_seatParameters' -Value $PSBoundParameters -Scope Global -Force

Invoke-ApiRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters
Invoke-DattoRequest -method GET -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters

}

Expand Down
10 changes: 5 additions & 5 deletions docs/DattoAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Sets the API public & secret keys used to authenticate API calls.
### [Add-DattoBaseURI](site/Internal/Add-DattoBaseURI.md)
Sets the base URI for the Datto API connection.

### [ConvertTo-QueryString](site/Internal/ConvertTo-QueryString.md)
### [ConvertTo-DattoQueryString](site/Internal/ConvertTo-DattoQueryString.md)
Converts uri filter parameters

### [Export-DattoModuleSettings](site/Internal/Export-DattoModuleSettings.md)
Expand Down Expand Up @@ -54,6 +54,9 @@ Gets Datto BCDR devices from the the Datto API.
### [Get-DattoDomain](site/SaaS/Get-DattoDomain.md)
Get Datto SaaS protection data about what domains are being protected

### [Get-DattoMetaData](site/Internal/Get-DattoMetaData.md)
Gets various Api metadata values

### [Get-DattoModuleSettings](site/Internal/Get-DattoModuleSettings.md)
Gets the saved Datto configuration settings

Expand All @@ -69,13 +72,10 @@ Gets Datto BCDR shares for a given device
### [Get-DattoVolume](site/BCDR/Get-DattoVolume.md)
Gets an asset(s)(agent or share) for a specific volume on a device

### [Get-InvokeMetaData](site/Internal/Get-InvokeMetaData.md)
Gets various Api metadata values

### [Import-DattoModuleSettings](site/Internal/Import-DattoModuleSettings.md)
Imports the Datto BaseURI, API, & JSON configuration information to the current session.

### [Invoke-ApiRequest](site/Internal/Invoke-ApiRequest.md)
### [Invoke-DattoRequest](site/Internal/Invoke-DattoRequest.md)
Makes an API request

### [Remove-DattoAPIKey](site/Internal/Remove-DattoAPIKey.md)
Expand Down
6 changes: 3 additions & 3 deletions docs/Endpoints.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ BCDR,/bcdr/device/{serialNumber}/asset/share,GET,Get-DattoShare,YES,
BCDR,/bcdr/device/{serialNumber}/asset/{volumeName},GET,Get-DattoVolume,YES,
Internal,,POST,Add-DattoAPIKey,YES,
Internal,,POST,Add-DattoBaseURI,YES,
Internal,,PUT,ConvertTo-QueryString,YES,
Internal,,PUT,ConvertTo-DattoQueryString,YES,
Internal,,GET,Export-DattoModuleSettings,YES,
Internal,,GET,Get-DattoAPIKey,YES,
Internal,,GET,Get-DattoBaseURI,YES,
Internal,,GET,Get-DattoModuleSettings,YES,
Internal,,GET,Import-DattoModuleSettings,YES,
Internal,,GET,Invoke-APIRequest,YES,
Internal,,GET,Invoke-DattoRequest,YES,
Internal,,DELETE,Remove-DattoAPIKey,YES,
Internal,,DELETE,Remove-DattoBaseURI,YES,
Internal,,DELETE,Remove-DattoModuleSettings,YES,
Internal,,GET,Test-DattoAPIKey,YES,
Internal,,GET,Get-InvokeMetaData,YES,
Internal,,GET,Get-DattoMetaData,YES,
Reporting,/report/activity-log,GET,Get-DattoActivityLog,YES,
SaaS,/sass/{sassCustomerId}/applications,GET,Get-DattoApplication,YES,
SaaS,/sass/domains,GET,Get-DattoDomain,YES,
Expand Down
6 changes: 3 additions & 3 deletions docs/TrackingCSV.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ I recommend downloading the CSV from the link provided rather then viewing the t
|BCDR |/bcdr/device/{serialNumber}/asset/{volumeName}|GET |Get-DattoVolume |YES | |
|Internal | |POST |Add-DattoAPIKey |YES | |
|Internal | |POST |Add-DattoBaseURI |YES | |
|Internal | |PUT |ConvertTo-QueryString |YES | |
|Internal | |PUT |ConvertTo-DattoQueryString |YES | |
|Internal | |GET |Export-DattoModuleSettings|YES | |
|Internal | |GET |Get-DattoAPIKey |YES | |
|Internal | |GET |Get-DattoBaseURI |YES | |
|Internal | |GET |Get-DattoModuleSettings |YES | |
|Internal | |GET |Import-DattoModuleSettings|YES | |
|Internal | |GET |Invoke-APIRequest |YES | |
|Internal | |GET |Invoke-DattoRequest |YES | |
|Internal | |DELETE|Remove-DattoAPIKey |YES | |
|Internal | |DELETE|Remove-DattoBaseURI |YES | |
|Internal | |DELETE|Remove-DattoModuleSettings|YES | |
|Internal | |GET |Test-DattoAPIKey |YES | |
|Internal | |GET |Get-InvokeMetaData |YES | |
|Internal | |GET |Get-DattoMetaData |YES | |
|Reporting|/report/activity-log |GET |Get-DattoActivityLog |YES | |
|SaaS |/sass/{sassCustomerId}/applications |GET |Get-DattoApplication |YES | |
|SaaS |/sass/domains |GET |Get-DattoDomain |YES | |
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit a5412a9

Please sign in to comment.