Skip to content

Commit

Permalink
Initial 2.3.0 build
Browse files Browse the repository at this point in the history
  • Loading branch information
Celerium committed Jan 20, 2024
1 parent 4b28a24 commit 782838e
Show file tree
Hide file tree
Showing 34 changed files with 11,144 additions and 7,920 deletions.
Binary file modified DattoAPI/DattoAPI.psd1
Binary file not shown.
3 changes: 2 additions & 1 deletion DattoAPI/Private/apiCalls/ConvertTo-DattoQueryString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ param(
'allPages', 'page', 'perPage',
'endpoint_Agents', 'endpoint_Devices', 'endpoint_byDevice', 'endpoint_byDeviceAgent',
'endpoint_byDeviceAlert', 'endpoint_byDeviceAsset', 'endpoint_byDeviceShare', 'endpoint_byDeviceVolume',
'endpoint_Domains', 'endpoint_CustomerSeats', 'endpoint_CustomerApps', 'saasCustomerId','externalSubscriptionId','seatType','remoteId','actionType'
'endpoint_Domains', 'endpoint_CustomerSeats', 'endpoint_CustomerApps',
'saasCustomerId','externalSubscriptionId','seatType','remoteId','actionType'

$query_Parameters = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)

Expand Down
7 changes: 6 additions & 1 deletion DattoAPI/Private/apiCalls/Invoke-DattoRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,14 @@ function Invoke-DattoRequest {
$parameters = [ordered] @{
"Method" = $method
"Uri" = $query_string.Uri
"Headers" = @{ 'Authorization' = 'Basic {0}'-f $Api_Token_base64; 'Content-Type' = 'application/json' }
"Headers" = @{ 'Authorization' = 'Basic {0}'-f $Api_Token_base64 }
"Body" = $body
}

if ( $method -ne 'GET' ) {
$parameters['ContentType'] = 'application/json; charset=utf-8'
}

Set-Variable -Name 'Datto_invokeParameters' -Value $parameters -Scope Global -Force

if ($allPages){
Expand Down
2 changes: 0 additions & 2 deletions DattoAPI/Public/BCDR/Get-DattoAgent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ function Get-DattoAgent {
.PARAMETER serialNumber
Defines the BCDR serial number to get agents from
The parameter is mandatory
.PARAMETER page
Defines the page number to return
Expand Down
2 changes: 0 additions & 2 deletions DattoAPI/Public/BCDR/Get-DattoAlert.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ function Get-DattoAlert {
.PARAMETER serialNumber
Defines the BCDR serial number to get
The parameter is mandatory
.PARAMETER page
Defines the page number to return
Expand Down
2 changes: 0 additions & 2 deletions DattoAPI/Public/BCDR/Get-DattoAsset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ function Get-DattoAsset {
.PARAMETER serialNumber
Defines the BCDR serial number to get
The parameter is mandatory
.PARAMETER page
Defines the page number to return
Expand Down
2 changes: 0 additions & 2 deletions DattoAPI/Public/BCDR/Get-DattoShare.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ function Get-DattoShare {
.PARAMETER serialNumber
Defines the BCDR serial number to get
The parameter is mandatory
.PARAMETER page
Defines the page number to return
Expand Down
4 changes: 0 additions & 4 deletions DattoAPI/Public/BCDR/Get-DattoVolume.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ function Get-DattoVolume {
.PARAMETER serialNumber
Defines the BCDR serial number to get
The parameter is mandatory
.PARAMETER volumeName
Defines the name (id) of the protected volume
The content of the 'volume' field when calling /v1/bcdr/device/{serialNumber}/asset
The parameter is mandatory
.EXAMPLE
Get-DattoVolume -serialNumber "12345678" -volumeName "0987654321"
Expand Down
34 changes: 30 additions & 4 deletions DattoAPI/Public/SaaS/Get-DattoApplication.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,32 @@ function Get-DattoApplication {
backup data for a given customer
.PARAMETER saasCustomerId
Defines the id of the customer to get SaaS information from
Defines the id of the Datto SaaS organization
The parameter is mandatory
.PARAMETER daysUntil
Defines the number of days until the report should be generated
.PARAMETER includeRemoteID
Defines if remote ids are included in the return
Note:
0 = No
1 = Yes
Allowed Values:
0, 1
.EXAMPLE
Get-DattoApplication -saasCustomerId "12345678"
Gets the Datto SaaS protection backup data from the define customer id
Gets the Datto SaaS protection backup data from the define customer id and
does not include remote ids
.EXAMPLE
Get-DattoApplication -saasCustomerId "12345678" -includeRemoteID 1
Gets the Datto SaaS protection backup data from the define customer id and
includes remote ids
.NOTES
N\A
Expand All @@ -28,7 +46,15 @@ function Get-DattoApplication {
Param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'index')]
[ValidateNotNullOrEmpty()]
[string]$saasCustomerId
[string]$saasCustomerId,

[Parameter(Mandatory = $false, ParameterSetName = 'index')]
[ValidateRange(1, [int]::MaxValue)]
[int]$daysUntil,

[Parameter(Mandatory = $false, ParameterSetName = 'index')]
[ValidateSet( 0, 1 )]
[int]$includeRemoteID
)

begin {
Expand Down
29 changes: 27 additions & 2 deletions DattoAPI/Public/SaaS/Get-DattoSaaS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,24 @@ function Get-DattoSaaS {
.PARAMETER saasCustomerId
Defines the id of the customer to get SaaS information from
The parameter is mandatory
.PARAMETER daysUntil
Defines the number of days until the report should be generated
Parameter Set:
endpoint_CustomerApps
.PARAMETER includeRemoteID
Defines if remote ids are included in the return
Note:
0 = No
1 = Yes
Allowed Values:
0, 1
Parameter Set:
endpoint_CustomerApps
.EXAMPLE
Get-DattoSaaS
Expand Down Expand Up @@ -68,7 +85,15 @@ function Get-DattoSaaS {
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'index_byCustomerSeats' )]
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'index_byCustomerApps' )]
[ValidateNotNullOrEmpty()]
[string]$saasCustomerId
[string]$saasCustomerId,

[Parameter(Mandatory = $false, ParameterSetName = 'index_byCustomerApps')]
[ValidateRange(1, [int]::MaxValue)]
[int]$daysUntil,

[Parameter(Mandatory = $false, ParameterSetName = 'index_byCustomerApps')]
[ValidateSet( 0, 1 )]
[int]$includeRemoteID
)

begin {
Expand Down
4 changes: 1 addition & 3 deletions DattoAPI/Public/SaaS/Get-DattoSeat.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ function Get-DattoSeat {
for a given customer
.PARAMETER saasCustomerId
Defines the id of the customer to get SaaS information from
The parameter is mandatory
Defines the id of the Datto SaaS organization
.EXAMPLE
Get-DattoSeat -saasCustomerId "12345678"
Expand Down
91 changes: 52 additions & 39 deletions DattoAPI/Public/SaaS/Set-DattoBulkSeatChange.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,51 @@ function Set-DattoBulkSeatChange {
Sets Datto SaaS Protection bulk seat changes
.DESCRIPTION
The Set-DattoBulkSeatChange cmdlet is used to set SaaS Protection bulk seat changes
The Set-DattoBulkSeatChange cmdlet is used to bulk set SaaS Protection seat changes
.PARAMETER saasCustomerId
Defines the id of the Organization to set SaaS information from
Defines the id of the Datto SaaS organization
.PARAMETER externalSubscriptionId
Defines the external Subscription ID of the SaaS Protection Organization used to set SaaS bulk seat changes
Defines the external Subscription ID used to set SaaS bulk seat changes
The externalSubscriptionId can be found by referencing the data returned form Get-DattoApplication
Example:
'Classic:Office365:123456'
'Classic:GoogleApps:123456'
.PARAMETER seatType
Defines the seat type to backup
Example:
SharedMailbox, Site, TeamSite, User
.PARAMETER actionType
Defines what active to take against the seat
Active: The seat exists in the organization and is actively backed up, meaning the seat is protected.
Paused: The seat exists in the organization; backups were enabled but are currently paused.
Unprotected: The seat exists in the organization but backups are not enabled.
Allowed values:
License, Pause, Unlicense
.PARAMETER remoteId
Defines the target ids to change
Remote ids can be found by referencing the data returned form Get-DattoApplication
Example:
ab23-bdf234-1234-asdf
.EXAMPLE
Set-DattoBulkSeatChange -saasCustomerId "12345678" -externalSubscriptionId 'Classic:Office365:123456' -seatType "User" -remoteId "ab23-bdf234-1234-asdf" -actionType "License"
Set-DattoBulkSeatChange -customerId "123456" -externalSubscriptionId 'Classic:Office365:654321' -seatType "User" -actionType License -remoteId "ab23-bdf234-1234-asdf"
Sets the Datto SaaS protection seats from the defined Office365 customer id
.EXAMPLE
Set-DattoBulkSeatChange -saasCustomerId "12345678" -externalSubscriptionId 'Classic:GoogleApps:123456' -seatType "SharedDrive" -remoteId "ab23-bdf234-1234-asdf","cd45-cfe567-5678-qwer" -actionType "Pause"
Set-DattoBulkSeatChange -customerId "123456" -externalSubscriptionId 'Classic:GoogleApps:654321' -seatType "SharedDrive" -actionType Pause -remoteId "ab23-bdf234-1234-asdf","cd45-cfe567-5678-1234"
Sets the Datto SaaS protection seats from the defined Google customer id
Expand All @@ -29,44 +59,25 @@ function Set-DattoBulkSeatChange {
https://celerium.github.io/Datto-PowerShellWrapper/site/SaaS/Set-DattoBulkSeatChange.html
#>

[CmdletBinding(DefaultParameterSetName = 'index', SupportsShouldProcess = $true)]
[CmdletBinding(DefaultParameterSetName = 'set', SupportsShouldProcess)]
Param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'index')]
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'set')]
[ValidateNotNullOrEmpty()]
[string]$saasCustomerId,

[Parameter(Mandatory = $true, ParameterSetName = 'index')]
[Parameter(Mandatory = $true, ParameterSetName = 'set')]
[ValidateNotNullOrEmpty()]
[string]$externalSubscriptionId,

# Parameter help description
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'index'
)]
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'set')]
[ValidateNotNullOrEmpty()]
[string]$seatType,

