Skip to content

Commit

Permalink
[APP-16093] add smart classes to tf provider (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-willis authored Jan 17, 2025
1 parent ed8148a commit 843569b
Show file tree
Hide file tree
Showing 26 changed files with 3,536 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ website/node_modules
.terraform/
*.log
*.bak
.env
*~
.*.swp
.idea
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ If you create a new one, be sure to add the file to the [genqlient.yaml](jupiter
You should always generate the gql client from the production api so that you do not include any in-progress work from dev. Set these environment variables before running the next commands.

```shell
export JUPITERONE_ACCOUNT=:your_account_id
export JUPITERONE_ACCOUNT_ID=:your_account_id
export JUPITERONE_API_KEY=:your_api_key
export JUPITERONE_REGION=us
```
Expand Down
50 changes: 50 additions & 0 deletions docs/resources/smart_class.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "jupiterone_smart_class Resource - terraform-provider-jupiterone"
subcategory: ""
description: |-
JupiterOne Smart Class
---

# jupiterone_smart_class (Resource)

JupiterOne Smart Class

## Example Usage

```terraform
resource "jupiterone_smart_class" "example" {
tag_name = "Example"
description = "Example smart class"
}
resource "jupiterone_smart_class_query" "query1" {
smart_class_id = jupiterone_smart_class.example.id
query = "Find User"
description = "Example query"
}
resource "jupiterone_smart_class_tag" "tag2" {
smart_class_id = jupiterone_smart_class.example.id
name = "user"
type = "boolean"
value = "true"
}
```

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

### Required

- `tag_name` (String) The tag name of the smart class.

### Optional

- `description` (String) The description of the smart class.

### Read-Only

- `id` (String) The ID of this resource.


36 changes: 36 additions & 0 deletions docs/resources/smart_class_query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "jupiterone_smart_class_query Resource - terraform-provider-jupiterone"
subcategory: ""
description: |-
A smart class query is a J1QL query that finds entities to associate with a smart class
---

# jupiterone_smart_class_query (Resource)

A smart class query is a J1QL query that finds entities to associate with a smart class

## Example Usage

```terraform
resource "jupiterone_smart_class_query" "query1" {
smart_class_id = jupiterone_smart_class.example.id
query = "Find User with active=true"
description = "Find all active users"
}
```

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

### Required

- `description` (String) A description of the smart class query
- `query` (String) The J1QL query to find entities for the smart class
- `smart_class_id` (String) The ID of the smart class to associate the query with

### Read-Only

- `id` (String) The ID of this resource.


52 changes: 52 additions & 0 deletions docs/resources/smart_class_tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "jupiterone_smart_class_tag Resource - terraform-provider-jupiterone"
subcategory: ""
description: |-
A smart class tag is another tag applied to entities found by a smart class query
---

# jupiterone_smart_class_tag (Resource)

A smart class tag is another tag applied to entities found by a smart class query

## Example Usage

```terraform
resource "jupiterone_smart_class_tag" "tag1" {
smart_class_id = jupiterone_smart_class.example.id
name = "person"
type = "boolean"
value = "true"
}
resource "jupiterone_smart_class_tag" "tag2" {
smart_class_id = jupiterone_smart_class.example.id
name = "worth"
type = "number"
value = "50000"
}
resource "jupiterone_smart_class_tag" "tag3" {
smart_class_id = jupiterone_smart_class.example.id
name = "label"
type = "string"
value = "example"
}
```

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

### Required

- `name` (String) The name (key) of the tag
- `smart_class_id` (String) The ID of the smart class to associate the tag with
- `type` (String) The type of the tag, one of 'string', 'boolean', or 'number'
- `value` (String) The value of the tag as a string

### Read-Only

- `id` (String) The ID of this resource.


18 changes: 18 additions & 0 deletions examples/resources/jupiterone_smart_class/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "jupiterone_smart_class" "example" {
tag_name = "Example"
description = "Example smart class"
}

resource "jupiterone_smart_class_query" "query1" {
smart_class_id = jupiterone_smart_class.example.id
query = "Find User"
description = "Example query"
}

resource "jupiterone_smart_class_tag" "tag2" {
smart_class_id = jupiterone_smart_class.example.id
name = "user"
type = "boolean"
value = "true"
}

5 changes: 5 additions & 0 deletions examples/resources/jupiterone_smart_class_query/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "jupiterone_smart_class_query" "query1" {
smart_class_id = jupiterone_smart_class.example.id
query = "Find User with active=true"
description = "Find all active users"
}
20 changes: 20 additions & 0 deletions examples/resources/jupiterone_smart_class_tag/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "jupiterone_smart_class_tag" "tag1" {
smart_class_id = jupiterone_smart_class.example.id
name = "person"
type = "boolean"
value = "true"
}

resource "jupiterone_smart_class_tag" "tag2" {
smart_class_id = jupiterone_smart_class.example.id
name = "worth"
type = "number"
value = "50000"
}

resource "jupiterone_smart_class_tag" "tag3" {
smart_class_id = jupiterone_smart_class.example.id
name = "label"
type = "string"
value = "example"
}
82 changes: 80 additions & 2 deletions jupiterone/cassettes/TestResourcePermission_Basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,86 @@ interactions:
- "0"
status: 200 OK
code: 200
duration: 664.85025ms
duration: 533.467416ms
- id: 1
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 544
transfer_encoding: []
trailer: {}
host: graphql.dev.jupiterone.io
remote_addr: ""
request_uri: ""
body: '{"query":"\nquery GetResourcePermissions ($filter: GetResourcePermissionsFilter!, $cursor: String, $limit: Int) {\n\tgetResourcePermissions(filter: $filter, cursor: $cursor, limit: $limit) {\n\t\tcanCreate\n\t\tcanDelete\n\t\tcanRead\n\t\tcanUpdate\n\t\tresourceArea\n\t\tresourceId\n\t\tresourceType\n\t\tsubjectId\n\t\tsubjectType\n\t}\n}\n","variables":{"filter":{"subjectType":"group","subjectId":"example-group-id","resourceArea":"rule","resourceType":"*","resourceId":"*"},"cursor":"","limit":10},"operationName":"GetResourcePermissions"}'
form: {}
headers:
Cache-Control:
- no-cache
Content-Type:
- application/json
url: https://graphql.dev.jupiterone.io/
method: POST
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 217
uncompressed: false
body: |
{"data":{"getResourcePermissions":[{"canCreate":true,"canDelete":true,"canRead":true,"canUpdate":true,"resourceArea":"rule","resourceId":"*","resourceType":"*","subjectId":"example-group-id","subjectType":"group"}]}}
headers:
Access-Control-Allow-Credentials:
- "true"
Content-Length:
- "217"
Content-Security-Policy:
- 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' https: data:;form-action ''self'';frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
Content-Type:
- application/json
Cross-Origin-Embedder-Policy:
- require-corp
Cross-Origin-Opener-Policy:
- same-origin
Cross-Origin-Resource-Policy:
- same-origin
Expect-Ct:
- max-age=0
Origin-Agent-Cluster:
- ?1
Ratelimit-Limit:
- "1000"
Ratelimit-Remaining:
- "999"
Ratelimit-Requested:
- "1"
Ratelimit-Reset:
- "1"
Referrer-Policy:
- no-referrer
Strict-Transport-Security:
- max-age=15552000; includeSubDomains
Vary:
- Origin
X-Content-Type-Options:
- nosniff
X-Dns-Prefetch-Control:
- "off"
X-Download-Options:
- noopen
X-Frame-Options:
- SAMEORIGIN
X-Permitted-Cross-Domain-Policies:
- none
X-Xss-Protection:
- "0"
status: 200 OK
code: 200
duration: 450.648917ms
- id: 2
request:
proto: HTTP/1.1
proto_major: 1
Expand Down Expand Up @@ -156,4 +234,4 @@ interactions:
- "0"
status: 200 OK
code: 200
duration: 234.689667ms
duration: 482.037916ms
Loading

0 comments on commit 843569b

Please sign in to comment.