From ff5e95e532aff3516a870471828cb2d1d46c6c79 Mon Sep 17 00:00:00 2001 From: Clifton Dhanee <106665532+cliftonHPE@users.noreply.github.com> Date: Wed, 27 Nov 2024 09:41:10 +0200 Subject: [PATCH 1/3] add agent group assignment examples (#140) --- docs/data-sources/agent_group_assignment.md | 11 +++++++++- docs/resources/agent_group_assignment.md | 22 +++++++++++++++++++ .../uxi_agent_group_assignment/data-source.tf | 6 +++++ .../uxi_agent_group_assignment/import.sh | 8 +++++++ .../uxi_agent_group_assignment/resource.tf | 4 ++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 examples/data-sources/uxi_agent_group_assignment/data-source.tf create mode 100644 examples/resources/uxi_agent_group_assignment/import.sh create mode 100644 examples/resources/uxi_agent_group_assignment/resource.tf diff --git a/docs/data-sources/agent_group_assignment.md b/docs/data-sources/agent_group_assignment.md index e9d38dde..76d12737 100644 --- a/docs/data-sources/agent_group_assignment.md +++ b/docs/data-sources/agent_group_assignment.md @@ -10,7 +10,16 @@ description: |- Retrieves a specific agent group assignment. - +## Example Usage + +```terraform +# Retrieve data for an agent group assignment +data "uxi_agent_group_assignment" "my_agent_group_assignment" { + filter = { + id = "" + } +} +``` ## Schema diff --git a/docs/resources/agent_group_assignment.md b/docs/resources/agent_group_assignment.md index d8ad4417..8d531d27 100644 --- a/docs/resources/agent_group_assignment.md +++ b/docs/resources/agent_group_assignment.md @@ -10,7 +10,14 @@ description: |- Manages an agent group assignment. +## Example Usage +```terraform +resource "uxi_agent_group_assignment" "my_agent_group_assignment" { + agent_id = uxi_agent.my_agent.id + group_id = uxi_group.my_group.id +} +``` ## Schema @@ -23,3 +30,18 @@ Manages an agent group assignment. ### Read-Only - `id` (String) The identifier of the agent group assignment. + +## Import + +Import is supported using the following syntax: + +```shell +# Import an agent group assignment using its ID +terraform import uxi_agent_group_assignment.my_agent_group_assignment + +# Import an agent group assignment using its ID with an import block +import { + to = uxi_agent_group_assignment.my_agent_group_assignment + id = "" +} +``` diff --git a/examples/data-sources/uxi_agent_group_assignment/data-source.tf b/examples/data-sources/uxi_agent_group_assignment/data-source.tf new file mode 100644 index 00000000..ed505400 --- /dev/null +++ b/examples/data-sources/uxi_agent_group_assignment/data-source.tf @@ -0,0 +1,6 @@ +# Retrieve data for an agent group assignment +data "uxi_agent_group_assignment" "my_agent_group_assignment" { + filter = { + id = "" + } +} diff --git a/examples/resources/uxi_agent_group_assignment/import.sh b/examples/resources/uxi_agent_group_assignment/import.sh new file mode 100644 index 00000000..940e66d5 --- /dev/null +++ b/examples/resources/uxi_agent_group_assignment/import.sh @@ -0,0 +1,8 @@ +# Import an agent group assignment using its ID +terraform import uxi_agent_group_assignment.my_agent_group_assignment + +# Import an agent group assignment using its ID with an import block +import { + to = uxi_agent_group_assignment.my_agent_group_assignment + id = "" +} diff --git a/examples/resources/uxi_agent_group_assignment/resource.tf b/examples/resources/uxi_agent_group_assignment/resource.tf new file mode 100644 index 00000000..c3acf044 --- /dev/null +++ b/examples/resources/uxi_agent_group_assignment/resource.tf @@ -0,0 +1,4 @@ +resource "uxi_agent_group_assignment" "my_agent_group_assignment" { + agent_id = uxi_agent.my_agent.id + group_id = uxi_group.my_group.id +} From 48e170bb52633e93d3b6b6b5c6bfe11731982f6d Mon Sep 17 00:00:00 2001 From: Alistair Yan <52126234+1riatsila1@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:30:30 +0200 Subject: [PATCH 2/3] fix!: rm uneccesary code (#142) --- Justfile | 25 +------ README.md | 11 ++- examples/full-demo/main.tf | 150 ------------------------------------- 3 files changed, 13 insertions(+), 173 deletions(-) delete mode 100644 examples/full-demo/main.tf diff --git a/Justfile b/Justfile index efaed941..905f44a3 100644 --- a/Justfile +++ b/Justfile @@ -1,4 +1,3 @@ -OPEN_API_TMP_DIR := "tmp" CLIENT_DIR := "pkg/config-api-client" TOOLS_PROVIDER_DIR := "tools" OPENAPI_SPEC := "pkg/config-api-client/api" @@ -8,18 +7,10 @@ SOURCE_OPEN_API_SPEC_FILE := ".openapi.source.yaml" help: @just --list -_retrieve-config-api-openapi-spec: - rm -rf {{ OPEN_API_TMP_DIR }} - git clone git@github.com:aruba-uxi/configuration-api.git --depth=1 {{ OPEN_API_TMP_DIR }} - mkdir -p {{ OPENAPI_SPEC }} - cp {{ OPEN_API_TMP_DIR }}/oas/openapi.yaml {{ OPENAPI_SPEC }}/{{ SOURCE_OPEN_API_SPEC_FILE }} - rm -rf {{ OPEN_API_TMP_DIR }} - _remove-client-files: cd {{ CLIENT_DIR }} && cat .openapi-generator/FILES | xargs -n 1 rm -f -generate-config-api-client: _retrieve-config-api-openapi-spec - just _remove-client-files +generate-config-api-client: _remove-client-files docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \ --input-spec /local/{{ OPENAPI_SPEC }}/{{ SOURCE_OPEN_API_SPEC_FILE }} \ --generator-name go \ @@ -33,11 +24,11 @@ generate-config-api-client: _retrieve-config-api-openapi-spec just tidy-client just fmt-client -setup-dev: +setup-run: grep -q "registry.terraform.io/arubauxi/hpeuxi" ~/.terraformrc && echo "Dev override found - installing provider locally" || { echo "Dev override not found - please follow README setup guide"; exit 1; } go install . -remove-dev-override: +remove-setup-run-dev-override: sed -i '' '/registry\.terraform\.io\/arubauxi\/hpeuxi/d' ~/.terraformrc build-local: @@ -140,13 +131,3 @@ tidy: clean: find . -name ".coverage*" -type f -delete - -DEFAULT_EXAMPLE := "full-demo" - -plan example=DEFAULT_EXAMPLE +ARGS='': - go install . - cd examples/{{example}} && terraform plan {{ ARGS }} - -apply example=DEFAULT_EXAMPLE +ARGS='': - go install . - cd examples/{{example}} && terraform apply {{ ARGS }} diff --git a/README.md b/README.md index 5c8a8c79..71e874a4 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ - [Justfile](#justfile) - [Installing the provider locally](#installing-the-provider-locally) - [Running Local Test Suite](#running-local-test-suite) + - [Updating the client](#updating-the-client) - [Running Acceptance Tests](#running-acceptance-tests) - [Building and Distribution](#building-and-distribution) @@ -134,7 +135,7 @@ just help ### Installing the provider locally ```shell -just setup-dev +just setup-run ``` ## Running Local Test Suite @@ -143,6 +144,14 @@ just setup-dev just test ``` +## Updating the client + +The client used for interfacing with the UXI backend is autogenerated using an API Spec and [openapitools](https://github.com/OpenAPITools/openapi-generator-cli). In order to generate a client, ensure that the desired OpenAPI spec is copied to `./pkg/config-api-client/api/openapi.yaml`. Thereafter run: + +```shell +just generate-config-api-client +``` + ## Running Acceptance Tests Set the `GREENLAKE_UXI_CLIENT_ID` and `GREENLAKE_UXI_CLIENT_SECRET` environment variables for the acceptance test customer. The client credentials must have sufficient permissions execute create, read, update and destroy operations for the UXI customer. Also set the `UXI_HOST` environment variable to target the staging diff --git a/examples/full-demo/main.tf b/examples/full-demo/main.tf deleted file mode 100644 index 797a53e4..00000000 --- a/examples/full-demo/main.tf +++ /dev/null @@ -1,150 +0,0 @@ -terraform { - required_providers { - uxi = { - source = "registry.terraform.io/arubauxi/hpeuxi" - } - } -} - -provider "uxi" { - client_id = "client_id" - client_secret = "some_random_secret" -} - -resource "uxi_group" "my_group" { - name = "parent" -} - -resource "uxi_group" "my_group_2" { - name = "child" - parent_group_id = uxi_group.my_group.id -} - -// Sensor Resource -/* -To remove: -removed { - from = uxi_sensor.my_sensor - - lifecycle { - destroy = false - } -} -*/ - -resource "uxi_sensor" "my_sensor" { - name = "name" - address_note = "address_note" - notes = "notes" - pcap_mode = "pcap_mode" -} - -import { - to = uxi_sensor.my_sensor - id = "uid" -} - - -// Agent Resource -/* -To remove: -removed { - from = uxi_agent.my_agent - - lifecycle { - destroy = false - } -} -*/ -resource "uxi_agent" "my_agent" { - name = "name" - notes = "notes" - pcap_mode = "pcap_mode" -} - -import { - to = uxi_agent.my_agent - id = "uid" -} - - -// Wireless Network Resource -/* -To remove: -removed { - from = uxi_wireless_network.my_wireless_network - - lifecycle { - destroy = false - } -} -*/ -resource "uxi_wireless_network" "my_wireless_network" { - name = "name" -} - -import { - to = uxi_wireless_network.my_wireless_network - id = "uid" -} - -// Wired Network Resource -/* -To remove: -removed { - from = uxi_wired_network.my_wired_network - - lifecycle { - destroy = false - } -} -*/ -resource "uxi_wired_network" "my_wired_network" { - name = "name" -} - -import { - to = uxi_wired_network.my_wired_network - id = "uid" -} -// Service Test Resource -/* -To remove: -removed { - from = uxi_service_test.my_service_test - - lifecycle { - destroy = false - } -} -*/ -resource "uxi_service_test" "my_service_test" { - name = "name" -} - -import { - to = uxi_service_test.my_service_test - id = "uid" -} - -// Sensor Group Assignment -resource "uxi_sensor_group_assignment" "my_uxi_sensor_group_assignment" { - sensor_id = uxi_sensor.my_sensor.id - group_id = uxi_group.my_group.id -} - -// Agent Group Assignment -resource "uxi_agent_group_assignment" "my_uxi_agent_group_assignment" { - agent_id = uxi_agent.my_agent.id - group_id = uxi_group.my_group.id -} - -// Network Group Assignment -resource "uxi_network_group_assignment" "my_uxi_network_group_assignment" { - network_id = uxi_agent.my_agent.id - group_id = uxi_group.my_group.id -} - -# output "group" { -# value = uxi_group.group -# } From 074c97669cb00aeccb96a0988a2b0e00ef492395 Mon Sep 17 00:00:00 2001 From: Clifton Dhanee <106665532+cliftonHPE@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:31:14 +0200 Subject: [PATCH 3/3] service test group assignments example (#141) Co-authored-by: Brandon <79970283+brandon-piner-aruba@users.noreply.github.com> --- .../service_test_group_assignment.md | 11 +++++++++- .../service_test_group_assignment.md | 22 +++++++++++++++++++ .../data-source.tf | 6 +++++ .../import.sh | 8 +++++++ .../resource.tf | 4 ++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 examples/data-sources/uxi_service_test_group_assignment/data-source.tf create mode 100644 examples/resources/uxi_service_test_group_assignment/import.sh create mode 100644 examples/resources/uxi_service_test_group_assignment/resource.tf diff --git a/docs/data-sources/service_test_group_assignment.md b/docs/data-sources/service_test_group_assignment.md index 83b6f4a7..199236bc 100644 --- a/docs/data-sources/service_test_group_assignment.md +++ b/docs/data-sources/service_test_group_assignment.md @@ -10,7 +10,16 @@ description: |- Retrieves a specific service test group assignment. - +## Example Usage + +```terraform +# Retrieve data for a service test group assignment +data "uxi_service_test_group_assignment" "my_service_test_group_assignment" { + filter = { + id = "" + } +} +``` ## Schema diff --git a/docs/resources/service_test_group_assignment.md b/docs/resources/service_test_group_assignment.md index cbfdf426..b7255460 100644 --- a/docs/resources/service_test_group_assignment.md +++ b/docs/resources/service_test_group_assignment.md @@ -10,7 +10,14 @@ description: |- Manages a service test group assignment. +## Example Usage +```terraform +resource "uxi_service_test_group_assignment" "my_service_test_group_assignment" { + service_test_id = uxi_service_test.my_service_test.id + group_id = uxi_group.my_group.id +} +``` ## Schema @@ -23,3 +30,18 @@ Manages a service test group assignment. ### Read-Only - `id` (String) The identifier of the service test group assignment + +## Import + +Import is supported using the following syntax: + +```shell +# Import service test group assignment using its ID +terraform import uxi_service_test_group_assignment.my_service_test_group_assignment + +# Import service test group assignment using its ID with an import block +import { + to = uxi_service_test_group_assignment.my_service_test_group_assignment + id = "" +} +``` diff --git a/examples/data-sources/uxi_service_test_group_assignment/data-source.tf b/examples/data-sources/uxi_service_test_group_assignment/data-source.tf new file mode 100644 index 00000000..17d49e2a --- /dev/null +++ b/examples/data-sources/uxi_service_test_group_assignment/data-source.tf @@ -0,0 +1,6 @@ +# Retrieve data for a service test group assignment +data "uxi_service_test_group_assignment" "my_service_test_group_assignment" { + filter = { + id = "" + } +} diff --git a/examples/resources/uxi_service_test_group_assignment/import.sh b/examples/resources/uxi_service_test_group_assignment/import.sh new file mode 100644 index 00000000..e12252e0 --- /dev/null +++ b/examples/resources/uxi_service_test_group_assignment/import.sh @@ -0,0 +1,8 @@ +# Import service test group assignment using its ID +terraform import uxi_service_test_group_assignment.my_service_test_group_assignment + +# Import service test group assignment using its ID with an import block +import { + to = uxi_service_test_group_assignment.my_service_test_group_assignment + id = "" +} diff --git a/examples/resources/uxi_service_test_group_assignment/resource.tf b/examples/resources/uxi_service_test_group_assignment/resource.tf new file mode 100644 index 00000000..6498d615 --- /dev/null +++ b/examples/resources/uxi_service_test_group_assignment/resource.tf @@ -0,0 +1,4 @@ +resource "uxi_service_test_group_assignment" "my_service_test_group_assignment" { + service_test_id = uxi_service_test.my_service_test.id + group_id = uxi_group.my_group.id +}