diff --git a/.github/workflows/go-code-check.yml b/.github/workflows/go-code-check.yml index 8c85f67fb9..32d22838ee 100644 --- a/.github/workflows/go-code-check.yml +++ b/.github/workflows/go-code-check.yml @@ -29,7 +29,6 @@ jobs: ssh-private-key: ${{ secrets.GRPC_GATEWAY_DEPLOY_KEY }} - name: Check formatting and build run: | - git config --global url."git@github.com:".insteadOf "https://github.com/" go mod tidy go install google.golang.org/protobuf/cmd/protoc-gen-go go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest @@ -65,7 +64,6 @@ jobs: LOGS_BUCKET: ${{ secrets.LOGS_BUCKET }} GOPRIVATE: ${{ secrets.GOPRIVATE }} run: | - git config --global url."git@github.com:".insteadOf "https://github.com/" go install google.golang.org/protobuf/cmd/protoc-gen-go go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest make test @@ -92,7 +90,7 @@ jobs: LOGS_BUCKET: ${{ secrets.LOGS_BUCKET }} GOPRIVATE: ${{ secrets.GOPRIVATE }} run: | - git config --global url."git@github.com:".insteadOf "https://github.com/" go install google.golang.org/protobuf/cmd/protoc-gen-go go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest make test-openapi + make test-openapi-ro diff --git a/.github/workflows/go-readonly-tests.yml b/.github/workflows/go-readonly-tests.yml new file mode 100644 index 0000000000..3305fcda73 --- /dev/null +++ b/.github/workflows/go-readonly-tests.yml @@ -0,0 +1,31 @@ +name: "[Tools] Go Readonly Tests Image" + +on: + workflow_dispatch: + push: + branches: [ master ] + paths: + - 'go/**' + - 'proto/**' +jobs: + build-example-image: + name: "[Tools] Build Go Readonly Tests Image" + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ vars.ECR_ROLE }} + aws-region: ${{ vars.DEFAULT_ECR_REGISTRY_REGION }} + - uses: aws-actions/amazon-ecr-login@v2 + - uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + context: . + file: go/openapi/Dockerfile + push: true + tags: ${{ vars.DEFAULT_ECR_REGISTRY }}/go-readonly-tests:latest diff --git a/.github/workflows/protobuf-code-check.yml b/.github/workflows/protobuf-code-check.yml deleted file mode 100644 index 2a3419d7fb..0000000000 --- a/.github/workflows/protobuf-code-check.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: "[Protobuf] Lint & Build Facade" - - -# token for buf to annotate the PR -permissions: - contents: read - pull-requests: write - - -on: - workflow_dispatch: - pull_request: - branches: [ master ] - paths: - - 'proto/**' - - '.github/workflows/**' - -env: - CARGO_TERM_COLOR: always - RUST_BACKTRACE: full - PROTOC_VERSION: "33.x" - -jobs: - protobuf_lint_and_build: - name: "[Protobuf] Lint & Build Facade" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: bufbuild/buf-action@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/setup-go@v5 - - uses: arduino/setup-protoc@v3 - with: - version: ${{env.PROTOC_VERSION}} - - name: Install dependencies - run: | - go install google.golang.org/protobuf/cmd/protoc-gen-go - go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest - go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest - go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest - - name: Run OpenAPI facade build - run: | - bash tools/build_facade_files.sh diff --git a/Makefile b/Makefile index f207926560..3e165d0408 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,9 @@ test: test-openapi: cd ./go; make test-openapi TESTARGS=${TESTARGS} +test-openapi-ro: + cd ./go; make test-openapi-ro TESTARGS=${TESTARGS} + proto-go-generate: proto-renew cd ./go; make proto-clean; make proto-compile diff --git a/go.mod b/go.mod index 89903be6f2..312093e6e0 100644 --- a/go.mod +++ b/go.mod @@ -24,4 +24,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/coralogix/grpc-gateway/v2 v2.0.0-20251017075809-7f84c876b2e5 +replace github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/coralogix/grpc-gateway/v2 v2.0.0-20260113093058-adb9ff6b56db diff --git a/go.sum b/go.sum index 4b1a8faf38..11cc528abf 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/coralogix/grpc-gateway/v2 v2.0.0-20251017075809-7f84c876b2e5 h1:mqmL/WJA8Cdzim6r3jmXY8uiPn9KX4AvqxjEPDRXKj4= -github.com/coralogix/grpc-gateway/v2 v2.0.0-20251017075809-7f84c876b2e5/go.mod h1:bqGO/kNOHTFiDIfPmXLQcox10aWQs5Q3b9sXUFoaFFk= +github.com/coralogix/grpc-gateway/v2 v2.0.0-20260113093058-adb9ff6b56db h1:v4wKbMIBYg4JZIaEpZF//EJFFrbcFIv0nuZtAX86PYE= +github.com/coralogix/grpc-gateway/v2 v2.0.0-20260113093058-adb9ff6b56db/go.mod h1:bqGO/kNOHTFiDIfPmXLQcox10aWQs5Q3b9sXUFoaFFk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/go/Makefile b/go/Makefile index c401889119..c612d87c87 100644 --- a/go/Makefile +++ b/go/Makefile @@ -53,5 +53,8 @@ test: build test-openapi: go test ${BUILD_ARGS} -v ${TESTARGS} -cover -timeout=120s -parallel=4 ./openapi/examples/... +test-openapi-ro: + go test ${BUILD_ARGS} -v ${TESTARGS} -cover -timeout=120s -parallel=8 ./openapi/tests/... + generate: go generate \ No newline at end of file diff --git a/go/examples/integrations_test.go b/go/examples/integrations_test.go index 14fb69b47f..fdae38177d 100644 --- a/go/examples/integrations_test.go +++ b/go/examples/integrations_test.go @@ -180,7 +180,7 @@ func TestWebhooks(t *testing.T) { crud(t, &cxsdk.CreateOutgoingWebhookRequest{ Data: &cxsdk.OutgoingWebhookInputData{ Name: wrapperspb.String("custom-webhook"), - Url: wrapperspb.String("https://example-url.com"), + Url: wrapperspb.String("https://api.staging.coralogix.net/mgmt/testing/tools/httpbin/get/"), Type: cxsdk.WebhookTypeGeneric, Config: &cxsdk.GenericWebhookInputData{ GenericWebhook: &cxsdk.GenericWebhookConfig{ @@ -195,7 +195,7 @@ func TestWebhooks(t *testing.T) { crud(t, &cxsdk.CreateOutgoingWebhookRequest{ Data: &cxsdk.OutgoingWebhookInputData{ Name: wrapperspb.String("pager-duty-webhook"), - Url: wrapperspb.String("https://example-url.com/"), + Url: wrapperspb.String("https://api.staging.coralogix.net/mgmt/testing/tools/httpbin/post/"), Type: cxsdk.WebhookTypePagerduty, Config: &cxsdk.PagerDutyWebhookInputData{ PagerDuty: &cxsdk.PagerDutyConfig{ @@ -208,7 +208,7 @@ func TestWebhooks(t *testing.T) { crud(t, &cxsdk.CreateOutgoingWebhookRequest{ Data: &cxsdk.OutgoingWebhookInputData{ Name: wrapperspb.String("email-group-webhook"), - Url: wrapperspb.String("https://example-url.com/"), + Url: wrapperspb.String("https://api.staging.coralogix.net/mgmt/testing/tools/httpbin/post/"), Type: cxsdk.WebhookTypeEmailGroup, Config: &cxsdk.EmailGroupWebhookInputData{ EmailGroup: &cxsdk.EmailGroupConfig{ @@ -236,7 +236,7 @@ func TestWebhooks(t *testing.T) { crud(t, &cxsdk.CreateOutgoingWebhookRequest{ Data: &cxsdk.OutgoingWebhookInputData{ Name: wrapperspb.String("opsgenie-webhook"), - Url: wrapperspb.String("https://example.opsgenie.com"), + Url: wrapperspb.String("https://api.opsgenie.com"), Type: cxsdk.WebhookTypeOpsgenie, Config: &cxsdk.OpsgenieWebhookInputData{ Opsgenie: &cxsdk.OpsgenieConfig{}, diff --git a/go/openapi/Dockerfile b/go/openapi/Dockerfile new file mode 100644 index 0000000000..a3235779f7 --- /dev/null +++ b/go/openapi/Dockerfile @@ -0,0 +1,42 @@ +# Copyright 2026 Coralogix Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + + +ARG TARGETARCH +FROM golang:1.25-alpine AS interim +FROM interim AS interim-amd64 +ENV ARCH=x86_64 +FROM interim AS interim-arm64 +ENV ARCH=aarch_64 + +FROM interim-${TARGETARCH} + + +RUN apk add --no-cache make && \ + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \ + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest + +# Set working directory +WORKDIR /app + +# Copy Makefile and required files +COPY ../ . +# Set environment variables +ENV CORALOGIX_REGION=us +ENV CORALOGIX_API_KEY=test_key + +# Run tests using Makefile target +CMD ["make", "test-openapi-ro"] \ No newline at end of file diff --git a/go/openapi/examples/integrations_test.go b/go/openapi/examples/integrations_test.go index ef2b13d32c..a8b2d6ecbd 100644 --- a/go/openapi/examples/integrations_test.go +++ b/go/openapi/examples/integrations_test.go @@ -173,7 +173,7 @@ func TestWebhooks(t *testing.T) { &webhooks.OutgoingWebhookInputDataPagerDuty{ Name: webhooks.PtrString("pager-duty-webhook"), Type: webhooks.WEBHOOKTYPE_PAGERDUTY.Ptr(), - Url: webhooks.PtrString("https://example-url.com/"), + Url: webhooks.PtrString("https://api.staging.coralogix.net/mgmt/testing/tools/httpbin/post/"), PagerDuty: &webhooks.PagerDutyConfig{ ServiceKey: webhooks.PtrString("example-key"), }, @@ -186,7 +186,7 @@ func TestWebhooks(t *testing.T) { &webhooks.OutgoingWebhookInputDataEmailGroup{ Name: webhooks.PtrString("email-group-webhook"), Type: webhooks.WEBHOOKTYPE_EMAIL_GROUP.Ptr(), - Url: webhooks.PtrString("https://example-url.com/"), + Url: webhooks.PtrString("https://api.staging.coralogix.net/mgmt/testing/tools/httpbin/post/"), EmailGroup: &webhooks.EmailGroupConfig{ EmailAddresses: []string{"user@example.com"}}, }, @@ -214,7 +214,7 @@ func TestWebhooks(t *testing.T) { &webhooks.OutgoingWebhookInputDataOpsgenie{ Name: webhooks.PtrString("opsgenie-webhook"), Type: webhooks.WEBHOOKTYPE_OPSGENIE.Ptr(), - Url: webhooks.PtrString("https://example.opsgenie.com"), + Url: webhooks.PtrString("https://api.opsgenie.com"), Opsgenie: map[string]interface{}{}, }, ), diff --git a/go/openapi/tests/actions_list_read_test.go b/go/openapi/tests/actions_list_read_test.go new file mode 100644 index 0000000000..db04e96866 --- /dev/null +++ b/go/openapi/tests/actions_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestActionsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewActionsClient(cfg) + + listResp, httpResp, err := client. + ActionsServiceListActions(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Actions) == 0 { + t.Skip("no resources to read") + } + + actionID := listResp.Actions[0].GetId() + if actionID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + ActionsServiceGetAction(context.Background(), actionID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, actionID, getResp.GetAction().Id) +} diff --git a/go/openapi/tests/alerts_list_read_test.go b/go/openapi/tests/alerts_list_read_test.go new file mode 100644 index 0000000000..c9d19d079f --- /dev/null +++ b/go/openapi/tests/alerts_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestAlertsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewAlertsClient(cfg) + + listResp, httpResp, err := client. + AlertDefsServiceListAlertDefs(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.AlertDefs) == 0 { + t.Skip("no resources to read") + } + + alertID := listResp.AlertDefs[0].GetId() + if alertID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + AlertDefsServiceGetAlertDef(context.Background(), alertID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, alertID, *getResp.GetAlertDef().Id) +} diff --git a/go/openapi/tests/api_keys_list_read_test.go b/go/openapi/tests/api_keys_list_read_test.go new file mode 100644 index 0000000000..7bc2b727fd --- /dev/null +++ b/go/openapi/tests/api_keys_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestAPIKeysListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewAPIKeysClient(cfg) + + listResp, httpResp, err := client. + ApiKeysServiceGetSendDataApiKeys(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Keys) == 0 { + t.Skip("no resources to read") + } + + keyID := listResp.Keys[0].GetId() + if keyID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + ApiKeysServiceGetApiKey(context.Background(), keyID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, keyID, *getResp.GetKeyInfo().Id) +} diff --git a/go/openapi/tests/archive_logs_list_read_test.go b/go/openapi/tests/archive_logs_list_read_test.go new file mode 100644 index 0000000000..42d5d1af12 --- /dev/null +++ b/go/openapi/tests/archive_logs_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "reflect" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestArchiveLogsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewArchiveLogsClient(cfg) + + listResp, httpResp, err := client. + S3TargetServiceGetTarget(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + listTarget := listResp.Target.GetActualInstance() + if listTarget == nil { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + S3TargetServiceGetTarget(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + getTarget := getResp.Target.GetActualInstance() + require.NotNil(t, getTarget) + require.Equal(t, reflect.TypeOf(listTarget), reflect.TypeOf(getTarget)) +} diff --git a/go/openapi/tests/archive_metrics_list_read_test.go b/go/openapi/tests/archive_metrics_list_read_test.go new file mode 100644 index 0000000000..beb2e982d2 --- /dev/null +++ b/go/openapi/tests/archive_metrics_list_read_test.go @@ -0,0 +1,43 @@ +package tests + +import ( + "context" + "reflect" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestArchiveMetricsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewArchiveMetricsClient(cfg) + + listResp, httpResp, err := client. + MetricsConfiguratorPublicServiceGetTenantConfig(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if listResp == nil || listResp.TenantConfig == nil { + t.Skip("no resources to read") + } + + listConfig := listResp.TenantConfig.GetActualInstance() + if listConfig == nil { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + MetricsConfiguratorPublicServiceGetTenantConfig(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if getResp == nil || getResp.TenantConfig == nil { + t.Skip("no resources to read") + } + + getConfig := getResp.TenantConfig.GetActualInstance() + require.NotNil(t, getConfig) + require.Equal(t, reflect.TypeOf(listConfig), reflect.TypeOf(getConfig)) +} diff --git a/go/openapi/tests/archive_retentions_list_read_test.go b/go/openapi/tests/archive_retentions_list_read_test.go new file mode 100644 index 0000000000..d379c42b33 --- /dev/null +++ b/go/openapi/tests/archive_retentions_list_read_test.go @@ -0,0 +1,43 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestArchiveRetentionsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewArchiveRetentionsClient(cfg) + + listResp, httpResp, err := client. + RetentionsServiceGetRetentions(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Retentions) == 0 { + t.Skip("no resources to read") + } + + retentionID := listResp.Retentions[0].GetId() + if retentionID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + RetentionsServiceGetRetentions(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + found := false + for _, retention := range getResp.Retentions { + if retention.GetId() == retentionID { + found = true + break + } + } + require.True(t, found) +} diff --git a/go/openapi/tests/connectors_list_read_test.go b/go/openapi/tests/connectors_list_read_test.go new file mode 100644 index 0000000000..fca337912f --- /dev/null +++ b/go/openapi/tests/connectors_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestConnectorsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewConnectorsClient(cfg) + + listResp, httpResp, err := client. + ConnectorsServiceListConnectors(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Connectors) == 0 { + t.Skip("no resources to read") + } + + connectorID := listResp.Connectors[0].GetId() + if connectorID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + ConnectorsServiceGetConnector(context.Background(), connectorID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, connectorID, *getResp.GetConnector().Id) +} diff --git a/go/openapi/tests/custom_enrichments_list_read_test.go b/go/openapi/tests/custom_enrichments_list_read_test.go new file mode 100644 index 0000000000..7514a2c84c --- /dev/null +++ b/go/openapi/tests/custom_enrichments_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestCustomEnrichmentsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewCustomEnrichmentsClient(cfg) + + listResp, httpResp, err := client. + CustomEnrichmentServiceGetCustomEnrichments(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.CustomEnrichments) == 0 { + t.Skip("no resources to read") + } + + enrichmentID := listResp.CustomEnrichments[0].GetId() + if enrichmentID == 0 { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + CustomEnrichmentServiceGetCustomEnrichment(context.Background(), enrichmentID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, enrichmentID, *getResp.GetCustomEnrichment().Id) +} diff --git a/go/openapi/tests/custom_roles_list_read_test.go b/go/openapi/tests/custom_roles_list_read_test.go new file mode 100644 index 0000000000..132138795e --- /dev/null +++ b/go/openapi/tests/custom_roles_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestCustomRolesListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewCustomRolesClient(cfg) + + listResp, httpResp, err := client. + RoleManagementServiceListCustomRoles(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Roles) == 0 { + t.Skip("no resources to read") + } + + roleID := listResp.Roles[0].GetRoleId() + if roleID == 0 { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + RoleManagementServiceGetCustomRole(context.Background(), roleID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, roleID, getResp.GetRole().RoleId) +} diff --git a/go/openapi/tests/dashboard_folders_list_read_test.go b/go/openapi/tests/dashboard_folders_list_read_test.go new file mode 100644 index 0000000000..8b21bf00bb --- /dev/null +++ b/go/openapi/tests/dashboard_folders_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestDashboardFoldersListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewDashboardFoldersClient(cfg) + + listResp, httpResp, err := client. + DashboardFoldersServiceListDashboardFolders(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Folder) == 0 { + t.Skip("no resources to read") + } + + folderID := listResp.Folder[0].GetId() + if folderID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + DashboardFoldersServiceGetDashboardFolder(context.Background(), folderID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, folderID, getResp.GetFolder().Id) +} diff --git a/go/openapi/tests/dashboards_list_read_test.go b/go/openapi/tests/dashboards_list_read_test.go new file mode 100644 index 0000000000..03c71bcf12 --- /dev/null +++ b/go/openapi/tests/dashboards_list_read_test.go @@ -0,0 +1,43 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestDashboardsListRead(t *testing.T) { + t.Skip("Dashboards cannot be deserialized right now") + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewDashboardClient(cfg) + + listResp, httpResp, err := client. + DashboardCatalogServiceGetDashboardCatalog(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Items) == 0 { + t.Skip("no resources to read") + } + + dashboardID := listResp.Items[0].GetId() + if dashboardID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + DashboardsServiceGetDashboard(context.Background(), dashboardID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + actual := getResp.GetDashboard().GetActualInstanceValue() + if actual == nil { + t.Skip("no resources to read") + } + idProvider, ok := actual.(interface{ GetId() string }) + require.True(t, ok) + require.Equal(t, dashboardID, idProvider.GetId()) +} diff --git a/go/openapi/tests/e2ms_list_read_test.go b/go/openapi/tests/e2ms_list_read_test.go new file mode 100644 index 0000000000..0f9c9d3b92 --- /dev/null +++ b/go/openapi/tests/e2ms_list_read_test.go @@ -0,0 +1,47 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestE2MsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewEvents2MetricsClient(cfg) + + listResp, httpResp, err := client. + Events2MetricServiceListE2M(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.E2m) == 0 { + t.Skip("no resources to read") + } + + var e2mID string + if listResp.E2m[0].E2MLogsQuery != nil { + e2mID = listResp.E2m[0].E2MLogsQuery.GetId() + } else if listResp.E2m[0].E2MSpansQuery != nil { + e2mID = listResp.E2m[0].E2MSpansQuery.GetId() + } + if e2mID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + Events2MetricServiceGetE2M(context.Background(), e2mID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + var readID string + if getResp.E2m.E2MLogsQuery != nil { + readID = getResp.E2m.E2MLogsQuery.GetId() + } else if getResp.E2m.E2MSpansQuery != nil { + readID = getResp.E2m.E2MSpansQuery.GetId() + } + require.Equal(t, e2mID, readID) +} diff --git a/go/openapi/tests/enrichments_list_read_test.go b/go/openapi/tests/enrichments_list_read_test.go new file mode 100644 index 0000000000..5500487d2d --- /dev/null +++ b/go/openapi/tests/enrichments_list_read_test.go @@ -0,0 +1,43 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestEnrichmentsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewEnrichmentsClient(cfg) + + listResp, httpResp, err := client. + EnrichmentServiceGetEnrichments(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Enrichments) == 0 { + t.Skip("no resources to read") + } + + enrichmentID := listResp.Enrichments[0].GetId() + if enrichmentID == 0 { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + EnrichmentServiceGetEnrichments(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + found := false + for _, enrichment := range getResp.Enrichments { + if enrichment.GetId() == enrichmentID { + found = true + break + } + } + require.True(t, found) +} diff --git a/go/openapi/tests/extensions_list_read_test.go b/go/openapi/tests/extensions_list_read_test.go new file mode 100644 index 0000000000..59895645f6 --- /dev/null +++ b/go/openapi/tests/extensions_list_read_test.go @@ -0,0 +1,42 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" + extensions "github.com/coralogix/coralogix-management-sdk/go/openapi/gen/extension_service" +) + +func TestExtensionsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewExtensionsClient(cfg) + + includeHidden := false + listReq := extensions.GetAllExtensionsRequest{ + IncludeHiddenExtensions: &includeHidden, + } + + listResp, httpResp, err := client. + ExtensionServiceGetAllExtensions(context.Background()). + GetAllExtensionsRequest(listReq). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Extensions) == 0 { + t.Skip("no resources to read") + } + + extensionID := listResp.Extensions[0].GetId() + if extensionID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + ExtensionServiceGetExtension(context.Background(), extensionID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, extensionID, getResp.GetId()) +} diff --git a/go/openapi/tests/groups_list_read_test.go b/go/openapi/tests/groups_list_read_test.go new file mode 100644 index 0000000000..e4704bf26d --- /dev/null +++ b/go/openapi/tests/groups_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestGroupsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewGroupsClient(cfg) + + listResp, httpResp, err := client. + TeamPermissionsMgmtServiceGetTeamGroups(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Groups) == 0 { + t.Skip("no resources to read") + } + + groupID := listResp.Groups[0].GetGroupId().Id + if groupID == nil { + t.Skip("no resources to read") + } + t.Skip("not implemented (yet)") + getResp, httpResp, err := client. + TeamPermissionsMgmtServiceGetTeamGroup(context.Background(), *groupID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, groupID, getResp.GetGroup().GroupId.Id) +} diff --git a/go/openapi/tests/integrations_list_read_test.go b/go/openapi/tests/integrations_list_read_test.go new file mode 100644 index 0000000000..8323a4a722 --- /dev/null +++ b/go/openapi/tests/integrations_list_read_test.go @@ -0,0 +1,48 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" + integrations "github.com/coralogix/coralogix-management-sdk/go/openapi/gen/integration_service" +) + +func integrationDetailsID(details integrations.IntegrationDetails) string { + actual := details.GetActualInstance() + switch typed := actual.(type) { + case *integrations.IntegrationDetailsExternal: + return *typed.GetIntegration().Id + case *integrations.IntegrationDetailsLocal: + return *typed.GetIntegration().Id + default: + return "" + } +} + +func TestIntegrationsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewIntegrationsClient(cfg) + + listResp, httpResp, err := client. + IntegrationServiceGetIntegrations(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Integrations) == 0 { + t.Skip("no resources to read") + } + + integrationID := listResp.Integrations[0].GetIntegration().Id + if integrationID == nil { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + IntegrationServiceGetIntegrationDetails(context.Background(), *integrationID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, *integrationID, integrationDetailsID(getResp.GetIntegrationDetail())) +} diff --git a/go/openapi/tests/ip_access_list_read_test.go b/go/openapi/tests/ip_access_list_read_test.go new file mode 100644 index 0000000000..415530b278 --- /dev/null +++ b/go/openapi/tests/ip_access_list_read_test.go @@ -0,0 +1,31 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestIPAccessListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewIPAccessClient(cfg) + + listResp, httpResp, err := client. + IpAccessServiceGetCompanyIpAccessSettings(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + settingsID := listResp.GetSettings().Id + if settingsID == nil { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + IpAccessServiceGetCompanyIpAccessSettings(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, settingsID, getResp.GetSettings().Id) +} diff --git a/go/openapi/tests/policies_list_read_test.go b/go/openapi/tests/policies_list_read_test.go new file mode 100644 index 0000000000..67d189df6a --- /dev/null +++ b/go/openapi/tests/policies_list_read_test.go @@ -0,0 +1,51 @@ +package tests + +import ( + "context" + "testing" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" + "github.com/stretchr/testify/require" +) + +func TestPoliciesListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewTCOPoliciesClient(cfg) + + listResp, httpResp, err := client. + PoliciesServiceGetCompanyPolicies(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Policies) == 0 { + t.Skip("no resources to read") + } + + policyID := "" + selected := listResp.Policies[0] + span := false + if selected.PolicyLogRules != nil { + policyID = selected.PolicyLogRules.Id + } + if selected.PolicySpanRules != nil { + policyID = selected.PolicySpanRules.Id + span = true + } + + if policyID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + PoliciesServiceGetPolicy(context.Background(), policyID). + Execute() + actualID := "" + if span { + actualID = getResp.GetPolicy().PolicySpanRules.Id + } else { + actualID = getResp.GetPolicy().PolicyLogRules.Id + } + + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, policyID, actualID) +} diff --git a/go/openapi/tests/presets_list_read_test.go b/go/openapi/tests/presets_list_read_test.go new file mode 100644 index 0000000000..95b7981aca --- /dev/null +++ b/go/openapi/tests/presets_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestPresetsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewPresetsClient(cfg) + + listResp, httpResp, err := client. + PresetsServiceListPresetSummaries(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.PresetSummaries) == 0 { + t.Skip("no resources to read") + } + + presetID := listResp.PresetSummaries[0].GetId() + if presetID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + PresetsServiceGetPreset(context.Background(), presetID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, presetID, *getResp.GetPreset().Id) +} diff --git a/go/openapi/tests/recording_rules_list_read_test.go b/go/openapi/tests/recording_rules_list_read_test.go new file mode 100644 index 0000000000..41b20d52f6 --- /dev/null +++ b/go/openapi/tests/recording_rules_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestRecordingRulesListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewRecordingRulesClient(cfg) + + listResp, httpResp, err := client. + RuleGroupSetsList(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Sets) == 0 { + t.Skip("no resources to read") + } + + setID := listResp.Sets[0].GetId() + if setID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + RuleGroupSetsFetch(context.Background(), setID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, setID, getResp.GetId()) +} diff --git a/go/openapi/tests/rule_groups_list_read_test.go b/go/openapi/tests/rule_groups_list_read_test.go new file mode 100644 index 0000000000..d95b952036 --- /dev/null +++ b/go/openapi/tests/rule_groups_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestRuleGroupsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewRuleGroupsClient(cfg) + + listResp, httpResp, err := client. + RuleGroupsServiceListRuleGroups(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.RuleGroups) == 0 { + t.Skip("no resources to read") + } + + groupID := listResp.RuleGroups[0].GetId() + if groupID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + RuleGroupsServiceGetRuleGroup(context.Background(), groupID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, groupID, *getResp.GetRuleGroup().Id) +} diff --git a/go/openapi/tests/scopes_list_read_test.go b/go/openapi/tests/scopes_list_read_test.go new file mode 100644 index 0000000000..80ebf5dadd --- /dev/null +++ b/go/openapi/tests/scopes_list_read_test.go @@ -0,0 +1,39 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestScopesListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewScopesClient(cfg) + + listResp, httpResp, err := client. + ScopesServiceGetTeamScopes(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Scopes) == 0 { + t.Skip("no resources to read") + } + + scopeID := listResp.Scopes[0].GetId() + if scopeID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + ScopesServiceGetTeamScopesByIds(context.Background()). + Ids([]string{scopeID}). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + if len(getResp.Scopes) == 0 { + t.Skip("no resources to read") + } + require.Equal(t, scopeID, getResp.Scopes[0].GetId()) +} diff --git a/go/openapi/tests/slos_list_read_test.go b/go/openapi/tests/slos_list_read_test.go new file mode 100644 index 0000000000..bb9bff49ef --- /dev/null +++ b/go/openapi/tests/slos_list_read_test.go @@ -0,0 +1,51 @@ +package tests + +import ( + "context" + "testing" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" + "github.com/coralogix/coralogix-management-sdk/go/openapi/gen/slos_service" + "github.com/stretchr/testify/require" +) + +func TestSLOsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewSLOsClient(cfg) + + listResp, httpResp, err := client. + SlosServiceListSlos(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Slos) == 0 { + t.Skip("no resources to read") + } + + sloID := getIDFromSlo(listResp.Slos[0]) + + if sloID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + SlosServiceGetSlo(context.Background(), sloID). + Execute() + + id := getIDFromSlo(getResp.Slo) + + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, sloID, id) +} + +func getIDFromSlo(slo slos_service.Slo) string { + id := "" + if slo.SloRequestBasedMetricSli != nil { + id = *slo.SloRequestBasedMetricSli.Id + } + + if slo.SloWindowBasedMetricSli != nil { + id = *slo.SloWindowBasedMetricSli.Id + } + return id +} diff --git a/go/openapi/tests/views_folders_list_read_test.go b/go/openapi/tests/views_folders_list_read_test.go new file mode 100644 index 0000000000..6eb3f165ab --- /dev/null +++ b/go/openapi/tests/views_folders_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestViewsFoldersListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewViewsFoldersClient(cfg) + + listResp, httpResp, err := client. + ViewsFoldersServiceListViewFolders(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Folders) == 0 { + t.Skip("no resources to read") + } + + folderID := listResp.Folders[0].GetId() + if folderID == "" { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + ViewsFoldersServiceGetViewFolder(context.Background(), folderID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, folderID, getResp.GetId()) +} diff --git a/go/openapi/tests/views_list_read_test.go b/go/openapi/tests/views_list_read_test.go new file mode 100644 index 0000000000..2c22ef586a --- /dev/null +++ b/go/openapi/tests/views_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" +) + +func TestViewsListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewViewsClient(cfg) + + listResp, httpResp, err := client. + ViewsServiceListViews(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + if len(listResp.Views) == 0 { + t.Skip("no resources to read") + } + + viewID := listResp.Views[0].GetId() + if viewID == 0 { + t.Skip("no resources to read") + } + + getResp, httpResp, err := client. + ViewsServiceGetView(context.Background(), viewID). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + require.Equal(t, viewID, getResp.GetId()) +} diff --git a/go/openapi/tests/webhooks_list_read_test.go b/go/openapi/tests/webhooks_list_read_test.go new file mode 100644 index 0000000000..1e1cab271e --- /dev/null +++ b/go/openapi/tests/webhooks_list_read_test.go @@ -0,0 +1,35 @@ +package tests + +import ( + "context" + "testing" + + "github.com/coralogix/coralogix-management-sdk/go/openapi/cxsdk" + "github.com/stretchr/testify/require" +) + +func TestWebhooksListRead(t *testing.T) { + cfg := cxsdk.NewConfigBuilder().WithAPIKeyEnv().WithRegionEnv().Build() + client := cxsdk.NewWebhooksClient(cfg) + + _, httpResp, err := client. + OutgoingWebhooksServiceListAllOutgoingWebhooks(context.Background()). + Execute() + require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + + // skip the remainder because each type has their own id field and that would become a massive if chain... + // if len(listResp.Deployed) == 0 { + // t.Skip("no resources to read") + // } + + // webhookID := listResp.Deployed[0].GetId() + // if webhookID == "" { + // t.Skip("no resources to read") + // } + + // getResp, httpResp, err := client. + // OutgoingWebhooksServiceGetOutgoingWebhook(context.Background(), webhookID). + // Execute() + // require.NoError(t, cxsdk.NewAPIError(httpResp, err)) + // require.Equal(t, webhookID, getResp.GetWebhook().()) +} diff --git a/rust/examples/integrations/src/lib.rs b/rust/examples/integrations/src/lib.rs index eea3964d6f..87f5b1c82e 100644 --- a/rust/examples/integrations/src/lib.rs +++ b/rust/examples/integrations/src/lib.rs @@ -177,7 +177,7 @@ mod tests { crud( "custom-webhook".into(), WebhookType::Generic, - "https://example-url.com/".parse().unwrap(), + "https://api.staging.coralogix.net/mgmt/testing/tools/httpbin/post/".parse().unwrap(), Config::GenericWebhook(GenericWebhookConfig { uuid: Some(Uuid::new_v4().to_string()), method: generic_webhook_config::MethodType::Get.into(), @@ -190,7 +190,7 @@ mod tests { crud( "pager-duty-webhook".into(), WebhookType::Pagerduty, - "https://example-url.com/".parse().unwrap(), + "https://api.staging.coralogix.net/mgmt/testing/tools/httpbin/post/".parse().unwrap(), Config::PagerDuty(PagerDutyConfig { service_key: Some("service-key".into()), }), @@ -200,7 +200,7 @@ mod tests { crud( "email-group-webhook".into(), WebhookType::EmailGroup, - "https://example-url.com/".parse().unwrap(), + "https://api.staging.coralogix.net/mgmt/testing/tools/httpbin/post/".parse().unwrap(), Config::EmailGroup(EmailGroupConfig { email_addresses: vec!["user@example.com".into()], }), @@ -222,7 +222,7 @@ mod tests { crud( "opsgenie-webhook".into(), WebhookType::Opsgenie, - "https://example.opsgenie.com/".parse().unwrap(), + "https://api.opsgenie.com/".parse().unwrap(), Config::Opsgenie(OpsgenieConfig {}), ) .await;