# Valid methods are 'License' to "Protect", 'Pause' to "Pause", and 'Unlicense' to "Unprotect"
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'index'
)]
[ValidateSet('License','Pause','Unlicense')]
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'set')]
[ValidateSet('License', 'Pause', 'Unlicense')]
[string]$actionType,

# Either like 'Classic:Office365:123456', or 'Classic:GoogleApps:123456'
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'index'
)]
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'set')]
[ValidateNotNullOrEmpty()]
[string[]]$remoteId
)
Expand All @@ -75,21 +86,23 @@ function Set-DattoBulkSeatChange {

$resource_uri = "/saas/$saasCustomerId/$externalSubscriptionId/bulkSeatChange"

$requestBody = @{
seat_type = $seatType
action_type = $actionType
ids = $remoteId
}

}

process {

if ($PSCmdlet.ShouldProcess("saasCustomerId: $saasCustomerId, externalSubscriptionId: $externalSubscriptionId, $remoteId", "$actionType $seatType")) {
$request_Body = @{
seat_type = $seatType
action_type = $actionType
ids = $remoteId
}

if ($PSCmdlet.ShouldProcess("saasCustomerId: [ $saasCustomerId ], externalSubscriptionId: [ $externalSubscriptionId, $remoteId ]", "actionType: [ $actionType $seatType ]")) {

Write-Verbose "Running the [ $($PSCmdlet.ParameterSetName) ] parameterSet"
Set-Variable -Name 'Datto_bulkSeatParameters' -Value $PSBoundParameters -Scope Global -Force

Invoke-DattoRequest -method PUT -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -data $requestBody
Invoke-DattoRequest -method PUT -resource_Uri $resource_Uri -uri_Filter $PSBoundParameters -data $request_Body

}

}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ Calling an API resource is as simple as running `Get-Datto<resourceName>`
| BCDR | **BCDR** * | - | `Get-DattoBCDR` | - | - |
| BCDR | Device | - | `Get-DattoDevice` | - | - |
| BCDR | Share | - | `Get-DattoShare` | - | - |
| BCDR | VMRestore | - | `Get-DattoGet-DattoVMRestore` | - | - |
| BCDR | VMRestore | - | `Get-DattoVMRestore` | - | - |
| BCDR | Volume | - | `Get-DattoVolume` | - | - |
| SaaS | **SaaS** * | - | `Get-DattoSaaS` | - | - |
| SaaS | Domains | - | `Get-DattoDomain` | - | - |
| SaaS | Seats | - | `Get-DattoSeat` | - | - |
| SaaS | Applications | - | `Get-DattoApplication` | - | - |
| SaaS | BulkSeatChange | - | - | `Set-DattoBulkSeatChange` | - |
| SaaS | BulkSeatChange | - | - | `Set-DattoBulkSeatChange` | - |

- :warning: `Get-DattoBCDR` & `Get-DattoSaaS` are special functions.
- These are **NOT** endpoints in Datto's REST API and are a single set of commands that can run endpoints in their associate sections.
Expand Down
Loading

0 comments on commit 782838e

Please sign in to comment.