Public/Fabric/vifs.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
#
# Copyright 2020, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
#

function Get-NSXTFabricVifs {

    <#
        .SYNOPSIS
        Get information about Vifs (Virtual Interfaces)

        .DESCRIPTION
        Returns information about Vifs (Virtual Interfaces)

        .EXAMPLE
        Get-NSXTFabricVifs

        Display all Vifs (Virtual Interfaces)

        .EXAMPLE
        Get-NSXTFabricVifs -host_id ede3e69a-6562-49a6-98c4-d23408bd832c

        Display Vifs (Virtual Interfaces) with host_id ede3e69a-6562-49a6-98c4-d23408bd832c

        .EXAMPLE
        Get-NSXTFabricVifs -lport_attachment_id a934f1be-8f87-4851-8175-0572206a50e3

        Display Vifs (Virtual Interfaces) with lport_attachment_id a934f1be-8f87-4851-8175-0572206a50e3

        .EXAMPLE
        Get-NSXTFabricVifs -owner_vm_id ede3e69a-6562-49a6-98c4-d23408bd832c

        Display Vifs (Virtual Interfaces) with owner_vm_id ede3e69a-6562-49a6-98c4-d23408bd832c

    #>


    [CmdletBinding(DefaultParametersetname = "Default")]
    Param(
        [Parameter(Mandatory = $false, ParameterSetName = "Default")]
        [string]$host_id,
        [Parameter(Mandatory = $false, ParameterSetName = "Default")]
        [string]$lport_attachment_id,
        [Parameter(Mandatory = $false, ParameterSetName = "Default")]
        [string]$owner_vm_id,
        [Parameter(Mandatory = $false)]
        [psobject]$connection = $DefaultNSXTConnection
    )

    Begin {
    }

    Process {

        $uri = 'api/v1/fabric/vifs?'

        if ( $PsBoundParameters.ContainsKey('host_id') ) {
            $uri += "&host_id=$host_id"
        }

        if ( $PsBoundParameters.ContainsKey('lport_attachment_id') ) {
            $uri += "&lport_attachment_id=$lport_attachment_id"
        }

        if ( $PsBoundParameters.ContainsKey('owner_vm_id') ) {
            $uri += "&owner_vm_id=$owner_vm_id"
        }

        $response = Invoke-NSXTRestMethod -uri $uri -method 'GET' -connection $connection
        $response.results

    }

    End {
    }
}