NetboxPS/Functions/Helpers/Get-ModelDefinition.ps1
Ben Claussen cfb53cf933
Version 1.3.0 (#3)
* Add `OPTIONS` method validation

* Remove parameter validation as workaround for CHOICES API endpoint until further testing

* Add help block for Get-NetboxTenant

* SkipConnectedCheck for Get-NetboxAPIDefinition

* Correct help block for New-NetboxIPAMAddress

* Add parameter position 0 for 'Address' in Get-NetboxIPAMAddress

* Allow pipeline input for Address parameter in New-NetboxIPAMAddress

* Update parameter types

* Add parameter sets and logic for ID/Query searches

* Add Get-NetboxDCIMSite

* Update psproj

* Update deploy.ps1

* Move Get-NetboxCircuit

* Add Circuit cmdlets
- New-NetboxCircuit
- Get-NetboxCircuitProvider
- Get-NetboxCircuitTermination
- Get-NetboxCircuitType

* Update deploy script output path

* Update Set-NetboxIPAMAddress
- Replace Interface parameter with Assigned_Object_Type and Assigned_Object_Id
- Add validation logic for Assigned_Object_ parameters
- Change Status parameter to string

* Add Get-ModelDefinition function

* Update psproj

* Update deploy.ps1 variables

* Update exported files

* Remove references to `_choices` API calls

* Add Postman collection

* Add Postman collection

* Update deploy.ps1

* Add Set-NetboxIPAMPrefix function

* Increment version to 1.3.0

Co-authored-by: Ben Claussen <claussen@neonet.org>
2021-03-25 16:52:08 -04:00

64 lines
1.8 KiB
PowerShell

<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.181
Created on: 2020-11-04 14:23
Created by: Claussen
Organization: NEOnet
Filename: Get-ModelDefinition.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
function Get-ModelDefinition {
[CmdletBinding(DefaultParameterSetName = 'ByName')]
param
(
[Parameter(ParameterSetName = 'ByName',
Mandatory = $true)]
[string]$ModelName,
[Parameter(ParameterSetName = 'ByPath',
Mandatory = $true)]
[string]$URIPath,
[Parameter(ParameterSetName = 'ByPath')]
[string]$Method = "post"
)
switch ($PsCmdlet.ParameterSetName) {
'ByName' {
$script:NetboxConfig.APIDefinition.definitions.$ModelName
break
}
'ByPath' {
switch ($Method) {
"get" {
break
}
"post" {
if (-not $URIPath.StartsWith('/')) {
$URIPath = "/$URIPath"
}
if (-not $URIPath.EndsWith('/')) {
$URIPath = "$URIPath/"
}
$ModelName = $script:NetboxConfig.APIDefinition.paths.$URIPath.post.parameters.schema.'$ref'.split('/')[-1]
$script:NetboxConfig.APIDefinition.definitions.$ModelName
break
}
}
break
}
}
}