Public/Configuration/organization.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# Copyright 2020, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
#

function Set-ArubaIAPOrganization {

    <#
        .SYNOPSIS
        Set an organization to Aruba Instant AP

        .DESCRIPTION
        Set organization to Aruba Instant AP

        .EXAMPLE
        Set-ArubaIAPOrganization MyOrg

        Set Organization MyOrg to IAP
    #>


    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Low')]
    Param(
        [Parameter (Mandatory = $true, Position = 1)]
        [string]$organization,
        [Parameter (Mandatory = $false)]
        [ipaddress]$iap_ip_addr = ${DefaultArubaIAPConnection}.iap_ip_addr
    )

    Begin {
    }

    Process {

        $uri = "rest/organization"

        $organization_info = @{
            "action"       = "create"
            "organization" = $organization
        }

        $body = @{
            "organization_info" = $organization_info
        }

        if ($PSCmdlet.ShouldProcess($iap_ip_addr, 'Set Organization')) {
            $response = Invoke-ArubaIAPRestMethod -uri $uri -body $body -method 'POST'

            $response
        }
    }

    End {
    }
}

function Remove-ArubaIAPOrganization {

    <#
        .SYNOPSIS
        Remove organization to Aruba Instant AP

        .DESCRIPTION
        Remove organization to Aruba Instant AP

        .EXAMPLE
        Remove-ArubaIAPorganization

        Remove Organization Server to IAP

        .EXAMPLE
        Remove-ArubaIAPOrganization -confirm:$false

        Remove Organization Server to IAP without confirmation
    #>


    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'high')]
    Param(
        [Parameter (Mandatory = $false)]
        [ipaddress]$iap_ip_addr = ${DefaultArubaIAPConnection}.iap_ip_addr
    )

    Begin {
    }

    Process {

        $uri = "rest/organization"

        $organization_info = @{
            "action" = "delete"
        }

        $body = @{
            "organization_info" = $organization_info
        }

        if ($PSCmdlet.ShouldProcess($iap_ip_addr, 'Remove Organization')) {
            $response = Invoke-ArubaIAPRestMethod -uri $uri -body $body -method 'POST'

            $response
        }
    }

    End {
    }
}