Skip to content

Commit

Permalink
feat: add rooms support and space claim token
Browse files Browse the repository at this point in the history
  • Loading branch information
witalisoft committed Jan 18, 2024
1 parent af1d316 commit bf328e5
Show file tree
Hide file tree
Showing 26 changed files with 739 additions and 84 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Initial version.
FEATURES:

- support for the Netdata Cloud Spaces
- support for the Netdata Cloud Rooms
34 changes: 0 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ This provider allows you to install and manage Netdata Cloud resources using Ter

* [Requirements](#requirements)
* [Getting Started](#getting-started)
* [Example](#example)

## Requirements

Expand Down Expand Up @@ -42,36 +41,3 @@ TODO
```console
$ make local-build
```

## Example

```hcl
terraform {
required_providers {
netdata = {
# TODO: Update this string with the published name of your provider.
source = "netdata.cloud/todo/netdata"
}
}
required_version = ">= 1.1.0"
}
provider "netdata" {
url = "https://app.netdata.cloud"
authtoken = "<authtoken>"
}
resource "netdata_space" "test" {
name = "MyTestingSpace"
description = "Created by Terraform"
}
data "netdata_space" "test" {
id = "ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1"
}
output "datasource" {
value = data.netdata_space.test.name
}
```
33 changes: 33 additions & 0 deletions docs/data-sources/room.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "netdata_room Data Source - terraform-provider-netdata"
subcategory: ""
description: |-
---

# netdata_room (Data Source)



## Example Usage

```terraform
data "netdata_room" "test" {
spaceid = "<spaceid>"
id = "<roomid>"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) The ID of the room
- `spaceid` (String) The ID of the space

### Read-Only

- `description` (String) The description of the room
- `name` (String) The name of the room
3 changes: 2 additions & 1 deletion docs/data-sources/space.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description: |-

```terraform
data "netdata_space" "test" {
id = "ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1"
id = "<spaceid>"
}
```

Expand All @@ -27,5 +27,6 @@ data "netdata_space" "test" {

### Read-Only

- `claimtoken` (String) The claim token of the space
- `description` (String) The description of the space
- `name` (String) The name of the space
47 changes: 47 additions & 0 deletions docs/resources/room.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "netdata_room Resource - terraform-provider-netdata"
subcategory: ""
description: |-
---

# netdata_room (Resource)



## Example Usage

```terraform
resource "netdata_room" "test" {
spaceid = "<spaceid>"
name = "MyTestingSpace"
description = "Created by Terraform"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the room
- `spaceid` (String) The ID of the space

### Optional

- `description` (String) The description of the room

### Read-Only

- `id` (String) The ID of the room

## Import

Import is supported using the following syntax:

```shell
#!/bin/sh

terraform import netdata_room.test spaceid,roomid
```
3 changes: 2 additions & 1 deletion docs/resources/space.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ resource "netdata_space" "test" {

### Read-Only

- `claimtoken` (String) The claim token of the space
- `id` (String) The ID of the space

## Import
Expand All @@ -41,5 +42,5 @@ Import is supported using the following syntax:
```shell
#!/bin/sh

terraform import netdata_space.test ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1
terraform import netdata_space.test spaceid
```
35 changes: 35 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
terraform {
required_providers {
netdata = {
# TODO: Update this string with the published name of your provider.
source = "netdata.cloud/todo/netdata"
}
}
required_version = ">= 1.1.0"
}

provider "netdata" {}

resource "netdata_space" "test" {
name = "MyTestingSpace"
description = "Created by Terraform"
}

resource "netdata_room" "test" {
spaceid = netdata_space.test.id
name = "MyTestingRoom"
description = "Created by Terraform2"
}

data "netdata_space" "test" {
id = netdata_space.test.id
}

data "netdata_room" "test" {
id = netdata_room.test.id
spaceid = netdata_space.test.id
}

output "datasource" {
value = data.netdata_space.test.name
}
4 changes: 4 additions & 0 deletions examples/data-sources/netdata_room/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "netdata_room" "test" {
spaceid = "<spaceid>"
id = "<roomid>"
}
2 changes: 1 addition & 1 deletion examples/data-sources/netdata_space/data-source.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
data "netdata_space" "test" {
id = "ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1"
id = "<spaceid>"
}
3 changes: 3 additions & 0 deletions examples/resources/netdata_room/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

terraform import netdata_room.test spaceid,roomid
5 changes: 5 additions & 0 deletions examples/resources/netdata_room/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "netdata_room" "test" {
spaceid = "<spaceid>"
name = "MyTestingSpace"
description = "Created by Terraform"
}
2 changes: 1 addition & 1 deletion examples/resources/netdata_space/import.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

terraform import netdata_space.test ee3ec76d-0180-4ef4-93ae-c94c1e7ed2f1
terraform import netdata_space.test spaceid
26 changes: 0 additions & 26 deletions examples/spaces/main.tf

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/hashicorp/terraform-plugin-framework v1.5.0
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-go v0.20.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-testing v1.6.0
)

Expand Down Expand Up @@ -38,7 +39,6 @@ require (
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.19.0 // indirect
github.com/hashicorp/terraform-json v0.18.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
Expand Down
6 changes: 6 additions & 0 deletions internal/client/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ type SpaceInfo struct {
Name string `json:"name"`
Description string `json:"description"`
}

type RoomInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
}
Loading

0 comments on commit bf328e5

Please sign in to comment.