Skip to content

Commit

Permalink
Fix naming for database events
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul Bhardwaj committed Apr 3, 2024
1 parent 3056785 commit 7f18142
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
databaseTopicPath = databaseBasePath + "/%s/topics/%s"
databaseTopicsPath = databaseBasePath + "/%s/topics"
databaseMetricsCredentialsPath = databaseBasePath + "/metrics/credentials"
databaseProjectEvents = databaseBasePath + "/%s/events"
databaseEvents = databaseBasePath + "/%s/events"
)

// SQL Mode constants allow for MySQL-specific SQL flavor configuration.
Expand Down Expand Up @@ -158,7 +158,7 @@ type DatabasesService interface {
UpdateTopic(context.Context, string, string, *DatabaseUpdateTopicRequest) (*Response, error)
GetMetricsCredentials(context.Context) (*DatabaseMetricsCredentials, *Response, error)
UpdateMetricsCredentials(context.Context, *DatabaseUpdateMetricsCredentialsRequest) (*Response, error)
ListProjectEvents(context.Context, string) ([]*ProjectEvent, *Response, error)
ListDatabaseEvents(context.Context, string) ([]*DatabaseEvent, *Response, error)
}

// DatabasesServiceOp handles communication with the Databases related methods
Expand Down Expand Up @@ -713,21 +713,21 @@ type DatabaseLayout struct {
Sizes []string `json:"sizes"`
}

// ListProjectEventsResponse contains a list of project events.
type ListProjectEvents struct {
Events []*ProjectEvent `json:"events"`
// ListDatabaseEvents contains a list of project events.
type ListDatabaseEvents struct {
Events []*DatabaseEvent `json:"events"`
}

// ProjectEvent contains the information about a project event.
type ProjectEvent struct {
// DatbaseEvent contains the information about a Datbase event.
type DatabaseEvent struct {
ID string `json:"id"`
ServiceName string `json:"cluster_name"`
EventType string `json:"event_type"`
CreateTime string `json:"create_time"`
}

type ListProjectEventsRoot struct {
Events []*ProjectEvent `json:"events"`
type ListDatabaseEventsRoot struct {
Events []*DatabaseEvent `json:"events"`
}

// URN returns a URN identifier for the database
Expand Down Expand Up @@ -1537,9 +1537,9 @@ func (svc *DatabasesServiceOp) UpdateMetricsCredentials(ctx context.Context, upd
return resp, nil
}

func (svc *DatabasesServiceOp) ListProjectEvents(ctx context.Context, databaseID string) ([]*ProjectEvent, *Response, error) {
path := fmt.Sprintf(databaseProjectEvents, databaseID)
root := new(ListProjectEventsRoot)
func (svc *DatabasesServiceOp) ListDatabaseEvents(ctx context.Context, databaseID string) ([]*DatabaseEvent, *Response, error) {
path := fmt.Sprintf(databaseEvents, databaseID)
root := new(ListDatabaseEventsRoot)
req, err := svc.client.NewRequest(ctx, http.MethodGet, path, nil)
if err != nil {
return nil, nil, err
Expand Down
6 changes: 3 additions & 3 deletions databases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3129,15 +3129,15 @@ func TestDatabases_UpdateMetricsCredentials(t *testing.T) {
require.NoError(t, err)
}

func TestDatabases_ListProjectEvents(t *testing.T) {
func TestDatabases_ListDatabaseEvents(t *testing.T) {
setup()
defer teardown()

dbID := "deadbeef-dead-4aa5-beef-deadbeef347d"

path := fmt.Sprintf("/v2/databases/%s/events", dbID)

want := []*ProjectEvent{
want := []*DatabaseEvent{
{
ID: "pe8u2huh",
ServiceName: "customer-events",
Expand All @@ -3162,7 +3162,7 @@ func TestDatabases_ListProjectEvents(t *testing.T) {
fmt.Fprint(w, body)
})

got, _, err := client.Databases.ListProjectEvents(ctx, dbID)
got, _, err := client.Databases.ListDatabaseEvents(ctx, dbID)
require.NoError(t, err)
require.Equal(t, want, got)
}

0 comments on commit 7f18142

Please sign in to comment.