-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add notification center API * Add Go client and examples * Add rust client and examples
- Loading branch information
Showing
165 changed files
with
20,157 additions
and
7,415 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
// Copyright 2024 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. | ||
|
||
package examples | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
cxsdk "github.com/coralogix/coralogix-management-sdk/go" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestConnectors(t *testing.T) { | ||
t.Skip("Connectors are not supported in the current version of the SDK") | ||
region, err := cxsdk.CoralogixRegionFromEnv() | ||
assert.Nil(t, err) | ||
authContext, err := cxsdk.AuthContextFromEnv() | ||
assert.Nil(t, err) | ||
creator := cxsdk.NewCallPropertiesCreator(region, authContext) | ||
|
||
c := cxsdk.NewNotificationsClient(creator) | ||
createRes, err := c.CreateConnector(context.Background(), &cxsdk.CreateConnectorRequest{ | ||
Connector: &cxsdk.Connector{ | ||
Type: cxsdk.ConnectorTypeGenericHTTPS, | ||
Name: "TestConnector", | ||
Description: "This is the connector to use for Notification Center testing.", | ||
EntityType: "alerts", | ||
ConnectorConfigs: []*cxsdk.ConnectorConfig{ | ||
{ | ||
OutputSchemaId: "default", | ||
Fields: []*cxsdk.ConnectorConfigField{ | ||
{FieldName: "url", Template: "https://example@coralogix.com"}, | ||
{FieldName: "method", Template: "post"}, | ||
{FieldName: "additionalHeaders", Template: "{}"}, | ||
{FieldName: "additionalBodyFields", Template: "{}"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
connectorId := createRes.Connector.Id | ||
connector, err := c.GetConnector(context.Background(), &cxsdk.GetConnectorRequest{ | ||
Id: *connectorId, | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
assert.Equal(t, connector.Connector.Name, "TestConnector") | ||
|
||
_, err = c.DeleteConnector(context.Background(), &cxsdk.DeleteConnectorRequest{ | ||
Id: *connectorId, | ||
}) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func TestPresets(t *testing.T) { | ||
t.Skip("Presets are not supported in the current version of the SDK") | ||
region, err := cxsdk.CoralogixRegionFromEnv() | ||
assert.Nil(t, err) | ||
authContext, err := cxsdk.AuthContextFromEnv() | ||
assert.Nil(t, err) | ||
creator := cxsdk.NewCallPropertiesCreator(region, authContext) | ||
|
||
c := cxsdk.NewNotificationsClient(creator) | ||
presetType := cxsdk.PresetTypeCustom | ||
parentId := "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" | ||
createRes, err := c.CreateCustomPreset(context.Background(), &cxsdk.CreateCustomPresetRequest{ | ||
Preset: &cxsdk.Preset{ | ||
Name: "TestPreset", | ||
Description: "This is the preset to use for Notification Center testing.", | ||
PresetType: &presetType, | ||
EntityType: "alerts", | ||
Parent: &cxsdk.Preset{ | ||
Id: &parentId, | ||
}, | ||
ConnectorType: cxsdk.ConnectorTypeGenericHTTPS, | ||
ConfigOverrides: []*cxsdk.ConfigOverrides{ | ||
{ | ||
ConditionType: &cxsdk.ConditionType{ | ||
Condition: &cxsdk.ConditionTypeMatchEntityType{ | ||
MatchEntityType: &cxsdk.MatchEntityTypeCondition{ | ||
EntityType: "alerts", | ||
}, | ||
}, | ||
}, | ||
OutputSchemaId: "default", | ||
MessageConfig: &cxsdk.MessageConfig{ | ||
Fields: []*cxsdk.MessageConfigField{ | ||
{ | ||
Template: "{ \"test\": \"test\" }", | ||
FieldName: "headers", | ||
}, | ||
{ | ||
Template: "{ \"test\": \"test\" }", | ||
FieldName: "body", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
presetId := createRes.Preset.Id | ||
preset, err := c.GetPreset(context.Background(), &cxsdk.GetPresetRequest{ | ||
Id: *presetId, | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
assert.Equal(t, preset.Preset.Name, "TestPreset") | ||
|
||
_, err = c.DeleteCustomPreset(context.Background(), &cxsdk.DeleteCustomPresetRequest{ | ||
Id: *presetId, | ||
}) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
25 changes: 18 additions & 7 deletions
25
go/internal/coralogix/archive/kafka_out_targets/v1/kafka_out_targets_service_grpc.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 18 additions & 7 deletions
25
go/internal/coralogix/archive/kafka_out_targets/v2/kafka_out_target_service_grpc.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.