davidfischer-ch / terraform-provider-aria

This is a Terraform provider for working with VMware's Aria Automation Platform (unofficial).
Mozilla Public License 2.0
3 stars 0 forks source link

Add filtering capabilities to `aria_resource_action` #25

Closed davidfischer-ch closed 2 months ago

davidfischer-ch commented 2 months ago

Example :

{
    "id": "Cloud.vSphere.Machine.custom.tme-test-condition",
    "name": "TME-Test-Condition",
    "displayName": "Install IIS (pour Windows)",
    "providerName": "xaas",
    "resourceType": "Cloud.vSphere.Machine",
    "status": "RELEASED",
    "orgId": "2817c6e5-7408-449f-a86d-8f511105e5ba",
    "runnableItem": {
        "id": "8a7480538f3b51b1019082dcb7894bb4",
        "name": "TME.IIS.create",
        "projectId": "97f484f0-8329-440f-8fa7-5c8f8fa491fd",
        "type": "abx.action",
        "inputParameters": []
    },
    "formDefinition": {
        "tenant": "2817c6e5-7408-449f-a86d-8f511105e5ba",
        "id": "cae3758e-88e0-4a9a-aad3-e8d3950f825e",
        "name": "TME-Test-Condition",
        "form": "{\"layout\":{\"pages\":[{\"id\":\"page_1\",\"title\":\"Page 1\",\"sections\":[]}]},\"schema\":{}}",
        "sourceType": "resource.action",
        "sourceId": "Cloud.vSphere.Machine.custom.tme-test-condition",
        "type": "requestForm",
        "status": "ON",
        "formFormat": "JSON"
    },
    "criteria": {
        "matchExpression": [
            {
               "and": [
                    {
                        "key": "${properties.osType}",
                        "operator": "eq",
                        "value": "WINDOWS"
                    }
                ]
            }
        ]
    }
}
hotcross commented 2 months ago

Here is a more complex example with tags:

{
    "id": "Cloud.vSphere.Machine.custom.tme_csc_library.cloud.vsphere.machine.dotnetruntime_v1.install",
    "name": "TME_CSC_Library.Cloud.vSphere.Machine.DotNetRuntime_v1.install",
    "displayName": "TME Install .NET Runtime",
    "description": "Installe .NET Runtime.",
    "providerName": "xaas",
    "resourceType": "Cloud.vSphere.Machine",
    "status": "RELEASED",
    "orgId": "2817c6e5-7408-449f-a86d-8f511105e5ba",
    "runnableItem": {
        "id": "8a7480538f3b51b10190a77327840c41",
        "name": "TME_CSC_Library.Cloud.vSphere.Machine.DotNetRuntime_v1.install",
        "projectId": "97f484f0-8329-440f-8fa7-5c8f8fa491fd",
        "type": "abx.action",
        "inputParameters": [],
        "outputParameters": []
    },
    "formDefinition": {
        "tenant": "2817c6e5-7408-449f-a86d-8f511105e5ba",
        "id": "cb307e0d-3d46-42e5-ab35-391c41f2d9bf",
        "name": "TME_CSC_Library.Cloud.vSphere.Machine.DotNetRuntime_v1.install",
        "form": "{\"layout\":{\"pages\":[{\"id\":\"page_1\",\"title\":\"Page 1\",\"sections\":[{\"id\":\"section_519ac0ec\",\"fields\":[{\"id\":\"dotNetRuntimeVersion\",\"display\":\"dropDown\",\"state\":{\"visible\":true,\"read-only\":false},\"signpostPosition\":\"right-middle\"}]}],\"state\":{}}]},\"schema\":{\"dotNetRuntimeVersion\":{\"label\":\"Version .NET Runtime à installer\",\"type\":{\"dataType\":\"string\"},\"valueList\":[{\"label\":\"8.0.7\",\"value\":\"8.0.7.33813\",\"description\":\"Version 8.0.7.33813\"},{\"label\":\"7.0.5\",\"value\":\"7.0.5.32324\",\"description\":\"Version 7.0.5.32324\"},{\"label\":\"6.0.32\",\"value\":\"6.0.32.33814\",\"description\":\"Version 6.0.32.33814\"},{\"label\":\"6.0.16\",\"value\":\"6.0.16.32323\",\"description\":\"Version 6.0.16.32323\"}],\"placeholder\":\".NET Runtime version\",\"constraints\":{\"required\":true}}},\"options\":{\"externalValidations\":[]}}",
        "sourceType": "resource.action",
        "sourceId": "Cloud.vSphere.Machine.custom.tme_csc_library.cloud.vsphere.machine.dotnetruntime_v1.install",
        "type": "requestForm",
        "status": "ON",
        "formFormat": "JSON"
    },
    "criteria": {
        "matchExpression": [
            {
                "and": [
                    {
                        "key": "${properties.osType}",
                        "operator": "eq",
                        "value": "WINDOWS"
                    },
                    {
                        "key": "${properties.totalMemoryMB}",
                        "operator": "greaterThan",
                        "value": "1024"
                    },
                    {
                        "key": "${properties.tags}",
                        "operator": "hasAny",
                        "value": {
                            "matchExpression": [
                                {
                                    "and": [
                                        {
                                            "key": "key",
                                            "operator": "eq",
                                            "value": "env"
                                        },
                                        {
                                            "key": "value",
                                            "operator": "eq",
                                            "value": "REC"
                                        }
                                    ]
                                }
                            ]
                        }
                    }
                ]
            }
        ]
    }
}
davidfischer-ch commented 2 months ago

Initial release will be based on JSON encoding / decoding to make it more flexible (and fast to develop).