diff --git a/Datto.DBPool.API/0.2.0/Datto.DBPool.API.psd1 b/Datto.DBPool.API/0.2.0/Datto.DBPool.API.psd1 new file mode 100644 index 0000000..18e172f --- /dev/null +++ b/Datto.DBPool.API/0.2.0/Datto.DBPool.API.psd1 @@ -0,0 +1,171 @@ +# +# Module manifest for module 'Datto.DBPool.API' +# +# Generated by: Kent Sapp +# +# Generated on: 2023-09-26 +# + +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'Datto.DBPool.API.psm1' + + # Version number of this module. + # Follows https://semver.org Semantic Versioning 2.0.0 + # Given a version number MAJOR.MINOR.PATCH, increment the: + # -- MAJOR version when you make incompatible API changes, + # -- MINOR version when you add functionality in a backwards-compatible manner, and + # -- PATCH version when you make backwards-compatible bug fixes. + + # Version number of this module. + ModuleVersion = '0.2.0' + + # Supported PSEditions + # CompatiblePSEditions = @() + + # ID used to uniquely identify this module + GUID = '8c050520-2433-464a-9415-2445197aff4e' + + # Author of this module + Author = 'Kent Sapp (@CKSapp)' + + # Company or vendor of this module + # CompanyName = '' + + # Copyright statement for this module + Copyright = '(c) 2023 Kent Sapp. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'This module is designed to make it easier to use the internal Datto DBPool API in your PowerShell scripts. As much of the hard work is done, you can develop your scripts faster and be more effecient. + There is no need to go through a big learning curve spending lots of time working out how to use the Datto DBPool API. + Simply load the module, enter your API key and get results within minutes!' + + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '5.1' + + # Name of the Windows PowerShell host required by this module + # PowerShellHostName = '' + + # Minimum version of the Windows PowerShell host required by this module + # PowerShellHostVersion = '' + + # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # DotNetFrameworkVersion = '' + + # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # CLRVersion = '' + + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' + + # Modules that must be imported into the global environment prior to importing this module + # RequiredModules = @() + + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() + + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() + + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() + + # Format files (.ps1xml) to be loaded when importing this module + # FormatsToProcess = @() + + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + <#NestedModules = @( + 'Private/Set-DBPoolApiParameter.ps1', + 'Private/Test-DBPoolApi.ps1', + + 'Private/apiCalls/ConvertTo-DBPoolQueryString.ps1', + 'Private/apiCalls/Get-DBPoolMetaData.ps1', + 'Private/apiCalls/Invoke-DBPoolRequest.ps1', + + 'Private/apiKeys/Add-DBPoolApiKey.ps1', + 'Private/apiKeys/Get-DBPoolApiKey.ps1', + 'Private/apiKeys/Remove-DBPoolApiKey.ps1', + 'Private/apiKeys/Test-DBPoolApiKey.ps1', + + 'Private/baseUri/Add-DBPoolBaseUri.ps1', + 'Private/baseUri/Get-DBPoolBaseUri.ps1', + 'Private/baseUri/Remove-DBPoolBaseUri.ps1', + + 'Private/moduleSettings/Export-DBPoolModuleSetting.ps1', + 'Private/moduleSettings/Get-DBPoolModuleSetting.ps1', + 'Private/moduleSettings/Import-DBPoolModuleSetting.ps1', + 'Private/moduleSettings/Initialize-DBPoolModuleSetting.ps1', + 'Private/moduleSettings/Remove-DBPoolModuleSetting.ps1', + + 'Public/Containers/Containers/Get-DBPoolContainer.ps1', + 'Public/Containers/Containers/New-DBPoolContainer.ps1', + 'Public/Containers/Containers/Remove-DBPoolContainer.ps1', + 'Public/Containers/Containers/Rename-DBPoolContainer.ps1', + + 'Public/Containers/Containers/access/Invoke-DBPoolContainerAccess.ps1', + + 'Public/Containers/Containers/actions/Invoke-DBPoolContainerAction.ps1', + + 'Public/Debug/Invoke-DBPoolDebug.ps1', + + 'Public/OpenAPI/Get-DBPoolOpenAPI.ps1', + + 'Public/Users/Get-DBPoolUser.ps1' + )#> + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @('Invoke-DBPoolContainerAccess','Invoke-DBPoolContainerAction','Get-DBPoolContainer','New-DBPoolContainer','Remove-DBPoolContainer','Rename-DBPoolContainer','Invoke-DBPoolContainer','Invoke-DBPoolDebug','Get-DBPoolOpenAPI','Get-DBPoolUser','ConvertTo-DBPoolQueryString','Get-DBPoolMetaData','Invoke-DBPoolRequest','Add-DBPoolApiKey','Get-DBPoolApiKey','Remove-DBPoolApiKey','Test-DBPoolApiKey','Add-DBPoolBaseURI','Get-DBPoolBaseURI','Remove-DBPoolBaseURI','Export-DBPoolModuleSetting','Get-DBPoolModuleSetting','Import-DBPoolModuleSetting','Initialize-DBPoolModuleSetting','Remove-DBPoolModuleSetting','Set-DBPoolApiParameter','Test-DBPoolApi') + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = '*' + + # Variables to export from this module + VariablesToExport = '*' + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = '*' + + # DSC resources to export from this module + # DscResourcesToExport = @() + + # List of all modules packaged with this module + # ModuleList = @() + + # List of all files packaged with this module + # FileList = @() + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = @('Datto', 'Internal', 'DBPool', 'DattoDBPool', 'Containers', 'Database', 'API') + + # A URL to the license for this module. + LicenseUri = 'https://github.com/cksapp/Datto-DBPool_PSWrapper/blob/main/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/cksapp/Datto-DBPool_PSWrapper' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # Prerelease string of this module + Prerelease = 'BETA' + + } # End of PSData hashtable + + } # End of PrivateData hashtable + + # HelpInfo URI of this module + HelpInfoURI = 'https://github.com/cksapp/Datto-DBPool_PSWrapper/blob/main/README.md' + + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = 'Datto' # As of 2024-08 the 'Import-Module' cmdlet does not support $null -Prefix parameter + +} diff --git a/Datto.DBPool.API/0.2.0/Datto.DBPool.API.psm1 b/Datto.DBPool.API/0.2.0/Datto.DBPool.API.psm1 new file mode 100644 index 0000000..50e1f00 --- /dev/null +++ b/Datto.DBPool.API/0.2.0/Datto.DBPool.API.psm1 @@ -0,0 +1,3072 @@ + + +#Region +function Set-DBPoolApiParameter { +<# + .SYNOPSIS + The Set-DBPoolApiParameter function is used to set parameters for the Datto DBPool API. + + .DESCRIPTION + The Set-DBPoolApiParameter function is used to set the API URL and API Key for the Datto DBPool API. + + .PARAMETER base_uri + Provide the URL of the Datto DBPool API. + The default value is https://dbpool.datto.net. + + .PARAMETER apiKey + Provide Datto DBPool API Key for authorization. + You can find your user API key at [ /web/self ](https://dbpool.datto.net/web/self). + + .PARAMETER Force + Force the operation without confirmation. + + .INPUTS + [Uri] - The base URL of the DBPool API. + [SecureString] - The API key for the DBPool. + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Set-DBPoolApiParameter + + Sets the default base URI and prompts for the API Key. + + .EXAMPLE + Set-DBPoolApiParameter -base_uri "https://dbpool.example.com" -apiKey $secureString + + Sets the base URI to https://dbpool.example.com and sets the API Key. + + .NOTES + See Datto DBPool API help files for more information. + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/Set-DBPoolApiParameter/ +#> + + [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')] + [OutputType([void])] + Param( + [Parameter(Position = 0, Mandatory = $False, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = "Provide the base URL of the DBPool API.")] + [Uri]$base_uri = "https://dbpool.datto.net", + + [Parameter(Position = 1, Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = "Provide Datto DBPool API Key for authorization.")] + [securestring]$apiKey, + + [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Force the operation without confirmation.")] + [switch]$Force + ) + + Begin { + + # Cast URI Variable to string type + [String]$base_uri = $base_uri.AbsoluteUri + + # Check for trailing slash and remove if present + $base_uri = $base_uri.TrimEnd('/') + + # Check to replace existing variables + if ((Get-Variable -Name DBPool_Base_URI -ErrorAction SilentlyContinue) -and (Get-Variable -Name DBPool_ApiKey -ErrorAction SilentlyContinue)) { + if (-not ($Force -or $PSCmdlet.ShouldContinue("Variables 'DBPool_Base_URI' and 'DBPool_ApiKey' already exist. Do you want to replace them?", "Confirm overwrite"))) { + Write-Warning "Existing variables were not replaced." + break + } + } + + } + + Process { + + # Set or replace the parameters + if ($Force -or $PSCmdlet.ShouldProcess('Setting DBPool API parameters')) { + try { + Add-DBPoolBaseURI -base_uri $base_uri -Verbose:$VerbosePreference -ErrorAction Stop + Add-DBPoolApiKey -apiKey $apiKey -Verbose:$PSBoundParameters.ContainsKey('Verbose') -Force -ErrorAction Stop + } catch { + Write-Error $_ + } + } + + } + + End {} +} +#EndRegion + +#Region +function Test-DBPoolApi { +<# + .SYNOPSIS + Checks the availability of the DBPool API using an HTTP HEAD request. + + .DESCRIPTION + This function sends an HTTP HEAD request to the specified API URL using Invoke-WebRequest. + Checks if the HTTP status code is 200, indicating that the API is available. + + .PARAMETER base_uri + The base URL of the API to be checked. + + .PARAMETER resource_Uri + The URI of the API resource to be checked. + + The default value is '/api/docs/openapi.json'. + + .PARAMETER ApiKey + Optional: Access token for authorization. + + .INPUTS + [string] - The base URI for the DBPool API connection. + [SecureString] - The API key for the DBPool. + + .OUTPUTS + [System.Boolean] - Returns $true if the API is available, $false if not. + + .EXAMPLE + Test-DBPoolApi -base_uri "https://api.example.com" + + Checks the availability of the API at https://api.example.com + + .EXAMPLE + Test-DBPoolApi -base_uri "https://api.example.com" -resource_Uri "/api/docs" + + Checks the availability of the API at https://api.example.com/api/docs + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/Test-DBPoolApi/ +#> + + [CmdletBinding()] + [OutputType([System.Boolean], ParameterSetName = "API_Available")] + param ( + [Parameter(Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = "The URL of the API to be checked.")] + [string]$base_uri = $DBPool_Base_URI, + + [Parameter(Position = 1, Mandatory = $false)] + [string]$resource_Uri = '/api/docs/openapi.json', + + [Parameter(Position = 2, Mandatory = $false, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = "API Key for authorization.")] + [securestring]$apiKey = $DBPool_ApiKey + ) + + begin { + + # Check if API Parameters are set + Write-Debug -Message "Api URL is $base_uri" + Write-Debug -Message "Api Key is $DBPool_ApiKey" + if (!($base_uri -and $apiKey)) { + Write-Warning "API parameters are missing. Please run 'Set-DBPoolApiParameter' first!" + } + + # Use 'Add-DBPoolBaseURI' to remove superfluous trailing slashes + Add-DBPoolBaseURI -base_uri $base_uri -Verbose:$false + + } + + process { + + Write-Verbose -Message "Checking Uri: [ $($base_uri + $resource_Uri) ]" + try { + Invoke-DBPoolRequest -Method 'HEAD' -resource_Uri $resource_Uri -ErrorAction Stop -Verbose:$false | Out-Null + $true + } catch { + if ($_.Exception.Response.StatusCode -ne 200) { + Write-Error $_.Exception.Message + $false + } + } + + } + + end {} + +} +#EndRegion + +#Region +function ConvertTo-DBPoolQueryString { +<# + .SYNOPSIS + Converts uri filter parameters + + As of June 2024, DBPool does not support any query parameters. + This is only provided to allow forward compatibility + + .DESCRIPTION + The ConvertTo-DBPoolQueryString 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-DBPoolRequest & any public functions that define parameters + + As of June 2024, DBPool does not support any query parameters. + This is only provided to allow forward compatibility + + .PARAMETER uri_Filter + Hashtable of values to combine a functions parameters with + the resource_Uri parameter. + + This allows for the full uri query to occur + + As of June 2024, DBPool does not support any query parameters. + This is only provided to allow forward compatibility + + .PARAMETER resource_Uri + Defines the short resource uri (url) to use when creating the API call + + .INPUTS + [hashtable] - uri_Filter + + .OUTPUTS + [System.UriBuilder] - uri_Request + + .EXAMPLE + ConvertTo-DBPoolQueryString -uri_Filter $uri_Filter -resource_Uri '/api/v2/containers' + + Example: (From public function) + $uri_Filter = @{} + + ForEach ( $Key in $PSBoundParameters.GetEnumerator() ){ + if( $excludedParameters -contains $Key.Key ){$null} + else{ $uri_Filter += @{ $Key.Key = $Key.Value } } + } + + 1x key = https://api.DBPool.com/v1/api/v2/containers?parentId=12345 + 2x key = https://api.DBPool.com/v1/api/v2/containers?parentId=12345&power=True + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/ConvertTo-DBPoolQueryString/ + +#> + + [CmdletBinding()] + [OutputType([System.UriBuilder])] + param( + [Parameter(Mandatory = $false, ValueFromPipeline = $true)] + [hashtable]$uri_Filter, + + [Parameter(Mandatory = $true)] + [String]$resource_Uri + ) + + begin {} + + process { + + $excludedParameters = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', + 'OutBuffer', 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable', + 'allPages', 'page', 'perPage' + + $query_Parameters = [System.Web.HttpUtility]::ParseQueryString([String]::Empty) + + if ($uri_Filter) { + ForEach ( $Key in $uri_Filter.GetEnumerator() ) { + + if ( $excludedParameters -contains $Key.Key ){$null} + elseif ( $Key.Value.GetType().IsArray ) { + Write-Verbose "[ $($Key.Key) ] is an array parameter" + foreach ($Value in $Key.Value) { + $query_Parameters.Add($Key.Key, $Value) + } + } else { + $query_Parameters.Add($Key.Key, $Key.Value) + } + + } + } + + # Build the request and load it with the query string. + $uri_Request = [System.UriBuilder]($DBPool_Base_URI + $resource_Uri) + $uri_Request.Query = $query_Parameters.ToString() + + # Return the full uri + $uri_Request + + } + + end {} + +} +#EndRegion + +#Region +function Get-DBPoolMetaData { +<# + .SYNOPSIS + Gets various API metadata values + + .DESCRIPTION + The Get-DBPoolMetaData cmdlet gets various API metadata values from an + Invoke-WebRequest to assist in various troubleshooting scenarios such + as rate-limiting. + + .PARAMETER base_uri + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. + + The default base URI is https://dbpool.datto.net + + .PARAMETER resource_uri + Define the resource URI for the DBPool API connection. + + The default resource URI is /api/v2/self + + .INPUTS + [string] - base_uri + + .OUTPUTS + [PSCustomObject] - Various API metadata values + + .EXAMPLE + Get-DBPoolMetaData + + Gets various API metadata values from an Invoke-WebRequest to assist + in various troubleshooting scenarios such as rate-limiting. + + The default full base uri test path is: + https://dbpool.datto.net + + .EXAMPLE + Get-DBPoolMetaData -base_uri http://dbpool.example.com + + Gets various API metadata values from an Invoke-WebRequest to assist + in various troubleshooting scenarios such as rate-limiting. + + The full base uri test path in this example is: + http://dbpool.example.com/device + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Get-DBPoolMetaData/ +#> + + [CmdletBinding()] + [OutputType([PSCustomObject])] + Param ( + [parameter(Mandatory = $false, ValueFromPipeline = $true)] + [string]$base_uri = $DBPool_Base_URI, + + [string]$resource_uri = '/api/v2/self' + ) + + begin { + + $method = 'GET' + + } + + process { + + try { + + $api_Key = $(Get-DBPoolAPIKey -AsPlainText).'ApiKey' + + $DBPool_Headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" + $DBPool_Headers.Add("Content-Type", 'application/json') + $DBPool_Headers.Add('X-App-APIkey', $api_Key) + + $rest_output = Invoke-WebRequest -method $method -uri ($base_uri + $resource_uri) -headers $DBPool_Headers -ErrorAction Stop + } + catch { + + [PSCustomObject]@{ + URI = $($base_uri + $resource_uri) + Method = $method + StatusCode = $_.Exception.Response.StatusCode.value__ + StatusDescription = $_.Exception.Response.ReasonPhrase + Message = $_.Exception.Message + } + + } + finally { + Remove-Variable -Name DBPool_Headers -Force + } + + if ($rest_output){ + $data = @{} + $data = $rest_output + + [PSCustomObject]@{ + RequestUri = $($DBPool_Base_URI + $resource_uri) + StatusCode = $data.StatusCode + StatusDescription = $data.StatusDescription + 'Content-Type' = $data.headers.'Content-Type' + <#'X-App-Request-Id' = $data.headers.'X-App-Request-Id' + 'X-API-Limit-Remaining' = $data.headers.'X-API-Limit-Remaining' + 'X-API-Limit-Resets' = $data.headers.'X-API-Limit-Resets' + 'X-API-Limit-Cost' = $data.headers.'X-API-Limit-Cost'#> + raw = $data + } + } + + } + + end {} +} +#EndRegion + +#Region +function Invoke-DBPoolRequest { +<# + .SYNOPSIS + Internal function to make an API request to the DBPool API + + .DESCRIPTION + The Invoke-DBPoolRequest cmdlet invokes an API request to DBPool API + + This is an internal function that is used by all public functions + + .PARAMETER method + Defines the type of API method to use + + Allowed values: + 'DEFAULT', 'DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT' + + .PARAMETER resource_Uri + Defines the resource uri (url) to use when creating the API call + + .PARAMETER uri_Filter + Used with the internal function [ ConvertTo-DBPoolQueryString ] 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 + $DBPool_Base_URI + $resource_Uri + ConvertTo-DBPoolQueryString + + As of June 2024, DBPool does not support any query parameters. + This is only provided to allow forward compatibility + + .PARAMETER data + Defines the data to be sent with the API request body when using POST or PATCH + + .PARAMETER DBPool_JSON_Conversion_Depth + Defines the depth of the JSON conversion for the 'data' parameter request body + + .PARAMETER allPages + Returns all items from an endpoint + + When using this parameter there is no need to use either the page or perPage + parameters + + As of June 2024, DBPool does not support any paging parameters. + This is only provided to allow forward compatibility + + .INPUTS + N/A + + .OUTPUTS + [Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject] - The response from the DBPool API + + .EXAMPLE + Invoke-DBPoolRequest -method GET -resource_Uri '/api/v2/self' -uri_Filter $uri_Filter + + Name Value + ---- ----- + Method GET + Uri https://dbpool.datto.net/api/v2/self + Headers {X-App-Apikey = 3feb2b29-919c-409c-985d-e99cbae43a6d} + Body + + Invoke an API request against the defined resource using any of the provided parameters + + .EXAMPLE + Invoke-DBPoolRequest -method GET -resource_Uri '/api/openapi.json' -uri_Filter $uri_Filter + Name Value + ---- ----- + Method GET + Uri https://dbpool.datto.net/api/openapi.json + Headers {X-App-Apikey = 3feb2b29-919c-409c-985d-e99cbae43a6d} + Body + + Invoke an API request against the defined resource using any of the provided parameters + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Invoke-DBPoolRequest/ + +#> + + [CmdletBinding()] + [OutputType([Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject])] + param ( + [Parameter(Mandatory = $false)] + [ValidateSet('DEFAULT', 'DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT')] + [String]$method = 'DEFAULT', + + [Parameter(Mandatory = $true)] + [String]$resource_Uri, + + [Parameter(DontShow = $true, Mandatory = $false)] + [Hashtable]$uri_Filter = $null, + + [Parameter(Mandatory = $false)] + [Hashtable]$data = $null, + + [Parameter(Mandatory = $false)] + #[ValidateRange(0, [int]::MaxValue)] + [int]$DBPool_JSON_Conversion_Depth = 5, + + [Parameter(DontShow = $true, Mandatory = $false)] + [Switch]$allPages + + ) + + begin { + $ConfirmPreference = 'None' + } + + process { + + # Load Web assembly when needed as PowerShell Core has the assembly preloaded + if ( !('System.Web.HttpUtility' -as [Type]) ) { + Add-Type -Assembly System.Web + } + + if (!($DBPool_base_URI)) { + Write-Warning 'The DBPool base URI is not set. Run Add-DBPoolBaseURI to set the base URI.' + } + + $query_String = ConvertTo-DBPoolQueryString -resource_Uri $resource_Uri -uri_Filter $uri_Filter + + Set-Variable -Name 'DBPool_queryString' -Value $query_String -Scope Global -Force + + if ($null -eq $data) { + $request_Body = $null + } else { + $request_Body = $data | ConvertTo-Json -Depth $DBPool_JSON_Conversion_Depth + } + + try { + $api_Key = $(Get-DBPoolAPIKey -AsPlainText).'ApiKey' + + $parameters = [ordered] @{ + 'Method' = $method + 'Uri' = $query_String.Uri + 'Headers' = @{ 'X-App-Apikey' = "$api_Key" } + 'Body' = $request_Body + } + + if ( $method -ne 'GET' ) { + $parameters['ContentType'] = 'application/json; charset=utf-8' + } + + Set-Variable -Name 'DBPool_invokeParameters' -Value $parameters -Scope Global -Force + + if ($allPages) { + + Write-Verbose "Gathering all items from [ $( $DBPool_Base_URI + $resource_Uri ) ] " + + $page_Number = 1 + $all_responseData = [System.Collections.Generic.List[object]]::new() + + do { + + $parameters['Uri'] = $query_String.Uri -replace '_page=\d+', "_page=$page_Number" + + Write-Verbose "Making API request to Uri: [ $($parameters['Uri']) ]" + $current_Page = Invoke-WebRequest @parameters -ErrorAction Stop + + Write-Verbose "[ $page_Number ] of [ $($current_Page.pagination.totalPages) ] pages" + + foreach ($item in $current_Page.items) { + $all_responseData.add($item) + } + + $page_Number++ + + } while ($current_Page.pagination.totalPages -ne $page_Number - 1 -and $current_Page.pagination.totalPages -ne 0) + + } else { + Write-Verbose "Making API request to Uri: [ $($parameters['Uri']) ]" + $api_Response = Invoke-WebRequest @parameters -ErrorAction Stop + $appRequestId = $api_Response.Headers['X-App-Request-Id'] + Write-Debug "If you need to report an error to the DBE team, include this request ID which can be used to search through the application logs for messages that were logged while processing your request [ X-App-Request-Id: $appRequestId ]" + Set-Variable -Name 'DBPool_appRequestId' -Value $appRequestId -Scope Global -Force + } + + } catch { + + $exceptionError = $_ + Write-Warning 'The [ DBPool_invokeParameters, DBPool_queryString, DBPool_appRequestId, & DBPool_CmdletNameParameters ] variables can provide extra details' + + # Extract the 'X-App-Request-Id' header if needed for reporting to DBE team + $appRequestId = $null + if ($_.Exception.Response -and $_.Exception.Response.Headers) { + $appRequestId = $_.Exception.Response.Headers.GetValues('X-App-Request-Id') + Set-Variable -Name 'DBPool_appRequestId' -Value $appRequestId -Scope Global -Force + Write-Debug "If you need to report an error to the DBE team, include this request ID which can be used to search through the application logs for messages that were logged while processing your request [ X-App-Request-Id: $appRequestId ]" + } + + switch -Wildcard ( $($exceptionError.Exception.Message) ) { + '*401*' { Write-Error 'Status 401 : Unauthorized. Invalid API key' } + '*404*' { Write-Error "Status 404 : [ $( $DBPool_base_URI + $resource_Uri ) ] not found!" } + '*429*' { Write-Error 'Status 429 : API rate limited' } + '*500*' { + $e = $($exceptionError.ErrorDetails.Message) + if ($null -ne $e) { + [string]$e = $( $e | ConvertFrom-Json -ErrorAction SilentlyContinue ).error.message + } + Write-Error "Status 500 : Internal Server Error. $e" + } + '*504*' { Write-Error "Status 504 : Gateway Timeout" } + default { Write-Error $_ } + } + } finally { + + $Auth = $DBPool_invokeParameters['headers']['X-App-Apikey'] + $DBPool_invokeParameters['headers']['X-App-Apikey'] = $Auth.Substring( 0, [Math]::Min($Auth.Length, 9) ) + '*******' + + } + + + if($allPages){ + + #Making output consistent + if( [string]::IsNullOrEmpty($all_responseData.data) ){ + $api_Response = $null + } + else{ + $api_Response = [PSCustomObject]@{ + pagination = $null + items = $all_responseData + } + } + + # Return the response + $api_Response + + } + else{ $api_Response } + + } + + end { + # Variables to remove + $var = @( + 'api_Key', + 'parameters', + 'Auth' + ) + foreach ($v in $var) { + Remove-Variable -Name $v -ErrorAction SilentlyContinue -Force + } + } + +} +#EndRegion + +#Region +function Add-DBPoolApiKey { +<# + .SYNOPSIS + Sets the API key for the DBPool. + + .DESCRIPTION + The Add-DBPoolApiKey cmdlet sets the API key which is used to authenticate API calls made to DBPool. + + Once the API key is defined, the secret key is encrypted using SecureString. + + The DBPool API key is retrieved via the DBPool UI at My Profile -> API key + + .PARAMETER ApiKey + Defines your API key for the DBPool. + + .PARAMETER Force + Forces the setting of the DBPool API key. + + .INPUTS + [SecureString] - The API key for the DBPool. + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Add-DBPoolApiKey + + Prompts to enter in your personal API key. + + .EXAMPLE + Add-DBPoolApiKey -ApiKey $secureString + Read-Host "Enter your DBPool API Key" -AsSecureString | Add-DBPoolApiKey + + Sets the API key for the DBPool. + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Add-DBPoolApiKey/ +#> + + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + [Alias("Set-DBPoolApiKey")] + [OutputType([void])] + param ( + [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "API Key for authorization to DBPool.")] + [ValidateNotNullOrEmpty()] + [securestring]$apiKey, + + [switch]$Force + ) + + begin {} + + process { + + if ($Force -or $PSCmdlet.ShouldProcess("Name: DBPool_ApiKey Value: $apiKey", 'Set variable')) { + Write-Verbose 'Setting the DBPool API Key.' + Set-Variable -Name 'DBPool_ApiKey' -Value $apiKey -Option ReadOnly -Scope Global -Force -Confirm:$false + } + + } + + end {} +} +#EndRegion + +#Region +function Get-DBPoolApiKey { +<# + .SYNOPSIS + Gets the DBPool API key global variable. + + .DESCRIPTION + The Get-DBPoolApiKey cmdlet gets the DBPool API key global variable and returns this as an object. + + .PARAMETER AsPlainText + Decrypt and return the API key in plain text. + + .INPUTS + N/A + + .OUTPUTS + [PSCustomObject] - The DBPool API key global variable. + + .EXAMPLE + Get-DBPoolApiKey + + Gets the DBPool API key global variable and returns this as an object with the secret key as a SecureString. + + .EXAMPLE + Get-DBPoolApiKey -AsPlainText + + Gets the DBPool API key global variable and returns this as an object with the secret key as plain text. + + + .NOTES + N\A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Get-DBPoolApiKey/ +#> + + [cmdletbinding()] + [OutputType([PSCustomObject])] + Param ( + [Parameter( Mandatory = $false )] + [Switch]$AsPlainText + ) + + begin {} + + process { + + try { + + if ($DBPool_ApiKey) { + + if ($AsPlainText) { + if ($isWindows -or $PSEdition -eq 'Desktop') { + $ApiKeyBSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($DBPool_ApiKey) + try { + $ApiKeyPlainText = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($ApiKeyBSTR) + [PSCustomObject]@{ + "ApiKey" = $ApiKeyPlainText + } + } finally { + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ApiKeyBSTR) + } + } else { + $ApiKeyPlainText = ConvertFrom-SecureString -SecureString $DBPool_ApiKey -AsPlainText + + [PSCustomObject]@{ + "ApiKey" = $ApiKeyPlainText + } + } + + $ApiKeyPlainText = $null + + } else { + [PSCustomObject]@{ + "ApiKey" = $DBPool_ApiKey + } + } + + } else { + Write-Warning "The DBPool API [ secret ] key is not set. Run Add-DBPoolApiKey to set the API key." + } + + } catch { + Write-Error $_ + } finally { + if ($ApiKeyBSTR) { + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ApiKeyBSTR) + } + } + + } + + end {} +} +#EndRegion + +#Region +function Remove-DBPoolApiKey { +<# + .SYNOPSIS + Removes the DBPool API Key global variable. + + .DESCRIPTION + The Remove-DBPoolAPIKey cmdlet removes the DBPool API Key global variable. + + .PARAMETER Force + Forces the removal of the DBPool API Key global variable without prompting for confirmation. + + .INPUTS + N/A + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Remove-DBPoolAPIKey + + Removes the DBPool API Key global variable. + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Remove-DBPoolApiKey/ +#> + + [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'Low')] + [OutputType([void])] + Param ( + [switch]$Force + ) + + begin {} + + process { + + switch ([bool]$DBPool_ApiKey) { + $true { + if ($Force -or $PSCmdlet.ShouldProcess('DBPool_ApiKey', 'Remove variable')) { + Write-Verbose 'Removing the DBPool API Key.' + try { + Remove-Variable -Name 'DBPool_ApiKey' -Scope Global -Force + } + catch { + Write-Error $_ + } + } + } + $false { + Write-Warning "The DBPool API [ secret ] key is not set. Nothing to remove" + } + } + + } + + end {} + +} +#EndRegion + +#Region +function Test-DBPoolApiKey { +<# + .SYNOPSIS + Test the DBPool API Key. + + .DESCRIPTION + The Test-DBPoolApiKey cmdlet tests the base URI & API Key that were defined in the Add-DBPoolBaseURI & Add-DBPoolAPIKey cmdlets. + + .PARAMETER base_uri + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. + + The default base URI is https://dbpool.datto.net/api + + .INPUTS + [string] - base_uri + + .OUTPUTS + [PSCustomObject] - Various API metadata values + + .EXAMPLE + Test-DBPoolApiKey + + Tests the base URI & API key that was defined in the Add-DBPoolBaseURI & Add-DBPoolAPIKey cmdlets. + + The default full base uri test path is: + https://dbpool.datto.net/api/v2/self + + .EXAMPLE + Test-DBPoolApiKey -base_uri http://dbpool.example.com + + Tests the base URI & API key that was defined in the Add-DBPoolBaseURI & Add-DBPoolAPIKey cmdlets. + + The full base uri test path in this example is: + http://dbpool.example.com/api/v2/self + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Test-DBPoolApiKey/ +#> + + [cmdletbinding()] + [OutputType([PSCustomObject])] + Param ( + [parameter( Position = 0, Mandatory = $false, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Define the base URI for the DBPool connection. Default is Datto's DBPool URI or set a custom URI." )] + [string]$base_uri = $DBPool_Base_URI + ) + + begin { $resource_uri = "/api/v2/self" } + + process { + + try { + + $api_key = $(Get-DBPoolApiKey -AsPlainText).'ApiKey' + $DBPool_Headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" + + $DBPool_Headers.Add("Content-Type", 'application/json') + $DBPool_Headers.Add('X-App-Apikey', $api_key) + + $rest_output = Invoke-WebRequest -method Get -uri ($base_uri + $resource_uri) -headers $DBPool_Headers -ErrorAction Stop + } + catch { + + [PSCustomObject]@{ + Method = $_.Exception.Response.Method + StatusCode = $_.Exception.Response.StatusCode.value__ + StatusDescription = $_.Exception.Response.StatusDescription + Message = $_.Exception.Message + URI = $($DBPool_Base_URI + $resource_uri) + "Response Header 'X-App-Request-Id'" = [string]($_.Exception.Response.Headers.GetValues('X-App-Request-Id')) + } + + } + finally { + Remove-Variable -Name DBPool_Headers -Force + } + + if ($rest_output){ + $data = @{} + $data = $rest_output + + [PSCustomObject]@{ + StatusCode = $data.StatusCode + StatusDescription = $data.StatusDescription + URI = $($DBPool_Base_URI + $resource_uri) + } + } + + } + + end {} + +} +#EndRegion + +#Region +function Add-DBPoolBaseURI { +<# + .SYNOPSIS + Sets the base URI for the DBPool API connection. + + .DESCRIPTION + The Add-DBPoolBaseURI cmdlet sets the base URI which is later used + to construct the full URI for all API calls. + + .PARAMETER base_uri + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. + + .PARAMETER instance + DBPool's URI connection point that can be one of the predefined data centers. + + The accepted values for this parameter are: + [ DEFAULT ] + DEFAULT = https://dbpool.datto.net + + Placeholder for other data centers. + + .INPUTS + [string] - The base URI for the DBPool API connection. + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Add-DBPoolBaseURI + + The base URI will use https://dbpool.datto.net which is Datto's default DBPool URI. + + .EXAMPLE + Add-DBPoolBaseURI -instance Datto + + The base URI will use https://dbpool.datto.net which is DBPool's default URI. + + .EXAMPLE + Add-DBPoolBaseURI -base_uri http://dbpool.example.com + + A custom API gateway of http://dbpool.example.com will be used for all API calls to DBPool's API. + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Add-DBPoolBaseURI/ +#> + + [cmdletbinding()] + [OutputType([void])] + [Alias("Set-DBPoolBaseURI")] + Param ( + [Parameter(Mandatory = $false , ValueFromPipeline = $true)] + [ValidateNotNullOrEmpty()] + [string]$base_uri = 'https://dbpool.datto.net', + + [ValidateSet('Datto')] + [String]$instance + ) + + begin {} + + process { + + # Trim superfluous forward slash from address (if applicable) + $base_uri = $base_uri.TrimEnd('/') + + switch ($instance) { + 'Datto' { $base_uri = 'https://dbpool.datto.net' } + } + + Set-Variable -Name "DBPool_Base_URI" -Value $base_uri -Option ReadOnly -Scope Global -Force + Write-Verbose "DBPool Base URI set to `'$base_uri`'." + + } + + end {} + +} +#EndRegion + +#Region +function Get-DBPoolBaseURI { +<# + .SYNOPSIS + Shows the DBPool base URI global variable. + + .DESCRIPTION + The Get-DBPoolBaseURI cmdlet shows the DBPool base URI global variable value. + + .INPUTS + N/A + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Get-DBPoolBaseURI + + Shows the DBPool base URI global variable value. + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Get-DBPoolBaseURI/ +#> + + [cmdletbinding()] + [OutputType([void])] + Param () + + begin {} + + process { + + switch ([bool]$DBPool_Base_URI) { + $true { $DBPool_Base_URI } + $false { Write-Warning "The DBPool base URI is not set. Run Add-DBPoolBaseURI to set the base URI." } + } + + } + + end {} + +} +#EndRegion + +#Region +function Remove-DBPoolBaseURI { +<# + .SYNOPSIS + Removes the DBPool base URI global variable. + + .DESCRIPTION + The Remove-DBPoolBaseURI cmdlet removes the DBPool base URI global variable. + + .PARAMETER Force + Forces the removal of the DBPool base URI global variable without prompting for confirmation. + + .INPUTS + N/A + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Remove-DBPoolBaseURI + + Removes the DBPool base URI global variable. + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Remove-DBPoolBaseURI/ +#> + + [cmdletbinding(SupportsShouldProcess)] + [OutputType([void])] + Param () + + begin {} + + process { + + switch ([bool]$DBPool_Base_URI) { + $true { Remove-Variable -Name "DBPool_Base_URI" -Scope Global -Force } + $false { Write-Warning "The DBPool base URI variable is not set. Nothing to remove" } + } + + } + + end {} + +} +#EndRegion + +#Region +function Export-DBPoolModuleSetting { +<# + .SYNOPSIS + Exports the DBPool BaseURI, API Key, & JSON configuration information to file. + + .DESCRIPTION + The Export-DBPoolModuleSetting cmdlet exports the DBPool BaseURI, API Key, & JSON configuration information to file. + + Making use of PowerShell's System.Security.SecureString type, exporting module settings encrypts your API key in a format + that can only be unencrypted with the your Windows account as this encryption is tied to your user principal. + This means that you cannot copy your configuration file to another computer or user account and expect it to work. + + .PARAMETER DBPoolConfPath + Define the location to store the DBPool configuration file. + + By default the configuration file is stored in the following location: + $env:USERPROFILE\DBPoolAPI + + .PARAMETER DBPoolConfFile + Define the name of the DBPool configuration file. + + By default the configuration file is named: + config.psd1 + + .INPUTS + N/A + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Export-DBPoolModuleSetting + + Validates that the BaseURI, API Key, and JSON depth are set then exports their values + to the current user's DBPool configuration file located at: + $env:USERPROFILE\DBPoolAPI\config.psd1 + + .EXAMPLE + Export-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -DBPoolConfFile MyConfig.psd1 + + Validates that the BaseURI, API Key, and JSON depth are set then exports their values + to the current user's DBPool configuration file located at: + C:\DBPoolAPI\MyConfig.psd1 + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Export-DBPoolModuleSetting/ +#> + + [CmdletBinding(DefaultParameterSetName = 'set')] + [OutputType([void])] + Param ( + [Parameter(ParameterSetName = 'set')] + [string]$DBPoolConfPath = $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ), + + [Parameter(ParameterSetName = 'set')] + [string]$DBPoolConfFile = 'config.psd1' + ) + + begin {} + + process { + + if (-not ($IsWindows -or $PSEdition -eq 'Desktop') ) { + Write-Warning "Secrets are stored using Windows Data Protection API (DPAPI)" + Write-Warning "DPAPI provides user context encryption in Windows but NOT in other operating systems like Linux or UNIX. It is recommended to use a more secure & cross-platform storage method" + } + + $DBPoolConfig = Join-Path -Path $DBPoolConfPath -ChildPath $DBPoolConfFile + + # Confirm variables exist and are not null before exporting + if ($DBPool_Base_URI -and $DBPool_ApiKey -and $DBPool_JSON_Conversion_Depth) { + $secureString = $DBPool_ApiKey | ConvertFrom-SecureString + + if ($IsWindows -or $PSEdition -eq 'Desktop') { + New-Item -Path $DBPoolConfPath -ItemType Directory -Force | ForEach-Object { $_.Attributes = $_.Attributes -bor "Hidden" } + } else { + New-Item -Path $DBPoolConfPath -ItemType Directory -Force + } +@" + @{ + DBPool_Base_URI = '$DBPool_Base_URI' + DBPool_ApiKey = '$secureString' + DBPool_JSON_Conversion_Depth = '$DBPool_JSON_Conversion_Depth' + } +"@ | Out-File -FilePath $DBPoolConfig -Force + Write-Verbose "DBPool Module settings exported to [ $DBPoolConfig ]" + } else { + Write-Error "Failed to export DBPool Module settings to [ $DBPoolConfig ]" + Write-Error $_ -ErrorAction Stop + } + + } + + end {} + +} +#EndRegion + +#Region +function Get-DBPoolModuleSetting { +<# + .SYNOPSIS + Gets the saved DBPool configuration settings + + .DESCRIPTION + The Get-DBPoolModuleSetting cmdlet gets the saved DBPool configuration settings + from the local system. + + By default the configuration file is stored in the following location: + $env:USERPROFILE\DBPoolAPI + + .PARAMETER DBPoolConfPath + Define the location to store the DBPool configuration file. + + By default the configuration file is stored in the following location: + $env:USERPROFILE\DBPoolAPI + + .PARAMETER DBPoolConfFile + Define the name of the DBPool configuration file. + + By default the configuration file is named: + config.psd1 + + .PARAMETER openConfFile + Opens the DBPool configuration file + + .INPUTS + N/A + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Get-DBPoolModuleSetting + + Gets the contents of the configuration file that was created with the + Export-DBPoolModuleSetting + + The default location of the DBPool configuration file is: + $env:USERPROFILE\DBPoolAPI\config.psd1 + + .EXAMPLE + Get-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -DBPoolConfFile MyConfig.psd1 -openConfFile + + Opens the configuration file from the defined location in the default editor + + The location of the DBPool configuration file in this example is: + C:\DBPoolAPI\MyConfig.psd1 + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Get-DBPoolModuleSetting/ +#> + + [CmdletBinding(DefaultParameterSetName = 'index')] + [OutputType([void])] + Param ( + [Parameter(Mandatory = $false, ParameterSetName = 'index')] + [string]$DBPoolConfPath = $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ), + + [Parameter(Mandatory = $false, ParameterSetName = 'index')] + [String]$DBPoolConfFile = 'config.psd1', + + [Parameter(Mandatory = $false, ParameterSetName = 'show')] + [Switch]$openConfFile + ) + + begin { + $DBPoolConfig = Join-Path -Path $DBPoolConfPath -ChildPath $DBPoolConfFile + } + + process { + + if ( Test-Path -Path $DBPoolConfig ){ + + if($openConfFile){ + Invoke-Item -Path $DBPoolConfig + } + else{ + Import-LocalizedData -BaseDirectory $DBPoolConfPath -FileName $DBPoolConfFile + } + + } + else{ + Write-Verbose "No configuration file found at [ $DBPoolConfig ]" + } + + } + + end {} + +} +#EndRegion + +#Region +function Import-DBPoolModuleSetting { +<# + .SYNOPSIS + Imports the DBPool BaseURI, API Key, & JSON configuration information to the current session. + + .DESCRIPTION + The Import-DBPoolModuleSetting cmdlet imports the DBPool BaseURI, API Key, & JSON configuration + information stored in the DBPool configuration file to the users current session. + + By default the configuration file is stored in the following location: + $env:USERPROFILE\DBPoolAPI + + .PARAMETER DBPoolConfPath + Define the location to store the DBPool configuration file. + + By default the configuration file is stored in the following location: + $env:USERPROFILE\DBPoolAPI + + .PARAMETER DBPoolConfFile + Define the name of the DBPool configuration file. + + By default the configuration file is named: + config.psd1 + + .INPUTS + N/A + + .OUTPUTS + N/A + + .EXAMPLE + Import-DBPoolModuleSetting + + Validates that the configuration file created with the Export-DBPoolModuleSetting cmdlet exists + then imports the stored data into the current users session. + + The default location of the DBPool configuration file is: + $env:USERPROFILE\DBPoolAPI\config.psd1 + + .EXAMPLE + Import-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -DBPoolConfFile MyConfig.psd1 + + Validates that the configuration file created with the Export-DBPoolModuleSetting cmdlet exists + then imports the stored data into the current users session. + + The location of the DBPool configuration file in this example is: + C:\DBPoolAPI\MyConfig.psd1 + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Import-DBPoolModuleSetting/ +#> + + [CmdletBinding(DefaultParameterSetName = 'set')] + Param ( + [Parameter(ParameterSetName = 'set')] + [string]$DBPoolConfPath = $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ), + + [Parameter(ParameterSetName = 'set')] + [string]$DBPoolConfFile = 'config.psd1' + ) + + begin { + $DBPoolConfig = Join-Path -Path $DBPoolConfPath -ChildPath $DBPoolConfFile + } + + process { + + if ( Test-Path $DBPoolConfig ) { + $tmp_config = Import-LocalizedData -BaseDirectory $DBPoolConfPath -FileName $DBPoolConfFile + + # Send to function to strip potentially superfluous slash (/) + Add-DBPoolBaseURI $tmp_config.DBPool_Base_URI + + $tmp_config.DBPool_ApiKey = ConvertTo-SecureString $tmp_config.DBPool_ApiKey + + Set-Variable -Name "DBPool_ApiKey" -Value $tmp_config.DBPool_ApiKey -Option ReadOnly -Scope global -Force + + Set-Variable -Name "DBPool_JSON_Conversion_Depth" -Value $tmp_config.DBPool_JSON_Conversion_Depth -Scope global -Force + + Write-Verbose "DBPoolAPI Module configuration loaded successfully from [ $DBPoolConfig ]" + + # Clean things up + Remove-Variable "tmp_config" + } + else { + Write-Verbose "No configuration file found at [ $DBPoolConfig ] run 'Add-DBPoolAPIKey' to get started." + + Add-DBPoolBaseURI + + Set-Variable -Name "DBPool_Base_URI" -Value $(Get-DBPoolBaseURI) -Option ReadOnly -Scope global -Force + Set-Variable -Name "DBPool_JSON_Conversion_Depth" -Value 100 -Scope global -Force + } + + } + + end {} + +} +#EndRegion + +#Region +# Used to auto load either baseline settings or saved configurations when the module is imported +Import-DBPoolModuleSetting -Verbose:$false +#EndRegion + +#Region +function Remove-DBPoolModuleSetting { +<# + .SYNOPSIS + Removes the stored DBPool configuration folder. + + .DESCRIPTION + The Remove-DBPoolModuleSetting cmdlet removes the DBPool folder and its files. + This cmdlet also has the option to remove sensitive DBPool variables as well. + + By default configuration files are stored in the following location and will be removed: + $env:USERPROFILE\DBPoolAPI + + .PARAMETER DBPoolConfPath + Define the location of the DBPool configuration folder. + + By default the configuration folder is located at: + $env:USERPROFILE\DBPoolAPI + + .PARAMETER andVariables + Define if sensitive DBPool variables should be removed as well. + + By default the variables are not removed. + + .INPUTS + N/A + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Remove-DBPoolModuleSetting + + Checks to see if the default configuration folder exists and removes it if it does. + + The default location of the DBPool configuration folder is: + $env:USERPROFILE\DBPoolAPI + + .EXAMPLE + Remove-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -andVariables + + Checks to see if the defined configuration folder exists and removes it if it does. + If sensitive DBPool variables exist then they are removed as well. + + The location of the DBPool configuration folder in this example is: + C:\DBPoolAPI + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Remove-DBPoolModuleSetting/ +#> + + [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'set')] + [OutputType([void])] + Param ( + [Parameter(ParameterSetName = 'set')] + [string]$DBPoolConfPath = $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ), + + [Parameter(ParameterSetName = 'set')] + [switch]$andVariables + ) + + begin {} + + process { + + if (Test-Path $DBPoolConfPath) { + + Remove-Item -Path $DBPoolConfPath -Recurse -Force -WhatIf:$WhatIfPreference + + If ($andVariables) { + Remove-DBPoolAPIKey + Remove-DBPoolBaseURI + } + + if (!(Test-Path $DBPoolConfPath)) { + Write-Verbose "The DBPoolAPI configuration folder has been removed successfully from [ $DBPoolConfPath ]" + } + else { + Write-Error "The DBPoolAPI configuration folder could not be removed from [ $DBPoolConfPath ]" + } + + } + else { + Write-Warning "No configuration folder found at [ $DBPoolConfPath ]" + } + + } + + end {} + +} +#EndRegion + +#Region +#EndRegion + +#Region +function Get-DBPoolContainer { + <# + .SYNOPSIS + The Get-DBPoolContainer function retrieves container information from the DBPool API. + + .DESCRIPTION + This function retrieves container details from the DBPool API. + + It can get containers, parent containers, or child containers, and also retrieve containers or container status by ID. + This also can filter or exclude by container name or database. + + .PARAMETER Id + The ID of the container details to get from the DBPool. + + .PARAMETER Status + Gets the status of a container by ID. + Returns basic container details, and dockerContainerRunning, mysqlServiceResponding, and mysqlServiceRespondingCached statuses. + + .PARAMETER ListContainer + Retrieves a list of containers from the DBPool API. This is the default parameter set. + + .PARAMETER ParentContainer + Retrieves a list of parent containers from the DBPool API. + + .PARAMETER ChildContainer + Retrieves a list of child containers from the DBPool API. + + .PARAMETER Name + Filters containers returned from the DBPool API by name. + Accepts wildcard input. + + .PARAMETER DefaultDatabase + Filters containers returned from the DBPool API by database. + Accepts wildcard input. + + .PARAMETER NotLike + Excludes containers returned from the DBPool API by Name or DefaultDatabase using the -NotLike switch. + Requires the -Name or -DefaultDatabase parameter to be specified. + + Returns containers where the Name or DefaultDatabase does not match the provided filter. + + .INPUTS + [int] - Id + The ID of the container to get details for. + + [string] Name + The name of the container to get details for. + + [string] - DefaultDatabase + The database of the container to get details for. + + .OUTPUTS + [PSCustomObject] - The response from the DBPool API. + + .EXAMPLE + Get-DBPoolContainer + + Get a list of all containers from the DBPool API + + .EXAMPLE + Get-DBPoolContainer -Id 12345 + + Get a list of containers from the DBPool API by ID + + .EXAMPLE + Get-DBPoolContainer -Status + + Get the status of all containers from the DBPool API + + .EXAMPLE + Get-DBPoolContainer -Status -Id 12345, 67890 + + Get the status of an array of containers by IDs + + .EXAMPLE + Get-DBPoolContainer -ParentContainer + + Get a list of parent containers from the DBPool API + + .EXAMPLE + Get-DBPoolContainer -ParentContainer -Id 12345 + + Get a list of parent containers from the DBPool API by ID + + .EXAMPLE + Get-DBPoolContainer -ChildContainer + + Get a list of child containers from the DBPool API + + .EXAMPLE + Get-DBPoolContainer -Name 'MyContainer' + Get-DBPoolContainer -ParentContainer -Name 'ParentContainer*' + + Uses 'Where-Object' to get a list of containers from the DBPool API, or parent containers by name + Accepts wildcard input + + .EXAMPLE + Get-DBPoolContainer -Name 'MyContainer' -NotLike + Get-DBPoolContainer -ParentContainer -Name 'ParentContainer*' -NotLike + + Uses 'Where-Object' to get a list of containers from the DBPool API, or parent containers where the name does not match the filter + Accepts wildcard input + + .EXAMPLE + Get-DBPoolContainer -DefaultDatabase 'Database' + Get-DBPoolContainer -ParentContainer -DefaultDatabase 'Database*' + + Get a list of containers from the DBPool API, or parent containers by database + Accepts wildcard input + + .EXAMPLE + Get-DBPoolContainer -DefaultDatabase 'Database' -NotLike + Get-DBPoolContainer -ParentContainer -DefaultDatabase 'Database*' -NotLike + + Get a list of containers from the DBPool API, or parent containers where the database does not match the filter + Accepts wildcard input + + .NOTES + The -Name, and -DefaultDatabase parameters are not native endpoints of the DBPool API. + This is a custom function which uses 'Where-Object', along with the optional -NotLike parameter to return the response using the provided filter. + + If no match is found an error is output, and the original response is returned. + + Equivalent API endpoint: + - GET /api/v2/containers + - GET /api/v2/parents + - GET /api/v2/children + - GET /api/v2/containers/{id} + - GET /api/v2/containers/{id}/status + + .LINK + https://datto-dbpool-api.kentsapp.com/Containers/Get-DBPoolContainer/ +#> + + [CmdletBinding(DefaultParameterSetName = 'ListContainer')] + [OutputType([PSCustomObject])] + param ( + [Parameter(ParameterSetName = 'ListContainer')] + [switch]$ListContainer, + + [Parameter(ParameterSetName = 'ParentContainer')] + [switch]$ParentContainer, + + [Parameter(ParameterSetName = 'ChildContainer')] + [switch]$ChildContainer, + + [Parameter(ParameterSetName = 'ParentContainer', Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Parameter(ParameterSetName = 'ListContainer', Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Parameter(ParameterSetName = 'ContainerStatus', Mandatory = $false, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + #[ValidateRange(0, [int]::MaxValue)] + [int[]]$Id, + + [Parameter(ParameterSetName = 'ContainerStatus')] + [switch]$Status, + + [Parameter(ParameterSetName = 'ListContainer', ValueFromPipelineByPropertyName = $true)] + [Parameter(ParameterSetName = 'ParentContainer', ValueFromPipelineByPropertyName = $true)] + [SupportsWildcards()][string[]]$Name, + + [Parameter(ParameterSetName = 'ListContainer', ValueFromPipelineByPropertyName = $true)] + [Parameter(ParameterSetName = 'ParentContainer', ValueFromPipelineByPropertyName = $true)] + [Alias('Database')] + [SupportsWildcards()][string[]]$DefaultDatabase, + + [Parameter(ParameterSetName = 'ListContainer')] + [Parameter(ParameterSetName = 'ParentContainer')] + [switch]$NotLike + ) + + begin { + + $method = 'GET' + switch ($PSCmdlet.ParameterSetName) { + 'ListContainer' { $requestPath = '/api/v2/containers' } + 'ParentContainer' { $requestPath = '/api/v2/parents' } + 'ChildContainer' { $requestPath = '/api/v2/children' } + 'ContainerStatus' { $requestPath = '/api/v2/containers' } + } + + # Validate filter parameters for name or DefaultDatabase if -NotLike switch is used + if ($PSCmdlet.ParameterSetName -eq 'ListContainer' -or $PSCmdlet.ParameterSetName -eq 'ParentContainer') { + if ($NotLike -and -not ($Name -or $DefaultDatabase)) { + Write-Error 'The -NotLike switch requires either the -Name or -DefaultDatabase parameter to be specified.' -ErrorAction Stop + } + } + + # Internal Function to filter the response by Container Name or DefaultDatabase if provided + function Select-DBPoolContainer { + param( + [Parameter(Mandatory = $true, ValueFromPipeline = $true)] + [PSObject[]]$Container, + + [Parameter(Mandatory = $false)] + [string[]]$Name, + + [Parameter(Mandatory = $false)] + [string[]]$DefaultDatabase, + + [Parameter(Mandatory = $false)] + [switch]$NotLike + ) + + process { + # Verbose filter output + $Filter = @() + $filterParameter = @() + + if ($Name) { + $Filter += 'Name' + $filterParameter += ($Name -join ', ') + } + if ($DefaultDatabase) { + $Filter += 'DefaultDatabase' + $filterParameter += ($DefaultDatabase -join ', ') + } + + $filterHeader = $Filter -join '; ' + $filterValues = @() + + if ($Name) { + $filterValues += ($Name -join ', ') + } + if ($DefaultDatabase) { + $filterValues += ($DefaultDatabase -join ', ') + } + + if ($NotLike) { + Write-Verbose "Excluding response by containers matching $filterHeader [ $($filterValues -join '; ') ]" + } else { + Write-Verbose "Filtering response by containers matching $filterHeader [ $($filterValues -join '; ') ]" + } + + # Filter containers + $FilteredContainers = $Container | Where-Object { + $matchesName = $true + $matchesDB = $true + + # Handle Name filtering + if ($Name) { + $matchesName = $false + foreach ($n in $Name) { + if ($_.name -like $n) { + $matchesName = $true + break + } + } + if ($NotLike) { + $matchesName = -not $matchesName + } + } + + # Handle DefaultDatabase filtering + if ($DefaultDatabase) { + $matchesDB = $false + foreach ($db in $DefaultDatabase) { + if ($_.defaultDatabase -like $db) { + $matchesDB = $true + break + } + } + if ($NotLike) { + $matchesDB = -not $matchesDB + } + } + + # Return true if both conditions match + $matchesName -and $matchesDB + } + + # Output filtered containers + if (!$FilteredContainers) { + Write-Warning "No containers found matching the $filterHeader filter parameter [ $($filterValues -join '; ') ]. Returning all containers." + return $Container + } + + return $FilteredContainers + } + } + + } + + process { + + # Get list of containers by ID + if ($PSBoundParameters.ContainsKey('Id')) { + $response = foreach ($n in $Id) { + $requestResponse = $null + Write-Verbose "Running the [ $($PSCmdlet.ParameterSetName) ] parameter set for ID $n" + + # Define the ContainerStatus parameter request path if set + $uri = "$requestPath/$n" + if ($Status) { + $uri += '/status' + } + + try { + $requestResponse = Invoke-DBPoolRequest -method $method -resource_Uri $uri -ErrorAction Stop + if ($null -ne $requestResponse) { + $requestResponse | ConvertFrom-Json + } + } catch { + Write-Error $_ + continue + } + + } + # Get list of containers based on the parameter set, returns all listed containers + } else { + Write-Verbose "Running the [ $($PSCmdlet.ParameterSetName) ] parameter set" + + try { + $requestResponse = Invoke-DBPoolRequest -method $method -resource_Uri $requestPath -ErrorAction Stop + # Convert the response to JSON, return the response based on the parameter set + if ($null -ne $requestResponse) { + $response = $requestResponse | ConvertFrom-Json + + if ($PSCmdlet.ParameterSetName -eq 'ParentContainer') { + $response = $response.parents + } elseif ($PSCmdlet.ParameterSetName -eq 'ListContainer') { + $response = $response.containers + } elseif ($PSCmdlet.ParameterSetName -eq 'ContainerStatus') { + foreach ($container in $($response.containers | Sort-Object -Property Name)) { + $requestResponse = $null + Write-Verbose "Running the [ $($PSCmdlet.ParameterSetName) ] parameter set for Container Name: [ $($container.name) ] - ID: $($container.id)" + + $uri = "$requestPath/$($container.id)/status" + + try { + $requestResponse = Invoke-DBPoolRequest -method $method -resource_Uri $uri -ErrorAction Stop -Verbose:$false + if ($null -ne $requestResponse) { + $requestResponse | ConvertFrom-Json + } + } catch { + Write-Error $_ + Write-Warning "If you need to report an error to the DBE team, include this request ID which can be used to search through the application logs for messages that were logged while processing your request [ X-App-Request-Id: $DBPool_appRequestId ]" + continue + } + + } + } + } + } catch { + Write-Error $_ + } + + } + + + # Filter the response by Name or DefaultDatabase if provided using internal helper function + if ($null -ne $response -and ($PSBoundParameters.ContainsKey('Name') -or $PSBoundParameters.ContainsKey('DefaultDatabase'))) { + try { + $response = Select-DBPoolContainer -Container $response -Name $Name -DefaultDatabase $DefaultDatabase -NotLike:$NotLike -ErrorAction Stop + } catch { + Write-Error $_ + } + } + + # Return the response + $response + + } + + end {} + +} +#EndRegion + +#Region +function New-DBPoolContainer { +<# + .SYNOPSIS + The New-DBPoolContainer function is used to create a new container from the DBPool API. + + .DESCRIPTION + This function creates a new container in the DBPool based on the provided container name and parent container information. + The ContainerName parameter is mandatory, and at least one of the parent parameters (ParentId, ParentName, or ParentDefaultDatabase) must be specified. + + .PARAMETER ContainerName + The name for the new container. + + .PARAMETER ParentId + The ID of the parent container to clone. + + .PARAMETER ParentName + The name of the parent container to clone. + + .PARAMETER ParentDefaultDatabase + The default database of the parent container to clone. + + .PARAMETER Force + Force the operation without confirmation. + + .INPUTS + [string] - ContainerName + The name for the new container. + + [int] - ParentId + The ID of the parent container to clone. + + [string] - ParentName + The name of the parent container to clone. + + [string] - ParentDefaultDatabase + The default database of the parent container to clone. + + .OUTPUTS + [PSCustomObject] - The response from the DBPool API. + + .EXAMPLE + New-DBPoolContainer -ContainerName 'MyNewContainer' -ParentId 12345 + + This will create a new container named 'MyNewContainer' based on the parent container with ID 12345. + + .EXAMPLE + Get-DBPoolContainer -ParentContainer -Id 1 | New-DBPoolContainer -ContainerName 'MyNewContainer' + + This will create a new container named 'MyNewContainer' based on the piped in parent container. + + .NOTES + Equivalent API endpoint: + - POST /api/v2/containers + + .LINK + https://datto-dbpool-api.kentsapp.com/Containers/New-DBPoolContainer/ +#> + + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] + [OutputType([PSCustomObject])] + param ( + [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [string]$ContainerName, + + [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] + [ValidateRange(1, [int]::MaxValue)] + [Alias("Id")] + [int]$ParentId, + + [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] + [Alias("Name")] + [string]$ParentName, + + [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] + [Alias("DefaultDatabase")] + [string]$ParentDefaultDatabase, + + [Parameter(Mandatory = $false, DontShow = $true)] + [Switch]$Force + ) + + begin { + + $method = 'POST' + $requestPath = "/api/v2/containers" + $body = @{} + + } + + process { + + $body['name'] = $ContainerName + + # Check that at least one parent parameter is provided + # This is done rather than using parameter sets or mandatory parameters to allow for multiple parent parameters to be provided as API accepts multiple parent parameter inputs + # If multiple fields are specified, both conditions will have to match a parent for it to be selected. + if (-not ($PSBoundParameters.ContainsKey('ParentId') -or $PSBoundParameters.ContainsKey('ParentName') -or $PSBoundParameters.ContainsKey('ParentDefaultDatabase'))) { + Write-Error "At least one parent parameter (ParentId, ParentName, or ParentDefaultDatabase) must be provided." -ErrorAction Stop + } + + # Insert specified parent parameters into the request body + if ($PSBoundParameters.ContainsKey('ParentId')) { + $body.'parent.id' = $ParentId + } + if ($PSBoundParameters.ContainsKey('ParentName')) { + $body.'parent.name' = $ParentName + } + if ($PSBoundParameters.ContainsKey('ParentDefaultDatabase')) { + $body.'parent.defaultDatabase' = $ParentDefaultDatabase + } + + try { + if ($Force -or $PSCmdlet.ShouldProcess("Container Name: $ContainerName", "Create new Container")) { + $response = Invoke-DBPoolRequest -Method $method -resource_Uri $requestPath -data $body -ErrorAction Stop + } + + if ($null -ne $response) { + $response = $response | ConvertFrom-Json + } + } + catch { + Write-Error $_ + } + + # Return the response + $response + + } + + end {} + +} +#EndRegion + +#Region +function Remove-DBPoolContainer { + <# + .SYNOPSIS + The Remove-DBPoolContainer function is used to delete a container in the DBPool. + + .DESCRIPTION + The Remove-DBPoolContainer function is used to delete containers in the DBPool based on the provided container ID. + + !! This is a destructive operation and will destory the container !! + + .PARAMETER Id + The ID of the container to delete. + This accepts an array of integers. + + .PARAMETER Force + Forces the removal of the container without prompting for confirmation. + + .INPUTS + [int] - The ID of the container to delete. + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Remove-DBPoolContainer -Id '12345' + + This will delete the provided container by ID. + + .EXAMPLE + @( 12345, 56789 ) | Remove-DBPoolContainer -Confirm:$false + + This will delete the containers with ID 12345, and 56789. + + .NOTES + Equivalent API endpoint: + - DELETE /api/v2/containers/{id} + + .LINK + https://datto-dbpool-api.kentsapp.com/Containers/Remove-DBPoolContainer/ +#> + + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([void])] + param ( + [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [ValidateRange(1, [int]::MaxValue)] + [Alias('ContainerId')] + [int[]]$Id, + + [switch]$Force + ) + + begin { + + $method = 'DELETE' + + # Pass the InformationAction parameter if bound, default to 'Continue' + if ($PSBoundParameters.ContainsKey('InformationAction')) { + $InformationPreference = $PSBoundParameters['InformationAction'] + } else { + $InformationPreference = 'Continue' + } + + } + + process { + + foreach ($n in $Id) { + $response = $null + $requestPath = "/api/v2/containers/$n" + + # Try to get the container name to output for the ID when using the Verbose preference + if ($VerbosePreference -eq 'Continue') { + try { + $containerName = (Get-DBPoolContainer -Id $n -WarningAction SilentlyContinue -ErrorAction Stop -Verbose:$false).name + } catch { + Write-Warning "Failed to get the container name for ID $n. $_" + $containerName = '## FailedToGetContainerName ##' + } + } + + if ($Force -or $PSCmdlet.ShouldProcess("Container [ ID: $n ]", 'Destroy')) { + Write-Verbose "Destroying Container [ ID: $n, Name: $containerName ]" + + try { + $response = Invoke-DBPoolRequest -method $method -resource_Uri $requestPath -ErrorAction Stop + if ($response.StatusCode -eq 204) { + Write-Information "Success: Container [ ID: $n ] destroyed." + } + } catch { + Write-Error $_ + } + + } + } + + } + + end {} +} +#EndRegion + +#Region +function Rename-DBPoolContainer { + <# + .SYNOPSIS + The Rename-DBPoolContainer function is used to update a container in the DBPool. + + .DESCRIPTION + The Rename-DBPoolContainer function is used to change the name a container in the DBPool API. + + .PARAMETER Id + The ID of the container to update. + This accepts an array of integers. + + .PARAMETER Name + The new name for the container. + + .INPUTS + [int] - The ID of the container to update. + [string] - The new name for the container. + + .OUTPUTS + [PSCustomObject] - The response from the DBPool API. + + .EXAMPLE + Rename-DBPoolContainer -Id 12345 -Name 'NewContainerName' + + This will update the container with ID 12345 to have the name 'NewContainerName' + + .EXAMPLE + @( 12345, 56789 ) | Rename-DBPoolContainer -Name 'NewContainerName' + + This will update the containers with ID 12345, and 56789 to have the name 'NewContainerName' + + .NOTES + Equivalent API endpoint: + - PATCH /api/v2/containers/{id} + + .LINK + https://datto-dbpool-api.kentsapp.com/Containers/Rename-DBPoolContainer/ +#> + + [CmdletBinding()] + [OutputType([PSCustomObject])] + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [ValidateRange(1, [int]::MaxValue)] + [Alias('ContainerId')] + [int[]]$Id, + + [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [string]$Name + ) + + begin { + + $method = 'PATCH' + $body = @{ + name = $Name + } + + # Pass the InformationAction parameter if bound, default to 'Continue' + if ($PSBoundParameters.ContainsKey('InformationAction')) { + $InformationPreference = $PSBoundParameters['InformationAction'] + } else { + $InformationPreference = 'Continue' + } + + } + + process { + + foreach ($n in $Id) { + $requestResponse = $null + $requestPath = "/api/v2/containers/$n" + + # Try to get the container name to output for the ID when using the Verbose preference + if ($VerbosePreference -eq 'Continue') { + try { + $containerName = (Get-DBPoolContainer -Id $n -WarningAction SilentlyContinue -ErrorAction Stop -Verbose:$false).name + } catch { + Write-Warning "Failed to get the container name for ID $n. $_" + $containerName = '## FailedToGetContainerName ##' + } + } + + try { + Write-Verbose "Updating Container [ ID: $n, Name: $containerName ]" + $requestResponse = Invoke-DBPoolRequest -method $method -resource_Uri $requestPath -data $body -ErrorAction Stop + if ($requestResponse.StatusCode -eq 200) { + Write-Information "Successfully updated Container [ ID: $n ]" + } + if ($null -ne $requestResponse) { + $requestResponse | ConvertFrom-Json -ErrorAction Stop + } + } catch { + Write-Error $_ + } + + } + + } + + end {} +} +#EndRegion + +#Region +function Invoke-DBPoolContainerAccess { +<# + .SYNOPSIS + The Invoke-DBPoolContainerAccess function is used to interact with various container access operations in the Datto DBPool API. + + .DESCRIPTION + The Invoke-DBPoolContainerAccess function is used to Get, Add, or Remove access to a container in the Datto DBPool API based on a given username. + + .PARAMETER Id + The ID of the container to access. + This accepts an array of integers. + + .PARAMETER Username + The username to access the container. + This accepts an array of strings. + + .PARAMETER GetAccess + Gets the current access to a container by ID for the given username. + + .PARAMETER AddAccess + Adds access to a container by ID for the given username. + + .PARAMETER RemoveAccess + Removes access to a container by ID for the given username. + + .INPUTS + [int] - The ID of the container to access. + [string] - The username to access the container. + + .OUTPUTS + [PSCustomObject] - The response from the DBPool API. + [void] - No output is returned. + + .EXAMPLE + Invoke-DBPoolContainerAccess -Id '12345' -Username 'John.Doe' + Invoke-DBPoolContainerAccess -Id '12345' -Username 'John.Doe' -GetAccess + + This will get access to the container with ID 12345 for the user "John.Doe" + + .EXAMPLE + Invoke-DBPoolContainerAccess -Id @( '12345', '56789' ) -Username 'John.Doe' -AddAccess + + This will add access to the containers with ID 12345, and 56789 for the user "John.Doe" + + .EXAMPLE + Invoke-DBPoolContainerAccess -Id '12345' -Username @( 'Jane.Doe', 'John.Doe' ) -RemoveAccess + + This will remove access to the container with ID 12345 for the users "Jane.Doe", and "John.Doe" + + .NOTES + Equivalent API endpoint: + - GET /api/v2/containers/{id}/access/{username} + - PUT /api/v2/containers/{id}/access/{username} + - DELETE /api/v2/containers/{id}/access/{username} + + .LINK + https://datto-dbpool-api.kentsapp.com/Containers/access/Invoke-DBPoolContainerAccess/ +#> + + [CmdletBinding(DefaultParameterSetName = 'GetAccess', SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] + [OutputType([PSCustomObject], ParameterSetName = { 'GetAccess', 'AddAccess' })] + [OutputType([void], ParameterSetName = 'RemoveAccess')] + param ( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + #[ValidateRange(1, [int]::MaxValue)] + [Alias('ContainerId')] + [int[]]$Id, + + [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'GetAccess', ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'AddAccess', ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'RemoveAccess', ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [string[]]$Username, + + [Parameter(Mandatory = $false, ParameterSetName = 'GetAccess')] + [Switch]$GetAccess, + + [Parameter(Mandatory = $false, ParameterSetName = 'AddAccess')] + [Switch]$AddAccess, + + [Parameter(Mandatory = $false, ParameterSetName = 'RemoveAccess')] + [Switch]$RemoveAccess + ) + + begin { + + # Pass the InformationAction parameter if bound, default to 'Continue' + if ($PSBoundParameters.ContainsKey('InformationAction')) { + $InformationPreference = $PSBoundParameters['InformationAction'] + } else { + $InformationPreference = 'Continue' + } + + } + + process { + + $response = foreach ($n in $Id) { + foreach ($uName in $Username) { + $requestPath = "/api/v2/containers/$n/access/$uName" + $method = $null + $requestResponse = $null + $responseContent = $null + + switch ($PSCmdlet.ParameterSetName) { + 'GetAccess' { + $method = 'GET' + } + 'AddAccess' { + if ($PSCmdlet.ShouldProcess("[ $uName ] for Container [ ID: $n ]", "[ $($PSCmdlet.ParameterSetName) ]")) { + $method = 'PUT' + } + } + 'RemoveAccess' { + if ($PSCmdlet.ShouldProcess("[ $uName ] for Container [ ID: $n ]", "[ $($PSCmdlet.ParameterSetName) ]")) { + $method = 'DELETE' + } + } + } + + if ($method) { + + try { + $requestResponse = Invoke-DBPoolRequest -method $method -resource_Uri $requestPath -ErrorAction Stop + } + catch { + $requestResponse = $null + Write-Error $_ + } + + if ($null -ne $requestResponse) { + $responseContent = $requestResponse.Content | ConvertFrom-Json + } + + switch ($PSCmdlet.ParameterSetName) { + 'GetAccess' { + $responseContent + } + 'AddAccess' { + if ($requestResponse.StatusCode -eq 200) { + Write-Information "User access on Container [ ID: $n ] already exists for [ $uName ]" + } elseif ($requestResponse.StatusCode -eq 201) { + Write-Information "User access on Container [ ID: $n ] successfully created for [ $uName ]" + } + $responseContent + } + 'RemoveAccess' { + if ($requestResponse.StatusCode -eq 204) { + Write-Information "User access on Container [ ID: $n ] successfully removed for [ $uName ]" + } + $responseContent + } + } + } + } + } + + # Return the responses + $response + + } + + end {} + +} +#EndRegion + +#Region +function Invoke-DBPoolContainerAction { + <# + .SYNOPSIS + The Invoke-DBPoolContainerAction function is used to interact with various container action operations in the Datto DBPool API. + + .DESCRIPTION + The Invoke-DBPoolContainerAction function is used to perform actions on a container such as refresh, schema-merge, start, restart, or stop. + + .PARAMETER Id + The ID(s) of the container(s) to perform the action on. + + .PARAMETER Action + The action to perform on the container. Valid actions are: refresh, schema-merge, start, restart, or stop. + + Start, Stop, and Restart are all considered minor actions and will not require a confirmation prompt. + Refresh and Schema-Merge are considered major actions and will require a confirmation prompt. + + .PARAMETER Force + Skip the confirmation prompt for major actions, such as 'Refresh' and 'Schema-Merge'. + + .PARAMETER TimeoutSeconds + The maximum time in seconds to wait for the action to complete. Default is 3600 seconds (60 minutes). + + .PARAMETER ThrottleLimit + The maximum number of containers to process in parallel. Default is twice the number of processor cores. + + .INPUTS + [int] - The ID of the container to perform the action on. + [string] - The action to perform on the container. + + .OUTPUTS + [void] - No output is returned. + + .EXAMPLE + Invoke-DBPoolContainerAction -Action 'restart' -Id '12345' + + This will restart the container with ID 12345 + + .EXAMPLE + Invoke-DBPoolContainerAction refresh 12345,56789 + + This will refresh the containers with ID 12345, and 56789 + + .EXAMPLE + Invoke-DBPoolContainerAction -Action refresh -Id (Get-DBPoolContainer).Id -Force + + This will refresh all containers without prompting for confirmation. + + .NOTES + Equivalent API endpoint: + - POST /api/v2/containers/{id}/actions/{action} + + Actions: + + refresh: + Recreate the Docker container and ZFS snapshot for the container. + + schema-merge: + Attempt to apply upstream changes to the parent container to this child container. + This may break your container. Refreshing a container is the supported way to update a child container's database schema. + + start: + Start the Docker container for the container. + + restart: + Stop and start the Docker container. + + stop: + Stop the Docker container. + + .LINK + https://datto-dbpool-api.kentsapp.com/Containers/actions/Invoke-DBPoolContainerAction/ +#> + + [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] + [OutputType([void])] + param ( + [Parameter(Mandatory = $true, Position = 0)] + [ValidateSet('refresh', 'schema-merge', 'start', 'restart', 'stop', IgnoreCase = $false)] + [string]$Action, + + [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [ValidateRange(1, [int]::MaxValue)] + [Alias('ContainerId')] + [int[]]$Id, + + [switch]$Force, + + [Parameter(DontShow = $true)] + [ValidateRange(0, [int]::MaxValue)] + [int]$TimeoutSeconds = 3600, # Default timeout of 60 minutes (3600 seconds) for longer running actions + + [Parameter(DontShow = $true)] + [ValidateRange(1, [int]::MaxValue)] + [int]$ThrottleLimit = ([Environment]::ProcessorCount * 2) + ) + + begin { + + $method = 'POST' + + # Pass the InformationAction parameter if bound, default to 'Continue' + if ($PSBoundParameters.ContainsKey('InformationAction')) { + $InformationPreference = $PSBoundParameters['InformationAction'] + } else { + $InformationPreference = 'Continue' + } + + # Write warning when using deprecated 'schema-merge' action, otherwise set confirmation prompt for 'major' actions + if ($Action -eq 'schema-merge') { + Write-Warning 'The action [ schema-merge ] is deprecated! Use the [ refresh ] action as the supported way to update a container.' + $ConfirmPreference = 'Medium' + } elseif ($Action -eq 'refresh' -and -not $Force) { + $ConfirmPreference = 'Medium' + } + + $moduleName = $MyInvocation.MyCommand.Module.Name + if ([string]::IsNullOrEmpty($moduleName)) { + Write-Error 'This function is not loaded as part of a module or the module name is unavailable.' -ErrorAction Stop + } + $modulePath = (Get-Module -Name $moduleName).Path + + if ($Id.Count -gt 1) { + # Check if the ForEach-Object cmdlet supports the Parallel parameter + $supportsParallel = ((Get-Command ForEach-Object).Parameters.keys) -contains 'Parallel' + + # Create shared runspace pool for parallel tasks + if (!$supportsParallel) { + $runspacePool = [runspacefactory]::CreateRunspacePool(1, $ThrottleLimit) + $runspacePool.Open() + $runspaceQueue = [System.Collections.Concurrent.ConcurrentQueue[PSCustomObject]]::new() + } + } + + } + + process { + + if ($Id.Count -eq 1) { + # Process a single container ID without parallel processing + $n = $Id[0] + $requestPath = "/api/v2/containers/$n/actions/$Action" + + if ($Force -or $PSCmdlet.ShouldProcess("Container [ ID: $n ]", "[ $Action ]")) { + # Try to get the container name to output for the ID when using the Verbose preference + if ($VerbosePreference -eq 'Continue') { + try { + $containerName = (Get-DBPoolContainer -Id $n -WarningAction SilentlyContinue -ErrorAction Stop -Verbose:$false).name + } catch { + Write-Warning "Failed to get the container name for ID $n. $_" + $containerName = '## FailedToGetContainerName ##' + } + } + Write-Verbose "Performing action [ $Action ] on Container [ ID: $n, Name: $containerName ]" + + try { + $requestResponse = Invoke-DBPoolRequest -method $method -resource_Uri $requestPath -ErrorAction Stop + if ($requestResponse.StatusCode -eq 204) { + Write-Information "Success: Invoking Action [ $Action ] on Container [ ID: $n ]." + } + } catch { + Write-Error $_ + } + } + + } elseif ($supportsParallel) { + + $IdsToAction = [System.Collections.ArrayList]::new() + foreach ($n in $Id) { + if ($Force -or $PSCmdlet.ShouldProcess("Container [ ID: $n ]", "[ $Action ]")) { + $IdsToAction.Add($n) | Out-Null + } + } + + if ($IdsToAction.Count -gt 0) { + try { + $IdsToAction | ForEach-Object -Parallel { + $n = $_ + + Import-Module $using:modulePath + Add-DBPoolBaseURI -base_uri $using:DBPool_Base_URI + Add-DBPoolApiKey -apiKey $using:DBPool_ApiKey + + $requestPath = "/api/v2/containers/$n/actions/$using:Action" + + # Try to get the container name to output for the ID when using the Verbose preference + if ($using:VerbosePreference -eq 'Continue') { + try { + $containerName = (Get-DBPoolContainer -Id $n -WarningAction SilentlyContinue -ErrorAction Stop -Verbose:$false).name + } catch { + Write-Warning "Failed to get the container name for ID $n. $_" + $containerName = '## FailedToGetContainerName ##' + } + } + Write-Verbose "Performing action [ $using:Action ] on Container [ ID: $n, Name: $containerName ]" -Verbose:($using:VerbosePreference -eq 'Continue') + + try { + $requestResponse = Invoke-DBPoolRequest -method $using:method -resource_Uri $requestPath -ErrorAction Stop -WarningAction:SilentlyContinue + if ($requestResponse.StatusCode -eq 204) { + Write-Information "Success: Invoking Action [ $using:Action ] on Container [ ID: $n ]." + } + } catch { + Write-Error $_ + } + } -ThrottleLimit $ThrottleLimit -TimeoutSeconds $TimeoutSeconds + } catch { + Write-Error $_ + } + } + + } else { + # Process each container ID in parallel using runspaces where the ForEach-Object cmdlet does not support the Parallel parameter in Windows PowerShell 5.1 _(or version prior to [PowerShell 7.0](https://devblogs.microsoft.com/powershell/powershell-foreach-object-parallel-feature/))_ + # This is a manual implementation workaround of parallel processing using runspaces + # TODO: Refactor to use [Invoke-Parallel](https://github.com/RamblingCookieMonster/Invoke-Parallel), or [PSParallelPipeline](https://github.com/santisq/PSParallelPipeline) module for parallel processing for better performance optimization as current implementation appears to have high performance overheard + foreach ($n in $Id) { + $requestPath = "/api/v2/containers/$n/actions/$Action" + + if ($Force -or $PSCmdlet.ShouldProcess("Container [ ID: $n ]", "[ $Action ]")) { + # Try to get the container name to output for the ID when using the Verbose preference + if ($VerbosePreference -eq 'Continue') { + try { + $containerName = (Get-DBPoolContainer -Id $n -WarningAction SilentlyContinue -ErrorAction Stop -Verbose:$false).name + } catch { + Write-Warning "Failed to get the container name for ID $n. $_" + $containerName = '## FailedToGetContainerName ##' + } + } + Write-Verbose "Performing action [ $Action ] on Container [ ID: $n, Name: $containerName ]" + + $runspace = [powershell]::Create().AddScript({ + param ($method, $requestPath, $modulePath, $baseUri, $apiKey, $containerId) + + Import-Module $modulePath + Add-DBPoolBaseURI -base_uri $baseUri + Add-DBPoolApiKey -apiKey $apiKey + + $VerbosePreference = $VerbosePreference + + try { + $requestResponse = Invoke-DBPoolRequest -method $method -resource_Uri $requestPath -ErrorAction Stop + return [pscustomobject]@{ + Success = $true + StatusCode = $requestResponse.StatusCode + Content = $requestResponse.Content + ContainerId = $containerId + } + } catch { + return [pscustomobject]@{ + Success = $false + ErrorMessage = $_.Exception.Message + ErrorDetails = $_.Exception.ToString() + ContainerId = $containerId + } + } + }).AddArgument($method).AddArgument($requestPath).AddArgument($modulePath).AddArgument($DBPool_Base_URI).AddArgument($DBPool_ApiKey).AddArgument($n) + + $runspaceQueue.Enqueue([PSCustomObject]@{ Pipe = $runspace; ContainerId = $n; Status = $runspace.BeginInvoke(); StartTime = [datetime]::Now }) + } + } + + # Initialize sleep control variables + $sleepDuration = 1 # Initial sleep duration in seconds + $i = 0 # Counter to track iterations + $initialThreshold = 10 # Initial threshold to increase sleep duration + $maxSleepDuration = 60 # Maximum sleep duration in seconds + + # Process results as they complete or timeout + while ($runspaceQueue.Count -gt 0) { + $task = $null + while ($runspaceQueue.TryDequeue([ref]$task)) { + if ($task.Status.IsCompleted) { + $result = $task.Pipe.EndInvoke($task.Status) + $task.Pipe.Dispose() + + if ($result.Success) { + $statusCode = $result.StatusCode + if ($statusCode -eq 204) { + Write-Information "Success: Invoking Action [ $Action ] on Container [ ID: $($result.ContainerId) ]." + } else { + Write-Error "Failed: Status $statusCode. Response: $($result.Content)" + } + } else { + Write-Error "$($result.ErrorMessage)" + } + } elseif ($TimeoutSeconds -gt 0 -and $(([datetime]::Now - $task.StartTime).TotalSeconds) -ge $TimeoutSeconds) { + Write-Error "Action [ $Action ] on Container [ ID: $($task.ContainerId) ] exceeded timeout of $TimeoutSeconds seconds." + $task.Pipe.Stop() + $task.Pipe.Dispose() + } else { + # If task has neither completed nor timed out, re-enqueue it + $runspaceQueue.Enqueue($task) + } + } + + Start-Sleep -Seconds $sleepDuration + + # Increment the counter + $i++ + + # Check if the counter has reached the dynamic threshold + if ($i -ge $threshold) { + # Increase the sleep duration exponentially + $sleepDuration = [math]::Min($sleepDuration * 2, $maxSleepDuration) + # Increase the threshold linearly + $threshold += $initialThreshold + # Reset the counter + $i = 0 + } + } + + } + + } + + end { + + # Close and dispose of the runspace pool + if ($Id.Count -gt 1 -and !$supportsParallel) { + $runspacePool.Close() + $runspacePool.Dispose() + } + + } + +} +#EndRegion + +#Region +function Invoke-DBPoolDebug { +<# + .SYNOPSIS + Provides an example exception response from the DBPool API for debugging purposes. + + .DESCRIPTION + Uses the Invoke-DBPoolRequest function to make a request to the DBPool API. + Returns an example exception response for debugging and testing purposes. + + .PARAMETER method + The HTTP method to use when making the request to the DBPool API. + Default is 'GET'. + + .INPUTS + N/A + + .OUTPUTS + [System.Management.Automation.ErrorRecord] - Returns an example exception response from the DBPool API. + + .EXAMPLE + Invoke-DBPoolDebug -method GET + + Sends a 'GET' request to the DBPool API and returns a '418' exception response error. + + .NOTES + Equivalent API endpoint: + - GET /api/docs/error + + .LINK + https://datto-dbpool-api.kentsapp.com/Debug/Invoke-DBPoolDebug/ + +#> + + [CmdletBinding()] + [OutputType([System.Management.Automation.ErrorRecord])] + param ( + [Parameter(Mandatory = $false)] + [ValidateSet('DELETE', 'GET', 'PATCH', 'POST')] + [string]$method = 'GET' + ) + + begin { + $requestPath = '/api/docs/error' + } + + process { + + Write-Debug "Invoking DBPool Debug Exception API with method [ $method ]" + + try { + $response = Invoke-DBPoolRequest -method $method -resource_Uri $requestPath -ErrorAction Stop + if ($null -ne $response) { + $response | ConvertFrom-Json -ErrorAction Stop + } + } catch { + Write-Error $_ + } + + } + + end {} +} +#EndRegion + +#Region +function Get-DBPoolOpenAPI { +<# + .SYNOPSIS + Gets the DBPool OpenAPI documentation. + + .DESCRIPTION + Gets the OpenAPI json spec for the DBPool API documentation. + + .PARAMETER OpenAPI_Path + The path to the OpenAPI json spec. + This defaults to '/api/docs/openapi.json' + + .INPUTS + N/A + + .OUTPUTS + [PSCustomObject] - The OpenAPI json spec for the DBPool API documentation. + + .EXAMPLE + Get-DBPoolOpenAPI + + This will get the OpenAPI json spec for the DBPool API documentation. + + .NOTES + Equivalent API endpoint: + - GET /api/docs/openapi.json + + .LINK + https://datto-dbpool-api.kentsapp.com/OpenAPI/Get-DBPoolOpenAPI/ +#> + + + [CmdletBinding()] + [Alias("Get-DBPoolApiSpec", "Get-DBPoolSwagger")] + [OutputType([PSCustomObject])] + param ( + [Parameter(Mandatory = $false)] + [string]$OpenAPI_Path = '/api/docs/openapi.json' + ) + + begin { + $requestPath = $OpenAPI_Path + } + + process { + + try { + $response = Invoke-DBPoolRequest -method Get -resource_Uri $requestPath -ErrorAction Stop -WarningAction SilentlyContinue + if ($null -ne $response) { + $response | ConvertFrom-Json -ErrorAction Stop + } + } catch { + Write-Error $_ + } + + } + + end {} +} +#EndRegion + +#Region +function Get-DBPoolUser { +<# + .SYNOPSIS + Get a user from DBPool + + .DESCRIPTION + The Get-DBPoolUser function is used to get a user details from DBPool. + Will retrieve the current authenticated user details, but can also be used to get other user details by username. + + .PARAMETER PlainTextAPIKey + This switch will return the API Key in plain text. + By default, the API Key is returned as a SecureString. + + .PARAMETER Username + The username of the user to get details for. + This accepts an array of strings. + + .INPUTS + [string] - The username of the user to get details for. + + .OUTPUTS + [PSCustomObject] - The user details from DBPool. + + .EXAMPLE + Get-DBPoolUser + + This will get the user details for the current authenticated user. + + ---------------------------------------------------------------- + + id : 1234 + username : john.doe + displayName : John Doe + email : John.Doe@company.tld + apiKey : System.Security.SecureString + + .EXAMPLE + Get-DBPoolUser -username "John.Doe" + + This will get the user details for the user "John.Doe". + + ---------------------------------------------------------------- + + id username displayName email + -- -------- ----------- ----- + 1234 john.doe John Doe John.Doe@company.tld + + .NOTES + Equivalent API endpoint: + - GET /api/v2/self + - GET /api/v2/users/{username} + + .LINK + https://datto-dbpool-api.kentsapp.com/Users/Get-DBPoolUser/ + +#> + + + [CmdletBinding(DefaultParameterSetName = 'Self')] + [OutputType([PSCustomObject])] + param ( + [Parameter(ParameterSetName = 'Self', Position = 0)] + [switch]$PlainTextAPIKey, + + [Parameter(ParameterSetName = 'User', Mandatory = $false, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] + [string[]]$Username + ) + + begin { + $method = 'GET' + } + + process { + + if ($PSCmdlet.ParameterSetName -eq 'Self') { + Write-Verbose "Running the [ $($PSCmdlet.ParameterSetName) ] parameter set" + + try { + $response = Invoke-DBPoolRequest -Method $method -resource_Uri '/api/v2/self' -ErrorAction Stop + if ($null -ne $response) { + $response = $response | ConvertFrom-Json + if ($response.ApiKey -and -not $PlainTextAPIKey) { + $response.ApiKey = $response.ApiKey | ConvertTo-SecureString -AsPlainText -Force + } + $response + } + } + catch { + Write-Error $_ + } + + } else { + foreach ($uName in $Username) { + $requestResponse = $null + Write-Verbose "Running the [ $($PSCmdlet.ParameterSetName) ] parameter set for Username $uName" + $requestPath = "/api/v2/users/$uName" + + try { + $requestResponse = Invoke-DBPoolRequest -method $method -resource_Uri $requestPath -ErrorAction Stop + if ($null -ne $requestResponse) { + $requestResponse | ConvertFrom-Json | Write-Output + } + } catch { + Write-Error $_ + } + } + } + + } + + end { + + Remove-Variable -Name response -Force -ErrorAction SilentlyContinue + + } +} +#EndRegion +# This section is used to dot source all the module functions for development +if (Test-Path -Path $(Join-Path -Path $PSScriptRoot -ChildPath 'Public')) { + # Directories to import from + $directory = 'Public', 'Private' + + # Import functions + $functionsToExport = @() + $aliasesToExport = @() + + foreach ($dir in $directory) { + $Functions = @( Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath "$dir") -Filter '*.ps1' -Recurse -ErrorAction SilentlyContinue) + foreach ($Import in @($Functions)) { + try { + . $Import.fullname + $functionsToExport += $Import.BaseName + } catch { + throw "Could not import function [$($Import.fullname)]: $_" + continue + } + } + } + + foreach ($alias in Get-Alias) { + if ($functionsToExport -contains $alias.Definition) { + $aliasesToExport += $alias.Name + } + } + + if ($functionsToExport.Count -gt 0) { + Export-ModuleMember -Function $functionsToExport + } + if ($aliasesToExport.Count -gt 0) { + Export-ModuleMember -Alias $aliasesToExport + } + +} + diff --git a/Datto.DBPool.API/0.2.0/en-US/Datto.DBPool.API-help.xml b/Datto.DBPool.API/0.2.0/en-US/Datto.DBPool.API-help.xml new file mode 100644 index 0000000..f485a49 --- /dev/null +++ b/Datto.DBPool.API/0.2.0/en-US/Datto.DBPool.API-help.xml @@ -0,0 +1,4028 @@ + + + + + Add-DBPoolApiKey + Add + DBPoolApiKey + + Sets the API key for the DBPool. + + + + The Add-DBPoolApiKey cmdlet sets the API key which is used to authenticate API calls made to DBPool. + Once the API key is defined, the secret key is encrypted using SecureString. + The DBPool API key is retrieved via the DBPool UI at My Profile -> API key + + + + Add-DBPoolApiKey + + apiKey + + Defines your API key for the DBPool. + + SecureString + + SecureString + + + None + + + Force + + Forces the setting of the DBPool API key. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + apiKey + + Defines your API key for the DBPool. + + SecureString + + SecureString + + + None + + + Force + + Forces the setting of the DBPool API key. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + [SecureString] - The API key for the DBPool. + + + + + + + + + + [void] - No output is returned. + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Add-DBPoolApiKey + + Prompts to enter in your personal API key. + + + + -------------------------- EXAMPLE 2 -------------------------- + Add-DBPoolApiKey -ApiKey $secureString +Read-Host "Enter your DBPool API Key" -AsSecureString | Add-DBPoolApiKey + + Sets the API key for the DBPool. + + + + + + N/A + + + + + + + Add-DBPoolBaseURI + Add + DBPoolBaseURI + + Sets the base URI for the DBPool API connection. + + + + The Add-DBPoolBaseURI cmdlet sets the base URI which is later used to construct the full URI for all API calls. + + + + Add-DBPoolBaseURI + + base_uri + + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. + + String + + String + + + Https://dbpool.datto.net + + + instance + + DBPool's URI connection point that can be one of the predefined data centers. + The accepted values for this parameter are: [ DEFAULT ] DEFAULT = https://dbpool.datto.net + Placeholder for other data centers. + + String + + String + + + None + + + + + + base_uri + + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. + + String + + String + + + Https://dbpool.datto.net + + + instance + + DBPool's URI connection point that can be one of the predefined data centers. + The accepted values for this parameter are: [ DEFAULT ] DEFAULT = https://dbpool.datto.net + Placeholder for other data centers. + + String + + String + + + None + + + + + + [string] - The base URI for the DBPool API connection. + + + + + + + + + + [void] - No output is returned. + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Add-DBPoolBaseURI + + The base URI will use https://dbpool.datto.net which is Datto's default DBPool URI. + + + + -------------------------- EXAMPLE 2 -------------------------- + Add-DBPoolBaseURI -instance Datto + + The base URI will use https://dbpool.datto.net which is DBPool's default URI. + + + + -------------------------- EXAMPLE 3 -------------------------- + Add-DBPoolBaseURI -base_uri http://dbpool.example.com + + A custom API gateway of http://dbpool.example.com will be used for all API calls to DBPool's API. + + + + + + N/A + + + + + + + ConvertTo-DBPoolQueryString + ConvertTo + DBPoolQueryString + + Converts uri filter parameters + As of June 2024, DBPool does not support any query parameters. This is only provided to allow forward compatibility + + + + The ConvertTo-DBPoolQueryString 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-DBPoolRequest & any public functions that define parameters + As of June 2024, DBPool does not support any query parameters. This is only provided to allow forward compatibility + + + + ConvertTo-DBPoolQueryString + + uri_Filter + + Hashtable of values to combine a functions parameters with the resource_Uri parameter. + This allows for the full uri query to occur + As of June 2024, DBPool does not support any query parameters. This is only provided to allow forward compatibility + + Hashtable + + Hashtable + + + None + + + resource_Uri + + Defines the short resource uri (url) to use when creating the API call + + String + + String + + + None + + + + + + uri_Filter + + Hashtable of values to combine a functions parameters with the resource_Uri parameter. + This allows for the full uri query to occur + As of June 2024, DBPool does not support any query parameters. This is only provided to allow forward compatibility + + Hashtable + + Hashtable + + + None + + + resource_Uri + + Defines the short resource uri (url) to use when creating the API call + + String + + String + + + None + + + + + + [hashtable] - uri_Filter + + + + + + + + + + [System.UriBuilder] - uri_Request + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + ConvertTo-DBPoolQueryString -uri_Filter $uri_Filter -resource_Uri '/api/v2/containers' + + Example: (From public function) $uri_Filter = @{} + ForEach ( $Key in $PSBoundParameters.GetEnumerator() ){ if( $excludedParameters -contains $Key.Key ){$null} else{ $uri_Filter += @{ $Key.Key = $Key.Value } } } + 1x key = https://api.DBPool.com/v1/api/v2/containers?parentId=12345 2x key = https://api.DBPool.com/v1/api/v2/containers?parentId=12345&power=True + + + + + + N/A + + + + + + + Export-DBPoolModuleSetting + Export + DBPoolModuleSetting + + Exports the DBPool BaseURI, API Key, & JSON configuration information to file. + + + + The Export-DBPoolModuleSetting cmdlet exports the DBPool BaseURI, API Key, & JSON configuration information to file. + Making use of PowerShell's System.Security.SecureString type, exporting module settings encrypts your API key in a format that can only be unencrypted with the your Windows account as this encryption is tied to your user principal. This means that you cannot copy your configuration file to another computer or user account and expect it to work. + + + + Export-DBPoolModuleSetting + + DBPoolConfPath + + Define the location to store the DBPool configuration file. + By default the configuration file is stored in the following location: $env:USERPROFILE\DBPoolAPI + + String + + String + + + $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ) + + + DBPoolConfFile + + Define the name of the DBPool configuration file. + By default the configuration file is named: config.psd1 + + String + + String + + + Config.psd1 + + + + + + DBPoolConfPath + + Define the location to store the DBPool configuration file. + By default the configuration file is stored in the following location: $env:USERPROFILE\DBPoolAPI + + String + + String + + + $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ) + + + DBPoolConfFile + + Define the name of the DBPool configuration file. + By default the configuration file is named: config.psd1 + + String + + String + + + Config.psd1 + + + + + + N/A + + + + + + + + + + [void] - No output is returned. + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Export-DBPoolModuleSetting + + Validates that the BaseURI, API Key, and JSON depth are set then exports their values to the current user's DBPool configuration file located at: $env:USERPROFILE\DBPoolAPI\config.psd1 + + + + -------------------------- EXAMPLE 2 -------------------------- + Export-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -DBPoolConfFile MyConfig.psd1 + + Validates that the BaseURI, API Key, and JSON depth are set then exports their values to the current user's DBPool configuration file located at: C:\DBPoolAPI\MyConfig.psd1 + + + + + + N/A + + + + + + + Get-DBPoolApiKey + Get + DBPoolApiKey + + Gets the DBPool API key global variable. + + + + The Get-DBPoolApiKey cmdlet gets the DBPool API key global variable and returns this as an object. + + + + Get-DBPoolApiKey + + AsPlainText + + Decrypt and return the API key in plain text. + + + SwitchParameter + + + False + + + + + + AsPlainText + + Decrypt and return the API key in plain text. + + SwitchParameter + + SwitchParameter + + + False + + + + + + N/A + + + + + + + + + + [PSCustomObject] - The DBPool API key global variable. + + + + + + + + + N\A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-DBPoolApiKey + + Gets the DBPool API key global variable and returns this as an object with the secret key as a SecureString. + + + + -------------------------- EXAMPLE 2 -------------------------- + Get-DBPoolApiKey -AsPlainText + + Gets the DBPool API key global variable and returns this as an object with the secret key as plain text. + + + + + + N/A + + + + + + + Get-DBPoolBaseURI + Get + DBPoolBaseURI + + Shows the DBPool base URI global variable. + + + + The Get-DBPoolBaseURI cmdlet shows the DBPool base URI global variable value. + + + + Get-DBPoolBaseURI + + + + + + + N/A + + + + + + + + + + [void] - No output is returned. + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-DBPoolBaseURI + + Shows the DBPool base URI global variable value. + + + + + + N/A + + + + + + + Get-DBPoolContainer + Get + DBPoolContainer + + The Get-DBPoolContainer function retrieves container information from the DBPool API. + + + + This function retrieves container details from the DBPool API. + It can get containers, parent containers, or child containers, and also retrieve containers or container status by ID. This also can filter or exclude by container name or database. + + + + Get-DBPoolContainer + + Id + + The ID of the container details to get from the DBPool. + + Int32[] + + Int32[] + + + None + + + ListContainer + + Retrieves a list of containers from the DBPool API. This is the default parameter set. + + + SwitchParameter + + + False + + + Name + + Filters containers returned from the DBPool API by name. Accepts wildcard input. + + String[] + + String[] + + + None + + + DefaultDatabase + + Filters containers returned from the DBPool API by database. Accepts wildcard input. + + String[] + + String[] + + + None + + + NotLike + + Excludes containers returned from the DBPool API by Name or DefaultDatabase using the -NotLike switch. Requires the -Name or -DefaultDatabase parameter to be specified. + Returns containers where the Name or DefaultDatabase does not match the provided filter. + + + SwitchParameter + + + False + + + + Get-DBPoolContainer + + Id + + The ID of the container details to get from the DBPool. + + Int32[] + + Int32[] + + + None + + + ParentContainer + + Retrieves a list of parent containers from the DBPool API. + + + SwitchParameter + + + False + + + Name + + Filters containers returned from the DBPool API by name. Accepts wildcard input. + + String[] + + String[] + + + None + + + DefaultDatabase + + Filters containers returned from the DBPool API by database. Accepts wildcard input. + + String[] + + String[] + + + None + + + NotLike + + Excludes containers returned from the DBPool API by Name or DefaultDatabase using the -NotLike switch. Requires the -Name or -DefaultDatabase parameter to be specified. + Returns containers where the Name or DefaultDatabase does not match the provided filter. + + + SwitchParameter + + + False + + + + Get-DBPoolContainer + + ChildContainer + + Retrieves a list of child containers from the DBPool API. + + + SwitchParameter + + + False + + + + Get-DBPoolContainer + + Id + + The ID of the container details to get from the DBPool. + + Int32[] + + Int32[] + + + None + + + Status + + Gets the status of a container by ID. Returns basic container details, and dockerContainerRunning, mysqlServiceResponding, and mysqlServiceRespondingCached statuses. + + + SwitchParameter + + + False + + + + + + ListContainer + + Retrieves a list of containers from the DBPool API. This is the default parameter set. + + SwitchParameter + + SwitchParameter + + + False + + + ParentContainer + + Retrieves a list of parent containers from the DBPool API. + + SwitchParameter + + SwitchParameter + + + False + + + ChildContainer + + Retrieves a list of child containers from the DBPool API. + + SwitchParameter + + SwitchParameter + + + False + + + Id + + The ID of the container details to get from the DBPool. + + Int32[] + + Int32[] + + + None + + + Status + + Gets the status of a container by ID. Returns basic container details, and dockerContainerRunning, mysqlServiceResponding, and mysqlServiceRespondingCached statuses. + + SwitchParameter + + SwitchParameter + + + False + + + Name + + Filters containers returned from the DBPool API by name. Accepts wildcard input. + + String[] + + String[] + + + None + + + DefaultDatabase + + Filters containers returned from the DBPool API by database. Accepts wildcard input. + + String[] + + String[] + + + None + + + NotLike + + Excludes containers returned from the DBPool API by Name or DefaultDatabase using the -NotLike switch. Requires the -Name or -DefaultDatabase parameter to be specified. + Returns containers where the Name or DefaultDatabase does not match the provided filter. + + SwitchParameter + + SwitchParameter + + + False + + + + + + [int] - Id + + + + + + + + The ID of the container to get details for. + + + + + + + + [string] Name + + + + + + + + The name of the container to get details for. + + + + + + + + [string] - DefaultDatabase + + + + + + + + The database of the container to get details for. + + + + + + + + + + [PSCustomObject] - The response from the DBPool API. + + + + + + + + + The -Name, and -DefaultDatabase parameters are not native endpoints of the DBPool API. This is a custom function which uses 'Where-Object', along with the optional -NotLike parameter to return the response using the provided filter. + If no match is found an error is output, and the original response is returned. + Equivalent API endpoint: - GET /api/v2/containers - GET /api/v2/parents - GET /api/v2/children - GET /api/v2/containers/{id} - GET /api/v2/containers/{id}/status + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-DBPoolContainer + + Get a list of all containers from the DBPool API + + + + -------------------------- EXAMPLE 2 -------------------------- + Get-DBPoolContainer -Id 12345 + + Get a list of containers from the DBPool API by ID + + + + -------------------------- EXAMPLE 3 -------------------------- + Get-DBPoolContainer -Status + + Get the status of all containers from the DBPool API + + + + -------------------------- EXAMPLE 4 -------------------------- + Get-DBPoolContainer -Status -Id 12345, 67890 + + Get the status of an array of containers by IDs + + + + -------------------------- EXAMPLE 5 -------------------------- + Get-DBPoolContainer -ParentContainer + + Get a list of parent containers from the DBPool API + + + + -------------------------- EXAMPLE 6 -------------------------- + Get-DBPoolContainer -ParentContainer -Id 12345 + + Get a list of parent containers from the DBPool API by ID + + + + -------------------------- EXAMPLE 7 -------------------------- + Get-DBPoolContainer -ChildContainer + + Get a list of child containers from the DBPool API + + + + -------------------------- EXAMPLE 8 -------------------------- + Get-DBPoolContainer -Name 'MyContainer' +Get-DBPoolContainer -ParentContainer -Name 'ParentContainer*' + + Uses 'Where-Object' to get a list of containers from the DBPool API, or parent containers by name Accepts wildcard input + + + + -------------------------- EXAMPLE 9 -------------------------- + Get-DBPoolContainer -Name 'MyContainer' -NotLike +Get-DBPoolContainer -ParentContainer -Name 'ParentContainer*' -NotLike + + Uses 'Where-Object' to get a list of containers from the DBPool API, or parent containers where the name does not match the filter Accepts wildcard input + + + + -------------------------- EXAMPLE 10 -------------------------- + Get-DBPoolContainer -DefaultDatabase 'Database' +Get-DBPoolContainer -ParentContainer -DefaultDatabase 'Database*' + + Get a list of containers from the DBPool API, or parent containers by database Accepts wildcard input + + + + -------------------------- EXAMPLE 11 -------------------------- + Get-DBPoolContainer -DefaultDatabase 'Database' -NotLike +Get-DBPoolContainer -ParentContainer -DefaultDatabase 'Database*' -NotLike + + Get a list of containers from the DBPool API, or parent containers where the database does not match the filter Accepts wildcard input + + + + + + https://datto-dbpool-api.kentsapp.com/Containers/Get-DBPoolContainer/ + https://datto-dbpool-api.kentsapp.com/Containers/Get-DBPoolContainer/ + + + + + + Get-DBPoolMetaData + Get + DBPoolMetaData + + Gets various API metadata values + + + + The Get-DBPoolMetaData cmdlet gets various API metadata values from an Invoke-WebRequest to assist in various troubleshooting scenarios such as rate-limiting. + + + + Get-DBPoolMetaData + + base_uri + + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. + The default base URI is https://dbpool.datto.net + + String + + String + + + $DBPool_Base_URI + + + resource_uri + + Define the resource URI for the DBPool API connection. + The default resource URI is /api/v2/self + + String + + String + + + /api/v2/self + + + + + + base_uri + + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. + The default base URI is https://dbpool.datto.net + + String + + String + + + $DBPool_Base_URI + + + resource_uri + + Define the resource URI for the DBPool API connection. + The default resource URI is /api/v2/self + + String + + String + + + /api/v2/self + + + + + + [string] - base_uri + + + + + + + + + + [PSCustomObject] - Various API metadata values + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-DBPoolMetaData + + Gets various API metadata values from an Invoke-WebRequest to assist in various troubleshooting scenarios such as rate-limiting. + The default full base uri test path is: https://dbpool.datto.net + + + + -------------------------- EXAMPLE 2 -------------------------- + Get-DBPoolMetaData -base_uri http://dbpool.example.com + + Gets various API metadata values from an Invoke-WebRequest to assist in various troubleshooting scenarios such as rate-limiting. + The full base uri test path in this example is: http://dbpool.example.com/device + + + + + + N/A + + + + + + + Get-DBPoolModuleSetting + Get + DBPoolModuleSetting + + Gets the saved DBPool configuration settings + + + + The Get-DBPoolModuleSetting cmdlet gets the saved DBPool configuration settings from the local system. + By default the configuration file is stored in the following location: $env:USERPROFILE\DBPoolAPI + + + + Get-DBPoolModuleSetting + + DBPoolConfPath + + Define the location to store the DBPool configuration file. + By default the configuration file is stored in the following location: $env:USERPROFILE\DBPoolAPI + + String + + String + + + $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ) + + + DBPoolConfFile + + Define the name of the DBPool configuration file. + By default the configuration file is named: config.psd1 + + String + + String + + + Config.psd1 + + + + Get-DBPoolModuleSetting + + openConfFile + + Opens the DBPool configuration file + + + SwitchParameter + + + False + + + + + + DBPoolConfPath + + Define the location to store the DBPool configuration file. + By default the configuration file is stored in the following location: $env:USERPROFILE\DBPoolAPI + + String + + String + + + $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ) + + + DBPoolConfFile + + Define the name of the DBPool configuration file. + By default the configuration file is named: config.psd1 + + String + + String + + + Config.psd1 + + + openConfFile + + Opens the DBPool configuration file + + SwitchParameter + + SwitchParameter + + + False + + + + + + N/A + + + + + + + + + + [void] - No output is returned. + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-DBPoolModuleSetting + + Gets the contents of the configuration file that was created with the Export-DBPoolModuleSetting + The default location of the DBPool configuration file is: $env:USERPROFILE\DBPoolAPI\config.psd1 + + + + -------------------------- EXAMPLE 2 -------------------------- + Get-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -DBPoolConfFile MyConfig.psd1 -openConfFile + + Opens the configuration file from the defined location in the default editor + The location of the DBPool configuration file in this example is: C:\DBPoolAPI\MyConfig.psd1 + + + + + + N/A + + + + + + + Get-DBPoolOpenAPI + Get + DBPoolOpenAPI + + Gets the DBPool OpenAPI documentation. + + + + Gets the OpenAPI json spec for the DBPool API documentation. + + + + Get-DBPoolOpenAPI + + OpenAPI_Path + + The path to the OpenAPI json spec. This defaults to '/api/docs/openapi.json' + + String + + String + + + /api/docs/openapi.json + + + + + + OpenAPI_Path + + The path to the OpenAPI json spec. This defaults to '/api/docs/openapi.json' + + String + + String + + + /api/docs/openapi.json + + + + + + N/A + + + + + + + + + + [PSCustomObject] - The OpenAPI json spec for the DBPool API documentation. + + + + + + + + + Equivalent API endpoint: - GET /api/docs/openapi.json + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-DBPoolOpenAPI + + This will get the OpenAPI json spec for the DBPool API documentation. + + + + + + https://datto-dbpool-api.kentsapp.com/OpenAPI/Get-DBPoolOpenAPI/ + https://datto-dbpool-api.kentsapp.com/OpenAPI/Get-DBPoolOpenAPI/ + + + + + + Get-DBPoolUser + Get + DBPoolUser + + Get a user from DBPool + + + + The Get-DBPoolUser function is used to get a user details from DBPool. Will retrieve the current authenticated user details, but can also be used to get other user details by username. + + + + Get-DBPoolUser + + PlainTextAPIKey + + This switch will return the API Key in plain text. By default, the API Key is returned as a SecureString. + + + SwitchParameter + + + False + + + + Get-DBPoolUser + + Username + + The username of the user to get details for. This accepts an array of strings. + + String[] + + String[] + + + None + + + + + + PlainTextAPIKey + + This switch will return the API Key in plain text. By default, the API Key is returned as a SecureString. + + SwitchParameter + + SwitchParameter + + + False + + + Username + + The username of the user to get details for. This accepts an array of strings. + + String[] + + String[] + + + None + + + + + + [string] - The username of the user to get details for. + + + + + + + + + + [PSCustomObject] - The user details from DBPool. + + + + + + + + + Equivalent API endpoint: - GET /api/v2/self - GET /api/v2/users/{username} + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-DBPoolUser + + This will get the user details for the current authenticated user. + ---------------------------------------------------------------- + id : 1234 username : john.doe displayName : John Doe email : John.Doe@company.tld apiKey : System.Security.SecureString + + + + -------------------------- EXAMPLE 2 -------------------------- + Get-DBPoolUser -username "John.Doe" + + This will get the user details for the user "John.Doe". + ---------------------------------------------------------------- + id username displayName email -- -------- ----------- ----- 1234 john.doe John Doe John.Doe@company.tld + + + + + + https://datto-dbpool-api.kentsapp.com/Users/Get-DBPoolUser/ + https://datto-dbpool-api.kentsapp.com/Users/Get-DBPoolUser/ + + + + + + Import-DBPoolModuleSetting + Import + DBPoolModuleSetting + + Imports the DBPool BaseURI, API Key, & JSON configuration information to the current session. + + + + The Import-DBPoolModuleSetting cmdlet imports the DBPool BaseURI, API Key, & JSON configuration information stored in the DBPool configuration file to the users current session. + By default the configuration file is stored in the following location: $env:USERPROFILE\DBPoolAPI + + + + Import-DBPoolModuleSetting + + DBPoolConfPath + + Define the location to store the DBPool configuration file. + By default the configuration file is stored in the following location: $env:USERPROFILE\DBPoolAPI + + String + + String + + + $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ) + + + DBPoolConfFile + + Define the name of the DBPool configuration file. + By default the configuration file is named: config.psd1 + + String + + String + + + Config.psd1 + + + + + + DBPoolConfPath + + Define the location to store the DBPool configuration file. + By default the configuration file is stored in the following location: $env:USERPROFILE\DBPoolAPI + + String + + String + + + $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ) + + + DBPoolConfFile + + Define the name of the DBPool configuration file. + By default the configuration file is named: config.psd1 + + String + + String + + + Config.psd1 + + + + + + N/A + + + + + + + + + + N/A + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Import-DBPoolModuleSetting + + Validates that the configuration file created with the Export-DBPoolModuleSetting cmdlet exists then imports the stored data into the current users session. + The default location of the DBPool configuration file is: $env:USERPROFILE\DBPoolAPI\config.psd1 + + + + -------------------------- EXAMPLE 2 -------------------------- + Import-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -DBPoolConfFile MyConfig.psd1 + + Validates that the configuration file created with the Export-DBPoolModuleSetting cmdlet exists then imports the stored data into the current users session. + The location of the DBPool configuration file in this example is: C:\DBPoolAPI\MyConfig.psd1 + + + + + + N/A + + + + + + + Invoke-DBPoolContainerAccess + Invoke + DBPoolContainerAccess + + The Invoke-DBPoolContainerAccess function is used to interact with various container access operations in the Datto DBPool API. + + + + The Invoke-DBPoolContainerAccess function is used to Get, Add, or Remove access to a container in the Datto DBPool API based on a given username. + + + + Invoke-DBPoolContainerAccess + + Id + + The ID of the container to access. This accepts an array of integers. + + Int32[] + + Int32[] + + + None + + + Username + + The username to access the container. This accepts an array of strings. + + String[] + + String[] + + + None + + + GetAccess + + Gets the current access to a container by ID for the given username. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + Invoke-DBPoolContainerAccess + + Id + + The ID of the container to access. This accepts an array of integers. + + Int32[] + + Int32[] + + + None + + + Username + + The username to access the container. This accepts an array of strings. + + String[] + + String[] + + + None + + + AddAccess + + Adds access to a container by ID for the given username. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + Invoke-DBPoolContainerAccess + + Id + + The ID of the container to access. This accepts an array of integers. + + Int32[] + + Int32[] + + + None + + + Username + + The username to access the container. This accepts an array of strings. + + String[] + + String[] + + + None + + + RemoveAccess + + Removes access to a container by ID for the given username. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + Id + + The ID of the container to access. This accepts an array of integers. + + Int32[] + + Int32[] + + + None + + + Username + + The username to access the container. This accepts an array of strings. + + String[] + + String[] + + + None + + + GetAccess + + Gets the current access to a container by ID for the given username. + + SwitchParameter + + SwitchParameter + + + False + + + AddAccess + + Adds access to a container by ID for the given username. + + SwitchParameter + + SwitchParameter + + + False + + + RemoveAccess + + Removes access to a container by ID for the given username. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + [int] - The ID of the container to access. + + + + + + + + [string] - The username to access the container. + + + + + + + + + + [PSCustomObject] - The response from the DBPool API. + + + + + + + + [void] - No output is returned. + + + + + + + + + Equivalent API endpoint: - GET /api/v2/containers/{id}/access/{username} - PUT /api/v2/containers/{id}/access/{username} - DELETE /api/v2/containers/{id}/access/{username} + + + + + -------------------------- EXAMPLE 1 -------------------------- + Invoke-DBPoolContainerAccess -Id '12345' -Username 'John.Doe' +Invoke-DBPoolContainerAccess -Id '12345' -Username 'John.Doe' -GetAccess + + This will get access to the container with ID 12345 for the user "John.Doe" + + + + -------------------------- EXAMPLE 2 -------------------------- + Invoke-DBPoolContainerAccess -Id @( '12345', '56789' ) -Username 'John.Doe' -AddAccess + + This will add access to the containers with ID 12345, and 56789 for the user "John.Doe" + + + + -------------------------- EXAMPLE 3 -------------------------- + Invoke-DBPoolContainerAccess -Id '12345' -Username @( 'Jane.Doe', 'John.Doe' ) -RemoveAccess + + This will remove access to the container with ID 12345 for the users "Jane.Doe", and "John.Doe" + + + + + + https://datto-dbpool-api.kentsapp.com/Containers/access/Invoke-DBPoolContainerAccess/ + https://datto-dbpool-api.kentsapp.com/Containers/access/Invoke-DBPoolContainerAccess/ + + + + + + Invoke-DBPoolContainerAction + Invoke + DBPoolContainerAction + + The Invoke-DBPoolContainerAction function is used to interact with various container action operations in the Datto DBPool API. + + + + The Invoke-DBPoolContainerAction function is used to perform actions on a container such as refresh, schema-merge, start, restart, or stop. + + + + Invoke-DBPoolContainerAction + + Action + + The action to perform on the container. Valid actions are: refresh, schema-merge, start, restart, or stop. + Start, Stop, and Restart are all considered minor actions and will not require a confirmation prompt. Refresh and Schema-Merge are considered major actions and will require a confirmation prompt. + + String + + String + + + None + + + Id + + The ID(s) of the container(s) to perform the action on. + + Int32[] + + Int32[] + + + None + + + Force + + Skip the confirmation prompt for major actions, such as 'Refresh' and 'Schema-Merge'. + + + SwitchParameter + + + False + + + TimeoutSeconds + + The maximum time in seconds to wait for the action to complete. Default is 3600 seconds (60 minutes). + + Int32 + + Int32 + + + 3600 + + + ThrottleLimit + + The maximum number of containers to process in parallel. Default is twice the number of processor cores. + + Int32 + + Int32 + + + ([Environment]::ProcessorCount * 2) + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + Action + + The action to perform on the container. Valid actions are: refresh, schema-merge, start, restart, or stop. + Start, Stop, and Restart are all considered minor actions and will not require a confirmation prompt. Refresh and Schema-Merge are considered major actions and will require a confirmation prompt. + + String + + String + + + None + + + Id + + The ID(s) of the container(s) to perform the action on. + + Int32[] + + Int32[] + + + None + + + Force + + Skip the confirmation prompt for major actions, such as 'Refresh' and 'Schema-Merge'. + + SwitchParameter + + SwitchParameter + + + False + + + TimeoutSeconds + + The maximum time in seconds to wait for the action to complete. Default is 3600 seconds (60 minutes). + + Int32 + + Int32 + + + 3600 + + + ThrottleLimit + + The maximum number of containers to process in parallel. Default is twice the number of processor cores. + + Int32 + + Int32 + + + ([Environment]::ProcessorCount * 2) + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + [int] - The ID of the container to perform the action on. + + + + + + + + [string] - The action to perform on the container. + + + + + + + + + + [void] - No output is returned. + + + + + + + + + Equivalent API endpoint: - POST /api/v2/containers/{id}/actions/{action} + Actions: + refresh: Recreate the Docker container and ZFS snapshot for the container. + schema-merge: Attempt to apply upstream changes to the parent container to this child container. This may break your container. Refreshing a container is the supported way to update a child container's database schema. + start: Start the Docker container for the container. + restart: Stop and start the Docker container. + stop: Stop the Docker container. + + + + + -------------------------- EXAMPLE 1 -------------------------- + Invoke-DBPoolContainerAction -Action 'restart' -Id '12345' + + This will restart the container with ID 12345 + + + + -------------------------- EXAMPLE 2 -------------------------- + Invoke-DBPoolContainerAction refresh 12345,56789 + + This will refresh the containers with ID 12345, and 56789 + + + + -------------------------- EXAMPLE 3 -------------------------- + Invoke-DBPoolContainerAction -Action refresh -Id (Get-DBPoolContainer).Id -Force + + This will refresh all containers without prompting for confirmation. + + + + + + https://datto-dbpool-api.kentsapp.com/Containers/actions/Invoke-DBPoolContainerAction/ + https://datto-dbpool-api.kentsapp.com/Containers/actions/Invoke-DBPoolContainerAction/ + + + + + + Invoke-DBPoolDebug + Invoke + DBPoolDebug + + Provides an example exception response from the DBPool API for debugging purposes. + + + + Uses the Invoke-DBPoolRequest function to make a request to the DBPool API. Returns an example exception response for debugging and testing purposes. + + + + Invoke-DBPoolDebug + + method + + The HTTP method to use when making the request to the DBPool API. Default is 'GET'. + + String + + String + + + GET + + + + + + method + + The HTTP method to use when making the request to the DBPool API. Default is 'GET'. + + String + + String + + + GET + + + + + + N/A + + + + + + + + + + [System.Management.Automation.ErrorRecord] - Returns an example exception response from the DBPool API. + + + + + + + + + Equivalent API endpoint: - GET /api/docs/error + + + + + -------------------------- EXAMPLE 1 -------------------------- + Invoke-DBPoolDebug -method GET + + Sends a 'GET' request to the DBPool API and returns a '418' exception response error. + + + + + + https://datto-dbpool-api.kentsapp.com/Debug/Invoke-DBPoolDebug/ + https://datto-dbpool-api.kentsapp.com/Debug/Invoke-DBPoolDebug/ + + + + + + Invoke-DBPoolRequest + Invoke + DBPoolRequest + + Internal function to make an API request to the DBPool API + + + + The Invoke-DBPoolRequest cmdlet invokes an API request to DBPool API + This is an internal function that is used by all public functions + + + + Invoke-DBPoolRequest + + method + + Defines the type of API method to use + Allowed values: 'DEFAULT', 'DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT' + + String + + String + + + DEFAULT + + + resource_Uri + + Defines the resource uri (url) to use when creating the API call + + String + + String + + + None + + + uri_Filter + + Used with the internal function [ ConvertTo-DBPoolQueryString ] 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 $DBPool_Base_URI + $resource_Uri + ConvertTo-DBPoolQueryString + As of June 2024, DBPool does not support any query parameters. This is only provided to allow forward compatibility + + Hashtable + + Hashtable + + + None + + + data + + Defines the data to be sent with the API request body when using POST or PATCH + + Hashtable + + Hashtable + + + None + + + DBPool_JSON_Conversion_Depth + + Defines the depth of the JSON conversion for the 'data' parameter request body + + Int32 + + Int32 + + + 5 + + + allPages + + Returns all items from an endpoint + When using this parameter there is no need to use either the page or perPage parameters + As of June 2024, DBPool does not support any paging parameters. This is only provided to allow forward compatibility + + + SwitchParameter + + + False + + + + + + method + + Defines the type of API method to use + Allowed values: 'DEFAULT', 'DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT' + + String + + String + + + DEFAULT + + + resource_Uri + + Defines the resource uri (url) to use when creating the API call + + String + + String + + + None + + + uri_Filter + + Used with the internal function [ ConvertTo-DBPoolQueryString ] 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 $DBPool_Base_URI + $resource_Uri + ConvertTo-DBPoolQueryString + As of June 2024, DBPool does not support any query parameters. This is only provided to allow forward compatibility + + Hashtable + + Hashtable + + + None + + + data + + Defines the data to be sent with the API request body when using POST or PATCH + + Hashtable + + Hashtable + + + None + + + DBPool_JSON_Conversion_Depth + + Defines the depth of the JSON conversion for the 'data' parameter request body + + Int32 + + Int32 + + + 5 + + + allPages + + Returns all items from an endpoint + When using this parameter there is no need to use either the page or perPage parameters + As of June 2024, DBPool does not support any paging parameters. This is only provided to allow forward compatibility + + SwitchParameter + + SwitchParameter + + + False + + + + + + N/A + + + + + + + + + + [Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject] - The response from the DBPool API + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Invoke-DBPoolRequest -method GET -resource_Uri '/api/v2/self' -uri_Filter $uri_Filter + + Name Value ---- ----- Method GET Uri https://dbpool.datto.net/api/v2/self Headers {X-App-Apikey = 3feb2b29-919c-409c-985d-e99cbae43a6d} Body + Invoke an API request against the defined resource using any of the provided parameters + + + + -------------------------- EXAMPLE 2 -------------------------- + Invoke-DBPoolRequest -method GET -resource_Uri '/api/openapi.json' -uri_Filter $uri_Filter +Name Value +---- ----- +Method GET +Uri https://dbpool.datto.net/api/openapi.json +Headers {X-App-Apikey = 3feb2b29-919c-409c-985d-e99cbae43a6d} +Body + + Invoke an API request against the defined resource using any of the provided parameters + + + + + + N/A + + + + + + + New-DBPoolContainer + New + DBPoolContainer + + The New-DBPoolContainer function is used to create a new container from the DBPool API. + + + + This function creates a new container in the DBPool based on the provided container name and parent container information. The ContainerName parameter is mandatory, and at least one of the parent parameters (ParentId, ParentName, or ParentDefaultDatabase) must be specified. + + + + New-DBPoolContainer + + ContainerName + + The name for the new container. + + String + + String + + + None + + + ParentId + + The ID of the parent container to clone. + + Int32 + + Int32 + + + 0 + + + ParentName + + The name of the parent container to clone. + + String + + String + + + None + + + ParentDefaultDatabase + + The default database of the parent container to clone. + + String + + String + + + None + + + Force + + Force the operation without confirmation. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + ContainerName + + The name for the new container. + + String + + String + + + None + + + ParentId + + The ID of the parent container to clone. + + Int32 + + Int32 + + + 0 + + + ParentName + + The name of the parent container to clone. + + String + + String + + + None + + + ParentDefaultDatabase + + The default database of the parent container to clone. + + String + + String + + + None + + + Force + + Force the operation without confirmation. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + [string] - ContainerName + + + + + + + + The name for the new container. + + + + + + + + [int] - ParentId + + + + + + + + The ID of the parent container to clone. + + + + + + + + [string] - ParentName + + + + + + + + The name of the parent container to clone. + + + + + + + + [string] - ParentDefaultDatabase + + + + + + + + The default database of the parent container to clone. + + + + + + + + + + [PSCustomObject] - The response from the DBPool API. + + + + + + + + + Equivalent API endpoint: - POST /api/v2/containers + + + + + -------------------------- EXAMPLE 1 -------------------------- + New-DBPoolContainer -ContainerName 'MyNewContainer' -ParentId 12345 + + This will create a new container named 'MyNewContainer' based on the parent container with ID 12345. + + + + -------------------------- EXAMPLE 2 -------------------------- + Get-DBPoolContainer -ParentContainer -Id 1 | New-DBPoolContainer -ContainerName 'MyNewContainer' + + This will create a new container named 'MyNewContainer' based on the piped in parent container. + + + + + + https://datto-dbpool-api.kentsapp.com/Containers/New-DBPoolContainer/ + https://datto-dbpool-api.kentsapp.com/Containers/New-DBPoolContainer/ + + + + + + Remove-DBPoolApiKey + Remove + DBPoolApiKey + + Removes the DBPool API Key global variable. + + + + The Remove-DBPoolAPIKey cmdlet removes the DBPool API Key global variable. + + + + Remove-DBPoolApiKey + + Force + + Forces the removal of the DBPool API Key global variable without prompting for confirmation. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + Force + + Forces the removal of the DBPool API Key global variable without prompting for confirmation. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + N/A + + + + + + + + + + [void] - No output is returned. + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Remove-DBPoolAPIKey + + Removes the DBPool API Key global variable. + + + + + + N/A + + + + + + + Remove-DBPoolBaseURI + Remove + DBPoolBaseURI + + Removes the DBPool base URI global variable. + + + + The Remove-DBPoolBaseURI cmdlet removes the DBPool base URI global variable. + + + + Remove-DBPoolBaseURI + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + N/A + + + + + + + + + + [void] - No output is returned. + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Remove-DBPoolBaseURI + + Removes the DBPool base URI global variable. + + + + + + N/A + + + + + + + Remove-DBPoolContainer + Remove + DBPoolContainer + + The Remove-DBPoolContainer function is used to delete a container in the DBPool. + + + + The Remove-DBPoolContainer function is used to delete containers in the DBPool based on the provided container ID. + !! This is a destructive operation and will destory the container !! + + + + Remove-DBPoolContainer + + Id + + The ID of the container to delete. This accepts an array of integers. + + Int32[] + + Int32[] + + + None + + + Force + + Forces the removal of the container without prompting for confirmation. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + Id + + The ID of the container to delete. This accepts an array of integers. + + Int32[] + + Int32[] + + + None + + + Force + + Forces the removal of the container without prompting for confirmation. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + [int] - The ID of the container to delete. + + + + + + + + + + [void] - No output is returned. + + + + + + + + + Equivalent API endpoint: - DELETE /api/v2/containers/{id} + + + + + -------------------------- EXAMPLE 1 -------------------------- + Remove-DBPoolContainer -Id '12345' + + This will delete the provided container by ID. + + + + -------------------------- EXAMPLE 2 -------------------------- + @( 12345, 56789 ) | Remove-DBPoolContainer -Confirm:$false + + This will delete the containers with ID 12345, and 56789. + + + + + + https://datto-dbpool-api.kentsapp.com/Containers/Remove-DBPoolContainer/ + https://datto-dbpool-api.kentsapp.com/Containers/Remove-DBPoolContainer/ + + + + + + Remove-DBPoolModuleSetting + Remove + DBPoolModuleSetting + + Removes the stored DBPool configuration folder. + + + + The Remove-DBPoolModuleSetting cmdlet removes the DBPool folder and its files. This cmdlet also has the option to remove sensitive DBPool variables as well. + By default configuration files are stored in the following location and will be removed: $env:USERPROFILE\DBPoolAPI + + + + Remove-DBPoolModuleSetting + + DBPoolConfPath + + Define the location of the DBPool configuration folder. + By default the configuration folder is located at: $env:USERPROFILE\DBPoolAPI + + String + + String + + + $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ) + + + andVariables + + Define if sensitive DBPool variables should be removed as well. + By default the variables are not removed. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + DBPoolConfPath + + Define the location of the DBPool configuration folder. + By default the configuration folder is located at: $env:USERPROFILE\DBPoolAPI + + String + + String + + + $(Join-Path -Path $home -ChildPath $(if ($IsWindows -or $PSEdition -eq 'Desktop'){"DBPoolAPI"}else{".DBPoolAPI"}) ) + + + andVariables + + Define if sensitive DBPool variables should be removed as well. + By default the variables are not removed. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + N/A + + + + + + + + + + [void] - No output is returned. + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Remove-DBPoolModuleSetting + + Checks to see if the default configuration folder exists and removes it if it does. + The default location of the DBPool configuration folder is: $env:USERPROFILE\DBPoolAPI + + + + -------------------------- EXAMPLE 2 -------------------------- + Remove-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -andVariables + + Checks to see if the defined configuration folder exists and removes it if it does. If sensitive DBPool variables exist then they are removed as well. + The location of the DBPool configuration folder in this example is: C:\DBPoolAPI + + + + + + N/A + + + + + + + Rename-DBPoolContainer + Rename + DBPoolContainer + + The Rename-DBPoolContainer function is used to update a container in the DBPool. + + + + The Rename-DBPoolContainer function is used to change the name a container in the DBPool API. + + + + Rename-DBPoolContainer + + Id + + The ID of the container to update. This accepts an array of integers. + + Int32[] + + Int32[] + + + None + + + Name + + The new name for the container. + + String + + String + + + None + + + + + + Id + + The ID of the container to update. This accepts an array of integers. + + Int32[] + + Int32[] + + + None + + + Name + + The new name for the container. + + String + + String + + + None + + + + + + [int] - The ID of the container to update. + + + + + + + + [string] - The new name for the container. + + + + + + + + + + [PSCustomObject] - The response from the DBPool API. + + + + + + + + + Equivalent API endpoint: - PATCH /api/v2/containers/{id} + + + + + -------------------------- EXAMPLE 1 -------------------------- + Rename-DBPoolContainer -Id 12345 -Name 'NewContainerName' + + This will update the container with ID 12345 to have the name 'NewContainerName' + + + + -------------------------- EXAMPLE 2 -------------------------- + @( 12345, 56789 ) | Rename-DBPoolContainer -Name 'NewContainerName' + + This will update the containers with ID 12345, and 56789 to have the name 'NewContainerName' + + + + + + https://datto-dbpool-api.kentsapp.com/Containers/Rename-DBPoolContainer/ + https://datto-dbpool-api.kentsapp.com/Containers/Rename-DBPoolContainer/ + + + + + + Set-DBPoolApiParameter + Set + DBPoolApiParameter + + The Set-DBPoolApiParameter function is used to set parameters for the Datto DBPool API. + + + + The Set-DBPoolApiParameter function is used to set the API URL and API Key for the Datto DBPool API. + + + + Set-DBPoolApiParameter + + base_uri + + Provide the URL of the Datto DBPool API. The default value is https://dbpool.datto.net. + + Uri + + Uri + + + Https://dbpool.datto.net + + + apiKey + + Provide Datto DBPool API Key for authorization. You can find your user API key at \ /web/self \ (https://dbpool.datto.net/web/self). + + SecureString + + SecureString + + + None + + + Force + + Force the operation without confirmation. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + base_uri + + Provide the URL of the Datto DBPool API. The default value is https://dbpool.datto.net. + + Uri + + Uri + + + Https://dbpool.datto.net + + + apiKey + + Provide Datto DBPool API Key for authorization. You can find your user API key at \ /web/self \ (https://dbpool.datto.net/web/self). + + SecureString + + SecureString + + + None + + + Force + + Force the operation without confirmation. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + [Uri] - The base URL of the DBPool API. + + + + + + + + [SecureString] - The API key for the DBPool. + + + + + + + + + + [void] - No output is returned. + + + + + + + + + See Datto DBPool API help files for more information. + + + + + -------------------------- EXAMPLE 1 -------------------------- + Set-DBPoolApiParameter + + Sets the default base URI and prompts for the API Key. + + + + -------------------------- EXAMPLE 2 -------------------------- + Set-DBPoolApiParameter -base_uri "https://dbpool.example.com" -apiKey $secureString + + Sets the base URI to https://dbpool.example.com and sets the API Key. + + + + + + N/A + + + + + + + Test-DBPoolApi + Test + DBPoolApi + + Checks the availability of the DBPool API using an HTTP HEAD request. + + + + This function sends an HTTP HEAD request to the specified API URL using Invoke-WebRequest. Checks if the HTTP status code is 200, indicating that the API is available. + + + + Test-DBPoolApi + + base_uri + + The base URL of the API to be checked. + + String + + String + + + $DBPool_Base_URI + + + resource_Uri + + The URI of the API resource to be checked. + The default value is '/api/docs/openapi.json'. + + String + + String + + + /api/docs/openapi.json + + + apiKey + + Optional: Access token for authorization. + + SecureString + + SecureString + + + $DBPool_ApiKey + + + + + + base_uri + + The base URL of the API to be checked. + + String + + String + + + $DBPool_Base_URI + + + resource_Uri + + The URI of the API resource to be checked. + The default value is '/api/docs/openapi.json'. + + String + + String + + + /api/docs/openapi.json + + + apiKey + + Optional: Access token for authorization. + + SecureString + + SecureString + + + $DBPool_ApiKey + + + + + + [string] - The base URI for the DBPool API connection. + + + + + + + + [SecureString] - The API key for the DBPool. + + + + + + + + + + [System.Boolean] - Returns $true if the API is available, $false if not. + + + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + Test-DBPoolApi -base_uri "https://api.example.com" + + Checks the availability of the API at https://api.example.com + + + + + + + + Test-DBPoolApiKey + Test + DBPoolApiKey + + Test the DBPool API Key. + + + + The Test-DBPoolApiKey cmdlet tests the base URI & API Key that were defined in the Add-DBPoolBaseURI & Add-DBPoolAPIKey cmdlets. + + + + Test-DBPoolApiKey + + base_uri + + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. + The default base URI is https://dbpool.datto.net/api + + String + + String + + + $DBPool_Base_URI + + + + + + base_uri + + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. + The default base URI is https://dbpool.datto.net/api + + String + + String + + + $DBPool_Base_URI + + + + + + [string] - base_uri + + + + + + + + + + [PSCustomObject] - Various API metadata values + + + + + + + + + N/A + + + + + -------------------------- EXAMPLE 1 -------------------------- + Test-DBPoolApiKey + + Tests the base URI & API key that was defined in the Add-DBPoolBaseURI & Add-DBPoolAPIKey cmdlets. + The default full base uri test path is: https://dbpool.datto.net/api/v2/self + + + + -------------------------- EXAMPLE 2 -------------------------- + Test-DBPoolApiKey -base_uri http://dbpool.example.com + + Tests the base URI & API key that was defined in the Add-DBPoolBaseURI & Add-DBPoolAPIKey cmdlets. + The full base uri test path in this example is: http://dbpool.example.com/api/v2/self + + + + + + N/A + + + + + \ No newline at end of file diff --git a/docs/Containers/Get-DBPoolContainer.md b/docs/Containers/Get-DBPoolContainer.md index 107ff74..09d7524 100644 --- a/docs/Containers/Get-DBPoolContainer.md +++ b/docs/Containers/Get-DBPoolContainer.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/Get-DBPoolContainer/ schema: 2.0.0 --- @@ -14,24 +14,28 @@ The Get-DBPoolContainer function retrieves container information from the DBPool ## SYNTAX ### ListContainer (Default) -``` + +```PowerShell Get-DBPoolContainer [-ListContainer] [[-Id] ] [-Name ] [-DefaultDatabase ] [-NotLike] [] ``` ### ParentContainer -``` + +```PowerShell Get-DBPoolContainer [-ParentContainer] [[-Id] ] [-Name ] [-DefaultDatabase ] [-NotLike] [] ``` ### ChildContainer -``` + +```PowerShell Get-DBPoolContainer [-ChildContainer] [] ``` ### ContainerStatus -``` + +```PowerShell Get-DBPoolContainer [[-Id] ] [-Status] [] ``` @@ -63,20 +67,28 @@ Get a list of containers from the DBPool API by ID ### EXAMPLE 3 ```PowerShell -Get-DBPoolContainer -Status -Id @( 12345, 67890 ) +Get-DBPoolContainer -Status ``` -Get the status of an array of containers by IDs +Get the status of all containers from the DBPool API ### EXAMPLE 4 +```PowerShell +Get-DBPoolContainer -Status -Id 12345, 67890 +``` + +Get the status of an array of containers by IDs + +### EXAMPLE 5 + ```PowerShell Get-DBPoolContainer -ParentContainer ``` Get a list of parent containers from the DBPool API -### EXAMPLE 5 +### EXAMPLE 6 ```PowerShell Get-DBPoolContainer -ParentContainer -Id 12345 @@ -84,7 +96,7 @@ Get-DBPoolContainer -ParentContainer -Id 12345 Get a list of parent containers from the DBPool API by ID -### EXAMPLE 6 +### EXAMPLE 7 ```PowerShell Get-DBPoolContainer -ChildContainer @@ -92,7 +104,7 @@ Get-DBPoolContainer -ChildContainer Get a list of child containers from the DBPool API -### EXAMPLE 7 +### EXAMPLE 8 ```PowerShell Get-DBPoolContainer -Name 'MyContainer' @@ -102,7 +114,7 @@ Get-DBPoolContainer -ParentContainer -Name 'ParentContainer*' Uses 'Where-Object' to get a list of containers from the DBPool API, or parent containers by name Accepts wildcard input -### EXAMPLE 8 +### EXAMPLE 9 ```PowerShell Get-DBPoolContainer -Name 'MyContainer' -NotLike @@ -112,7 +124,7 @@ Get-DBPoolContainer -ParentContainer -Name 'ParentContainer*' -NotLike Uses 'Where-Object' to get a list of containers from the DBPool API, or parent containers where the name does not match the filter Accepts wildcard input -### EXAMPLE 9 +### EXAMPLE 10 ```PowerShell Get-DBPoolContainer -DefaultDatabase 'Database' @@ -122,7 +134,7 @@ Get-DBPoolContainer -ParentContainer -DefaultDatabase 'Database*' Get a list of containers from the DBPool API, or parent containers by database Accepts wildcard input -### EXAMPLE 10 +### EXAMPLE 11 ```PowerShell Get-DBPoolContainer -DefaultDatabase 'Database' -NotLike @@ -270,15 +282,16 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [int] -Id +### [int] - Id The ID of the container to get details for. -### [string] - Name +### [string] Name The name of the container to get details for. @@ -288,9 +301,7 @@ The database of the container to get details for. ## OUTPUTS -### [PSCustomObject] - -The response from the DBPool API. +### [PSCustomObject] - The response from the DBPool API ## NOTES @@ -299,6 +310,14 @@ This is a custom function which uses 'Where-Object', along with the optional -No If no match is found an error is output, and the original response is returned. +Equivalent API endpoint: + +- GET /api/v2/containers +- GET /api/v2/parents +- GET /api/v2/children +- GET /api/v2/containers/{id} +- GET /api/v2/containers/{id}/status + ## RELATED LINKS [https://datto-dbpool-api.kentsapp.com/Containers/Get-DBPoolContainer/](https://datto-dbpool-api.kentsapp.com/Containers/Get-DBPoolContainer/) diff --git a/docs/Containers/New-DBPoolContainer.md b/docs/Containers/New-DBPoolContainer.md index 0a8f563..78f98f8 100644 --- a/docs/Containers/New-DBPoolContainer.md +++ b/docs/Containers/New-DBPoolContainer.md @@ -1,37 +1,41 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/New-DBPoolContainer/ schema: 2.0.0 --- # New-DBPoolContainer ## SYNOPSIS + The New-DBPoolContainer function is used to create a new container from the DBPool API. ## SYNTAX -``` +```PowerShell New-DBPoolContainer [-ContainerName] [-ParentId ] [-ParentName ] [-ParentDefaultDatabase ] [-Force] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION + This function creates a new container in the DBPool based on the provided container name and parent container information. The ContainerName parameter is mandatory, and at least one of the parent parameters (ParentId, ParentName, or ParentDefaultDatabase) must be specified. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell New-DBPoolContainer -ContainerName 'MyNewContainer' -ParentId 12345 ``` This will create a new container named 'MyNewContainer' based on the parent container with ID 12345. ### EXAMPLE 2 -``` + +```PowerShell Get-DBPoolContainer -ParentContainer -Id 1 | New-DBPoolContainer -ContainerName 'MyNewContainer' ``` @@ -40,6 +44,7 @@ This will create a new container named 'MyNewContainer' based on the piped in pa ## PARAMETERS ### -ContainerName + The name for the new container. ```yaml @@ -55,6 +60,7 @@ Accept wildcard characters: False ``` ### -ParentId + The ID of the parent container to clone. ```yaml @@ -70,6 +76,7 @@ Accept wildcard characters: False ``` ### -ParentName + The name of the parent container to clone. ```yaml @@ -85,6 +92,7 @@ Accept wildcard characters: False ``` ### -ParentDefaultDatabase + The default database of the parent container to clone. ```yaml @@ -100,6 +108,7 @@ Accept wildcard characters: False ``` ### -Force + Force the operation without confirmation. ```yaml @@ -115,6 +124,7 @@ Accept wildcard characters: False ``` ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. @@ -131,6 +141,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -146,21 +157,37 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [string] - The name for the new container. -### [int] - The ID of the parent container to clone. -### [string] - The name of the parent container to clone. -### [string] - The default database of the parent container to clone. +### [string] - ContainerName + +The name for the new container. + +### [int] - ParentId + +The ID of the parent container to clone. + +### [string] - ParentName + +The name of the parent container to clone. + +### [string] - ParentDefaultDatabase + +The default database of the parent container to clone. + ## OUTPUTS -### [PSCustomObject] - The response from the DBPool API. +### [PSCustomObject] - The response from the DBPool API + ## NOTES -N/A -## RELATED LINKS +Equivalent API endpoint: + +- POST /api/v2/containers -[N/A]() +## RELATED LINKS +[https://datto-dbpool-api.kentsapp.com/Containers/New-DBPoolContainer/](https://datto-dbpool-api.kentsapp.com/Containers/New-DBPoolContainer/) diff --git a/docs/Containers/Remove-DBPoolContainer.md b/docs/Containers/Remove-DBPoolContainer.md index 440f5c7..854e100 100644 --- a/docs/Containers/Remove-DBPoolContainer.md +++ b/docs/Containers/Remove-DBPoolContainer.md @@ -1,38 +1,41 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/Remove-DBPoolContainer/ schema: 2.0.0 --- # Remove-DBPoolContainer ## SYNOPSIS + The Remove-DBPoolContainer function is used to delete a container in the DBPool. ## SYNTAX -``` +```PowerShell Remove-DBPoolContainer [-Id] [-Force] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION + The Remove-DBPoolContainer function is used to delete containers in the DBPool based on the provided container ID. -!! -This is a destructive operation and will destory the container !! +**!! This is a destructive operation and will destory the container !!** ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Remove-DBPoolContainer -Id '12345' ``` This will delete the provided container by ID. ### EXAMPLE 2 -``` + +```PowerShell @( 12345, 56789 ) | Remove-DBPoolContainer -Confirm:$false ``` @@ -41,6 +44,7 @@ This will delete the containers with ID 12345, and 56789. ## PARAMETERS ### -Id + The ID of the container to delete. This accepts an array of integers. @@ -57,6 +61,7 @@ Accept wildcard characters: False ``` ### -Force + Forces the removal of the container without prompting for confirmation. ```yaml @@ -72,6 +77,7 @@ Accept wildcard characters: False ``` ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. @@ -88,6 +94,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -103,18 +110,23 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [int] - The ID of the container to delete. +### [int] - The ID of the container to delete + ## OUTPUTS -### [void] - No output is returned. +### [void] - No output is returned + ## NOTES -N/A -## RELATED LINKS +Equivalent API endpoint: -[N/A]() +- DELETE /api/v2/containers/{id} + +## RELATED LINKS +[https://datto-dbpool-api.kentsapp.com/Containers/Remove-DBPoolContainer/](https://datto-dbpool-api.kentsapp.com/Containers/Remove-DBPoolContainer/) diff --git a/docs/Containers/Rename-DBPoolContainer.md b/docs/Containers/Rename-DBPoolContainer.md index 81392ce..d4c6a42 100644 --- a/docs/Containers/Rename-DBPoolContainer.md +++ b/docs/Containers/Rename-DBPoolContainer.md @@ -1,35 +1,39 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/Rename-DBPoolContainer/ schema: 2.0.0 --- # Rename-DBPoolContainer ## SYNOPSIS + The Rename-DBPoolContainer function is used to update a container in the DBPool. ## SYNTAX -``` +```PowerShell Rename-DBPoolContainer [-Id] [-Name] [] ``` ## DESCRIPTION + The Rename-DBPoolContainer function is used to change the name a container in the DBPool API. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Rename-DBPoolContainer -Id 12345 -Name 'NewContainerName' ``` This will update the container with ID 12345 to have the name 'NewContainerName' ### EXAMPLE 2 -``` + +```PowerShell @( 12345, 56789 ) | Rename-DBPoolContainer -Name 'NewContainerName' ``` @@ -38,6 +42,7 @@ This will update the containers with ID 12345, and 56789 to have the name 'NewCo ## PARAMETERS ### -Id + The ID of the container to update. This accepts an array of integers. @@ -54,6 +59,7 @@ Accept wildcard characters: False ``` ### -Name + The new name for the container. ```yaml @@ -69,19 +75,25 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [int] - The ID of the container to update. -### [string] - The new name for the container. +### [int] - The ID of the container to update + +### [string] - The new name for the container + ## OUTPUTS -### [PSCustomObject] - The response from the DBPool API. +### [PSCustomObject] - The response from the DBPool API + ## NOTES -N/A -## RELATED LINKS +Equivalent API endpoint: -[N/A]() +- PATCH /api/v2/containers/{id} + +## RELATED LINKS +[https://datto-dbpool-api.kentsapp.com/Containers/Rename-DBPoolContainer/](https://datto-dbpool-api.kentsapp.com/Containers/Rename-DBPoolContainer/) diff --git a/docs/Containers/access/Invoke-DBPoolContainerAccess.md b/docs/Containers/access/Invoke-DBPoolContainerAccess.md index 0ff8123..1bd422c 100644 --- a/docs/Containers/access/Invoke-DBPoolContainerAccess.md +++ b/docs/Containers/access/Invoke-DBPoolContainerAccess.md @@ -1,42 +1,48 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/access/Invoke-DBPoolContainerAccess/ schema: 2.0.0 --- # Invoke-DBPoolContainerAccess ## SYNOPSIS + The Invoke-DBPoolContainerAccess function is used to interact with various container access operations in the Datto DBPool API. ## SYNTAX ### GetAccess (Default) -``` + +```PowerShell Invoke-DBPoolContainerAccess [-Id] [-Username] [-GetAccess] [-WhatIf] [-Confirm] [] ``` ### RemoveAccess -``` + +```PowerShell Invoke-DBPoolContainerAccess [-Id] [-Username] [-RemoveAccess] [-WhatIf] [-Confirm] [] ``` ### AddAccess -``` + +```PowerShell Invoke-DBPoolContainerAccess [-Id] [-Username] [-AddAccess] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION + The Invoke-DBPoolContainerAccess function is used to Get, Add, or Remove access to a container in the Datto DBPool API based on a given username. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Invoke-DBPoolContainerAccess -Id '12345' -Username 'John.Doe' Invoke-DBPoolContainerAccess -Id '12345' -Username 'John.Doe' -GetAccess ``` @@ -44,14 +50,16 @@ Invoke-DBPoolContainerAccess -Id '12345' -Username 'John.Doe' -GetAccess This will get access to the container with ID 12345 for the user "John.Doe" ### EXAMPLE 2 -``` + +```PowerShell Invoke-DBPoolContainerAccess -Id @( '12345', '56789' ) -Username 'John.Doe' -AddAccess ``` This will add access to the containers with ID 12345, and 56789 for the user "John.Doe" ### EXAMPLE 3 -``` + +```PowerShell Invoke-DBPoolContainerAccess -Id '12345' -Username @( 'Jane.Doe', 'John.Doe' ) -RemoveAccess ``` @@ -60,6 +68,7 @@ This will remove access to the container with ID 12345 for the users "Jane.Doe", ## PARAMETERS ### -Id + The ID of the container to access. This accepts an array of integers. @@ -76,6 +85,7 @@ Accept wildcard characters: False ``` ### -Username + The username to access the container. This accepts an array of strings. @@ -92,6 +102,7 @@ Accept wildcard characters: False ``` ### -GetAccess + Gets the current access to a container by ID for the given username. ```yaml @@ -107,6 +118,7 @@ Accept wildcard characters: False ``` ### -AddAccess + Adds access to a container by ID for the given username. ```yaml @@ -122,6 +134,7 @@ Accept wildcard characters: False ``` ### -RemoveAccess + Removes access to a container by ID for the given username. ```yaml @@ -137,6 +150,7 @@ Accept wildcard characters: False ``` ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. @@ -153,6 +167,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -168,20 +183,29 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [int] - The ID of the container to access. -### [string] - The username to access the container. +### [int] - The ID of the container to access + +### [string] - The username to access the container + ## OUTPUTS -### [PSCustomObject] - The response from the DBPool API. -### [void] - No output is returned. +### [PSCustomObject] - The response from the DBPool API + +### [void] - No output is returned + ## NOTES -N/A -## RELATED LINKS +Equivalent API endpoint: + +- GET /api/v2/containers/{id}/access/{username} +- PUT /api/v2/containers/{id}/access/{username} +- DELETE /api/v2/containers/{id}/access/{username} -[N/A]() +## RELATED LINKS +[https://datto-dbpool-api.kentsapp.com/Containers/access/Invoke-DBPoolContainerAccess/](https://datto-dbpool-api.kentsapp.com/Containers/access/Invoke-DBPoolContainerAccess/) diff --git a/docs/Containers/actions/Invoke-DBPoolContainerAction.md b/docs/Containers/actions/Invoke-DBPoolContainerAction.md index 9185aab..017efb6 100644 --- a/docs/Containers/actions/Invoke-DBPoolContainerAction.md +++ b/docs/Containers/actions/Invoke-DBPoolContainerAction.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/actions/Invoke-DBPoolContainerAction/ schema: 2.0.0 --- @@ -13,7 +13,7 @@ The Invoke-DBPoolContainerAction function is used to interact with various conta ## SYNTAX -``` +```PowerShell Invoke-DBPoolContainerAction [-Action] [-Id] [-Force] [-TimeoutSeconds ] [-ThrottleLimit ] [-WhatIf] [-Confirm] [] ``` @@ -171,43 +171,42 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [int] +### [int] - The ID of the container to perform the action on -The ID of the container to perform the action on. - -### [string] - -The action to perform on the container. +### [string] - The action to perform on the container ## OUTPUTS -### [void] - -No output is returned. +### [void] - No output is returned ## NOTES -- **Actions:** +Equivalent API endpoint: + +- POST /api/v2/containers/{id}/actions/{action} + +**Actions:** - - `refresh` - - Recreate the Docker container and ZFS snapshot for the container. - - `schema-merge` - - Attempt to apply upstream changes to the parent container to this child container. - This may break your container. - Refreshing a container is the supported way to update a child container's database schema. - - `start` - - Start the Docker container for the container. +- `refresh` + - Recreate the Docker container and ZFS snapshot for the container. +- `schema-merge` + - Attempt to apply upstream changes to the parent container to this child container. + This may break your container. + Refreshing a container is the supported way to update a child container's database schema. +- `start` + - Start the Docker container for the container. - - `restart` - - Stop and start the Docker container. +- `restart` + - Stop and start the Docker container. - - `stop` - - Stop the Docker container. +- `stop` + - Stop the Docker container. ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Containers/actions/Invoke-DBPoolContainerAction/](https://datto-dbpool-api.kentsapp.com/Containers/actions/Invoke-DBPoolContainerAction/) diff --git a/docs/Debug/Invoke-DBPoolDebug.md b/docs/Debug/Invoke-DBPoolDebug.md index 28146d5..ef12e6d 100644 --- a/docs/Debug/Invoke-DBPoolDebug.md +++ b/docs/Debug/Invoke-DBPoolDebug.md @@ -1,29 +1,32 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Debug/Invoke-DBPoolDebug/ schema: 2.0.0 --- # Invoke-DBPoolDebug ## SYNOPSIS + Provides an example exception response from the DBPool API for debugging purposes. ## SYNTAX -``` +```PowerShell Invoke-DBPoolDebug [[-method] ] [] ``` ## DESCRIPTION + Uses the Invoke-DBPoolRequest function to make a request to the DBPool API. Returns an example exception response for debugging and testing purposes. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Invoke-DBPoolDebug -method GET ``` @@ -32,6 +35,7 @@ Sends a 'GET' request to the DBPool API and returns a '418' exception response e ## PARAMETERS ### -method + The HTTP method to use when making the request to the DBPool API. Default is 'GET'. @@ -48,18 +52,22 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS -### [System.Management.Automation.ErrorRecord] - Returns an example exception response from the DBPool API. +### [System.Management.Automation.ErrorRecord] - Returns an example exception response from the DBPool API + ## NOTES -N/A -## RELATED LINKS +Equivalent API endpoint: + - GET /api/docs/error -[N/A]() +## RELATED LINKS +[https://datto-dbpool-api.kentsapp.com/Debug/Invoke-DBPoolDebug/](https://datto-dbpool-api.kentsapp.com/Debug/Invoke-DBPoolDebug/) diff --git a/docs/Internal/Set-DBPoolApiParameter.md b/docs/Internal/Set-DBPoolApiParameter.md index b090946..c6f48b2 100644 --- a/docs/Internal/Set-DBPoolApiParameter.md +++ b/docs/Internal/Set-DBPoolApiParameter.md @@ -1,46 +1,51 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/Set-DBPoolApiParameter/ schema: 2.0.0 --- # Set-DBPoolApiParameter ## SYNOPSIS + The Set-DBPoolApiParameter function is used to set parameters for the Datto DBPool API. ## SYNTAX -``` +```PowerShell Set-DBPoolApiParameter [[-base_uri] ] [-apiKey] [-Force] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION + The Set-DBPoolApiParameter function is used to set the API URL and API Key for the Datto DBPool API. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Set-DBPoolApiParameter ``` Sets the default base URI and prompts for the API Key. ### EXAMPLE 2 -``` + +```PowerShell Set-DBPoolApiParameter -base_uri "https://dbpool.example.com" -apiKey $secureString ``` -Sets the base URI to https://dbpool.example.com and sets the API Key. +Sets the base URI to [https://dbpool.example.com](https://dbpool.example.com) and sets the API Key. ## PARAMETERS ### -base_uri + Provide the URL of the Datto DBPool API. -The default value is https://dbpool.datto.net. +The default value is [https://dbpool.datto.net](https://dbpool.datto.net). ```yaml Type: Uri @@ -55,8 +60,9 @@ Accept wildcard characters: False ``` ### -apiKey + Provide Datto DBPool API Key for authorization. -You can find your user API key at \[ /web/self \](https://dbpool.datto.net/web/self). +You can find your user API key at [/web/self](https://dbpool.datto.net/web/self). ```yaml Type: SecureString @@ -71,6 +77,7 @@ Accept wildcard characters: False ``` ### -Force + Force the operation without confirmation. ```yaml @@ -86,6 +93,7 @@ Accept wildcard characters: False ``` ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. @@ -102,6 +110,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -117,19 +126,23 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [Uri] - The base URL of the DBPool API. -### [SecureString] - The API key for the DBPool. +### [Uri] - The base URL of the DBPool API + +### [SecureString] - The API key for the DBPool + ## OUTPUTS -### [void] - No output is returned. +### [void] - No output is returned + ## NOTES + See Datto DBPool API help files for more information. ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/Set-DBPoolApiParameter/](https://datto-dbpool-api.kentsapp.com/Internal/Set-DBPoolApiParameter/) diff --git a/docs/Internal/Test-DBPoolApi.md b/docs/Internal/Test-DBPoolApi.md index afb6ec6..35173a1 100644 --- a/docs/Internal/Test-DBPoolApi.md +++ b/docs/Internal/Test-DBPoolApi.md @@ -1,38 +1,50 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/Test-DBPoolApi/ schema: 2.0.0 --- # Test-DBPoolApi ## SYNOPSIS + Checks the availability of the DBPool API using an HTTP HEAD request. ## SYNTAX -``` +```PowerShell Test-DBPoolApi [[-base_uri] ] [[-resource_Uri] ] [[-apiKey] ] [] ``` ## DESCRIPTION + This function sends an HTTP HEAD request to the specified API URL using Invoke-WebRequest. Checks if the HTTP status code is 200, indicating that the API is available. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Test-DBPoolApi -base_uri "https://api.example.com" ``` -Checks the availability of the API at https://api.example.com +Checks the availability of the API at [https://api.example.com](https://api.example.com) + +### EXAMPLE 2 + +```PowerShell +Test-DBPoolApi -base_uri "https://api.example.com" -resource_Uri "/api/docs" +``` + +Checks the availability of the API at [https://api.example.com/api/docs](https://api.example.com/api/docs) ## PARAMETERS ### -base_uri + The base URL of the API to be checked. ```yaml @@ -48,6 +60,7 @@ Accept wildcard characters: False ``` ### -resource_Uri + The URI of the API resource to be checked. The default value is '/api/docs/openapi.json'. @@ -65,6 +78,7 @@ Accept wildcard characters: False ``` ### -apiKey + Optional: Access token for authorization. ```yaml @@ -80,15 +94,23 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [string] - The base URI for the DBPool API connection. -### [SecureString] - The API key for the DBPool. +### [string] - The base URI for the DBPool API connection + +### [SecureString] - The API key for the DBPool + ## OUTPUTS -### [System.Boolean] - Returns $true if the API is available, $false if not. +### [System.Boolean] - Returns $true if the API is available, $false if not + ## NOTES +N/A + ## RELATED LINKS + +[https://datto-dbpool-api.kentsapp.com/Internal/Test-DBPoolApi/](https://datto-dbpool-api.kentsapp.com/Internal/Test-DBPoolApi/) diff --git a/docs/Internal/apiCalls/ConvertTo-DBPoolQueryString.md b/docs/Internal/apiCalls/ConvertTo-DBPoolQueryString.md index cbf510e..9a5c409 100644 --- a/docs/Internal/apiCalls/ConvertTo-DBPoolQueryString.md +++ b/docs/Internal/apiCalls/ConvertTo-DBPoolQueryString.md @@ -1,13 +1,14 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/ConvertTo-DBPoolQueryString/ schema: 2.0.0 --- # ConvertTo-DBPoolQueryString ## SYNOPSIS + Converts uri filter parameters As of June 2024, DBPool does not support any query parameters. @@ -15,11 +16,12 @@ This is only provided to allow forward compatibility ## SYNTAX -``` +```PowerShell ConvertTo-DBPoolQueryString [[-uri_Filter] ] [-resource_Uri] [] ``` ## DESCRIPTION + The ConvertTo-DBPoolQueryString cmdlet converts & formats uri filter parameters from a function which are later used to make the full resource uri for an API call @@ -33,24 +35,29 @@ This is only provided to allow forward compatibility ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell ConvertTo-DBPoolQueryString -uri_Filter $uri_Filter -resource_Uri '/api/v2/containers' ``` Example: (From public function) - $uri_Filter = @{} - ForEach ( $Key in $PSBoundParameters.GetEnumerator() ){ - if( $excludedParameters -contains $Key.Key ){$null} - else{ $uri_Filter += @{ $Key.Key = $Key.Value } } - } +```PowerShell +$uri_Filter = @{} + +ForEach ( $Key in $PSBoundParameters.GetEnumerator() ){ + if( $excludedParameters -contains $Key.Key ){$null} + else{ $uri_Filter += @{ $Key.Key = $Key.Value } } +} - 1x key = https://api.DBPool.com/v1/api/v2/containers?parentId=12345 - 2x key = https://api.DBPool.com/v1/api/v2/containers?parentId=12345&power=True +1x key = https://api.DBPool.com/v1/api/v2/containers?parentId=12345 +2x key = https://api.DBPool.com/v1/api/v2/containers?parentId=12345&power=True +``` ## PARAMETERS ### -uri_Filter + Hashtable of values to combine a functions parameters with the resource_Uri parameter. @@ -72,6 +79,7 @@ Accept wildcard characters: False ``` ### -resource_Uri + Defines the short resource uri (url) to use when creating the API call ```yaml @@ -87,18 +95,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### [hashtable] - uri_Filter + ## OUTPUTS ### [System.UriBuilder] - uri_Request + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/ConvertTo-DBPoolQueryString/](https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/ConvertTo-DBPoolQueryString/) diff --git a/docs/Internal/apiCalls/Get-DBPoolMetaData.md b/docs/Internal/apiCalls/Get-DBPoolMetaData.md index ce2fcfb..80d66d7 100644 --- a/docs/Internal/apiCalls/Get-DBPoolMetaData.md +++ b/docs/Internal/apiCalls/Get-DBPoolMetaData.md @@ -1,22 +1,24 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Get-DBPoolMetaData/ schema: 2.0.0 --- # Get-DBPoolMetaData ## SYNOPSIS + Gets various API metadata values ## SYNTAX -``` +```PowerShell Get-DBPoolMetaData [[-base_uri] ] [[-resource_uri] ] [] ``` ## DESCRIPTION + The Get-DBPoolMetaData cmdlet gets various API metadata values from an Invoke-WebRequest to assist in various troubleshooting scenarios such as rate-limiting. @@ -24,7 +26,8 @@ as rate-limiting. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Get-DBPoolMetaData ``` @@ -32,10 +35,11 @@ Gets various API metadata values from an Invoke-WebRequest to assist in various troubleshooting scenarios such as rate-limiting. The default full base uri test path is: - https://dbpool.datto.net + [https://dbpool.datto.net](https://dbpool.datto.net) ### EXAMPLE 2 -``` + +```PowerShell Get-DBPoolMetaData -base_uri http://dbpool.example.com ``` @@ -43,14 +47,16 @@ Gets various API metadata values from an Invoke-WebRequest to assist in various troubleshooting scenarios such as rate-limiting. The full base uri test path in this example is: - http://dbpool.example.com/device + [http://dbpool.example.com/api/v2/self](http://dbpool.example.com/api/v2/self) ## PARAMETERS ### -base_uri + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. -The default base URI is https://dbpool.datto.net +The default base URI is: + [https://dbpool.datto.net](https://dbpool.datto.net) ```yaml Type: String @@ -65,6 +71,7 @@ Accept wildcard characters: False ``` ### -resource_uri + Define the resource URI for the DBPool API connection. The default resource URI is /api/v2/self @@ -82,18 +89,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### [string] - base_uri + ## OUTPUTS ### [PSCustomObject] - Various API metadata values + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Get-DBPoolMetaData/](https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Get-DBPoolMetaData/) diff --git a/docs/Internal/apiCalls/Invoke-DBPoolRequest.md b/docs/Internal/apiCalls/Invoke-DBPoolRequest.md index fc979d1..d79fed5 100644 --- a/docs/Internal/apiCalls/Invoke-DBPoolRequest.md +++ b/docs/Internal/apiCalls/Invoke-DBPoolRequest.md @@ -1,23 +1,25 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Invoke-DBPoolRequest/ schema: 2.0.0 --- # Invoke-DBPoolRequest ## SYNOPSIS + Internal function to make an API request to the DBPool API ## SYNTAX -``` +```PowerShell Invoke-DBPoolRequest [[-method] ] [-resource_Uri] [[-uri_Filter] ] [[-data] ] [[-DBPool_JSON_Conversion_Depth] ] [-allPages] [] ``` ## DESCRIPTION + The Invoke-DBPoolRequest cmdlet invokes an API request to DBPool API This is an internal function that is used by all public functions @@ -25,9 +27,9 @@ This is an internal function that is used by all public functions ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Invoke-DBPoolRequest -method GET -resource_Uri '/api/v2/self' -uri_Filter $uri_Filter -``` Name Value ---- ----- @@ -35,12 +37,15 @@ Method GET Uri https://dbpool.datto.net/api/v2/self Headers {X-App-Apikey = 3feb2b29-919c-409c-985d-e99cbae43a6d} Body +``` Invoke an API request against the defined resource using any of the provided parameters ### EXAMPLE 2 -``` + +```PowerShell Invoke-DBPoolRequest -method GET -resource_Uri '/api/openapi.json' -uri_Filter $uri_Filter + Name Value ---- ----- Method GET @@ -54,6 +59,7 @@ Invoke an API request against the defined resource using any of the provided par ## PARAMETERS ### -method + Defines the type of API method to use Allowed values: @@ -72,6 +78,7 @@ Accept wildcard characters: False ``` ### -resource_Uri + Defines the resource uri (url) to use when creating the API call ```yaml @@ -87,7 +94,8 @@ Accept wildcard characters: False ``` ### -uri_Filter -Used with the internal function \[ ConvertTo-DBPoolQueryString \] to combine + +Used with the internal function `ConvertTo-DBPoolQueryString` to combine a functions parameters with the resource_Uri parameter. This allows for the full uri query to occur @@ -111,6 +119,7 @@ Accept wildcard characters: False ``` ### -data + Defines the data to be sent with the API request body when using POST or PATCH ```yaml @@ -126,6 +135,7 @@ Accept wildcard characters: False ``` ### -DBPool_JSON_Conversion_Depth + Defines the depth of the JSON conversion for the 'data' parameter request body ```yaml @@ -141,6 +151,7 @@ Accept wildcard characters: False ``` ### -allPages + Returns all items from an endpoint When using this parameter there is no need to use either the page or perPage @@ -162,18 +173,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS ### [Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject] - The response from the DBPool API + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Invoke-DBPoolRequest/](https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Invoke-DBPoolRequest/) diff --git a/docs/Internal/apiKeys/Add-DBPoolApiKey.md b/docs/Internal/apiKeys/Add-DBPoolApiKey.md index 3de1cf8..cdcd9f3 100644 --- a/docs/Internal/apiKeys/Add-DBPoolApiKey.md +++ b/docs/Internal/apiKeys/Add-DBPoolApiKey.md @@ -1,22 +1,24 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Add-DBPoolApiKey/ schema: 2.0.0 --- # Add-DBPoolApiKey ## SYNOPSIS + Sets the API key for the DBPool. ## SYNTAX -``` -Add-DBPoolApiKey [-apiKey] [] +```PowerShell +Add-DBPoolApiKey [-apiKey] [-Force] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION + The Add-DBPoolApiKey cmdlet sets the API key which is used to authenticate API calls made to DBPool. Once the API key is defined, the secret key is encrypted using SecureString. @@ -26,14 +28,16 @@ The DBPool API key is retrieved via the DBPool UI at My Profile -\> API key ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Add-DBPoolApiKey ``` Prompts to enter in your personal API key. ### EXAMPLE 2 -``` + +```PowerShell Add-DBPoolApiKey -ApiKey $secureString Read-Host "Enter your DBPool API Key" -AsSecureString | Add-DBPoolApiKey ``` @@ -43,6 +47,7 @@ Sets the API key for the DBPool. ## PARAMETERS ### -apiKey + Defines your API key for the DBPool. ```yaml @@ -57,19 +62,71 @@ Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` +### -Force + +Forces the setting of the DBPool API key. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf + +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm + +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [SecureString] - The API key for the DBPool. +### [SecureString] - The API key for the DBPool + ## OUTPUTS -### [void] - No output is returned. +### [void] - No output is returned + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Add-DBPoolApiKey/](https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Add-DBPoolApiKey/) diff --git a/docs/Internal/apiKeys/Get-DBPoolApiKey.md b/docs/Internal/apiKeys/Get-DBPoolApiKey.md index d3890c3..64b6a6d 100644 --- a/docs/Internal/apiKeys/Get-DBPoolApiKey.md +++ b/docs/Internal/apiKeys/Get-DBPoolApiKey.md @@ -1,35 +1,39 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Get-DBPoolApiKey/ schema: 2.0.0 --- # Get-DBPoolApiKey ## SYNOPSIS + Gets the DBPool API key global variable. ## SYNTAX -``` +```PowerShell Get-DBPoolApiKey [-AsPlainText] [] ``` ## DESCRIPTION + The Get-DBPoolApiKey cmdlet gets the DBPool API key global variable and returns this as an object. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Get-DBPoolApiKey ``` Gets the DBPool API key global variable and returns this as an object with the secret key as a SecureString. ### EXAMPLE 2 -``` + +```PowerShell Get-DBPoolApiKey -AsPlainText ``` @@ -38,6 +42,7 @@ Gets the DBPool API key global variable and returns this as an object with the s ## PARAMETERS ### -AsPlainText + Decrypt and return the API key in plain text. ```yaml @@ -53,18 +58,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS -### [PSCustomObject] - The DBPool API key global variable. +### [PSCustomObject] - The DBPool API key global variable + ## NOTES + N\A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Get-DBPoolApiKey/](https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Get-DBPoolApiKey/) diff --git a/docs/Internal/apiKeys/Remove-DBPoolApiKey.md b/docs/Internal/apiKeys/Remove-DBPoolApiKey.md index 26b8267..0960503 100644 --- a/docs/Internal/apiKeys/Remove-DBPoolApiKey.md +++ b/docs/Internal/apiKeys/Remove-DBPoolApiKey.md @@ -1,28 +1,31 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Remove-DBPoolApiKey/ schema: 2.0.0 --- # Remove-DBPoolApiKey ## SYNOPSIS + Removes the DBPool API Key global variable. ## SYNTAX -``` +```PowerShell Remove-DBPoolApiKey [-Force] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION + The Remove-DBPoolAPIKey cmdlet removes the DBPool API Key global variable. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Remove-DBPoolAPIKey ``` @@ -31,6 +34,7 @@ Removes the DBPool API Key global variable. ## PARAMETERS ### -Force + Forces the removal of the DBPool API Key global variable without prompting for confirmation. ```yaml @@ -46,6 +50,7 @@ Accept wildcard characters: False ``` ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. @@ -62,6 +67,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -77,18 +83,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS -### [void] - No output is returned. +### [void] - No output is returned + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Remove-DBPoolApiKey/](https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Remove-DBPoolApiKey/) diff --git a/docs/Internal/apiKeys/Test-DBPoolApiKey.md b/docs/Internal/apiKeys/Test-DBPoolApiKey.md index d7093ad..616a02c 100644 --- a/docs/Internal/apiKeys/Test-DBPoolApiKey.md +++ b/docs/Internal/apiKeys/Test-DBPoolApiKey.md @@ -1,52 +1,58 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Test-DBPoolApiKey/ schema: 2.0.0 --- # Test-DBPoolApiKey ## SYNOPSIS + Test the DBPool API Key. ## SYNTAX -``` +```PowerShell Test-DBPoolApiKey [[-base_uri] ] [] ``` ## DESCRIPTION + The Test-DBPoolApiKey cmdlet tests the base URI & API Key that were defined in the Add-DBPoolBaseURI & Add-DBPoolAPIKey cmdlets. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Test-DBPoolApiKey ``` Tests the base URI & API key that was defined in the Add-DBPoolBaseURI & Add-DBPoolAPIKey cmdlets. The default full base uri test path is: - https://dbpool.datto.net/api/v2/self + [https://dbpool.datto.net/api/v2/self](https://dbpool.datto.net/api/v2/self) ### EXAMPLE 2 -``` + +```PowerShell Test-DBPoolApiKey -base_uri http://dbpool.example.com ``` Tests the base URI & API key that was defined in the Add-DBPoolBaseURI & Add-DBPoolAPIKey cmdlets. The full base uri test path in this example is: - http://dbpool.example.com/api/v2/self + [http://dbpool.example.com/api/v2/self](http://dbpool.example.com/api/v2/self) ## PARAMETERS ### -base_uri + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. -The default base URI is https://dbpool.datto.net/api +The default base URI is: + [https://dbpool.datto.net/api](https://dbpool.datto.net/api) ```yaml Type: String @@ -61,18 +67,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### [string] - base_uri + ## OUTPUTS ### [PSCustomObject] - Various API metadata values + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Test-DBPoolApiKey/](https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Test-DBPoolApiKey/) diff --git a/docs/Internal/baseUri/Add-DBPoolBaseURI.md b/docs/Internal/baseUri/Add-DBPoolBaseURI.md index fa614d0..e351f75 100644 --- a/docs/Internal/baseUri/Add-DBPoolBaseURI.md +++ b/docs/Internal/baseUri/Add-DBPoolBaseURI.md @@ -1,51 +1,57 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Add-DBPoolBaseURI/ schema: 2.0.0 --- # Add-DBPoolBaseURI ## SYNOPSIS + Sets the base URI for the DBPool API connection. ## SYNTAX -``` +```PowerShell Add-DBPoolBaseURI [[-base_uri] ] [[-instance] ] [] ``` ## DESCRIPTION + The Add-DBPoolBaseURI cmdlet sets the base URI which is later used to construct the full URI for all API calls. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Add-DBPoolBaseURI ``` -The base URI will use https://dbpool.datto.net which is Datto's default DBPool URI. +The base URI will use [https://dbpool.datto.net](https://dbpool.datto.net) which is Datto's default DBPool URI. ### EXAMPLE 2 -``` + +```PowerShell Add-DBPoolBaseURI -instance Datto ``` -The base URI will use https://dbpool.datto.net which is DBPool's default URI. +The base URI will use [https://dbpool.datto.net](https://dbpool.datto.net) which is DBPool's default URI. ### EXAMPLE 3 -``` + +```PowerShell Add-DBPoolBaseURI -base_uri http://dbpool.example.com ``` -A custom API gateway of http://dbpool.example.com will be used for all API calls to DBPool's API. +A custom API gateway of [https://dbpool.datto.net](https://dbpool.datto.net) will be used for all API calls to DBPool's API. ## PARAMETERS ### -base_uri + Define the base URI for the DBPool API connection using Datto's DBPool URI or a custom URI. ```yaml @@ -61,11 +67,13 @@ Accept wildcard characters: False ``` ### -instance + DBPool's URI connection point that can be one of the predefined data centers. The accepted values for this parameter are: -\[ DEFAULT \] - DEFAULT = https://dbpool.datto.net + +- [ DEFAULT ] + - DEFAULT = [https://dbpool.datto.net](https://dbpool.datto.net) Placeholder for other data centers. @@ -82,18 +90,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [string] - The base URI for the DBPool API connection. +### [string] - The base URI for the DBPool API connection + ## OUTPUTS -### [void] - No output is returned. +### [void] - No output is returned + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Add-DBPoolBaseURI/](https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Add-DBPoolBaseURI/) diff --git a/docs/Internal/baseUri/Get-DBPoolBaseURI.md b/docs/Internal/baseUri/Get-DBPoolBaseURI.md index d9c879d..59dc187 100644 --- a/docs/Internal/baseUri/Get-DBPoolBaseURI.md +++ b/docs/Internal/baseUri/Get-DBPoolBaseURI.md @@ -1,28 +1,31 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Get-DBPoolBaseURI/ schema: 2.0.0 --- # Get-DBPoolBaseURI ## SYNOPSIS + Shows the DBPool base URI global variable. ## SYNTAX -``` +```PowerShell Get-DBPoolBaseURI [] ``` ## DESCRIPTION + The Get-DBPoolBaseURI cmdlet shows the DBPool base URI global variable value. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Get-DBPoolBaseURI ``` @@ -31,18 +34,21 @@ Shows the DBPool base URI global variable value. ## PARAMETERS ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS -### [void] - No output is returned. +### [void] - No output is returned + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Get-DBPoolBaseURI/](https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Get-DBPoolBaseURI/) diff --git a/docs/Internal/baseUri/Remove-DBPoolBaseURI.md b/docs/Internal/baseUri/Remove-DBPoolBaseURI.md index 6416e08..220c947 100644 --- a/docs/Internal/baseUri/Remove-DBPoolBaseURI.md +++ b/docs/Internal/baseUri/Remove-DBPoolBaseURI.md @@ -1,28 +1,31 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Remove-DBPoolBaseURI/ schema: 2.0.0 --- # Remove-DBPoolBaseURI ## SYNOPSIS + Removes the DBPool base URI global variable. ## SYNTAX -``` +```PowerShell Remove-DBPoolBaseURI [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION + The Remove-DBPoolBaseURI cmdlet removes the DBPool base URI global variable. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Remove-DBPoolBaseURI ``` @@ -31,6 +34,7 @@ Removes the DBPool base URI global variable. ## PARAMETERS ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. @@ -47,6 +51,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -62,18 +67,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS -### [void] - No output is returned. +### [void] - No output is returned + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Remove-DBPoolBaseURI/](https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Remove-DBPoolBaseURI/) diff --git a/docs/Internal/moduleSettings/Export-DBPoolModuleSetting.md b/docs/Internal/moduleSettings/Export-DBPoolModuleSetting.md index bd7b47a..bdef153 100644 --- a/docs/Internal/moduleSettings/Export-DBPoolModuleSetting.md +++ b/docs/Internal/moduleSettings/Export-DBPoolModuleSetting.md @@ -1,22 +1,24 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Export-DBPoolModuleSetting/ schema: 2.0.0 --- # Export-DBPoolModuleSetting ## SYNOPSIS + Exports the DBPool BaseURI, API Key, & JSON configuration information to file. ## SYNTAX -``` +```PowerShell Export-DBPoolModuleSetting [-DBPoolConfPath ] [-DBPoolConfFile ] [] ``` ## DESCRIPTION + The Export-DBPoolModuleSetting cmdlet exports the DBPool BaseURI, API Key, & JSON configuration information to file. Making use of PowerShell's System.Security.SecureString type, exporting module settings encrypts your API key in a format @@ -26,7 +28,8 @@ This means that you cannot copy your configuration file to another computer or u ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Export-DBPoolModuleSetting ``` @@ -35,7 +38,8 @@ to the current user's DBPool configuration file located at: $env:USERPROFILE\DBPoolAPI\config.psd1 ### EXAMPLE 2 -``` + +```PowerShell Export-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -DBPoolConfFile MyConfig.psd1 ``` @@ -46,6 +50,7 @@ to the current user's DBPool configuration file located at: ## PARAMETERS ### -DBPoolConfPath + Define the location to store the DBPool configuration file. By default the configuration file is stored in the following location: @@ -64,6 +69,7 @@ Accept wildcard characters: False ``` ### -DBPoolConfFile + Define the name of the DBPool configuration file. By default the configuration file is named: @@ -82,18 +88,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS -### [void] - No output is returned. +### [void] - No output is returned + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Export-DBPoolModuleSetting/](https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Export-DBPoolModuleSetting/) diff --git a/docs/Internal/moduleSettings/Get-DBPoolModuleSetting.md b/docs/Internal/moduleSettings/Get-DBPoolModuleSetting.md index 72c4259..e677e8e 100644 --- a/docs/Internal/moduleSettings/Get-DBPoolModuleSetting.md +++ b/docs/Internal/moduleSettings/Get-DBPoolModuleSetting.md @@ -1,28 +1,32 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Get-DBPoolModuleSetting/ schema: 2.0.0 --- # Get-DBPoolModuleSetting ## SYNOPSIS + Gets the saved DBPool configuration settings ## SYNTAX ### index (Default) -``` + +```PowerShell Get-DBPoolModuleSetting [-DBPoolConfPath ] [-DBPoolConfFile ] [] ``` ### show -``` + +```PowerShell Get-DBPoolModuleSetting [-openConfFile] [] ``` ## DESCRIPTION + The Get-DBPoolModuleSetting cmdlet gets the saved DBPool configuration settings from the local system. @@ -32,7 +36,8 @@ By default the configuration file is stored in the following location: ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Get-DBPoolModuleSetting ``` @@ -43,7 +48,8 @@ The default location of the DBPool configuration file is: $env:USERPROFILE\DBPoolAPI\config.psd1 ### EXAMPLE 2 -``` + +```PowerShell Get-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -DBPoolConfFile MyConfig.psd1 -openConfFile ``` @@ -55,6 +61,7 @@ The location of the DBPool configuration file in this example is: ## PARAMETERS ### -DBPoolConfPath + Define the location to store the DBPool configuration file. By default the configuration file is stored in the following location: @@ -73,6 +80,7 @@ Accept wildcard characters: False ``` ### -DBPoolConfFile + Define the name of the DBPool configuration file. By default the configuration file is named: @@ -91,6 +99,7 @@ Accept wildcard characters: False ``` ### -openConfFile + Opens the DBPool configuration file ```yaml @@ -106,18 +115,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS -### [void] - No output is returned. +### [void] - No output is returned + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Get-DBPoolModuleSetting/](https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Get-DBPoolModuleSetting/) diff --git a/docs/Internal/moduleSettings/Import-DBPoolModuleSetting.md b/docs/Internal/moduleSettings/Import-DBPoolModuleSetting.md index 5656ae8..c2df529 100644 --- a/docs/Internal/moduleSettings/Import-DBPoolModuleSetting.md +++ b/docs/Internal/moduleSettings/Import-DBPoolModuleSetting.md @@ -1,22 +1,24 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Import-DBPoolModuleSetting/ schema: 2.0.0 --- # Import-DBPoolModuleSetting ## SYNOPSIS + Imports the DBPool BaseURI, API Key, & JSON configuration information to the current session. ## SYNTAX -``` +```PowerShell Import-DBPoolModuleSetting [-DBPoolConfPath ] [-DBPoolConfFile ] [] ``` ## DESCRIPTION + The Import-DBPoolModuleSetting cmdlet imports the DBPool BaseURI, API Key, & JSON configuration information stored in the DBPool configuration file to the users current session. @@ -26,7 +28,8 @@ By default the configuration file is stored in the following location: ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Import-DBPoolModuleSetting ``` @@ -37,7 +40,8 @@ The default location of the DBPool configuration file is: $env:USERPROFILE\DBPoolAPI\config.psd1 ### EXAMPLE 2 -``` + +```PowerShell Import-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -DBPoolConfFile MyConfig.psd1 ``` @@ -50,6 +54,7 @@ The location of the DBPool configuration file in this example is: ## PARAMETERS ### -DBPoolConfPath + Define the location to store the DBPool configuration file. By default the configuration file is stored in the following location: @@ -68,6 +73,7 @@ Accept wildcard characters: False ``` ### -DBPoolConfFile + Define the name of the DBPool configuration file. By default the configuration file is named: @@ -86,18 +92,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS -### N/A +### [void] - No output is returned + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Import-DBPoolModuleSetting/](https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Import-DBPoolModuleSetting/) diff --git a/docs/Internal/moduleSettings/Remove-DBPoolModuleSetting.md b/docs/Internal/moduleSettings/Remove-DBPoolModuleSetting.md index 7f93bd8..dce3d43 100644 --- a/docs/Internal/moduleSettings/Remove-DBPoolModuleSetting.md +++ b/docs/Internal/moduleSettings/Remove-DBPoolModuleSetting.md @@ -1,22 +1,24 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Remove-DBPoolModuleSetting/ schema: 2.0.0 --- # Remove-DBPoolModuleSetting ## SYNOPSIS + Removes the stored DBPool configuration folder. ## SYNTAX -``` +```PowerShell Remove-DBPoolModuleSetting [-DBPoolConfPath ] [-andVariables] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION + The Remove-DBPoolModuleSetting cmdlet removes the DBPool folder and its files. This cmdlet also has the option to remove sensitive DBPool variables as well. @@ -26,7 +28,8 @@ By default configuration files are stored in the following location and will be ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Remove-DBPoolModuleSetting ``` @@ -36,7 +39,8 @@ The default location of the DBPool configuration folder is: $env:USERPROFILE\DBPoolAPI ### EXAMPLE 2 -``` + +```PowerShell Remove-DBPoolModuleSetting -DBPoolConfPath C:\DBPoolAPI -andVariables ``` @@ -49,6 +53,7 @@ The location of the DBPool configuration folder in this example is: ## PARAMETERS ### -DBPoolConfPath + Define the location of the DBPool configuration folder. By default the configuration folder is located at: @@ -67,6 +72,7 @@ Accept wildcard characters: False ``` ### -andVariables + Define if sensitive DBPool variables should be removed as well. By default the variables are not removed. @@ -84,6 +90,7 @@ Accept wildcard characters: False ``` ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. @@ -100,6 +107,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -115,18 +123,21 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS -### [void] - No output is returned. +### [void] - No output is returned + ## NOTES + N/A ## RELATED LINKS -[N/A]() - +[https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Remove-DBPoolModuleSetting/](https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Remove-DBPoolModuleSetting/) diff --git a/docs/OpenAPI/Get-DBPoolOpenAPI.md b/docs/OpenAPI/Get-DBPoolOpenAPI.md index 69639da..b49b744 100644 --- a/docs/OpenAPI/Get-DBPoolOpenAPI.md +++ b/docs/OpenAPI/Get-DBPoolOpenAPI.md @@ -1,28 +1,31 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/OpenAPI/Get-DBPoolOpenAPI/ schema: 2.0.0 --- # Get-DBPoolOpenAPI ## SYNOPSIS + Gets the DBPool OpenAPI documentation. ## SYNTAX -``` +```PowerShell Get-DBPoolOpenAPI [[-OpenAPI_Path] ] [] ``` ## DESCRIPTION + Gets the OpenAPI json spec for the DBPool API documentation. ## EXAMPLES ### EXAMPLE 1 -``` + +```PowerShell Get-DBPoolOpenAPI ``` @@ -31,8 +34,9 @@ This will get the OpenAPI json spec for the DBPool API documentation. ## PARAMETERS ### -OpenAPI_Path + The path to the OpenAPI json spec. -This defaults to '/api/docs/openapi.json' +This defaults to `/api/docs/openapi.json` ```yaml Type: String @@ -47,18 +51,23 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS ### N/A + ## OUTPUTS -### [PSCustomObject] - The OpenAPI json spec for the DBPool API documentation. +### [PSCustomObject] - The OpenAPI json spec for the DBPool API documentation + ## NOTES -N/A -## RELATED LINKS +Equivalent API endpoint: + +- GET /api/docs/openapi.json -[N/A]() +## RELATED LINKS +[https://datto-dbpool-api.kentsapp.com/OpenAPI/Get-DBPoolOpenAPI/](https://datto-dbpool-api.kentsapp.com/OpenAPI/Get-DBPoolOpenAPI/) diff --git a/docs/Users/Get-DBPoolUser.md b/docs/Users/Get-DBPoolUser.md index f339fb7..d2f4d91 100644 --- a/docs/Users/Get-DBPoolUser.md +++ b/docs/Users/Get-DBPoolUser.md @@ -1,50 +1,88 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Users/Get-DBPoolUser/ schema: 2.0.0 --- # Get-DBPoolUser ## SYNOPSIS + Get a user from DBPool ## SYNTAX ### Self (Default) -``` -Get-DBPoolUser [] + +```PowerShell +Get-DBPoolUser [-PlainTextAPIKey] [] ``` ### User -``` + +```PowerShell Get-DBPoolUser [[-Username] ] [] ``` ## DESCRIPTION + The Get-DBPoolUser function is used to get a user details from DBPool. -Default will get the current authenticated user details, but can be used to get any user details by username. +Will retrieve the current authenticated user details, but can also be used to get other user details by username. ## EXAMPLES ### EXAMPLE 1 -``` + +This will get the user details for the current authenticated user. + +```PowerShell Get-DBPoolUser ``` -This will get the user details for the current authenticated user. +```PowerShell +id : 1234 +username : john.doe +displayName : John Doe +email : John.Doe@company.tld +apiKey : System.Security.SecureString +``` ### EXAMPLE 2 -``` + +This will get the user details for the user "John.Doe". + +```PowerShell Get-DBPoolUser -username "John.Doe" ``` -This will get the user details for the user "John.Doe". +```PowerShell +id username displayName email +-- -------- ----------- ----- +1234 john.doe John Doe John.Doe@company.tld +``` ## PARAMETERS +### -PlainTextAPIKey + +This switch will return the API Key in plain text. +By default, the API Key is returned as a SecureString. + +```yaml +Type: SwitchParameter +Parameter Sets: Self +Aliases: + +Required: False +Position: 1 +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Username + The username of the user to get details for. This accepts an array of strings. @@ -61,18 +99,24 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS -### [string] - The username of the user to get details for. +### [string] - The username of the user to get details for + ## OUTPUTS -### [PSCustomObject] - The user details from DBPool. +### [PSCustomObject] - The user details from DBPool + ## NOTES -N/A -## RELATED LINKS +Equivalent API endpoint: -[N/A]() +- GET /api/v2/self +- GET /api/v2/users/{username} + +## RELATED LINKS +[https://datto-dbpool-api.kentsapp.com/Users/Get-DBPoolUser/](https://datto-dbpool-api.kentsapp.com/Users/Get-DBPoolUser/) diff --git a/docs/en-US/Add-DBPoolApiKey.md b/docs/generated/en-US/Add-DBPoolApiKey.md similarity index 88% rename from docs/en-US/Add-DBPoolApiKey.md rename to docs/generated/en-US/Add-DBPoolApiKey.md index a7b4e71..1e4e18d 100644 --- a/docs/en-US/Add-DBPoolApiKey.md +++ b/docs/generated/en-US/Add-DBPoolApiKey.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Add-DBPoolApiKey/ schema: 2.0.0 --- @@ -73,7 +73,8 @@ Accept wildcard characters: False ``` ### -WhatIf -Shows what would happen if the cmdlet runs. The cmdlet is not run. +Shows what would happen if the cmdlet runs. +The cmdlet is not run. ```yaml Type: SwitchParameter @@ -116,5 +117,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Add-DBPoolApiKey/](https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Add-DBPoolApiKey/) diff --git a/docs/en-US/Add-DBPoolBaseURI.md b/docs/generated/en-US/Add-DBPoolBaseURI.md similarity index 89% rename from docs/en-US/Add-DBPoolBaseURI.md rename to docs/generated/en-US/Add-DBPoolBaseURI.md index fa614d0..6c6f711 100644 --- a/docs/en-US/Add-DBPoolBaseURI.md +++ b/docs/generated/en-US/Add-DBPoolBaseURI.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Add-DBPoolBaseURI/ schema: 2.0.0 --- @@ -95,5 +95,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Add-DBPoolBaseURI/](https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Add-DBPoolBaseURI/) diff --git a/docs/en-US/ConvertTo-DBPoolQueryString.md b/docs/generated/en-US/ConvertTo-DBPoolQueryString.md similarity index 90% rename from docs/en-US/ConvertTo-DBPoolQueryString.md rename to docs/generated/en-US/ConvertTo-DBPoolQueryString.md index cbf510e..f0596a3 100644 --- a/docs/en-US/ConvertTo-DBPoolQueryString.md +++ b/docs/generated/en-US/ConvertTo-DBPoolQueryString.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/ConvertTo-DBPoolQueryString/ schema: 2.0.0 --- @@ -100,5 +100,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/ConvertTo-DBPoolQueryString/](https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/ConvertTo-DBPoolQueryString/) diff --git a/docs/en-US/Export-DBPoolModuleSetting.md b/docs/generated/en-US/Export-DBPoolModuleSetting.md similarity index 89% rename from docs/en-US/Export-DBPoolModuleSetting.md rename to docs/generated/en-US/Export-DBPoolModuleSetting.md index bd7b47a..9299767 100644 --- a/docs/en-US/Export-DBPoolModuleSetting.md +++ b/docs/generated/en-US/Export-DBPoolModuleSetting.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Export-DBPoolModuleSetting/ schema: 2.0.0 --- @@ -95,5 +95,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Export-DBPoolModuleSetting/](https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Export-DBPoolModuleSetting/) diff --git a/docs/en-US/Get-DBPoolApiKey.md b/docs/generated/en-US/Get-DBPoolApiKey.md similarity index 85% rename from docs/en-US/Get-DBPoolApiKey.md rename to docs/generated/en-US/Get-DBPoolApiKey.md index d3890c3..f03ffb1 100644 --- a/docs/en-US/Get-DBPoolApiKey.md +++ b/docs/generated/en-US/Get-DBPoolApiKey.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Get-DBPoolApiKey/ schema: 2.0.0 --- @@ -66,5 +66,5 @@ N\A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Get-DBPoolApiKey/](https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Get-DBPoolApiKey/) diff --git a/docs/en-US/Get-DBPoolBaseURI.md b/docs/generated/en-US/Get-DBPoolBaseURI.md similarity index 78% rename from docs/en-US/Get-DBPoolBaseURI.md rename to docs/generated/en-US/Get-DBPoolBaseURI.md index d9c879d..9b380cc 100644 --- a/docs/en-US/Get-DBPoolBaseURI.md +++ b/docs/generated/en-US/Get-DBPoolBaseURI.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Get-DBPoolBaseURI/ schema: 2.0.0 --- @@ -44,5 +44,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Get-DBPoolBaseURI/](https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Get-DBPoolBaseURI/) diff --git a/docs/en-US/Get-DBPoolContainer.md b/docs/generated/en-US/Get-DBPoolContainer.md similarity index 91% rename from docs/en-US/Get-DBPoolContainer.md rename to docs/generated/en-US/Get-DBPoolContainer.md index ad27245..157fc3e 100644 --- a/docs/en-US/Get-DBPoolContainer.md +++ b/docs/generated/en-US/Get-DBPoolContainer.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/Get-DBPoolContainer/ schema: 2.0.0 --- @@ -58,33 +58,40 @@ Get a list of containers from the DBPool API by ID ### EXAMPLE 3 ``` -Get-DBPoolContainer -Status -Id @( 12345, 67890 ) +Get-DBPoolContainer -Status ``` -Get the status of an array of containers by IDs +Get the status of all containers from the DBPool API ### EXAMPLE 4 ``` +Get-DBPoolContainer -Status -Id 12345, 67890 +``` + +Get the status of an array of containers by IDs + +### EXAMPLE 5 +``` Get-DBPoolContainer -ParentContainer ``` Get a list of parent containers from the DBPool API -### EXAMPLE 5 +### EXAMPLE 6 ``` Get-DBPoolContainer -ParentContainer -Id 12345 ``` Get a list of parent containers from the DBPool API by ID -### EXAMPLE 6 +### EXAMPLE 7 ``` Get-DBPoolContainer -ChildContainer ``` Get a list of child containers from the DBPool API -### EXAMPLE 7 +### EXAMPLE 8 ``` Get-DBPoolContainer -Name 'MyContainer' Get-DBPoolContainer -ParentContainer -Name 'ParentContainer*' @@ -93,7 +100,7 @@ Get-DBPoolContainer -ParentContainer -Name 'ParentContainer*' Uses 'Where-Object' to get a list of containers from the DBPool API, or parent containers by name Accepts wildcard input -### EXAMPLE 8 +### EXAMPLE 9 ``` Get-DBPoolContainer -Name 'MyContainer' -NotLike Get-DBPoolContainer -ParentContainer -Name 'ParentContainer*' -NotLike @@ -102,7 +109,7 @@ Get-DBPoolContainer -ParentContainer -Name 'ParentContainer*' -NotLike Uses 'Where-Object' to get a list of containers from the DBPool API, or parent containers where the name does not match the filter Accepts wildcard input -### EXAMPLE 9 +### EXAMPLE 10 ``` Get-DBPoolContainer -DefaultDatabase 'Database' Get-DBPoolContainer -ParentContainer -DefaultDatabase 'Database*' @@ -111,7 +118,7 @@ Get-DBPoolContainer -ParentContainer -DefaultDatabase 'Database*' Get a list of containers from the DBPool API, or parent containers by database Accepts wildcard input -### EXAMPLE 10 +### EXAMPLE 11 ``` Get-DBPoolContainer -DefaultDatabase 'Database' -NotLike Get-DBPoolContainer -ParentContainer -DefaultDatabase 'Database*' -NotLike @@ -170,7 +177,6 @@ Accept wildcard characters: False ### -Id The ID of the container details to get from the DBPool. -This parameter is required when using the 'ContainerStatus' parameter set. ```yaml Type: Int32[] @@ -270,7 +276,14 @@ This is a custom function which uses 'Where-Object', along with the optional -No If no match is found an error is output, and the original response is returned. +Equivalent API endpoint: + - GET /api/v2/containers + - GET /api/v2/parents + - GET /api/v2/children + - GET /api/v2/containers/{id} + - GET /api/v2/containers/{id}/status + ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Containers/Get-DBPoolContainer/](https://datto-dbpool-api.kentsapp.com/Containers/Get-DBPoolContainer/) diff --git a/docs/en-US/Get-DBPoolMetaData.md b/docs/generated/en-US/Get-DBPoolMetaData.md similarity index 89% rename from docs/en-US/Get-DBPoolMetaData.md rename to docs/generated/en-US/Get-DBPoolMetaData.md index ce2fcfb..2587f7b 100644 --- a/docs/en-US/Get-DBPoolMetaData.md +++ b/docs/generated/en-US/Get-DBPoolMetaData.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Get-DBPoolMetaData/ schema: 2.0.0 --- @@ -95,5 +95,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Get-DBPoolMetaData/](https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Get-DBPoolMetaData/) diff --git a/docs/en-US/Get-DBPoolModuleSetting.md b/docs/generated/en-US/Get-DBPoolModuleSetting.md similarity index 90% rename from docs/en-US/Get-DBPoolModuleSetting.md rename to docs/generated/en-US/Get-DBPoolModuleSetting.md index 72c4259..bf2e961 100644 --- a/docs/en-US/Get-DBPoolModuleSetting.md +++ b/docs/generated/en-US/Get-DBPoolModuleSetting.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Get-DBPoolModuleSetting/ schema: 2.0.0 --- @@ -119,5 +119,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Get-DBPoolModuleSetting/](https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Get-DBPoolModuleSetting/) diff --git a/docs/en-US/Get-DBPoolOpenAPI.md b/docs/generated/en-US/Get-DBPoolOpenAPI.md similarity index 81% rename from docs/en-US/Get-DBPoolOpenAPI.md rename to docs/generated/en-US/Get-DBPoolOpenAPI.md index 69639da..3bd9139 100644 --- a/docs/en-US/Get-DBPoolOpenAPI.md +++ b/docs/generated/en-US/Get-DBPoolOpenAPI.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/OpenAPI/Get-DBPoolOpenAPI/ schema: 2.0.0 --- @@ -56,9 +56,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### [PSCustomObject] - The OpenAPI json spec for the DBPool API documentation. ## NOTES -N/A +Equivalent API endpoint: + - GET /api/docs/openapi.json ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/OpenAPI/Get-DBPoolOpenAPI/](https://datto-dbpool-api.kentsapp.com/OpenAPI/Get-DBPoolOpenAPI/) diff --git a/docs/en-US/Get-DBPoolUser.md b/docs/generated/en-US/Get-DBPoolUser.md similarity index 55% rename from docs/en-US/Get-DBPoolUser.md rename to docs/generated/en-US/Get-DBPoolUser.md index f339fb7..76e7da6 100644 --- a/docs/en-US/Get-DBPoolUser.md +++ b/docs/generated/en-US/Get-DBPoolUser.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Users/Get-DBPoolUser/ schema: 2.0.0 --- @@ -14,7 +14,7 @@ Get a user from DBPool ### Self (Default) ``` -Get-DBPoolUser [] +Get-DBPoolUser [-PlainTextAPIKey] [] ``` ### User @@ -24,7 +24,7 @@ Get-DBPoolUser [[-Username] ] [] ## DESCRIPTION The Get-DBPoolUser function is used to get a user details from DBPool. -Default will get the current authenticated user details, but can be used to get any user details by username. +Will retrieve the current authenticated user details, but can also be used to get other user details by username. ## EXAMPLES @@ -35,6 +35,14 @@ Get-DBPoolUser This will get the user details for the current authenticated user. +---------------------------------------------------------------- + +id : 1234 +username : john.doe +displayName : John Doe +email : John.Doe@company.tld +apiKey : System.Security.SecureString + ### EXAMPLE 2 ``` Get-DBPoolUser -username "John.Doe" @@ -42,8 +50,30 @@ Get-DBPoolUser -username "John.Doe" This will get the user details for the user "John.Doe". +---------------------------------------------------------------- + +id username displayName email +-- -------- ----------- ----- +1234 john.doe John Doe John.Doe@company.tld + ## PARAMETERS +### -PlainTextAPIKey +This switch will return the API Key in plain text. +By default, the API Key is returned as a SecureString. + +```yaml +Type: SwitchParameter +Parameter Sets: Self +Aliases: + +Required: False +Position: 1 +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Username The username of the user to get details for. This accepts an array of strings. @@ -70,9 +100,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### [PSCustomObject] - The user details from DBPool. ## NOTES -N/A +Equivalent API endpoint: + - GET /api/v2/self + - GET /api/v2/users/{username} ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Users/Get-DBPoolUser/](https://datto-dbpool-api.kentsapp.com/Users/Get-DBPoolUser/) diff --git a/docs/en-US/Import-DBPoolModuleSetting.md b/docs/generated/en-US/Import-DBPoolModuleSetting.md similarity index 89% rename from docs/en-US/Import-DBPoolModuleSetting.md rename to docs/generated/en-US/Import-DBPoolModuleSetting.md index 5656ae8..bb0950b 100644 --- a/docs/en-US/Import-DBPoolModuleSetting.md +++ b/docs/generated/en-US/Import-DBPoolModuleSetting.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Import-DBPoolModuleSetting/ schema: 2.0.0 --- @@ -99,5 +99,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Import-DBPoolModuleSetting/](https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Import-DBPoolModuleSetting/) diff --git a/docs/en-US/Invoke-DBPoolContainerAccess.md b/docs/generated/en-US/Invoke-DBPoolContainerAccess.md similarity index 89% rename from docs/en-US/Invoke-DBPoolContainerAccess.md rename to docs/generated/en-US/Invoke-DBPoolContainerAccess.md index 0ff8123..1ce9c29 100644 --- a/docs/en-US/Invoke-DBPoolContainerAccess.md +++ b/docs/generated/en-US/Invoke-DBPoolContainerAccess.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/access/Invoke-DBPoolContainerAccess/ schema: 2.0.0 --- @@ -179,9 +179,12 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### [PSCustomObject] - The response from the DBPool API. ### [void] - No output is returned. ## NOTES -N/A +Equivalent API endpoint: + - GET /api/v2/containers/{id}/access/{username} + - PUT /api/v2/containers/{id}/access/{username} + - DELETE /api/v2/containers/{id}/access/{username} ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Containers/access/Invoke-DBPoolContainerAccess/](https://datto-dbpool-api.kentsapp.com/Containers/access/Invoke-DBPoolContainerAccess/) diff --git a/docs/en-US/Invoke-DBPoolContainerAction.md b/docs/generated/en-US/Invoke-DBPoolContainerAction.md similarity index 92% rename from docs/en-US/Invoke-DBPoolContainerAction.md rename to docs/generated/en-US/Invoke-DBPoolContainerAction.md index 0aa0d75..71b580d 100644 --- a/docs/en-US/Invoke-DBPoolContainerAction.md +++ b/docs/generated/en-US/Invoke-DBPoolContainerAction.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/actions/Invoke-DBPoolContainerAction/ schema: 2.0.0 --- @@ -168,6 +168,9 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### [void] - No output is returned. ## NOTES +Equivalent API endpoint: + - POST /api/v2/containers/{id}/actions/{action} + Actions: refresh: @@ -189,5 +192,5 @@ Refreshing a container is the supported way to update a child container's databa ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Containers/actions/Invoke-DBPoolContainerAction/](https://datto-dbpool-api.kentsapp.com/Containers/actions/Invoke-DBPoolContainerAction/) diff --git a/docs/en-US/Invoke-DBPoolDebug.md b/docs/generated/en-US/Invoke-DBPoolDebug.md similarity index 84% rename from docs/en-US/Invoke-DBPoolDebug.md rename to docs/generated/en-US/Invoke-DBPoolDebug.md index 28146d5..2abc156 100644 --- a/docs/en-US/Invoke-DBPoolDebug.md +++ b/docs/generated/en-US/Invoke-DBPoolDebug.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Debug/Invoke-DBPoolDebug/ schema: 2.0.0 --- @@ -57,9 +57,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### [System.Management.Automation.ErrorRecord] - Returns an example exception response from the DBPool API. ## NOTES -N/A +Equivalent API endpoint: + - GET /api/docs/error ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Debug/Invoke-DBPoolDebug/](https://datto-dbpool-api.kentsapp.com/Debug/Invoke-DBPoolDebug/) diff --git a/docs/en-US/Invoke-DBPoolRequest.md b/docs/generated/en-US/Invoke-DBPoolRequest.md similarity index 94% rename from docs/en-US/Invoke-DBPoolRequest.md rename to docs/generated/en-US/Invoke-DBPoolRequest.md index fc979d1..be13e3e 100644 --- a/docs/en-US/Invoke-DBPoolRequest.md +++ b/docs/generated/en-US/Invoke-DBPoolRequest.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Invoke-DBPoolRequest/ schema: 2.0.0 --- @@ -175,5 +175,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Invoke-DBPoolRequest/](https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Invoke-DBPoolRequest/) diff --git a/docs/en-US/New-DBPoolContainer.md b/docs/generated/en-US/New-DBPoolContainer.md similarity index 92% rename from docs/en-US/New-DBPoolContainer.md rename to docs/generated/en-US/New-DBPoolContainer.md index 0516cda..1a68775 100644 --- a/docs/en-US/New-DBPoolContainer.md +++ b/docs/generated/en-US/New-DBPoolContainer.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/New-DBPoolContainer/ schema: 2.0.0 --- @@ -162,9 +162,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### [PSCustomObject] - The response from the DBPool API. ## NOTES -N/A +Equivalent API endpoint: + - POST /api/v2/containers ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Containers/New-DBPoolContainer/](https://datto-dbpool-api.kentsapp.com/Containers/New-DBPoolContainer/) diff --git a/docs/en-US/Remove-DBPoolApiKey.md b/docs/generated/en-US/Remove-DBPoolApiKey.md similarity index 87% rename from docs/en-US/Remove-DBPoolApiKey.md rename to docs/generated/en-US/Remove-DBPoolApiKey.md index 26b8267..6627126 100644 --- a/docs/en-US/Remove-DBPoolApiKey.md +++ b/docs/generated/en-US/Remove-DBPoolApiKey.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Remove-DBPoolApiKey/ schema: 2.0.0 --- @@ -90,5 +90,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Remove-DBPoolApiKey/](https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Remove-DBPoolApiKey/) diff --git a/docs/en-US/Remove-DBPoolBaseURI.md b/docs/generated/en-US/Remove-DBPoolBaseURI.md similarity index 85% rename from docs/en-US/Remove-DBPoolBaseURI.md rename to docs/generated/en-US/Remove-DBPoolBaseURI.md index 6416e08..0bb6e64 100644 --- a/docs/en-US/Remove-DBPoolBaseURI.md +++ b/docs/generated/en-US/Remove-DBPoolBaseURI.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Remove-DBPoolBaseURI/ schema: 2.0.0 --- @@ -75,5 +75,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Remove-DBPoolBaseURI/](https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Remove-DBPoolBaseURI/) diff --git a/docs/en-US/Remove-DBPoolContainer.md b/docs/generated/en-US/Remove-DBPoolContainer.md similarity index 88% rename from docs/en-US/Remove-DBPoolContainer.md rename to docs/generated/en-US/Remove-DBPoolContainer.md index 440f5c7..997d523 100644 --- a/docs/en-US/Remove-DBPoolContainer.md +++ b/docs/generated/en-US/Remove-DBPoolContainer.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/Remove-DBPoolContainer/ schema: 2.0.0 --- @@ -112,9 +112,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### [void] - No output is returned. ## NOTES -N/A +Equivalent API endpoint: + - DELETE /api/v2/containers/{id} ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Containers/Remove-DBPoolContainer/](https://datto-dbpool-api.kentsapp.com/Containers/Remove-DBPoolContainer/) diff --git a/docs/en-US/Remove-DBPoolModuleSetting.md b/docs/generated/en-US/Remove-DBPoolModuleSetting.md similarity index 90% rename from docs/en-US/Remove-DBPoolModuleSetting.md rename to docs/generated/en-US/Remove-DBPoolModuleSetting.md index 7f93bd8..8a417b9 100644 --- a/docs/en-US/Remove-DBPoolModuleSetting.md +++ b/docs/generated/en-US/Remove-DBPoolModuleSetting.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Remove-DBPoolModuleSetting/ schema: 2.0.0 --- @@ -128,5 +128,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Remove-DBPoolModuleSetting/](https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Remove-DBPoolModuleSetting/) diff --git a/docs/en-US/Rename-DBPoolContainer.md b/docs/generated/en-US/Rename-DBPoolContainer.md similarity index 86% rename from docs/en-US/Rename-DBPoolContainer.md rename to docs/generated/en-US/Rename-DBPoolContainer.md index 81392ce..7555742 100644 --- a/docs/en-US/Rename-DBPoolContainer.md +++ b/docs/generated/en-US/Rename-DBPoolContainer.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Containers/Rename-DBPoolContainer/ schema: 2.0.0 --- @@ -79,9 +79,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### [PSCustomObject] - The response from the DBPool API. ## NOTES -N/A +Equivalent API endpoint: + - PATCH /api/v2/containers/{id} ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Containers/Rename-DBPoolContainer/](https://datto-dbpool-api.kentsapp.com/Containers/Rename-DBPoolContainer/) diff --git a/docs/en-US/Set-DBPoolApiParameter.md b/docs/generated/en-US/Set-DBPoolApiParameter.md similarity index 92% rename from docs/en-US/Set-DBPoolApiParameter.md rename to docs/generated/en-US/Set-DBPoolApiParameter.md index b090946..f837054 100644 --- a/docs/en-US/Set-DBPoolApiParameter.md +++ b/docs/generated/en-US/Set-DBPoolApiParameter.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/Set-DBPoolApiParameter/ schema: 2.0.0 --- @@ -131,5 +131,5 @@ See Datto DBPool API help files for more information. ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/Set-DBPoolApiParameter/](https://datto-dbpool-api.kentsapp.com/Internal/Set-DBPoolApiParameter/) diff --git a/docs/en-US/Test-DBPoolApi.md b/docs/generated/en-US/Test-DBPoolApi.md similarity index 84% rename from docs/en-US/Test-DBPoolApi.md rename to docs/generated/en-US/Test-DBPoolApi.md index afb6ec6..f48a010 100644 --- a/docs/en-US/Test-DBPoolApi.md +++ b/docs/generated/en-US/Test-DBPoolApi.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/Test-DBPoolApi/ schema: 2.0.0 --- @@ -30,6 +30,13 @@ Test-DBPoolApi -base_uri "https://api.example.com" Checks the availability of the API at https://api.example.com +### EXAMPLE 2 +``` +Test-DBPoolApi -base_uri "https://api.example.com" -resource_Uri "/api/docs" +``` + +Checks the availability of the API at https://api.example.com/api/docs + ## PARAMETERS ### -base_uri @@ -90,5 +97,9 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### [System.Boolean] - Returns $true if the API is available, $false if not. ## NOTES +N/A ## RELATED LINKS + +[https://datto-dbpool-api.kentsapp.com/Internal/Test-DBPoolApi/](https://datto-dbpool-api.kentsapp.com/Internal/Test-DBPoolApi/) + diff --git a/docs/en-US/Test-DBPoolApiKey.md b/docs/generated/en-US/Test-DBPoolApiKey.md similarity index 87% rename from docs/en-US/Test-DBPoolApiKey.md rename to docs/generated/en-US/Test-DBPoolApiKey.md index d7093ad..0aab63e 100644 --- a/docs/en-US/Test-DBPoolApiKey.md +++ b/docs/generated/en-US/Test-DBPoolApiKey.md @@ -1,7 +1,7 @@ --- external help file: Datto.DBPool.API-help.xml Module Name: Datto.DBPool.API -online version: +online version: https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Test-DBPoolApiKey/ schema: 2.0.0 --- @@ -74,5 +74,5 @@ N/A ## RELATED LINKS -[N/A]() +[https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Test-DBPoolApiKey/](https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Test-DBPoolApiKey/) diff --git a/psakeFile.ps1 b/psakeFile.ps1 index f6ea009..607adbe 100644 --- a/psakeFile.ps1 +++ b/psakeFile.ps1 @@ -11,6 +11,7 @@ properties { $PSBPreference.Help.DefaultLocale = 'en-US' $PSBPreference.Test.OutputFile = 'out/testResults.xml' $PSBPreference.Test.ImportModule = $true + $PSBPreference.Docs.RootDir = "$projectRoot/docs/generated" } task Default -depends Test diff --git a/src/Private/Set-DBPoolApiParameter.ps1 b/src/Private/Set-DBPoolApiParameter.ps1 index 28d50b1..2c22079 100644 --- a/src/Private/Set-DBPoolApiParameter.ps1 +++ b/src/Private/Set-DBPoolApiParameter.ps1 @@ -38,7 +38,7 @@ function Set-DBPoolApiParameter { See Datto DBPool API help files for more information. .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/Set-DBPoolApiParameter/ #> [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')] diff --git a/src/Private/Test-DBPoolApi.ps1 b/src/Private/Test-DBPoolApi.ps1 index 9bfad46..24bfa71 100644 --- a/src/Private/Test-DBPoolApi.ps1 +++ b/src/Private/Test-DBPoolApi.ps1 @@ -29,6 +29,17 @@ function Test-DBPoolApi { Test-DBPoolApi -base_uri "https://api.example.com" Checks the availability of the API at https://api.example.com + + .EXAMPLE + Test-DBPoolApi -base_uri "https://api.example.com" -resource_Uri "/api/docs" + + Checks the availability of the API at https://api.example.com/api/docs + + .NOTES + N/A + + .LINK + https://datto-dbpool-api.kentsapp.com/Internal/Test-DBPoolApi/ #> [CmdletBinding()] diff --git a/src/Private/apiCalls/ConvertTo-DBPoolQueryString.ps1 b/src/Private/apiCalls/ConvertTo-DBPoolQueryString.ps1 index 6ddd7a6..bb8eaf8 100644 --- a/src/Private/apiCalls/ConvertTo-DBPoolQueryString.ps1 +++ b/src/Private/apiCalls/ConvertTo-DBPoolQueryString.ps1 @@ -53,7 +53,7 @@ function ConvertTo-DBPoolQueryString { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/ConvertTo-DBPoolQueryString/ #> diff --git a/src/Private/apiCalls/Get-DBPoolMetaData.ps1 b/src/Private/apiCalls/Get-DBPoolMetaData.ps1 index 9fc4f94..593e27c 100644 --- a/src/Private/apiCalls/Get-DBPoolMetaData.ps1 +++ b/src/Private/apiCalls/Get-DBPoolMetaData.ps1 @@ -40,13 +40,13 @@ function Get-DBPoolMetaData { in various troubleshooting scenarios such as rate-limiting. The full base uri test path in this example is: - http://dbpool.example.com/device + http://dbpool.example.com/api/v2/self .NOTES N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Get-DBPoolMetaData/ #> [CmdletBinding()] @@ -74,7 +74,7 @@ function Get-DBPoolMetaData { $DBPool_Headers.Add("Content-Type", 'application/json') $DBPool_Headers.Add('X-App-APIkey', $api_Key) - $rest_output = Invoke-WebRequest -method $method -uri ($base_uri + $resource_uri) -headers $DBPool_Headers -ErrorAction Stop + $response = Invoke-WebRequest -method $method -uri ($base_uri + $resource_uri) -headers $DBPool_Headers -ErrorAction Stop } catch { @@ -91,17 +91,17 @@ function Get-DBPoolMetaData { Remove-Variable -Name DBPool_Headers -Force } - if ($rest_output){ + if ($response){ $data = @{} - $data = $rest_output + $data = $response [PSCustomObject]@{ RequestUri = $($DBPool_Base_URI + $resource_uri) StatusCode = $data.StatusCode StatusDescription = $data.StatusDescription 'Content-Type' = $data.headers.'Content-Type' - <#'X-App-Request-Id' = $data.headers.'X-App-Request-Id' - 'X-API-Limit-Remaining' = $data.headers.'X-API-Limit-Remaining' + 'X-App-Request-Id' = $data.headers.'X-App-Request-Id' + <#'X-API-Limit-Remaining' = $data.headers.'X-API-Limit-Remaining' 'X-API-Limit-Resets' = $data.headers.'X-API-Limit-Resets' 'X-API-Limit-Cost' = $data.headers.'X-API-Limit-Cost'#> raw = $data diff --git a/src/Private/apiCalls/Invoke-DBPoolRequest.ps1 b/src/Private/apiCalls/Invoke-DBPoolRequest.ps1 index 678e5f0..ad4a811 100644 --- a/src/Private/apiCalls/Invoke-DBPoolRequest.ps1 +++ b/src/Private/apiCalls/Invoke-DBPoolRequest.ps1 @@ -18,7 +18,7 @@ function Invoke-DBPoolRequest { Defines the resource uri (url) to use when creating the API call .PARAMETER uri_Filter - Used with the internal function [ ConvertTo-DBPoolQueryString ] to combine + Used with the internal function 'ConvertTo-DBPoolQueryString' to combine a functions parameters with the resource_Uri parameter. This allows for the full uri query to occur @@ -77,7 +77,7 @@ function Invoke-DBPoolRequest { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/apiCalls/Invoke-DBPoolRequest/ #> @@ -106,9 +106,7 @@ function Invoke-DBPoolRequest { ) - begin { - $ConfirmPreference = 'None' - } + begin {} process { @@ -123,7 +121,7 @@ function Invoke-DBPoolRequest { $query_String = ConvertTo-DBPoolQueryString -resource_Uri $resource_Uri -uri_Filter $uri_Filter - Set-Variable -Name 'DBPool_queryString' -Value $query_String -Scope Global -Force + Set-Variable -Name 'DBPool_queryString' -Value $query_String -Scope Global -Force -Confirm:$false if ($null -eq $data) { $request_Body = $null @@ -145,7 +143,7 @@ function Invoke-DBPoolRequest { $parameters['ContentType'] = 'application/json; charset=utf-8' } - Set-Variable -Name 'DBPool_invokeParameters' -Value $parameters -Scope Global -Force + Set-Variable -Name 'DBPool_invokeParameters' -Value $parameters -Scope Global -Force -Confirm:$false if ($allPages) { @@ -176,7 +174,7 @@ function Invoke-DBPoolRequest { $api_Response = Invoke-WebRequest @parameters -ErrorAction Stop $appRequestId = $api_Response.Headers['X-App-Request-Id'] Write-Debug "If you need to report an error to the DBE team, include this request ID which can be used to search through the application logs for messages that were logged while processing your request [ X-App-Request-Id: $appRequestId ]" - Set-Variable -Name 'DBPool_appRequestId' -Value $appRequestId -Scope Global -Force + Set-Variable -Name 'DBPool_appRequestId' -Value $appRequestId -Scope Global -Force -Confirm:$false } } catch { @@ -188,7 +186,7 @@ function Invoke-DBPoolRequest { $appRequestId = $null if ($_.Exception.Response -and $_.Exception.Response.Headers) { $appRequestId = $_.Exception.Response.Headers.GetValues('X-App-Request-Id') - Set-Variable -Name 'DBPool_appRequestId' -Value $appRequestId -Scope Global -Force + Set-Variable -Name 'DBPool_appRequestId' -Value $appRequestId -Scope Global -Force -Confirm:$false Write-Debug "If you need to report an error to the DBE team, include this request ID which can be used to search through the application logs for messages that were logged while processing your request [ X-App-Request-Id: $appRequestId ]" } @@ -243,7 +241,7 @@ function Invoke-DBPoolRequest { 'Auth' ) foreach ($v in $var) { - Remove-Variable -Name $v -ErrorAction SilentlyContinue -Force + Remove-Variable -Name $v -ErrorAction SilentlyContinue -Force -Confirm:$false } } diff --git a/src/Private/apiKeys/Add-DBPoolApiKey.ps1 b/src/Private/apiKeys/Add-DBPoolApiKey.ps1 index 520a55b..f62404e 100644 --- a/src/Private/apiKeys/Add-DBPoolApiKey.ps1 +++ b/src/Private/apiKeys/Add-DBPoolApiKey.ps1 @@ -37,7 +37,7 @@ function Add-DBPoolApiKey { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Add-DBPoolApiKey/ #> [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')] diff --git a/src/Private/apiKeys/Get-DBPoolApiKey.ps1 b/src/Private/apiKeys/Get-DBPoolApiKey.ps1 index a770886..f26bacc 100644 --- a/src/Private/apiKeys/Get-DBPoolApiKey.ps1 +++ b/src/Private/apiKeys/Get-DBPoolApiKey.ps1 @@ -30,7 +30,7 @@ function Get-DBPoolApiKey { N\A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Get-DBPoolApiKey/ #> [cmdletbinding()] diff --git a/src/Private/apiKeys/Remove-DBPoolApiKey.ps1 b/src/Private/apiKeys/Remove-DBPoolApiKey.ps1 index 78bcd6a..5b3cf09 100644 --- a/src/Private/apiKeys/Remove-DBPoolApiKey.ps1 +++ b/src/Private/apiKeys/Remove-DBPoolApiKey.ps1 @@ -24,7 +24,7 @@ function Remove-DBPoolApiKey { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Remove-DBPoolApiKey/ #> [cmdletbinding(SupportsShouldProcess, ConfirmImpact = 'Low')] diff --git a/src/Private/apiKeys/Test-DBPoolApiKey.ps1 b/src/Private/apiKeys/Test-DBPoolApiKey.ps1 index 7950d4f..59226e2 100644 --- a/src/Private/apiKeys/Test-DBPoolApiKey.ps1 +++ b/src/Private/apiKeys/Test-DBPoolApiKey.ps1 @@ -37,7 +37,7 @@ function Test-DBPoolApiKey { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/apiKeys/Test-DBPoolApiKey/ #> [cmdletbinding()] diff --git a/src/Private/baseUri/Add-DBPoolBaseURI.ps1 b/src/Private/baseUri/Add-DBPoolBaseURI.ps1 index 1d19250..ae2917c 100644 --- a/src/Private/baseUri/Add-DBPoolBaseURI.ps1 +++ b/src/Private/baseUri/Add-DBPoolBaseURI.ps1 @@ -44,7 +44,7 @@ function Add-DBPoolBaseURI { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Add-DBPoolBaseURI/ #> [cmdletbinding()] diff --git a/src/Private/baseUri/Get-DBPoolBaseURI.ps1 b/src/Private/baseUri/Get-DBPoolBaseURI.ps1 index c511d17..5da1d8d 100644 --- a/src/Private/baseUri/Get-DBPoolBaseURI.ps1 +++ b/src/Private/baseUri/Get-DBPoolBaseURI.ps1 @@ -21,7 +21,7 @@ function Get-DBPoolBaseURI { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Get-DBPoolBaseURI/ #> [cmdletbinding()] diff --git a/src/Private/baseUri/Remove-DBPoolBaseURI.ps1 b/src/Private/baseUri/Remove-DBPoolBaseURI.ps1 index 0f06794..bee4d61 100644 --- a/src/Private/baseUri/Remove-DBPoolBaseURI.ps1 +++ b/src/Private/baseUri/Remove-DBPoolBaseURI.ps1 @@ -24,7 +24,7 @@ function Remove-DBPoolBaseURI { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/baseUri/Remove-DBPoolBaseURI/ #> [cmdletbinding(SupportsShouldProcess)] diff --git a/src/Private/moduleSettings/Export-DBPoolModuleSetting.ps1 b/src/Private/moduleSettings/Export-DBPoolModuleSetting.ps1 index a4a218f..8bdd55d 100644 --- a/src/Private/moduleSettings/Export-DBPoolModuleSetting.ps1 +++ b/src/Private/moduleSettings/Export-DBPoolModuleSetting.ps1 @@ -46,7 +46,7 @@ function Export-DBPoolModuleSetting { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Export-DBPoolModuleSetting/ #> [CmdletBinding(DefaultParameterSetName = 'set')] diff --git a/src/Private/moduleSettings/Get-DBPoolModuleSetting.ps1 b/src/Private/moduleSettings/Get-DBPoolModuleSetting.ps1 index 0ecc6fb..44bab85 100644 --- a/src/Private/moduleSettings/Get-DBPoolModuleSetting.ps1 +++ b/src/Private/moduleSettings/Get-DBPoolModuleSetting.ps1 @@ -52,7 +52,7 @@ function Get-DBPoolModuleSetting { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Get-DBPoolModuleSetting/ #> [CmdletBinding(DefaultParameterSetName = 'index')] diff --git a/src/Private/moduleSettings/Import-DBPoolModuleSetting.ps1 b/src/Private/moduleSettings/Import-DBPoolModuleSetting.ps1 index 8376376..8481d7f 100644 --- a/src/Private/moduleSettings/Import-DBPoolModuleSetting.ps1 +++ b/src/Private/moduleSettings/Import-DBPoolModuleSetting.ps1 @@ -26,7 +26,7 @@ function Import-DBPoolModuleSetting { N/A .OUTPUTS - N/A + [void] - No output is returned. .EXAMPLE Import-DBPoolModuleSetting @@ -50,7 +50,7 @@ function Import-DBPoolModuleSetting { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Import-DBPoolModuleSetting/ #> [CmdletBinding(DefaultParameterSetName = 'set')] diff --git a/src/Private/moduleSettings/Remove-DBPoolModuleSetting.ps1 b/src/Private/moduleSettings/Remove-DBPoolModuleSetting.ps1 index 6e1c39d..1a39738 100644 --- a/src/Private/moduleSettings/Remove-DBPoolModuleSetting.ps1 +++ b/src/Private/moduleSettings/Remove-DBPoolModuleSetting.ps1 @@ -48,7 +48,7 @@ function Remove-DBPoolModuleSetting { N/A .LINK - N/A + https://datto-dbpool-api.kentsapp.com/Internal/moduleSettings/Remove-DBPoolModuleSetting/ #> [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'set')] diff --git a/src/Public/Containers/Containers/Get-DBPoolContainer.ps1 b/src/Public/Containers/Containers/Get-DBPoolContainer.ps1 index 829f669..c45d3de 100644 --- a/src/Public/Containers/Containers/Get-DBPoolContainer.ps1 +++ b/src/Public/Containers/Containers/Get-DBPoolContainer.ps1 @@ -63,7 +63,12 @@ function Get-DBPoolContainer { Get a list of containers from the DBPool API by ID .EXAMPLE - Get-DBPoolContainer -Status -Id @( 12345, 67890 ) + Get-DBPoolContainer -Status + + Get the status of all containers from the DBPool API + + .EXAMPLE + Get-DBPoolContainer -Status -Id 12345, 67890 Get the status of an array of containers by IDs diff --git a/src/Public/Users/Get-DBPoolUser.ps1 b/src/Public/Users/Get-DBPoolUser.ps1 index b1f61a9..2afee86 100644 --- a/src/Public/Users/Get-DBPoolUser.ps1 +++ b/src/Public/Users/Get-DBPoolUser.ps1 @@ -108,5 +108,9 @@ function Get-DBPoolUser { } - end {} + end { + + Remove-Variable -Name response -Force -ErrorAction SilentlyContinue + + } }