Functions/Public/catalog-service/DEPRECATED-Get-vRAConsumerResourceOperation.psm1

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
108
109
110
111
112
113
function Get-vRAConsumerResourceOperation {
<#
    .SYNOPSIS
    Get a consumer resource operation
    
    .DESCRIPTION
    Consumer Resource Operation API exposed to users. A resource operation represents a Day-2 operation that can be performed on a resource.
    Resource operations are registered in the Service Catalog and target a specific resource type.
    These operations can be invoked / accessed by consumers through the self-service interface on the resources they own.
    
    .PARAMETER Id
    The id of the resource operation

    .INPUTS
    System.String

    .OUTPUTS
    System.Management.Automation.PSObject.
    
    .EXAMPLE
    Get-vRAConsumerResourceOperation -Id "a4d57b16-9706-471b-9960-d0855fe544bb"

#>

[CmdletBinding(DefaultParameterSetName="Standard")][OutputType('System.Management.Automation.PSObject')]

    Param (

    [parameter(Mandatory=$true,ValueFromPipeline=$false,ParameterSetName="Standard")]
    [ValidateNotNullOrEmpty()]
    [String[]]$Id          

    )

    Write-Warning -Message "This command is deprecated and will be removed in a future release. Please use Get-vRAResourceOperation instead."
                
    try {

        # --- Get resource operation by id

        foreach ($ResourceOperation in $Id ) { 
            
            $URI = "/catalog-service/api/consumer/resourceOperations/$($ResourceOperation)"

            Write-Verbose -Message "Preparing GET to $($URI)"

            $Response = Invoke-vRARestMethod -Method GET -URI $URI

            Write-Verbose -Message "SUCCESS"

            Write-Verbose -Message "Returning type: $($Response.'@type')"                

            switch ($Response.'@type') {

                'ResourceAction' {                    

                    [pscustomobject] @{

                        Type = $Response.'@type'
                        Id = $Response.id
                        ExternalId = $Response.externalId
                        Name = $Response.name
                        Description = $Response.description
                        IconId = $Response.iconId
                        TargetCriteria = $Response.targetCriteria
                        TargetResourceTypeRef = $Response.targetResourceTypeRef
                        Status = $Response.status
                        Entitleable = $Response.entitleable
                        organization = $Response.organization
                        RequestSchema =$Response.requestSchema
                        Forms = $Response.forms
                        Callbacks = $Response.callbacks
                        LifecycleAction = $Response.lifecycleACtion
                        BindingId = $Response.bindingId
                        ProviderTypeRef =$Response.providerTypeRef

                    }

                    break
                    
                }

                'ResourceExtension' {

                    [pscustomobject] @{

                        Type = $Response.'@type'
                        Id = $Response.id
                        ExternalId = $Response.externalId
                        Name = $Response.name
                        Description = $Response.description
                        IconId = $Response.iconId
                        TargetCriteria = $Response.targetCriteria
                        TargetResourceTypeRef = $Response.targetResourceTypeRef
                        Status = $Response.status
                        Entitleable = $Response.entitleable
                        ExtensionId = $Response.extensionId

                    }

                    break

                }
            }

        }

    }
    catch [Exception]{

        throw
    }

}