-
Notifications
You must be signed in to change notification settings - Fork 0
🌟[Major]: Domeneshop API capabilities now available #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 47 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
21282d9
Bump PSModule/Process-PSModule/.github/workflows/workflow.yml
dependabot[bot] c11d1b8
Fix README placeholders
MariusStorhaug 35a5535
Standardize README landing page
MariusStorhaug d47c0c5
Require Pester 6.x in test files
MariusStorhaug 2f02acd
Drop the GUID from the Pester requirement
MariusStorhaug 6a28bc4
Adopt Process-PSModule v6.1.4
MariusStorhaug 23a4a98
📖 [Docs]: Remove Contributing section from placeholder README
MariusStorhaug eb063ec
📖 [Docs]: Clarify documentation is not published yet for placeholder
MariusStorhaug 6bc7a36
Add Domeneshop context auth flow
MariusStorhaug f32ed30
Add tests for context credential workflow
MariusStorhaug 25200d1
Implement full Domeneshop v0 endpoint commands
MariusStorhaug e142777
Expand tests for all API endpoint commands
MariusStorhaug 0b812c0
Harden Domeneshop command contracts
MariusStorhaug 137223a
Split tests by public command
MariusStorhaug 5983628
Document Domeneshop command groups
MariusStorhaug e444b23
Align baseline command help and validation
MariusStorhaug 5f14a7e
Merge PR #11 Process-PSModule v5.5.7 update
MariusStorhaug 6f25b85
Merge PR #13 Process-PSModule v6.1.4 and Pester 6 policy
MariusStorhaug 311f50a
Merge PR #12 README landing page improvements
MariusStorhaug f177577
Merge PR #14 Domeneshop API capabilities
MariusStorhaug 69aafaa
Merge PR #15 command standards hardening
MariusStorhaug 39f8bb9
Require Pester 6 in split test files
MariusStorhaug 785d8a7
Fix generated command documentation lint
MariusStorhaug f1090eb
Normalize generated HTTPS examples
MariusStorhaug 643f79e
Address release review feedback
MariusStorhaug a7ddcd0
Preserve Windows PowerShell REST compatibility
MariusStorhaug 0b36e9b
Align command prompts and test setup
MariusStorhaug eb3ec7e
Protect reserved context configuration
MariusStorhaug e643399
Reject empty API secrets
MariusStorhaug f30f681
Use portable test setup paths
MariusStorhaug 7127901
Add interactive API secret setup
MariusStorhaug 411039d
Address delayed release review findings
MariusStorhaug def7ed5
Add canonical public help links
MariusStorhaug 175cde4
Harden context lookup and WhatIf behavior
MariusStorhaug 6cc608e
Fix grouped public help links
MariusStorhaug d751c66
Align help links with grouped documentation
MariusStorhaug 401804f
Merge concurrent release help-link update
MariusStorhaug d565c8c
Restore exact generated help routes
MariusStorhaug 2affd9d
Enforce documented help URLs
MariusStorhaug f8591cf
Preserve generated URL trailing slashes
MariusStorhaug 4bcdb89
Restore documented no-slash help URLs
MariusStorhaug 066d50a
Keep help-link tests compatible with PowerShell 5.1
MariusStorhaug ebf7320
Target the latest PowerShell LTS
MariusStorhaug e7385a4
Reject whitespace domain filters
MariusStorhaug f8711c8
Reject whitespace-only command inputs
MariusStorhaug 0c36880
Require the latest PowerShell LTS
MariusStorhaug 41f39ca
Use canonical generated help routes
MariusStorhaug a8e167d
Keep credential prompting available without a browser
MariusStorhaug b866361
Update Process-PSModule to v6.1.13
MariusStorhaug a32219c
Group public command tests by feature
MariusStorhaug 3e045a5
Migrate module docs configuration to Zensical
MariusStorhaug ec2bcca
Add PR template foldable end sections
MariusStorhaug bc02714
Remove pull request template
MariusStorhaug fe18c35
Group command tests by feature file
MariusStorhaug 272aca4
Consolidate command tests by group
MariusStorhaug 9834688
Merge concurrent release updates
MariusStorhaug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,69 +1,27 @@ | ||
| # {{ NAME }} | ||
| # Domeneshop | ||
|
|
||
| {{ DESCRIPTION }} | ||
| Domeneshop is a PowerShell module for interacting with the Domeneshop API. | ||
|
|
||
| ## Prerequisites | ||
| ## Status | ||
|
|
||
| This uses the following external resources: | ||
| - The [PSModule framework](https://github.com/PSModule/Process-PSModule) for building, testing and publishing the module. | ||
| The module provides a pre-1.0 API for storing Domeneshop credentials and working with domains, DNS records, HTTP forwards, dynamic DNS, and invoices. Command names and parameters may change before v1.0.0. | ||
|
|
||
| ## Installation | ||
|
|
||
| To install the module from the PowerShell Gallery, you can use the following command: | ||
|
|
||
| ```powershell | ||
| Install-PSResource -Name {{ NAME }} | ||
| Import-Module -Name {{ NAME }} | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| Here is a list of example that are typical use cases for the module. | ||
|
|
||
| ### Example 1: Greet an entity | ||
|
|
||
| Provide examples for typical commands that a user would like to do with the module. | ||
|
|
||
| ```powershell | ||
| Greet-Entity -Name 'World' | ||
| Hello, World! | ||
| ``` | ||
|
|
||
| ### Example 2 | ||
|
|
||
| Provide examples for typical commands that a user would like to do with the module. | ||
|
|
||
| ```powershell | ||
| Import-Module -Name PSModuleTemplate | ||
| Install-PSResource -Name Domeneshop | ||
| Import-Module -Name Domeneshop | ||
| ``` | ||
|
|
||
| ### Find more examples | ||
|
|
||
| To find more examples of how to use the module, please refer to the [examples](examples) folder. | ||
| ## Commands | ||
|
|
||
| Alternatively, you can use the Get-Command -Module 'This module' to find more commands that are available in the module. | ||
| To find examples of each of the commands you can use Get-Help -Examples 'CommandName'. | ||
| - [Authentication](src/functions/public/Auth/Auth.md): Store credentials and select a default context. | ||
| - [Domains](src/functions/public/Domains/Domains.md): List domains or retrieve one by ID. | ||
| - [DNS](src/functions/public/Dns/Dns.md): List, add, update, and remove DNS records. | ||
| - [HTTP forwards](src/functions/public/Forwards/Forwards.md): List, add, update, and remove forwards. | ||
| - [Dynamic DNS](src/functions/public/Ddns/Ddns.md): Update a hostname with a supplied or detected address. | ||
| - [Invoices](src/functions/public/Invoices/Invoices.md): List invoices or retrieve one by ID. | ||
|
|
||
| ## Documentation | ||
|
|
||
| Link to further documentation if available, or describe where in the repository users can find more detailed documentation about | ||
| the module's functions and features. | ||
|
|
||
| ## Contributing | ||
|
|
||
| Coder or not, you can contribute to the project! We welcome all contributions. | ||
|
|
||
| ### For Users | ||
|
|
||
| If you don't code, you still sit on valuable information that can make this project even better. If you experience that the | ||
| product does unexpected things, throw errors or is missing functionality, you can help by submitting bugs and feature requests. | ||
| Please see the issues tab on this project and submit a new issue that matches your needs. | ||
|
|
||
| ### For Developers | ||
|
|
||
| If you do code, we'd love to have your contributions. Please read the [Contribution guidelines](CONTRIBUTING.md) for more information. | ||
| You can either help by picking up an existing issue or submit a new one if you have an idea for a new feature or improvement. | ||
|
|
||
| ## Acknowledgements | ||
|
|
||
| Here is a list of people and projects that helped this project in some way. | ||
| Each public command includes PowerShell help. After importing the module, run `Get-Help <CommandName> -Full` for parameter details and examples. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #Requires -Modules @{ ModuleName = 'Context'; ModuleVersion = '8.1.6' } | ||
|
|
||
| function Get-DomeneshopConfig { | ||
| <# | ||
| .SYNOPSIS | ||
| Get the Domeneshop module configuration. | ||
| .DESCRIPTION | ||
| Read the module configuration from the Context vault or return an in-memory default when no configuration has been stored. | ||
| .EXAMPLE | ||
| Get-DomeneshopConfig | ||
| Get the current Domeneshop module configuration. | ||
| .INPUTS | ||
| None | ||
| You can't pipe objects to Get-DomeneshopConfig. | ||
| .OUTPUTS | ||
| System.Object | ||
| The stored or default Domeneshop module configuration. | ||
| .NOTES | ||
| This read helper does not create or update Context vault entries. | ||
| .LINK | ||
| https://psmodule.io/Domeneshop/Functions/Auth/Get-DomeneshopContext | ||
| .LINK | ||
| https://psmodule.io/Context/ | ||
| #> | ||
| [OutputType([object])] | ||
| [CmdletBinding()] | ||
| param() | ||
|
|
||
| $vault = 'Domeneshop' | ||
| $id = '__Domeneshop.Config' | ||
| $config = Get-Context -ID $id -Vault $vault | ||
|
|
||
| if (-not $config) { | ||
| $config = [pscustomobject][ordered]@{ | ||
| DefaultContext = $null | ||
| ApiBaseUri = 'https://api.domeneshop.no/v0' | ||
| } | ||
| } | ||
|
|
||
| $config | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| function Resolve-DomeneshopContext { | ||
| <# | ||
| .SYNOPSIS | ||
| Validate a resolved Domeneshop context. | ||
|
|
||
| .DESCRIPTION | ||
| Verify that a context resolved by a public command contains the credentials and API endpoint required by private helpers. | ||
|
|
||
| .EXAMPLE | ||
| Resolve-DomeneshopContext -Context $storedContext | ||
|
|
||
| Validate and emit a stored Domeneshop context. | ||
|
|
||
| .INPUTS | ||
| None | ||
|
|
||
| You can't pipe objects to Resolve-DomeneshopContext. | ||
|
|
||
| .OUTPUTS | ||
| System.Object | ||
|
|
||
| The validated Domeneshop context. | ||
|
|
||
| .NOTES | ||
| This helper never selects or defaults a context. Public commands own that behavior. | ||
|
|
||
| .LINK | ||
| https://psmodule.io/Domeneshop/Functions/Auth/Get-DomeneshopContext | ||
|
|
||
| .LINK | ||
| https://psmodule.io/Context/ | ||
| #> | ||
| [OutputType([object])] | ||
| [CmdletBinding()] | ||
| param( | ||
| # The context object selected by a public command. | ||
| [Parameter(Mandatory)] | ||
| [AllowNull()] | ||
| [object] $Context | ||
| ) | ||
|
|
||
| if ($null -eq $Context) { | ||
| throw "No Domeneshop context found. Run 'Connect-DomeneshopAccount' first." | ||
| } | ||
|
|
||
| if ([string]::IsNullOrWhiteSpace([string] $Context.Token) -or -not ($Context.Secret -is [securestring])) { | ||
| throw "The Domeneshop context [$($Context.ID)] is missing valid credentials." | ||
| } | ||
|
|
||
| if ([string]::IsNullOrWhiteSpace([string] $Context.ApiBaseUri)) { | ||
| throw "The Domeneshop context [$($Context.ID)] is missing an API base URI." | ||
| } | ||
|
|
||
| $Context | ||
| } |
50 changes: 50 additions & 0 deletions
50
src/functions/private/Auth/Set-DomeneshopDefaultContext.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #Requires -Modules @{ ModuleName = 'Context'; ModuleVersion = '8.1.6' } | ||
|
|
||
| function Set-DomeneshopDefaultContext { | ||
| <# | ||
| .SYNOPSIS | ||
| Set the default Domeneshop context name. | ||
|
|
||
| .DESCRIPTION | ||
| Persist the selected default context name in the Domeneshop configuration entry. | ||
|
|
||
| .EXAMPLE | ||
| Set-DomeneshopDefaultContext -Context 'production' | ||
|
|
||
| Set production as the default Domeneshop context. | ||
|
|
||
| .INPUTS | ||
| None | ||
|
|
||
| You can't pipe objects to Set-DomeneshopDefaultContext. | ||
|
|
||
| .OUTPUTS | ||
| None | ||
|
|
||
| Set-DomeneshopDefaultContext doesn't emit output. | ||
|
|
||
| .NOTES | ||
| Supports WhatIf and Confirm before changing the module configuration. | ||
|
|
||
| .LINK | ||
| https://psmodule.io/Domeneshop/Functions/Auth/Connect-DomeneshopAccount | ||
|
|
||
| .LINK | ||
| https://psmodule.io/Context/ | ||
| #> | ||
| [OutputType([void])] | ||
| [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Low')] | ||
| param( | ||
| # The name of an existing Domeneshop context. | ||
| [Parameter(Mandatory)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [ValidateScript({ Test-DomeneshopContextName -Context $_ })] | ||
| [string] $Context | ||
|
MariusStorhaug marked this conversation as resolved.
|
||
| ) | ||
|
|
||
| $config = Get-DomeneshopConfig | ||
| if ($PSCmdlet.ShouldProcess('Domeneshop module configuration', "Set [$Context] as the default context")) { | ||
| $config.DefaultContext = $Context | ||
| $null = Set-Context -ID '__Domeneshop.Config' -Vault 'Domeneshop' -Context $config | ||
| } | ||
|
MariusStorhaug marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| function Test-DomeneshopContextName { | ||
| <# | ||
| .SYNOPSIS | ||
| Validate a Domeneshop credential context name. | ||
|
|
||
| .DESCRIPTION | ||
| Reject names reserved for internal Domeneshop module configuration. | ||
|
|
||
| .EXAMPLE | ||
| Test-DomeneshopContextName -Context 'production' | ||
|
|
||
| Confirm that production can be used as a credential context name. | ||
|
|
||
| .INPUTS | ||
| None | ||
|
|
||
| You can't pipe objects to Test-DomeneshopContextName. | ||
|
|
||
| .OUTPUTS | ||
| System.Boolean | ||
|
|
||
| True when the context name is available for credentials. | ||
|
|
||
| .NOTES | ||
| Throws when the context name is reserved. | ||
|
|
||
| .LINK | ||
| https://psmodule.io/Domeneshop/Functions/Auth/Connect-DomeneshopAccount | ||
| #> | ||
| [OutputType([bool])] | ||
| [CmdletBinding()] | ||
| param( | ||
| # The proposed credential context name. | ||
| [Parameter(Mandatory)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [string] $Context | ||
| ) | ||
|
|
||
| if ([string]::IsNullOrWhiteSpace($Context)) { | ||
| throw 'Context name cannot be empty or whitespace.' | ||
| } | ||
|
|
||
| if ($Context -eq '__Domeneshop.Config') { | ||
| throw "Context name [$Context] is reserved for Domeneshop module configuration." | ||
| } | ||
|
|
||
| $true | ||
|
Copilot marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| function Test-DomeneshopSecret { | ||
| <# | ||
| .SYNOPSIS | ||
| Validate a Domeneshop API secret. | ||
|
|
||
| .DESCRIPTION | ||
| Reject unsupported and empty values before credential storage. | ||
|
|
||
| .EXAMPLE | ||
| Test-DomeneshopSecret -Secret $secret | ||
|
|
||
| Confirm that the secret contains a value. | ||
|
|
||
| .INPUTS | ||
| None | ||
|
|
||
| You can't pipe objects to Test-DomeneshopSecret. | ||
|
|
||
| .OUTPUTS | ||
| System.Boolean | ||
|
|
||
| True when the secret has a supported type and is not empty. | ||
|
|
||
| .NOTES | ||
| Supported values are String and SecureString. | ||
|
|
||
| .LINK | ||
| https://psmodule.io/Domeneshop/Functions/Auth/Connect-DomeneshopAccount | ||
| #> | ||
| [OutputType([bool])] | ||
| [CmdletBinding()] | ||
| param( | ||
| # The proposed API secret. | ||
| [Parameter(Mandatory)] | ||
| [ValidateNotNull()] | ||
| [object] $Secret | ||
| ) | ||
|
|
||
| if ($Secret -isnot [string] -and $Secret -isnot [securestring]) { | ||
| throw 'Secret must be a SecureString or String value.' | ||
| } | ||
|
|
||
| if ( | ||
| ($Secret -is [string] -and [string]::IsNullOrWhiteSpace($Secret)) -or | ||
| ($Secret -is [securestring] -and $Secret.Length -eq 0) | ||
| ) { | ||
| throw 'Secret cannot be empty or whitespace.' | ||
| } | ||
|
|
||
| $true | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.