-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add eventqueries * add test * fmt * add project name * update function * Test * remove * why? * acceptance tests * acceptance tests * run tfdocs step * hey its me * branch * branch * maybe * origin * Actual checkout * correct email * push * origin * origin * origin2 * different * test * test * test * rever * Revert "rever" This reverts commit 79a62c6. * Reapply "rever" This reverts commit 5cdfcbc. * whoops * Revert "whoops" This reverts commit 318f271. * test * view remote * view remote * view remote * view remote * v3 * this? * creds * v3 * organize * Author * switch * switch * fetch depth 0 * don't persist creds * need that * version * added terraform docs --------- Co-authored-by: danhurwit <[email protected]>
- Loading branch information
Showing
12 changed files
with
488 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
1.90.0 | ||
1.91.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
type EventQueryAttributes struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
QueryString string `json:"query_string"` | ||
Source string `json:"source"` | ||
Type string `json:"type"` | ||
} | ||
|
||
type WireEventQueryAttributes struct { | ||
Attributes EventQueryAttributes `json:"attributes"` | ||
} | ||
|
||
func (c *Client) GetEventQuery(ctx context.Context, projectName string, eventQueryID string) (*EventQueryAttributes, error) { | ||
var ( | ||
event *WireEventQueryAttributes | ||
resp Envelope | ||
) | ||
|
||
if err := c.CallAPI(ctx, "GET", fmt.Sprintf("projects/%v/event_queries/%v", | ||
projectName, eventQueryID), nil, &resp); err != nil { | ||
return nil, err | ||
} | ||
if err := json.Unmarshal(resp.Data, &event); err != nil { | ||
return nil, err | ||
} | ||
return &event.Attributes, nil | ||
} | ||
|
||
func (c *Client) CreateEventQuery(ctx context.Context, projectName string, attributes EventQueryAttributes) (*EventQueryAttributes, error) { | ||
var ( | ||
event *EventQueryAttributes | ||
resp Envelope | ||
) | ||
|
||
body := WireEventQueryAttributes{Attributes: attributes} | ||
bytes, err := json.Marshal(body) | ||
if err != nil { | ||
return event, err | ||
} | ||
if err := c.CallAPI(ctx, "POST", | ||
fmt.Sprintf("projects/%v/event_queries", projectName), Envelope{Data: bytes}, &resp); err != nil { | ||
return nil, err | ||
} | ||
err = json.Unmarshal(resp.Data, &event) | ||
return event, err | ||
} | ||
|
||
func (c *Client) UpdateEventQuery(ctx context.Context, projectName string, eventQueryID string, attributes EventQueryAttributes) (*EventQueryAttributes, error) { | ||
var ( | ||
event *EventQueryAttributes | ||
resp Envelope | ||
) | ||
|
||
bytes, err := json.Marshal(attributes) | ||
if err != nil { | ||
return event, err | ||
} | ||
if err := c.CallAPI(ctx, "PUT", | ||
fmt.Sprintf("projects/%v/event_queries/%v", eventQueryID, projectName), bytes, &resp); err != nil { | ||
return nil, err | ||
} | ||
err = json.Unmarshal(resp.Data, &event) | ||
return event, err | ||
} | ||
|
||
func (c *Client) DeleteEventQuery(ctx context.Context, projectName string, eventQueryID string) error { | ||
err := c.CallAPI(ctx, "DELETE", | ||
fmt.Sprintf("projects/%v/event_queries/%v", projectName, eventQueryID), | ||
nil, | ||
nil) | ||
if err != nil { | ||
apiClientError, ok := err.(APIResponseCarrier) | ||
if !ok || apiClientError.GetStatusCode() != http.StatusNoContent { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "lightstep_event_query Resource - terraform-provider-lightstep" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# lightstep_event_query (Resource) | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) | ||
- `project_name` (String) Lightstep project name | ||
- `query_string` (String) | ||
- `source` (String) | ||
- `type` (String) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.