Skip to content

Commit

Permalink
feat: add monitorv2_action datasource (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
obs-gh-owengoebel authored Aug 6, 2024
1 parent e167e73 commit 1fb3cc6
Show file tree
Hide file tree
Showing 10 changed files with 602 additions and 13 deletions.
4 changes: 4 additions & 0 deletions client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,10 @@ func (c *Client) LookupMonitorV2(ctx context.Context, workspaceId *string, nameE
return c.Meta.LookupMonitorV2(ctx, workspaceId, nameExact)
}

func (c *Client) SearchMonitorV2Action(ctx context.Context, workspaceId *string, nameExact *string) (*meta.MonitorV2Action, error) {
return c.Meta.SearchMonitorV2Action(ctx, workspaceId, nameExact)
}

// CreateMonitorActionAttachment creates a monitor action attachment
func (c *Client) CreateMonitorActionAttachment(ctx context.Context, input *meta.MonitorActionAttachmentInput) (*meta.MonitorActionAttachment, error) {
if !c.Flags[flagObs2110] {
Expand Down
14 changes: 14 additions & 0 deletions client/internal/meta/operation/monitorv2_action.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ fragment MonitorV2Action on MonitorV2Action {
createdDate
}

fragment MonitorV2ActionSearchResult on MonitorV2ActionSearchResult {
# @genqlient(flatten: true)
results {
...MonitorV2Action
}
}

# @genqlient(for: "MonitorV2ActionInput.email", omitempty: true)
# @genqlient(for: "MonitorV2ActionInput.webhook", omitempty: true)
# @genqlient(for: "MonitorV2ActionInput.iconUrl", omitempty: true)
Expand Down Expand Up @@ -131,4 +138,11 @@ mutation deleteMonitorV2Action($id: ObjectId!) {
resultStatus: deleteMonitorV2Action(id: $id) {
...ResultStatus
}
}

query searchMonitorV2Action($workspaceId: ObjectId, $folderId: ObjectId, $nameExact: String, $nameSubstring: String) {
# @genqlient(flatten: true)
monitorV2Actions: searchMonitorV2Action(workspaceId: $workspaceId, folderId: $folderId, nameExact: $nameExact, nameSubstring: $nameSubstring) {
...MonitorV2ActionSearchResult
}
}
146 changes: 146 additions & 0 deletions client/meta/genqlient.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions client/meta/monitorv2_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ func (client *Client) SaveActionWithDestinationLinks(ctx context.Context, action
return monitorV2ActionOrError(resp, err)
}

func (client *Client) SearchMonitorV2Action(ctx context.Context, workspaceId *string, nameExact *string) (*MonitorV2Action, error) {
resp, err := searchMonitorV2Action(ctx, client.Gql, workspaceId, nil, nameExact, nil)
if err != nil || resp == nil || len(resp.MonitorV2Actions.Results) != 1 {
return nil, err
}
return &resp.MonitorV2Actions.Results[0], nil
}

func (m *MonitorV2Action) Oid() *oid.OID {
return &oid.OID{
Id: m.Id,
Expand Down
87 changes: 87 additions & 0 deletions docs/data-sources/monitor_v2_action.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "observe_monitor_v2_action Data Source - terraform-provider-observe"
subcategory: ""
description: |-
---

# observe_monitor_v2_action (Data Source)





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

### Optional

- `name` (String)
- `workspace` (String)

### Read-Only

- `description` (String)
- `destination` (Block List) (see [below for nested schema](#nestedblock--destination))
- `email` (Block List) (see [below for nested schema](#nestedblock--email))
- `id` (String) The ID of this resource.
- `oid` (String)
- `type` (String)
- `webhook` (Block List) (see [below for nested schema](#nestedblock--webhook))

<a id="nestedblock--destination"></a>
### Nested Schema for `destination`

Read-Only:

- `description` (String)
- `email` (Block List) (see [below for nested schema](#nestedblock--destination--email))
- `oid` (String)
- `webhook` (Block List) (see [below for nested schema](#nestedblock--destination--webhook))

<a id="nestedblock--destination--email"></a>
### Nested Schema for `destination.email`

Read-Only:

- `addresses` (List of String)
- `users` (List of String)


<a id="nestedblock--destination--webhook"></a>
### Nested Schema for `destination.webhook`

Read-Only:

- `method` (String)
- `url` (String)



<a id="nestedblock--email"></a>
### Nested Schema for `email`

Read-Only:

- `body` (String)
- `fragments` (String)
- `subject` (String)


<a id="nestedblock--webhook"></a>
### Nested Schema for `webhook`

Read-Only:

- `body` (String)
- `fragments` (String)
- `headers` (Block List) (see [below for nested schema](#nestedblock--webhook--headers))

<a id="nestedblock--webhook--headers"></a>
### Nested Schema for `webhook.headers`

Read-Only:

- `header` (String)
- `value` (String)
8 changes: 5 additions & 3 deletions observe/data_source_monitor_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func dataSourceMonitorV2() *schema.Resource {
Optional: true,
ValidateDiagFunc: validateOID(oid.TypeMonitorV2),
Description: descriptions.Get("common", "schema", "id"),
ExactlyOneOf: []string{"name", "id"},
},
"workspace": { // ObjectId!
Type: schema.TypeString,
Expand All @@ -32,9 +33,10 @@ func dataSourceMonitorV2() *schema.Resource {
Description: descriptions.Get("monitorv2", "schema", "workspace_id"),
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: descriptions.Get("monitorv2", "schema", "name"),
Type: schema.TypeString,
Optional: true,
Description: descriptions.Get("monitorv2", "schema", "name"),
ExactlyOneOf: []string{"name", "id"},
},
// fields of MonitorV2Input excluding the components of MonitorV2Definition
"comment": { // String
Expand Down
Loading

0 comments on commit 1fb3cc6

Please sign in to comment.