Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the Explorer API #1018

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sebasslash
Copy link
Contributor

@sebasslash sebasslash commented Dec 5, 2024

Description

Adds support for the two current GA endpoints of the Explorer API:

Testing plan

To run the tests, you will need an organization available with enough activity to test several different types of queries. The organization must be specified using the EXPLORER_TEST_ORGANIZATION environment variable; otherwise, the tests will be skipped. Test assertions rely on the current state of the specified organization, and failures may occur if the organization does not meet the required query conditions enumerated in the integration tests. For guidance on writing custom queries to smoke test on your own, refer to the code examples provided in the ./examples/explorer directory.

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

$ TFE_ADDRESS="https://example" TFE_TOKEN="example" go test ./... -v -run TestFunctionsAffectedByChange

...

@sebasslash sebasslash requested a review from a team as a code owner December 5, 2024 22:10
@datadog-terraform-cloud-hashicorp
Copy link

datadog-terraform-cloud-hashicorp bot commented Dec 5, 2024

Datadog Report

Branch report: sebasslash/add-explorer-api
Commit report: ddc129a
Test service: hashicorp/go-tfe

✅ 0 Failed, 1421 Passed, 167 Skipped, 16m 1.88s Total Time
🔻 Test Sessions change in coverage: 1 decreased (-0.6%)

🔻 Code Coverage Decreases vs Default Branch (1)

  • datadog-ci junit upload 58.7% (-0.6%) - Details

This commit adds support for the two generally available endpoints in
the Explorer API: execute a query, export data to CSV. Since the jsonapi
decoder does not support unmarshalling polymorphic slices, each view type has been
assigned its own query function returning the appropriate data type.
@sebasslash sebasslash force-pushed the sebasslash/add-explorer-api branch from 4716d65 to 2c834cb Compare December 5, 2024 22:30
@@ -51,7 +51,6 @@ type GHAInstallationListOptions struct {
func (s *gHAInstallations) List(ctx context.Context, options *GHAInstallationListOptions) (*GHAInstallationList, error) {
u := "github-app/installations"
req, err := s.client.NewRequest("GET", u, options)
fmt.Println(u)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

ctrombley
ctrombley previously approved these changes Jan 15, 2025
Copy link
Collaborator

@ctrombley ctrombley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smoke tested, looks great! Thanks for doing this! ✨

@notchairmk
Copy link
Member

This is cool, but might lock us into a path that we don't want to go down quite yet. One thing that we want to get to is an explorer discovery endpoint that could be used to look up type and field information, so that we don't have to hardcode all of the types and supported fields here and can instead read them from the backend and get some metadata around supported data types and operations.

There's a decent amount that we could use in the future, but I'd like to hold off on this for the moment just so we don't have to undo things in the near future. Thank you for taking a first swipe at this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants