diff --git a/integration_tests/aiven_credentials.lua b/integration_tests/aiven_credentials.lua index 13c75a899..37b027cc1 100644 --- a/integration_tests/aiven_credentials.lua +++ b/integration_tests/aiven_credentials.lua @@ -381,15 +381,16 @@ Helper.SQLExec(string.format([[ INSERT INTO activity_log_entries (actor, action, resource_type, resource_name, team_slug, environment, data, created_at) VALUES ('%s', 'CREDENTIALS_CREATED', 'OPENSEARCH', 'my-instance', '%s', 'dev', '{"permission":"READ","ttl":"1d"}', NOW() - INTERVAL '2 minutes'), - ('%s', 'CREDENTIALS_CREATED', 'VALKEY', 'my-valkey', '%s', 'dev', '{"ttl":"7d"}', NOW() - INTERVAL '1 minute') -]], user:email(), team:slug(), user:email(), team:slug())) + ('%s', 'CREDENTIALS_CREATED', 'VALKEY', 'my-valkey', '%s', 'dev', '{"ttl":"7d"}', NOW() - INTERVAL '1 minute'), + ('%s', 'CREDENTIALS_CREATED', 'KAFKA_TOPIC', 'dev', '%s', 'dev', '{"ttl":"7d"}', NOW() - INTERVAL '5 minute') +]], user:email(), team:slug(), user:email(), team:slug(), user:email(), team:slug())) Test.gql("Activity log returns credentials entries without panic", function(t) t.addHeader("x-user-email", user:email()) t.query(string.format([[ { team(slug: "%s") { - activityLog(first: 10, filter: { activityTypes: [CREDENTIALS_CREATED] }) { + activityLog(first: 10, filter: { activityTypes: [VALKEY_CREDENTIALS_CREATED, OPENSEARCH_CREDENTIALS_CREATED, KAFKA_CREDENTIALS_CREATED] }) { nodes { __typename message @@ -397,12 +398,23 @@ Test.gql("Activity log returns credentials entries without panic", function(t) resourceType resourceName environmentName - ... on CredentialsActivityLogEntry { + ... on ValkeyCredentialsCreatedActivityLogEntry { data { permission ttl } } + ... on OpenSearchCredentialsCreatedActivityLogEntry { + data { + permission + ttl + } + } + ... on KafkaCredentialsCreatedActivityLogEntry { + data { + ttl + } + } } } } @@ -415,8 +427,8 @@ Test.gql("Activity log returns credentials entries without panic", function(t) activityLog = { nodes = { { - __typename = "CredentialsActivityLogEntry", - message = "Created VALKEY credentials for my-valkey (TTL: 7d)", + __typename = "ValkeyCredentialsCreatedActivityLogEntry", + message = "Created credentials for \"my-valkey\" (TTL: 7d)", actor = user:email(), resourceType = "VALKEY", resourceName = "my-valkey", @@ -427,8 +439,8 @@ Test.gql("Activity log returns credentials entries without panic", function(t) }, }, { - __typename = "CredentialsActivityLogEntry", - message = "Created OPENSEARCH credentials for my-instance with READ permission (TTL: 1d)", + __typename = "OpenSearchCredentialsCreatedActivityLogEntry", + message = "Created credentials for \"my-instance\" with \"read\" permission (TTL: 1d)", actor = user:email(), resourceType = "OPENSEARCH", resourceName = "my-instance", @@ -438,6 +450,17 @@ Test.gql("Activity log returns credentials entries without panic", function(t) ttl = "1d", }, }, + { + __typename = "KafkaCredentialsCreatedActivityLogEntry", + message = "Created credentials for \"dev\" (TTL: 7d)", + actor = user:email(), + resourceType = "KAFKA_TOPIC", + resourceName = "dev", + environmentName = "dev", + data = { + ttl = "7d", + }, + }, }, }, }, diff --git a/internal/activitylog/model.go b/internal/activitylog/model.go index 19c466dda..f60674a4a 100644 --- a/internal/activitylog/model.go +++ b/internal/activitylog/model.go @@ -20,11 +20,12 @@ type ( ) const ( - ActivityLogEntryActionAdded ActivityLogEntryAction = "ADDED" - ActivityLogEntryActionCreated ActivityLogEntryAction = "CREATED" - ActivityLogEntryActionDeleted ActivityLogEntryAction = "DELETED" - ActivityLogEntryActionRemoved ActivityLogEntryAction = "REMOVED" - ActivityLogEntryActionUpdated ActivityLogEntryAction = "UPDATED" + ActivityLogEntryActionAdded ActivityLogEntryAction = "ADDED" + ActivityLogEntryActionCreated ActivityLogEntryAction = "CREATED" + ActivityLogEntryActionDeleted ActivityLogEntryAction = "DELETED" + ActivityLogEntryActionRemoved ActivityLogEntryAction = "REMOVED" + ActivityLogEntryActionUpdated ActivityLogEntryAction = "UPDATED" + ActivityLogEntryActionCredentialsCreated ActivityLogEntryAction = "CREDENTIALS_CREATED" ) type ActivityLogEntry interface { diff --git a/internal/cmd/api/http.go b/internal/cmd/api/http.go index 9d4c19372..9864a1ed5 100644 --- a/internal/cmd/api/http.go +++ b/internal/cmd/api/http.go @@ -343,14 +343,14 @@ func ConfigureGraph( ctx = bigquery.NewLoaderContext(ctx, watchers.BqWatcher) ctx = bucket.NewLoaderContext(ctx, watchers.BucketWatcher) ctx = job.NewLoaderContext(ctx, watchers.JobWatcher, watchers.RunWatcher) - ctx = kafkatopic.NewLoaderContext(ctx, watchers.KafkaTopicWatcher) + ctx = kafkatopic.NewLoaderContext(ctx, watchers.KafkaTopicWatcher, log) ctx = workload.NewLoaderContext(ctx, watchers.PodWatcher) ctx = secret.NewLoaderContext(ctx, watchers.SecretWatcher, secretClientCreator, dynamicClients, clusters, log) ctx = config.NewLoaderContext(ctx, watchers.ConfigWatcher, log) ctx = instancegroup.NewLoaderContext(ctx, watchers.ReplicaSetWatcher, watchers.PodWatcher, watchers.AppWatcher, dynamicClients, log) ctx = aiven.NewLoaderContext(ctx, aivenProjects) ctx = opensearch.NewLoaderContext(ctx, tenantName, watchers.OpenSearchWatcher, aivenClient, log) - ctx = valkey.NewLoaderContext(ctx, tenantName, watchers.ValkeyWatcher, aivenClient) + ctx = valkey.NewLoaderContext(ctx, tenantName, watchers.ValkeyWatcher, aivenClient, log) ctx = price.NewLoaderContext(ctx, priceRetriever, log) ctx = utilization.NewLoaderContext(ctx, prometheusClient, log) ctx = alerts.NewLoaderContext(ctx, prometheusClient, log) diff --git a/internal/graph/gengql/activitylog.generated.go b/internal/graph/gengql/activitylog.generated.go index 6f39ef33e..048de627f 100644 --- a/internal/graph/gengql/activitylog.generated.go +++ b/internal/graph/gengql/activitylog.generated.go @@ -17,7 +17,7 @@ import ( "github.com/nais/api/internal/graph/model" "github.com/nais/api/internal/graph/pagination" "github.com/nais/api/internal/kubernetes/event/pubsublog" - "github.com/nais/api/internal/persistence/aivencredentials" + "github.com/nais/api/internal/persistence/kafkatopic" "github.com/nais/api/internal/persistence/opensearch" "github.com/nais/api/internal/persistence/postgres" "github.com/nais/api/internal/persistence/valkey" @@ -516,6 +516,13 @@ func (ec *executionContext) _ActivityLogEntry(ctx context.Context, sel ast.Selec return graphql.Null } return ec._ValkeyDeletedActivityLogEntry(ctx, sel, obj) + case valkey.ValkeyCredentialsCreatedActivityLogEntry: + return ec._ValkeyCredentialsCreatedActivityLogEntry(ctx, sel, &obj) + case *valkey.ValkeyCredentialsCreatedActivityLogEntry: + if obj == nil { + return graphql.Null + } + return ec._ValkeyCredentialsCreatedActivityLogEntry(ctx, sel, obj) case valkey.ValkeyCreatedActivityLogEntry: return ec._ValkeyCreatedActivityLogEntry(ctx, sel, &obj) case *valkey.ValkeyCreatedActivityLogEntry: @@ -810,6 +817,13 @@ func (ec *executionContext) _ActivityLogEntry(ctx context.Context, sel ast.Selec return graphql.Null } return ec._OpenSearchDeletedActivityLogEntry(ctx, sel, obj) + case opensearch.OpenSearchCredentialsCreatedActivityLogEntry: + return ec._OpenSearchCredentialsCreatedActivityLogEntry(ctx, sel, &obj) + case *opensearch.OpenSearchCredentialsCreatedActivityLogEntry: + if obj == nil { + return graphql.Null + } + return ec._OpenSearchCredentialsCreatedActivityLogEntry(ctx, sel, obj) case opensearch.OpenSearchCreatedActivityLogEntry: return ec._OpenSearchCreatedActivityLogEntry(ctx, sel, &obj) case *opensearch.OpenSearchCreatedActivityLogEntry: @@ -817,6 +831,13 @@ func (ec *executionContext) _ActivityLogEntry(ctx context.Context, sel ast.Selec return graphql.Null } return ec._OpenSearchCreatedActivityLogEntry(ctx, sel, obj) + case kafkatopic.KafkaCredentialsCreatedActivityLogEntry: + return ec._KafkaCredentialsCreatedActivityLogEntry(ctx, sel, &obj) + case *kafkatopic.KafkaCredentialsCreatedActivityLogEntry: + if obj == nil { + return graphql.Null + } + return ec._KafkaCredentialsCreatedActivityLogEntry(ctx, sel, obj) case job.JobUpdatedActivityLogEntry: return ec._JobUpdatedActivityLogEntry(ctx, sel, &obj) case *job.JobUpdatedActivityLogEntry: @@ -866,13 +887,6 @@ func (ec *executionContext) _ActivityLogEntry(ctx context.Context, sel ast.Selec return graphql.Null } return ec._DeploymentActivityLogEntry(ctx, sel, obj) - case aivencredentials.CredentialsActivityLogEntry: - return ec._CredentialsActivityLogEntry(ctx, sel, &obj) - case *aivencredentials.CredentialsActivityLogEntry: - if obj == nil { - return graphql.Null - } - return ec._CredentialsActivityLogEntry(ctx, sel, obj) case config.ConfigUpdatedActivityLogEntry: return ec._ConfigUpdatedActivityLogEntry(ctx, sel, &obj) case *config.ConfigUpdatedActivityLogEntry: diff --git a/internal/graph/gengql/aiven_credentials.generated.go b/internal/graph/gengql/aiven_credentials.generated.go deleted file mode 100644 index b66434597..000000000 --- a/internal/graph/gengql/aiven_credentials.generated.go +++ /dev/null @@ -1,450 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package gengql - -import ( - "context" - "errors" - "math" - "strconv" - "sync/atomic" - "time" - - "github.com/99designs/gqlgen/graphql" - "github.com/nais/api/internal/activitylog" - "github.com/nais/api/internal/graph/ident" - "github.com/nais/api/internal/persistence/aivencredentials" - "github.com/nais/api/internal/slug" - "github.com/vektah/gqlparser/v2/ast" -) - -// region ************************** generated!.gotpl ************************** - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) _CredentialsActivityLogEntry_id(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntry) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntry_id(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.ID(), nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v ident.Ident) graphql.Marshaler { - return ec.marshalNID2githubᚗcomᚋnaisᚋapiᚋinternalᚋgraphᚋidentᚐIdent(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntry_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CredentialsActivityLogEntry", field, true, false, errors.New("field of type ID does not have child fields")) -} - -func (ec *executionContext) _CredentialsActivityLogEntry_actor(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntry) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntry_actor(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Actor, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntry_actor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CredentialsActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _CredentialsActivityLogEntry_createdAt(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntry) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntry_createdAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { - return ec.marshalNTime2timeᚐTime(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntry_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CredentialsActivityLogEntry", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _CredentialsActivityLogEntry_message(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntry) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntry_message(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Message, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntry_message(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CredentialsActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _CredentialsActivityLogEntry_resourceType(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntry) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntry_resourceType(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.ResourceType, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v activitylog.ActivityLogEntryResourceType) graphql.Marshaler { - return ec.marshalNActivityLogEntryResourceType2githubᚗcomᚋnaisᚋapiᚋinternalᚋactivitylogᚐActivityLogEntryResourceType(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntry_resourceType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CredentialsActivityLogEntry", field, false, false, errors.New("field of type ActivityLogEntryResourceType does not have child fields")) -} - -func (ec *executionContext) _CredentialsActivityLogEntry_resourceName(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntry) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntry_resourceName(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.ResourceName, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntry_resourceName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CredentialsActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _CredentialsActivityLogEntry_teamSlug(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntry) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntry_teamSlug(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.TeamSlug, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *slug.Slug) graphql.Marshaler { - return ec.marshalNSlug2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋslugᚐSlug(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntry_teamSlug(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CredentialsActivityLogEntry", field, false, false, errors.New("field of type Slug does not have child fields")) -} - -func (ec *executionContext) _CredentialsActivityLogEntry_environmentName(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntry) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntry_environmentName(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.EnvironmentName, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { - return ec.marshalOString2ᚖstring(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntry_environmentName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CredentialsActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _CredentialsActivityLogEntry_data(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntry) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntry_data(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Data, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *aivencredentials.CredentialsActivityLogEntryData) graphql.Marshaler { - return ec.marshalNCredentialsActivityLogEntryData2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialsActivityLogEntryData(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntry_data(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CredentialsActivityLogEntry", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_CredentialsActivityLogEntryData(ctx, field) - }, - } - return fc, nil -} - -func (ec *executionContext) _CredentialsActivityLogEntryData_permission(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntryData) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntryData_permission(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Permission, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalOString2string(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntryData_permission(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CredentialsActivityLogEntryData", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _CredentialsActivityLogEntryData_ttl(ctx context.Context, field graphql.CollectedField, obj *aivencredentials.CredentialsActivityLogEntryData) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_CredentialsActivityLogEntryData_ttl(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.TTL, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_CredentialsActivityLogEntryData_ttl(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("CredentialsActivityLogEntryData", field, false, false, errors.New("field of type String does not have child fields")) -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var credentialsActivityLogEntryImplementors = []string{"CredentialsActivityLogEntry", "ActivityLogEntry", "Node"} - -func (ec *executionContext) _CredentialsActivityLogEntry(ctx context.Context, sel ast.SelectionSet, obj *aivencredentials.CredentialsActivityLogEntry) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, credentialsActivityLogEntryImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CredentialsActivityLogEntry") - case "id": - out.Values[i] = ec._CredentialsActivityLogEntry_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "actor": - out.Values[i] = ec._CredentialsActivityLogEntry_actor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "createdAt": - out.Values[i] = ec._CredentialsActivityLogEntry_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "message": - out.Values[i] = ec._CredentialsActivityLogEntry_message(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "resourceType": - out.Values[i] = ec._CredentialsActivityLogEntry_resourceType(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "resourceName": - out.Values[i] = ec._CredentialsActivityLogEntry_resourceName(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "teamSlug": - out.Values[i] = ec._CredentialsActivityLogEntry_teamSlug(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "environmentName": - out.Values[i] = ec._CredentialsActivityLogEntry_environmentName(ctx, field, obj) - case "data": - out.Values[i] = ec._CredentialsActivityLogEntry_data(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.Deferred, int32(min(len(deferred), math.MaxInt32))) - - for label, dfs := range deferred { - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var credentialsActivityLogEntryDataImplementors = []string{"CredentialsActivityLogEntryData"} - -func (ec *executionContext) _CredentialsActivityLogEntryData(ctx context.Context, sel ast.SelectionSet, obj *aivencredentials.CredentialsActivityLogEntryData) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, credentialsActivityLogEntryDataImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CredentialsActivityLogEntryData") - case "permission": - out.Values[i] = ec._CredentialsActivityLogEntryData_permission(ctx, field, obj) - case "ttl": - out.Values[i] = ec._CredentialsActivityLogEntryData_ttl(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.Deferred, int32(min(len(deferred), math.MaxInt32))) - - for label, dfs := range deferred { - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) unmarshalNCredentialPermission2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialPermission(ctx context.Context, v any) (aivencredentials.CredentialPermission, error) { - var res aivencredentials.CredentialPermission - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNCredentialPermission2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialPermission(ctx context.Context, sel ast.SelectionSet, v aivencredentials.CredentialPermission) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalNCredentialsActivityLogEntryData2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialsActivityLogEntryData(ctx context.Context, sel ast.SelectionSet, v *aivencredentials.CredentialsActivityLogEntryData) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._CredentialsActivityLogEntryData(ctx, sel, v) -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/internal/graph/gengql/kafka.generated.go b/internal/graph/gengql/kafka.generated.go index 4471db4e2..31a4df9a7 100644 --- a/internal/graph/gengql/kafka.generated.go +++ b/internal/graph/gengql/kafka.generated.go @@ -8,12 +8,15 @@ import ( "math" "strconv" "sync/atomic" + "time" "github.com/99designs/gqlgen/graphql" + "github.com/nais/api/internal/activitylog" "github.com/nais/api/internal/graph/ident" "github.com/nais/api/internal/graph/model" "github.com/nais/api/internal/graph/pagination" "github.com/nais/api/internal/persistence/kafkatopic" + "github.com/nais/api/internal/slug" "github.com/nais/api/internal/team" "github.com/nais/api/internal/workload" "github.com/vektah/gqlparser/v2/ast" @@ -271,6 +274,245 @@ func (ec *executionContext) fieldContext_KafkaCredentials_schemaRegistry(_ conte return graphql.NewScalarFieldContext("KafkaCredentials", field, false, false, errors.New("field of type String does not have child fields")) } +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntry_id(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntry_id(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.ID(), nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v ident.Ident) graphql.Marshaler { + return ec.marshalNID2githubᚗcomᚋnaisᚋapiᚋinternalᚋgraphᚋidentᚐIdent(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_KafkaCredentialsCreatedActivityLogEntry_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("KafkaCredentialsCreatedActivityLogEntry", field, true, false, errors.New("field of type ID does not have child fields")) +} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntry_actor(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntry_actor(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Actor, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_KafkaCredentialsCreatedActivityLogEntry_actor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("KafkaCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntry_createdAt(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntry_createdAt(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.CreatedAt, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { + return ec.marshalNTime2timeᚐTime(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_KafkaCredentialsCreatedActivityLogEntry_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("KafkaCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type Time does not have child fields")) +} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntry_message(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntry_message(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Message, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_KafkaCredentialsCreatedActivityLogEntry_message(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("KafkaCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntry_resourceType(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntry_resourceType(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.ResourceType, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v activitylog.ActivityLogEntryResourceType) graphql.Marshaler { + return ec.marshalNActivityLogEntryResourceType2githubᚗcomᚋnaisᚋapiᚋinternalᚋactivitylogᚐActivityLogEntryResourceType(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_KafkaCredentialsCreatedActivityLogEntry_resourceType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("KafkaCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type ActivityLogEntryResourceType does not have child fields")) +} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntry_resourceName(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntry_resourceName(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.ResourceName, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_KafkaCredentialsCreatedActivityLogEntry_resourceName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("KafkaCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntry_teamSlug(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntry_teamSlug(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.TeamSlug, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v *slug.Slug) graphql.Marshaler { + return ec.marshalNSlug2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋslugᚐSlug(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_KafkaCredentialsCreatedActivityLogEntry_teamSlug(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("KafkaCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type Slug does not have child fields")) +} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntry_environmentName(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntry_environmentName(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.EnvironmentName, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { + return ec.marshalOString2ᚖstring(ctx, selections, v) + }, + true, + false, + ) +} +func (ec *executionContext) fieldContext_KafkaCredentialsCreatedActivityLogEntry_environmentName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("KafkaCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntry_data(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntry_data(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Data, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v *kafkatopic.KafkaCredentialsCreatedActivityLogEntryData) graphql.Marshaler { + return ec.marshalNKafkaCredentialsCreatedActivityLogEntryData2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋkafkatopicᚐKafkaCredentialsCreatedActivityLogEntryData(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_KafkaCredentialsCreatedActivityLogEntry_data(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "KafkaCredentialsCreatedActivityLogEntry", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.childFields_KafkaCredentialsCreatedActivityLogEntryData(ctx, field) + }, + } + return fc, nil +} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntryData_ttl(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntryData) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntryData_ttl(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.TTL, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_KafkaCredentialsCreatedActivityLogEntryData_ttl(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("KafkaCredentialsCreatedActivityLogEntryData", field, false, false, errors.New("field of type String does not have child fields")) +} + func (ec *executionContext) _KafkaTopic_id(ctx context.Context, field graphql.CollectedField, obj *kafkatopic.KafkaTopic) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -1642,6 +1884,121 @@ func (ec *executionContext) _KafkaCredentials(ctx context.Context, sel ast.Selec return out } +var kafkaCredentialsCreatedActivityLogEntryImplementors = []string{"KafkaCredentialsCreatedActivityLogEntry", "ActivityLogEntry", "Node"} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntry(ctx context.Context, sel ast.SelectionSet, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntry) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, kafkaCredentialsCreatedActivityLogEntryImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("KafkaCredentialsCreatedActivityLogEntry") + case "id": + out.Values[i] = ec._KafkaCredentialsCreatedActivityLogEntry_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "actor": + out.Values[i] = ec._KafkaCredentialsCreatedActivityLogEntry_actor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createdAt": + out.Values[i] = ec._KafkaCredentialsCreatedActivityLogEntry_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "message": + out.Values[i] = ec._KafkaCredentialsCreatedActivityLogEntry_message(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "resourceType": + out.Values[i] = ec._KafkaCredentialsCreatedActivityLogEntry_resourceType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "resourceName": + out.Values[i] = ec._KafkaCredentialsCreatedActivityLogEntry_resourceName(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "teamSlug": + out.Values[i] = ec._KafkaCredentialsCreatedActivityLogEntry_teamSlug(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "environmentName": + out.Values[i] = ec._KafkaCredentialsCreatedActivityLogEntry_environmentName(ctx, field, obj) + case "data": + out.Values[i] = ec._KafkaCredentialsCreatedActivityLogEntry_data(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.Deferred, int32(min(len(deferred), math.MaxInt32))) + + for label, dfs := range deferred { + ec.ProcessDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var kafkaCredentialsCreatedActivityLogEntryDataImplementors = []string{"KafkaCredentialsCreatedActivityLogEntryData"} + +func (ec *executionContext) _KafkaCredentialsCreatedActivityLogEntryData(ctx context.Context, sel ast.SelectionSet, obj *kafkatopic.KafkaCredentialsCreatedActivityLogEntryData) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, kafkaCredentialsCreatedActivityLogEntryDataImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("KafkaCredentialsCreatedActivityLogEntryData") + case "ttl": + out.Values[i] = ec._KafkaCredentialsCreatedActivityLogEntryData_ttl(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.Deferred, int32(min(len(deferred), math.MaxInt32))) + + for label, dfs := range deferred { + ec.ProcessDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var kafkaTopicImplementors = []string{"KafkaTopic", "Persistence", "Node", "SearchNode"} func (ec *executionContext) _KafkaTopic(ctx context.Context, sel ast.SelectionSet, obj *kafkatopic.KafkaTopic) graphql.Marshaler { @@ -2440,6 +2797,16 @@ func (ec *executionContext) marshalNKafkaCredentials2ᚖgithubᚗcomᚋnaisᚋap return ec._KafkaCredentials(ctx, sel, v) } +func (ec *executionContext) marshalNKafkaCredentialsCreatedActivityLogEntryData2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋkafkatopicᚐKafkaCredentialsCreatedActivityLogEntryData(ctx context.Context, sel ast.SelectionSet, v *kafkatopic.KafkaCredentialsCreatedActivityLogEntryData) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._KafkaCredentialsCreatedActivityLogEntryData(ctx, sel, v) +} + func (ec *executionContext) marshalNKafkaTopic2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋkafkatopicᚐKafkaTopic(ctx context.Context, sel ast.SelectionSet, v kafkatopic.KafkaTopic) graphql.Marshaler { return ec._KafkaTopic(ctx, sel, &v) } diff --git a/internal/graph/gengql/opensearch.generated.go b/internal/graph/gengql/opensearch.generated.go index 7e543eec0..6900d0aa4 100644 --- a/internal/graph/gengql/opensearch.generated.go +++ b/internal/graph/gengql/opensearch.generated.go @@ -17,6 +17,7 @@ import ( "github.com/nais/api/internal/graph/model" "github.com/nais/api/internal/graph/pagination" "github.com/nais/api/internal/issue" + "github.com/nais/api/internal/persistence/aivencredentials" "github.com/nais/api/internal/persistence/opensearch" "github.com/nais/api/internal/servicemaintenance" "github.com/nais/api/internal/slug" @@ -1443,6 +1444,268 @@ func (ec *executionContext) fieldContext_OpenSearchCredentials_uri(_ context.Con return graphql.NewScalarFieldContext("OpenSearchCredentials", field, false, false, errors.New("field of type String does not have child fields")) } +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntry_id(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_id(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.ID(), nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v ident.Ident) graphql.Marshaler { + return ec.marshalNID2githubᚗcomᚋnaisᚋapiᚋinternalᚋgraphᚋidentᚐIdent(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("OpenSearchCredentialsCreatedActivityLogEntry", field, true, false, errors.New("field of type ID does not have child fields")) +} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntry_actor(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_actor(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Actor, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_actor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("OpenSearchCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntry_createdAt(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_createdAt(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.CreatedAt, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { + return ec.marshalNTime2timeᚐTime(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("OpenSearchCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type Time does not have child fields")) +} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntry_message(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_message(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Message, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_message(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("OpenSearchCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntry_resourceType(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_resourceType(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.ResourceType, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v activitylog.ActivityLogEntryResourceType) graphql.Marshaler { + return ec.marshalNActivityLogEntryResourceType2githubᚗcomᚋnaisᚋapiᚋinternalᚋactivitylogᚐActivityLogEntryResourceType(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_resourceType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("OpenSearchCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type ActivityLogEntryResourceType does not have child fields")) +} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntry_resourceName(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_resourceName(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.ResourceName, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_resourceName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("OpenSearchCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntry_teamSlug(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_teamSlug(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.TeamSlug, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v *slug.Slug) graphql.Marshaler { + return ec.marshalNSlug2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋslugᚐSlug(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_teamSlug(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("OpenSearchCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type Slug does not have child fields")) +} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntry_environmentName(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_environmentName(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.EnvironmentName, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { + return ec.marshalOString2ᚖstring(ctx, selections, v) + }, + true, + false, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_environmentName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("OpenSearchCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntry_data(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_data(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Data, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v *opensearch.OpenSearchCredentialsCreatedActivityLogEntryData) graphql.Marshaler { + return ec.marshalNOpenSearchCredentialsCreatedActivityLogEntryData2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋopensearchᚐOpenSearchCredentialsCreatedActivityLogEntryData(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntry_data(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OpenSearchCredentialsCreatedActivityLogEntry", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.childFields_OpenSearchCredentialsCreatedActivityLogEntryData(ctx, field) + }, + } + return fc, nil +} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntryData_permission(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntryData) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntryData_permission(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Permission, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalOString2string(ctx, selections, v) + }, + true, + false, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntryData_permission(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("OpenSearchCredentialsCreatedActivityLogEntryData", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntryData_ttl(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntryData) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntryData_ttl(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.TTL, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_OpenSearchCredentialsCreatedActivityLogEntryData_ttl(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("OpenSearchCredentialsCreatedActivityLogEntryData", field, false, false, errors.New("field of type String does not have child fields")) +} + func (ec *executionContext) _OpenSearchDeletedActivityLogEntry_id(ctx context.Context, field graphql.CollectedField, obj *opensearch.OpenSearchDeletedActivityLogEntry) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -2287,7 +2550,7 @@ func (ec *executionContext) unmarshalInputCreateOpenSearchCredentialsInput(ctx c it.InstanceName = data case "permission": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permission")) - data, err := ec.unmarshalNCredentialPermission2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialPermission(ctx, v) + data, err := ec.unmarshalNOpenSearchPermission2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialPermission(ctx, v) if err != nil { return it, err } @@ -3552,6 +3815,123 @@ func (ec *executionContext) _OpenSearchCredentials(ctx context.Context, sel ast. return out } +var openSearchCredentialsCreatedActivityLogEntryImplementors = []string{"OpenSearchCredentialsCreatedActivityLogEntry", "ActivityLogEntry", "Node"} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntry(ctx context.Context, sel ast.SelectionSet, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntry) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, openSearchCredentialsCreatedActivityLogEntryImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("OpenSearchCredentialsCreatedActivityLogEntry") + case "id": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntry_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "actor": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntry_actor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createdAt": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntry_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "message": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntry_message(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "resourceType": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntry_resourceType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "resourceName": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntry_resourceName(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "teamSlug": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntry_teamSlug(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "environmentName": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntry_environmentName(ctx, field, obj) + case "data": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntry_data(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.Deferred, int32(min(len(deferred), math.MaxInt32))) + + for label, dfs := range deferred { + ec.ProcessDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var openSearchCredentialsCreatedActivityLogEntryDataImplementors = []string{"OpenSearchCredentialsCreatedActivityLogEntryData"} + +func (ec *executionContext) _OpenSearchCredentialsCreatedActivityLogEntryData(ctx context.Context, sel ast.SelectionSet, obj *opensearch.OpenSearchCredentialsCreatedActivityLogEntryData) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, openSearchCredentialsCreatedActivityLogEntryDataImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("OpenSearchCredentialsCreatedActivityLogEntryData") + case "permission": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntryData_permission(ctx, field, obj) + case "ttl": + out.Values[i] = ec._OpenSearchCredentialsCreatedActivityLogEntryData_ttl(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.Deferred, int32(min(len(deferred), math.MaxInt32))) + + for label, dfs := range deferred { + ec.ProcessDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var openSearchDeletedActivityLogEntryImplementors = []string{"OpenSearchDeletedActivityLogEntry", "ActivityLogEntry", "Node"} func (ec *executionContext) _OpenSearchDeletedActivityLogEntry(ctx context.Context, sel ast.SelectionSet, obj *opensearch.OpenSearchDeletedActivityLogEntry) graphql.Marshaler { @@ -4315,6 +4695,16 @@ func (ec *executionContext) marshalNOpenSearchCredentials2ᚖgithubᚗcomᚋnais return ec._OpenSearchCredentials(ctx, sel, v) } +func (ec *executionContext) marshalNOpenSearchCredentialsCreatedActivityLogEntryData2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋopensearchᚐOpenSearchCredentialsCreatedActivityLogEntryData(ctx context.Context, sel ast.SelectionSet, v *opensearch.OpenSearchCredentialsCreatedActivityLogEntryData) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._OpenSearchCredentialsCreatedActivityLogEntryData(ctx, sel, v) +} + func (ec *executionContext) marshalNOpenSearchEdge2githubᚗcomᚋnaisᚋapiᚋinternalᚋgraphᚋpaginationᚐEdge(ctx context.Context, sel ast.SelectionSet, v pagination.Edge[*opensearch.OpenSearch]) graphql.Marshaler { return ec._OpenSearchEdge(ctx, sel, &v) } @@ -4365,6 +4755,16 @@ func (ec *executionContext) marshalNOpenSearchOrderField2githubᚗcomᚋnaisᚋa return v } +func (ec *executionContext) unmarshalNOpenSearchPermission2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialPermission(ctx context.Context, v any) (aivencredentials.CredentialPermission, error) { + var res aivencredentials.CredentialPermission + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNOpenSearchPermission2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialPermission(ctx context.Context, sel ast.SelectionSet, v aivencredentials.CredentialPermission) graphql.Marshaler { + return v +} + func (ec *executionContext) unmarshalNOpenSearchState2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋopensearchᚐOpenSearchState(ctx context.Context, v any) (opensearch.OpenSearchState, error) { var res opensearch.OpenSearchState err := res.UnmarshalGQL(v) diff --git a/internal/graph/gengql/root_.generated.go b/internal/graph/gengql/root_.generated.go index a8e1eff62..85f459f78 100644 --- a/internal/graph/gengql/root_.generated.go +++ b/internal/graph/gengql/root_.generated.go @@ -750,23 +750,6 @@ type ComplexityRoot struct { Valkey func(childComplexity int) int } - CredentialsActivityLogEntry struct { - Actor func(childComplexity int) int - CreatedAt func(childComplexity int) int - Data func(childComplexity int) int - EnvironmentName func(childComplexity int) int - ID func(childComplexity int) int - Message func(childComplexity int) int - ResourceName func(childComplexity int) int - ResourceType func(childComplexity int) int - TeamSlug func(childComplexity int) int - } - - CredentialsActivityLogEntryData struct { - Permission func(childComplexity int) int - TTL func(childComplexity int) int - } - CurrentUnitPrices struct { CPU func(childComplexity int) int Memory func(childComplexity int) int @@ -1371,6 +1354,22 @@ type ComplexityRoot struct { Username func(childComplexity int) int } + KafkaCredentialsCreatedActivityLogEntry struct { + Actor func(childComplexity int) int + CreatedAt func(childComplexity int) int + Data func(childComplexity int) int + EnvironmentName func(childComplexity int) int + ID func(childComplexity int) int + Message func(childComplexity int) int + ResourceName func(childComplexity int) int + ResourceType func(childComplexity int) int + TeamSlug func(childComplexity int) int + } + + KafkaCredentialsCreatedActivityLogEntryData struct { + TTL func(childComplexity int) int + } + KafkaLagScalingStrategy struct { ConsumerGroup func(childComplexity int) int Threshold func(childComplexity int) int @@ -1668,6 +1667,23 @@ type ComplexityRoot struct { Username func(childComplexity int) int } + OpenSearchCredentialsCreatedActivityLogEntry struct { + Actor func(childComplexity int) int + CreatedAt func(childComplexity int) int + Data func(childComplexity int) int + EnvironmentName func(childComplexity int) int + ID func(childComplexity int) int + Message func(childComplexity int) int + ResourceName func(childComplexity int) int + ResourceType func(childComplexity int) int + TeamSlug func(childComplexity int) int + } + + OpenSearchCredentialsCreatedActivityLogEntryData struct { + Permission func(childComplexity int) int + TTL func(childComplexity int) int + } + OpenSearchDeletedActivityLogEntry struct { Actor func(childComplexity int) int CreatedAt func(childComplexity int) int @@ -3462,6 +3478,23 @@ type ComplexityRoot struct { Username func(childComplexity int) int } + ValkeyCredentialsCreatedActivityLogEntry struct { + Actor func(childComplexity int) int + CreatedAt func(childComplexity int) int + Data func(childComplexity int) int + EnvironmentName func(childComplexity int) int + ID func(childComplexity int) int + Message func(childComplexity int) int + ResourceName func(childComplexity int) int + ResourceType func(childComplexity int) int + TeamSlug func(childComplexity int) int + } + + ValkeyCredentialsCreatedActivityLogEntryData struct { + Permission func(childComplexity int) int + TTL func(childComplexity int) int + } + ValkeyDeletedActivityLogEntry struct { Actor func(childComplexity int) int CreatedAt func(childComplexity int) int @@ -6092,83 +6125,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.ComplexityRoot.CreateValkeyPayload.Valkey(childComplexity), true - case "CredentialsActivityLogEntry.actor": - if e.ComplexityRoot.CredentialsActivityLogEntry.Actor == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntry.Actor(childComplexity), true - - case "CredentialsActivityLogEntry.createdAt": - if e.ComplexityRoot.CredentialsActivityLogEntry.CreatedAt == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntry.CreatedAt(childComplexity), true - - case "CredentialsActivityLogEntry.data": - if e.ComplexityRoot.CredentialsActivityLogEntry.Data == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntry.Data(childComplexity), true - - case "CredentialsActivityLogEntry.environmentName": - if e.ComplexityRoot.CredentialsActivityLogEntry.EnvironmentName == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntry.EnvironmentName(childComplexity), true - - case "CredentialsActivityLogEntry.id": - if e.ComplexityRoot.CredentialsActivityLogEntry.ID == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntry.ID(childComplexity), true - - case "CredentialsActivityLogEntry.message": - if e.ComplexityRoot.CredentialsActivityLogEntry.Message == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntry.Message(childComplexity), true - - case "CredentialsActivityLogEntry.resourceName": - if e.ComplexityRoot.CredentialsActivityLogEntry.ResourceName == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntry.ResourceName(childComplexity), true - - case "CredentialsActivityLogEntry.resourceType": - if e.ComplexityRoot.CredentialsActivityLogEntry.ResourceType == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntry.ResourceType(childComplexity), true - - case "CredentialsActivityLogEntry.teamSlug": - if e.ComplexityRoot.CredentialsActivityLogEntry.TeamSlug == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntry.TeamSlug(childComplexity), true - - case "CredentialsActivityLogEntryData.permission": - if e.ComplexityRoot.CredentialsActivityLogEntryData.Permission == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntryData.Permission(childComplexity), true - - case "CredentialsActivityLogEntryData.ttl": - if e.ComplexityRoot.CredentialsActivityLogEntryData.TTL == nil { - break - } - - return e.ComplexityRoot.CredentialsActivityLogEntryData.TTL(childComplexity), true - case "CurrentUnitPrices.cpu": if e.ComplexityRoot.CurrentUnitPrices.CPU == nil { break @@ -8623,6 +8579,76 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.ComplexityRoot.KafkaCredentials.Username(childComplexity), true + case "KafkaCredentialsCreatedActivityLogEntry.actor": + if e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.Actor == nil { + break + } + + return e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.Actor(childComplexity), true + + case "KafkaCredentialsCreatedActivityLogEntry.createdAt": + if e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.CreatedAt == nil { + break + } + + return e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.CreatedAt(childComplexity), true + + case "KafkaCredentialsCreatedActivityLogEntry.data": + if e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.Data == nil { + break + } + + return e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.Data(childComplexity), true + + case "KafkaCredentialsCreatedActivityLogEntry.environmentName": + if e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.EnvironmentName == nil { + break + } + + return e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.EnvironmentName(childComplexity), true + + case "KafkaCredentialsCreatedActivityLogEntry.id": + if e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.ID == nil { + break + } + + return e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.ID(childComplexity), true + + case "KafkaCredentialsCreatedActivityLogEntry.message": + if e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.Message == nil { + break + } + + return e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.Message(childComplexity), true + + case "KafkaCredentialsCreatedActivityLogEntry.resourceName": + if e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.ResourceName == nil { + break + } + + return e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.ResourceName(childComplexity), true + + case "KafkaCredentialsCreatedActivityLogEntry.resourceType": + if e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.ResourceType == nil { + break + } + + return e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.ResourceType(childComplexity), true + + case "KafkaCredentialsCreatedActivityLogEntry.teamSlug": + if e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.TeamSlug == nil { + break + } + + return e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntry.TeamSlug(childComplexity), true + + case "KafkaCredentialsCreatedActivityLogEntryData.ttl": + if e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntryData.TTL == nil { + break + } + + return e.ComplexityRoot.KafkaCredentialsCreatedActivityLogEntryData.TTL(childComplexity), true + case "KafkaLagScalingStrategy.consumerGroup": if e.ComplexityRoot.KafkaLagScalingStrategy.ConsumerGroup == nil { break @@ -10312,6 +10338,83 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.ComplexityRoot.OpenSearchCredentials.Username(childComplexity), true + case "OpenSearchCredentialsCreatedActivityLogEntry.actor": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.Actor == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.Actor(childComplexity), true + + case "OpenSearchCredentialsCreatedActivityLogEntry.createdAt": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.CreatedAt == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.CreatedAt(childComplexity), true + + case "OpenSearchCredentialsCreatedActivityLogEntry.data": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.Data == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.Data(childComplexity), true + + case "OpenSearchCredentialsCreatedActivityLogEntry.environmentName": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.EnvironmentName == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.EnvironmentName(childComplexity), true + + case "OpenSearchCredentialsCreatedActivityLogEntry.id": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.ID == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.ID(childComplexity), true + + case "OpenSearchCredentialsCreatedActivityLogEntry.message": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.Message == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.Message(childComplexity), true + + case "OpenSearchCredentialsCreatedActivityLogEntry.resourceName": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.ResourceName == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.ResourceName(childComplexity), true + + case "OpenSearchCredentialsCreatedActivityLogEntry.resourceType": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.ResourceType == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.ResourceType(childComplexity), true + + case "OpenSearchCredentialsCreatedActivityLogEntry.teamSlug": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.TeamSlug == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntry.TeamSlug(childComplexity), true + + case "OpenSearchCredentialsCreatedActivityLogEntryData.permission": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntryData.Permission == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntryData.Permission(childComplexity), true + + case "OpenSearchCredentialsCreatedActivityLogEntryData.ttl": + if e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntryData.TTL == nil { + break + } + + return e.ComplexityRoot.OpenSearchCredentialsCreatedActivityLogEntryData.TTL(childComplexity), true + case "OpenSearchDeletedActivityLogEntry.actor": if e.ComplexityRoot.OpenSearchDeletedActivityLogEntry.Actor == nil { break @@ -18218,6 +18321,83 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.ComplexityRoot.ValkeyCredentials.Username(childComplexity), true + case "ValkeyCredentialsCreatedActivityLogEntry.actor": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.Actor == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.Actor(childComplexity), true + + case "ValkeyCredentialsCreatedActivityLogEntry.createdAt": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.CreatedAt == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.CreatedAt(childComplexity), true + + case "ValkeyCredentialsCreatedActivityLogEntry.data": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.Data == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.Data(childComplexity), true + + case "ValkeyCredentialsCreatedActivityLogEntry.environmentName": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.EnvironmentName == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.EnvironmentName(childComplexity), true + + case "ValkeyCredentialsCreatedActivityLogEntry.id": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.ID == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.ID(childComplexity), true + + case "ValkeyCredentialsCreatedActivityLogEntry.message": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.Message == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.Message(childComplexity), true + + case "ValkeyCredentialsCreatedActivityLogEntry.resourceName": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.ResourceName == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.ResourceName(childComplexity), true + + case "ValkeyCredentialsCreatedActivityLogEntry.resourceType": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.ResourceType == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.ResourceType(childComplexity), true + + case "ValkeyCredentialsCreatedActivityLogEntry.teamSlug": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.TeamSlug == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntry.TeamSlug(childComplexity), true + + case "ValkeyCredentialsCreatedActivityLogEntryData.permission": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntryData.Permission == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntryData.Permission(childComplexity), true + + case "ValkeyCredentialsCreatedActivityLogEntryData.ttl": + if e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntryData.TTL == nil { + break + } + + return e.ComplexityRoot.ValkeyCredentialsCreatedActivityLogEntryData.TTL(childComplexity), true + case "ValkeyDeletedActivityLogEntry.actor": if e.ComplexityRoot.ValkeyDeletedActivityLogEntry.Actor == nil { break @@ -19824,55 +20004,6 @@ type ActivityLogEntryEdge { """ node: ActivityLogEntry! } -`, BuiltIn: false}, - {Name: "../schema/aiven_credentials.graphqls", Input: `"Permission level for OpenSearch and Valkey credentials." -enum CredentialPermission { - READ - WRITE - READWRITE - ADMIN -} - -type CredentialsActivityLogEntry implements ActivityLogEntry & Node { - "ID of the entry." - id: ID! - - "The identity of the actor who performed the action." - actor: String! - - "Creation time of the entry." - createdAt: Time! - - "Message that summarizes the entry." - message: String! - - "Type of the resource that was affected by the action." - resourceType: ActivityLogEntryResourceType! - - "Name of the resource that was affected by the action." - resourceName: String! - - "The team slug that the entry belongs to." - teamSlug: Slug! - - "The environment name that the entry belongs to." - environmentName: String - - "Data associated with the credential creation." - data: CredentialsActivityLogEntryData! -} - -type CredentialsActivityLogEntryData { - "The permission level, if applicable." - permission: String - "The TTL that was requested for the credentials." - ttl: String! -} - -extend enum ActivityLogActivityType { - "Filter for credential creation events." - CREDENTIALS_CREATED -} `, BuiltIn: false}, {Name: "../schema/alerts.graphqls", Input: `extend type TeamEnvironment { """ @@ -24591,6 +24722,50 @@ type CreateKafkaCredentialsPayload { "The generated credentials." credentials: KafkaCredentials! } + +type KafkaCredentialsCreatedActivityLogEntry implements ActivityLogEntry & Node { + "ID of the entry." + id: ID! + + "The identity of the actor who performed the action." + actor: String! + + "Creation time of the entry." + createdAt: Time! + + "Message that summarizes the entry." + message: String! + + "Type of the resource that was affected by the action." + resourceType: ActivityLogEntryResourceType! + + "Name of the resource that was affected by the action." + resourceName: String! + + "The team slug that the entry belongs to." + teamSlug: Slug! + + "The environment name that the entry belongs to." + environmentName: String + + "Data associated with the credential creation." + data: KafkaCredentialsCreatedActivityLogEntryData! +} + +type KafkaCredentialsCreatedActivityLogEntryData { + "The TTL that was requested for the credentials." + ttl: String! +} + +extend enum ActivityLogActivityType { + "Filter for Kafka credential creation events." + KAFKA_CREDENTIALS_CREATED +} + +extend enum ActivityLogEntryResourceType { + "All activity log entries related to Kafka topics will use this resource type." + KAFKA_TOPIC +} `, BuiltIn: false}, {Name: "../schema/labels.graphqls", Input: `""" A user-defined label attached to a resource. @@ -25025,6 +25200,18 @@ type OpenSearch implements Persistence & Node { ): IssueConnection! } +"Permission level for OpenSearch credentials." +enum OpenSearchPermission { + "Read-only access." + READ + "Write-only access." + WRITE + "Read and write access." + READWRITE + "Administrative access." + ADMIN +} + enum OpenSearchState { POWEROFF REBALANCING @@ -25363,7 +25550,7 @@ input CreateOpenSearchCredentialsInput { "Name of the OpenSearch instance." instanceName: String! "Permission level for the credentials." - permission: CredentialPermission! + permission: OpenSearchPermission! "Time-to-live for the credentials (e.g. '1d', '7d'). Maximum 30 days." ttl: String! } @@ -25385,6 +25572,47 @@ type CreateOpenSearchCredentialsPayload { "The generated credentials." credentials: OpenSearchCredentials! } + +type OpenSearchCredentialsCreatedActivityLogEntry implements ActivityLogEntry & Node { + "ID of the entry." + id: ID! + + "The identity of the actor who performed the action." + actor: String! + + "Creation time of the entry." + createdAt: Time! + + "Message that summarizes the entry." + message: String! + + "Type of the resource that was affected by the action." + resourceType: ActivityLogEntryResourceType! + + "Name of the resource that was affected by the action." + resourceName: String! + + "The team slug that the entry belongs to." + teamSlug: Slug! + + "The environment name that the entry belongs to." + environmentName: String + + "Data associated with the credential creation." + data: OpenSearchCredentialsCreatedActivityLogEntryData! +} + +type OpenSearchCredentialsCreatedActivityLogEntryData { + "The permission level, if applicable." + permission: String + "The TTL that was requested for the credentials." + ttl: String! +} + +extend enum ActivityLogActivityType { + "Filter for credential creation events." + OPENSEARCH_CREDENTIALS_CREATED +} `, BuiltIn: false}, {Name: "../schema/persistence.graphqls", Input: `interface Persistence implements Node { id: ID! @@ -31163,6 +31391,18 @@ input ValkeyOrder { direction: OrderDirection! } +"Permission level for Valkey credentials." +enum ValkeyPermission { + "Read-only access." + READ + "Write-only access." + WRITE + "Read and write access." + READWRITE + "Administrative access." + ADMIN +} + enum ValkeyAccessOrderField { ACCESS WORKLOAD @@ -31425,7 +31665,7 @@ input CreateValkeyCredentialsInput { "Name of the Valkey instance." instanceName: String! "Permission level for the credentials." - permission: CredentialPermission! + permission: ValkeyPermission! "Time-to-live for the credentials (e.g. '1d', '7d'). Maximum 30 days." ttl: String! } @@ -31447,6 +31687,47 @@ type CreateValkeyCredentialsPayload { "The generated credentials." credentials: ValkeyCredentials! } + +type ValkeyCredentialsCreatedActivityLogEntry implements ActivityLogEntry & Node { + "ID of the entry." + id: ID! + + "The identity of the actor who performed the action." + actor: String! + + "Creation time of the entry." + createdAt: Time! + + "Message that summarizes the entry." + message: String! + + "Type of the resource that was affected by the action." + resourceType: ActivityLogEntryResourceType! + + "Name of the resource that was affected by the action." + resourceName: String! + + "The team slug that the entry belongs to." + teamSlug: Slug! + + "The environment name that the entry belongs to." + environmentName: String + + "Data associated with the credential creation." + data: ValkeyCredentialsCreatedActivityLogEntryData! +} + +type ValkeyCredentialsCreatedActivityLogEntryData { + "The permission level, if applicable." + permission: String + "The TTL that was requested for the credentials." + ttl: String! +} + +extend enum ActivityLogActivityType { + "Filter for credential creation events." + VALKEY_CREDENTIALS_CREATED +} `, BuiltIn: false}, {Name: "../schema/vulnerability.graphqls", Input: `extend type Mutation { """ @@ -33667,16 +33948,6 @@ func (ec *executionContext) childFields_CreateValkeyPayload(ctx context.Context, return nil, fmt.Errorf("no field named %q was found under type CreateValkeyPayload", field.Name) } -func (ec *executionContext) childFields_CredentialsActivityLogEntryData(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "permission": - return ec.fieldContext_CredentialsActivityLogEntryData_permission(ctx, field) - case "ttl": - return ec.fieldContext_CredentialsActivityLogEntryData_ttl(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CredentialsActivityLogEntryData", field.Name) -} - func (ec *executionContext) childFields_CurrentUnitPrices(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "cpu": @@ -34599,6 +34870,14 @@ func (ec *executionContext) childFields_KafkaCredentials(ctx context.Context, fi return nil, fmt.Errorf("no field named %q was found under type KafkaCredentials", field.Name) } +func (ec *executionContext) childFields_KafkaCredentialsCreatedActivityLogEntryData(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "ttl": + return ec.fieldContext_KafkaCredentialsCreatedActivityLogEntryData_ttl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type KafkaCredentialsCreatedActivityLogEntryData", field.Name) +} + func (ec *executionContext) childFields_KafkaTopic(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": @@ -34939,6 +35218,16 @@ func (ec *executionContext) childFields_OpenSearchCredentials(ctx context.Contex return nil, fmt.Errorf("no field named %q was found under type OpenSearchCredentials", field.Name) } +func (ec *executionContext) childFields_OpenSearchCredentialsCreatedActivityLogEntryData(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "permission": + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntryData_permission(ctx, field) + case "ttl": + return ec.fieldContext_OpenSearchCredentialsCreatedActivityLogEntryData_ttl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OpenSearchCredentialsCreatedActivityLogEntryData", field.Name) +} + func (ec *executionContext) childFields_OpenSearchEdge(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "cursor": @@ -37283,6 +37572,16 @@ func (ec *executionContext) childFields_ValkeyCredentials(ctx context.Context, f return nil, fmt.Errorf("no field named %q was found under type ValkeyCredentials", field.Name) } +func (ec *executionContext) childFields_ValkeyCredentialsCreatedActivityLogEntryData(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "permission": + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntryData_permission(ctx, field) + case "ttl": + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntryData_ttl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ValkeyCredentialsCreatedActivityLogEntryData", field.Name) +} + func (ec *executionContext) childFields_ValkeyEdge(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "cursor": diff --git a/internal/graph/gengql/schema.generated.go b/internal/graph/gengql/schema.generated.go index 021c55c7a..fd74a6fdc 100644 --- a/internal/graph/gengql/schema.generated.go +++ b/internal/graph/gengql/schema.generated.go @@ -29,7 +29,6 @@ import ( "github.com/nais/api/internal/kubernetes/event/pubsublog" "github.com/nais/api/internal/loki" "github.com/nais/api/internal/persistence" - "github.com/nais/api/internal/persistence/aivencredentials" "github.com/nais/api/internal/persistence/bigquery" "github.com/nais/api/internal/persistence/bucket" "github.com/nais/api/internal/persistence/kafkatopic" @@ -6089,6 +6088,13 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._ValkeyDeletedActivityLogEntry(ctx, sel, obj) + case valkey.ValkeyCredentialsCreatedActivityLogEntry: + return ec._ValkeyCredentialsCreatedActivityLogEntry(ctx, sel, &obj) + case *valkey.ValkeyCredentialsCreatedActivityLogEntry: + if obj == nil { + return graphql.Null + } + return ec._ValkeyCredentialsCreatedActivityLogEntry(ctx, sel, obj) case valkey.ValkeyCreatedActivityLogEntry: return ec._ValkeyCreatedActivityLogEntry(ctx, sel, &obj) case *valkey.ValkeyCreatedActivityLogEntry: @@ -6502,6 +6508,13 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._OpenSearchDeletedActivityLogEntry(ctx, sel, obj) + case opensearch.OpenSearchCredentialsCreatedActivityLogEntry: + return ec._OpenSearchCredentialsCreatedActivityLogEntry(ctx, sel, &obj) + case *opensearch.OpenSearchCredentialsCreatedActivityLogEntry: + if obj == nil { + return graphql.Null + } + return ec._OpenSearchCredentialsCreatedActivityLogEntry(ctx, sel, obj) case opensearch.OpenSearchCreatedActivityLogEntry: return ec._OpenSearchCreatedActivityLogEntry(ctx, sel, &obj) case *opensearch.OpenSearchCreatedActivityLogEntry: @@ -6558,6 +6571,13 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._KafkaTopic(ctx, sel, obj) + case kafkatopic.KafkaCredentialsCreatedActivityLogEntry: + return ec._KafkaCredentialsCreatedActivityLogEntry(ctx, sel, &obj) + case *kafkatopic.KafkaCredentialsCreatedActivityLogEntry: + if obj == nil { + return graphql.Null + } + return ec._KafkaCredentialsCreatedActivityLogEntry(ctx, sel, obj) case job.JobUpdatedActivityLogEntry: return ec._JobUpdatedActivityLogEntry(ctx, sel, &obj) case *job.JobUpdatedActivityLogEntry: @@ -6642,13 +6662,6 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._DeploymentActivityLogEntry(ctx, sel, obj) - case aivencredentials.CredentialsActivityLogEntry: - return ec._CredentialsActivityLogEntry(ctx, sel, &obj) - case *aivencredentials.CredentialsActivityLogEntry: - if obj == nil { - return graphql.Null - } - return ec._CredentialsActivityLogEntry(ctx, sel, obj) case workload.ContainerImage: return ec._ContainerImage(ctx, sel, &obj) case *workload.ContainerImage: diff --git a/internal/graph/gengql/valkey.generated.go b/internal/graph/gengql/valkey.generated.go index 748c092e1..792bdd005 100644 --- a/internal/graph/gengql/valkey.generated.go +++ b/internal/graph/gengql/valkey.generated.go @@ -17,6 +17,7 @@ import ( "github.com/nais/api/internal/graph/model" "github.com/nais/api/internal/graph/pagination" "github.com/nais/api/internal/issue" + "github.com/nais/api/internal/persistence/aivencredentials" "github.com/nais/api/internal/persistence/valkey" "github.com/nais/api/internal/servicemaintenance" "github.com/nais/api/internal/slug" @@ -1511,6 +1512,268 @@ func (ec *executionContext) fieldContext_ValkeyCredentials_uri(_ context.Context return graphql.NewScalarFieldContext("ValkeyCredentials", field, false, false, errors.New("field of type String does not have child fields")) } +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntry_id(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntry_id(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.ID(), nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v ident.Ident) graphql.Marshaler { + return ec.marshalNID2githubᚗcomᚋnaisᚋapiᚋinternalᚋgraphᚋidentᚐIdent(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntry_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("ValkeyCredentialsCreatedActivityLogEntry", field, true, false, errors.New("field of type ID does not have child fields")) +} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntry_actor(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntry_actor(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Actor, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntry_actor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("ValkeyCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntry_createdAt(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntry_createdAt(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.CreatedAt, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { + return ec.marshalNTime2timeᚐTime(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntry_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("ValkeyCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type Time does not have child fields")) +} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntry_message(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntry_message(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Message, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntry_message(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("ValkeyCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntry_resourceType(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntry_resourceType(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.ResourceType, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v activitylog.ActivityLogEntryResourceType) graphql.Marshaler { + return ec.marshalNActivityLogEntryResourceType2githubᚗcomᚋnaisᚋapiᚋinternalᚋactivitylogᚐActivityLogEntryResourceType(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntry_resourceType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("ValkeyCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type ActivityLogEntryResourceType does not have child fields")) +} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntry_resourceName(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntry_resourceName(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.ResourceName, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntry_resourceName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("ValkeyCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntry_teamSlug(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntry_teamSlug(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.TeamSlug, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v *slug.Slug) graphql.Marshaler { + return ec.marshalNSlug2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋslugᚐSlug(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntry_teamSlug(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("ValkeyCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type Slug does not have child fields")) +} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntry_environmentName(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntry_environmentName(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.EnvironmentName, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { + return ec.marshalOString2ᚖstring(ctx, selections, v) + }, + true, + false, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntry_environmentName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("ValkeyCredentialsCreatedActivityLogEntry", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntry_data(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntry) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntry_data(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Data, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v *valkey.ValkeyCredentialsCreatedActivityLogEntryData) graphql.Marshaler { + return ec.marshalNValkeyCredentialsCreatedActivityLogEntryData2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋvalkeyᚐValkeyCredentialsCreatedActivityLogEntryData(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntry_data(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ValkeyCredentialsCreatedActivityLogEntry", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.childFields_ValkeyCredentialsCreatedActivityLogEntryData(ctx, field) + }, + } + return fc, nil +} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntryData_permission(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntryData) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntryData_permission(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.Permission, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalOString2string(ctx, selections, v) + }, + true, + false, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntryData_permission(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("ValkeyCredentialsCreatedActivityLogEntryData", field, false, false, errors.New("field of type String does not have child fields")) +} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntryData_ttl(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyCredentialsCreatedActivityLogEntryData) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return ec.fieldContext_ValkeyCredentialsCreatedActivityLogEntryData_ttl(ctx, field) + }, + func(ctx context.Context) (any, error) { + return obj.TTL, nil + }, + nil, + func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { + return ec.marshalNString2string(ctx, selections, v) + }, + true, + true, + ) +} +func (ec *executionContext) fieldContext_ValkeyCredentialsCreatedActivityLogEntryData_ttl(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + return graphql.NewScalarFieldContext("ValkeyCredentialsCreatedActivityLogEntryData", field, false, false, errors.New("field of type String does not have child fields")) +} + func (ec *executionContext) _ValkeyDeletedActivityLogEntry_id(ctx context.Context, field graphql.CollectedField, obj *valkey.ValkeyDeletedActivityLogEntry) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -2254,7 +2517,7 @@ func (ec *executionContext) unmarshalInputCreateValkeyCredentialsInput(ctx conte it.InstanceName = data case "permission": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permission")) - data, err := ec.unmarshalNCredentialPermission2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialPermission(ctx, v) + data, err := ec.unmarshalNValkeyPermission2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialPermission(ctx, v) if err != nil { return it, err } @@ -3579,6 +3842,123 @@ func (ec *executionContext) _ValkeyCredentials(ctx context.Context, sel ast.Sele return out } +var valkeyCredentialsCreatedActivityLogEntryImplementors = []string{"ValkeyCredentialsCreatedActivityLogEntry", "ActivityLogEntry", "Node"} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntry(ctx context.Context, sel ast.SelectionSet, obj *valkey.ValkeyCredentialsCreatedActivityLogEntry) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, valkeyCredentialsCreatedActivityLogEntryImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ValkeyCredentialsCreatedActivityLogEntry") + case "id": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntry_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "actor": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntry_actor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createdAt": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntry_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "message": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntry_message(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "resourceType": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntry_resourceType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "resourceName": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntry_resourceName(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "teamSlug": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntry_teamSlug(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "environmentName": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntry_environmentName(ctx, field, obj) + case "data": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntry_data(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.Deferred, int32(min(len(deferred), math.MaxInt32))) + + for label, dfs := range deferred { + ec.ProcessDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var valkeyCredentialsCreatedActivityLogEntryDataImplementors = []string{"ValkeyCredentialsCreatedActivityLogEntryData"} + +func (ec *executionContext) _ValkeyCredentialsCreatedActivityLogEntryData(ctx context.Context, sel ast.SelectionSet, obj *valkey.ValkeyCredentialsCreatedActivityLogEntryData) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, valkeyCredentialsCreatedActivityLogEntryDataImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ValkeyCredentialsCreatedActivityLogEntryData") + case "permission": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntryData_permission(ctx, field, obj) + case "ttl": + out.Values[i] = ec._ValkeyCredentialsCreatedActivityLogEntryData_ttl(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.Deferred, int32(min(len(deferred), math.MaxInt32))) + + for label, dfs := range deferred { + ec.ProcessDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var valkeyDeletedActivityLogEntryImplementors = []string{"ValkeyDeletedActivityLogEntry", "ActivityLogEntry", "Node"} func (ec *executionContext) _ValkeyDeletedActivityLogEntry(ctx context.Context, sel ast.SelectionSet, obj *valkey.ValkeyDeletedActivityLogEntry) graphql.Marshaler { @@ -4256,6 +4636,16 @@ func (ec *executionContext) marshalNValkeyCredentials2ᚖgithubᚗcomᚋnaisᚋa return ec._ValkeyCredentials(ctx, sel, v) } +func (ec *executionContext) marshalNValkeyCredentialsCreatedActivityLogEntryData2ᚖgithubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋvalkeyᚐValkeyCredentialsCreatedActivityLogEntryData(ctx context.Context, sel ast.SelectionSet, v *valkey.ValkeyCredentialsCreatedActivityLogEntryData) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._ValkeyCredentialsCreatedActivityLogEntryData(ctx, sel, v) +} + func (ec *executionContext) marshalNValkeyEdge2githubᚗcomᚋnaisᚋapiᚋinternalᚋgraphᚋpaginationᚐEdge(ctx context.Context, sel ast.SelectionSet, v pagination.Edge[*valkey.Valkey]) graphql.Marshaler { return ec._ValkeyEdge(ctx, sel, &v) } @@ -4296,6 +4686,16 @@ func (ec *executionContext) marshalNValkeyOrderField2githubᚗcomᚋnaisᚋapi return v } +func (ec *executionContext) unmarshalNValkeyPermission2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialPermission(ctx context.Context, v any) (aivencredentials.CredentialPermission, error) { + var res aivencredentials.CredentialPermission + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNValkeyPermission2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋaivencredentialsᚐCredentialPermission(ctx context.Context, sel ast.SelectionSet, v aivencredentials.CredentialPermission) graphql.Marshaler { + return v +} + func (ec *executionContext) unmarshalNValkeyState2githubᚗcomᚋnaisᚋapiᚋinternalᚋpersistenceᚋvalkeyᚐValkeyState(ctx context.Context, v any) (valkey.ValkeyState, error) { var res valkey.ValkeyState err := res.UnmarshalGQL(v) diff --git a/internal/graph/schema/aiven_credentials.graphqls b/internal/graph/schema/aiven_credentials.graphqls deleted file mode 100644 index a212202ea..000000000 --- a/internal/graph/schema/aiven_credentials.graphqls +++ /dev/null @@ -1,48 +0,0 @@ -"Permission level for OpenSearch and Valkey credentials." -enum CredentialPermission { - READ - WRITE - READWRITE - ADMIN -} - -type CredentialsActivityLogEntry implements ActivityLogEntry & Node { - "ID of the entry." - id: ID! - - "The identity of the actor who performed the action." - actor: String! - - "Creation time of the entry." - createdAt: Time! - - "Message that summarizes the entry." - message: String! - - "Type of the resource that was affected by the action." - resourceType: ActivityLogEntryResourceType! - - "Name of the resource that was affected by the action." - resourceName: String! - - "The team slug that the entry belongs to." - teamSlug: Slug! - - "The environment name that the entry belongs to." - environmentName: String - - "Data associated with the credential creation." - data: CredentialsActivityLogEntryData! -} - -type CredentialsActivityLogEntryData { - "The permission level, if applicable." - permission: String - "The TTL that was requested for the credentials." - ttl: String! -} - -extend enum ActivityLogActivityType { - "Filter for credential creation events." - CREDENTIALS_CREATED -} diff --git a/internal/graph/schema/kafka.graphqls b/internal/graph/schema/kafka.graphqls index 261589e2a..4a244974f 100644 --- a/internal/graph/schema/kafka.graphqls +++ b/internal/graph/schema/kafka.graphqls @@ -224,3 +224,47 @@ type CreateKafkaCredentialsPayload { "The generated credentials." credentials: KafkaCredentials! } + +type KafkaCredentialsCreatedActivityLogEntry implements ActivityLogEntry & Node { + "ID of the entry." + id: ID! + + "The identity of the actor who performed the action." + actor: String! + + "Creation time of the entry." + createdAt: Time! + + "Message that summarizes the entry." + message: String! + + "Type of the resource that was affected by the action." + resourceType: ActivityLogEntryResourceType! + + "Name of the resource that was affected by the action." + resourceName: String! + + "The team slug that the entry belongs to." + teamSlug: Slug! + + "The environment name that the entry belongs to." + environmentName: String + + "Data associated with the credential creation." + data: KafkaCredentialsCreatedActivityLogEntryData! +} + +type KafkaCredentialsCreatedActivityLogEntryData { + "The TTL that was requested for the credentials." + ttl: String! +} + +extend enum ActivityLogActivityType { + "Filter for Kafka credential creation events." + KAFKA_CREDENTIALS_CREATED +} + +extend enum ActivityLogEntryResourceType { + "All activity log entries related to Kafka topics will use this resource type." + KAFKA_TOPIC +} diff --git a/internal/graph/schema/opensearch.graphqls b/internal/graph/schema/opensearch.graphqls index f089c4c7d..0c6887512 100644 --- a/internal/graph/schema/opensearch.graphqls +++ b/internal/graph/schema/opensearch.graphqls @@ -105,6 +105,18 @@ type OpenSearch implements Persistence & Node { ): IssueConnection! } +"Permission level for OpenSearch credentials." +enum OpenSearchPermission { + "Read-only access." + READ + "Write-only access." + WRITE + "Read and write access." + READWRITE + "Administrative access." + ADMIN +} + enum OpenSearchState { POWEROFF REBALANCING @@ -443,7 +455,7 @@ input CreateOpenSearchCredentialsInput { "Name of the OpenSearch instance." instanceName: String! "Permission level for the credentials." - permission: CredentialPermission! + permission: OpenSearchPermission! "Time-to-live for the credentials (e.g. '1d', '7d'). Maximum 30 days." ttl: String! } @@ -465,3 +477,44 @@ type CreateOpenSearchCredentialsPayload { "The generated credentials." credentials: OpenSearchCredentials! } + +type OpenSearchCredentialsCreatedActivityLogEntry implements ActivityLogEntry & Node { + "ID of the entry." + id: ID! + + "The identity of the actor who performed the action." + actor: String! + + "Creation time of the entry." + createdAt: Time! + + "Message that summarizes the entry." + message: String! + + "Type of the resource that was affected by the action." + resourceType: ActivityLogEntryResourceType! + + "Name of the resource that was affected by the action." + resourceName: String! + + "The team slug that the entry belongs to." + teamSlug: Slug! + + "The environment name that the entry belongs to." + environmentName: String + + "Data associated with the credential creation." + data: OpenSearchCredentialsCreatedActivityLogEntryData! +} + +type OpenSearchCredentialsCreatedActivityLogEntryData { + "The permission level, if applicable." + permission: String + "The TTL that was requested for the credentials." + ttl: String! +} + +extend enum ActivityLogActivityType { + "Filter for credential creation events." + OPENSEARCH_CREDENTIALS_CREATED +} diff --git a/internal/graph/schema/valkey.graphqls b/internal/graph/schema/valkey.graphqls index ab334172a..371979d4a 100644 --- a/internal/graph/schema/valkey.graphqls +++ b/internal/graph/schema/valkey.graphqls @@ -202,6 +202,18 @@ input ValkeyOrder { direction: OrderDirection! } +"Permission level for Valkey credentials." +enum ValkeyPermission { + "Read-only access." + READ + "Write-only access." + WRITE + "Read and write access." + READWRITE + "Administrative access." + ADMIN +} + enum ValkeyAccessOrderField { ACCESS WORKLOAD @@ -464,7 +476,7 @@ input CreateValkeyCredentialsInput { "Name of the Valkey instance." instanceName: String! "Permission level for the credentials." - permission: CredentialPermission! + permission: ValkeyPermission! "Time-to-live for the credentials (e.g. '1d', '7d'). Maximum 30 days." ttl: String! } @@ -486,3 +498,44 @@ type CreateValkeyCredentialsPayload { "The generated credentials." credentials: ValkeyCredentials! } + +type ValkeyCredentialsCreatedActivityLogEntry implements ActivityLogEntry & Node { + "ID of the entry." + id: ID! + + "The identity of the actor who performed the action." + actor: String! + + "Creation time of the entry." + createdAt: Time! + + "Message that summarizes the entry." + message: String! + + "Type of the resource that was affected by the action." + resourceType: ActivityLogEntryResourceType! + + "Name of the resource that was affected by the action." + resourceName: String! + + "The team slug that the entry belongs to." + teamSlug: Slug! + + "The environment name that the entry belongs to." + environmentName: String + + "Data associated with the credential creation." + data: ValkeyCredentialsCreatedActivityLogEntryData! +} + +type ValkeyCredentialsCreatedActivityLogEntryData { + "The permission level, if applicable." + permission: String + "The TTL that was requested for the credentials." + ttl: String! +} + +extend enum ActivityLogActivityType { + "Filter for credential creation events." + VALKEY_CREDENTIALS_CREATED +} diff --git a/internal/persistence/aivencredentials/activitylog.go b/internal/persistence/aivencredentials/activitylog.go deleted file mode 100644 index 45beeba50..000000000 --- a/internal/persistence/aivencredentials/activitylog.go +++ /dev/null @@ -1,47 +0,0 @@ -package aivencredentials - -import ( - "fmt" - - "github.com/nais/api/internal/activitylog" -) - -const ( - ActivityLogActivityTypeCredentialsCreated activitylog.ActivityLogActivityType = "CREDENTIALS_CREATED" - ActivityLogEntryActionCredentialsCreated activitylog.ActivityLogEntryAction = "CREDENTIALS_CREATED" -) - -func GetActivityLogEntry(entry activitylog.GenericActivityLogEntry) (activitylog.ActivityLogEntry, error) { - if entry.TeamSlug == nil { - return nil, fmt.Errorf("missing team slug for credentials activity log entry") - } - if entry.EnvironmentName == nil { - return nil, fmt.Errorf("missing environment name for credentials activity log entry") - } - data, err := activitylog.UnmarshalData[CredentialsActivityLogEntryData](entry) - if err != nil { - return nil, fmt.Errorf("transforming credentials activity log entry data: %w", err) - } - - msg := fmt.Sprintf("Created %s credentials for %s", entry.ResourceType, entry.ResourceName) - if data.Permission != "" { - msg += fmt.Sprintf(" with %s permission", data.Permission) - } - msg += fmt.Sprintf(" (TTL: %s)", data.TTL) - - return CredentialsActivityLogEntry{ - GenericActivityLogEntry: entry.WithMessage(msg), - Data: data, - }, nil -} - -type CredentialsActivityLogEntry struct { - activitylog.GenericActivityLogEntry - - Data *CredentialsActivityLogEntryData `json:"data"` -} - -type CredentialsActivityLogEntryData struct { - Permission string `json:"permission,omitempty"` - TTL string `json:"ttl"` -} diff --git a/internal/persistence/aivencredentials/models.go b/internal/persistence/aivencredentials/models.go index 5b3e3e4d7..b226f2bd9 100644 --- a/internal/persistence/aivencredentials/models.go +++ b/internal/persistence/aivencredentials/models.go @@ -6,7 +6,6 @@ import ( "strconv" ) -// CredentialPermission represents the permission level for OpenSearch and Valkey credentials. type CredentialPermission string const ( diff --git a/internal/persistence/aivencredentials/queries.go b/internal/persistence/aivencredentials/queries.go index 8729aec1d..a8da59a89 100644 --- a/internal/persistence/aivencredentials/queries.go +++ b/internal/persistence/aivencredentials/queries.go @@ -258,22 +258,3 @@ func parseTTL(ttl string, maxTTL time.Duration) (time.Duration, error) { } return d, nil } - -// LogCredentialCreation logs that credentials were created to the activity log. -func LogCredentialCreation(ctx context.Context, resourceType activitylog.ActivityLogEntryResourceType, req CredentialRequest) { - err := activitylog.Create(ctx, activitylog.CreateInput{ - Action: ActivityLogEntryActionCredentialsCreated, - Actor: authz.ActorFromContext(ctx).User, - ResourceType: resourceType, - ResourceName: req.InstanceName, - EnvironmentName: &req.EnvironmentName, - TeamSlug: &req.TeamSlug, - Data: CredentialsActivityLogEntryData{ - Permission: req.Permission, - TTL: req.TTL, - }, - }) - if err != nil { - fromContext(ctx).log.WithError(err).Warn("failed to create activity log entry") - } -} diff --git a/internal/persistence/kafkatopic/activitylog.go b/internal/persistence/kafkatopic/activitylog.go index 7dc8eac4f..6b0b9b807 100644 --- a/internal/persistence/kafkatopic/activitylog.go +++ b/internal/persistence/kafkatopic/activitylog.go @@ -1,9 +1,45 @@ package kafkatopic import ( + "fmt" + "github.com/nais/api/internal/activitylog" ) const ( ActivityLogEntryResourceTypeKafkaTopic activitylog.ActivityLogEntryResourceType = "KAFKA_TOPIC" ) + +func init() { + activitylog.RegisterTransformer(ActivityLogEntryResourceTypeKafkaTopic, func(entry activitylog.GenericActivityLogEntry) (activitylog.ActivityLogEntry, error) { + switch entry.Action { + case activitylog.ActivityLogEntryActionCredentialsCreated: + data, err := activitylog.UnmarshalData[KafkaCredentialsCreatedActivityLogEntryData](entry) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal Kafka credentials creation activity log entry data: %w", err) + } + + msg := fmt.Sprintf("Created credentials for %q", entry.ResourceName) + msg += fmt.Sprintf(" (TTL: %s)", data.TTL) + + return KafkaCredentialsCreatedActivityLogEntry{ + GenericActivityLogEntry: entry.WithMessage(msg), + Data: data, + }, nil + default: + return nil, fmt.Errorf("unsupported kafka topic activity log entry action: %q", entry.Action) + } + }) + + activitylog.RegisterFilter("KAFKA_CREDENTIALS_CREATED", activitylog.ActivityLogEntryActionCredentialsCreated, ActivityLogEntryResourceTypeKafkaTopic) +} + +type KafkaCredentialsCreatedActivityLogEntry struct { + activitylog.GenericActivityLogEntry + + Data *KafkaCredentialsCreatedActivityLogEntryData `json:"data"` +} + +type KafkaCredentialsCreatedActivityLogEntryData struct { + TTL string `json:"ttl"` +} diff --git a/internal/persistence/kafkatopic/dataloader.go b/internal/persistence/kafkatopic/dataloader.go index 52d08d70c..51ab6734a 100644 --- a/internal/persistence/kafkatopic/dataloader.go +++ b/internal/persistence/kafkatopic/dataloader.go @@ -4,6 +4,7 @@ import ( "context" "github.com/nais/api/internal/kubernetes/watcher" + "github.com/sirupsen/logrus" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -12,8 +13,8 @@ type ctxKey int const loadersKey ctxKey = iota -func NewLoaderContext(ctx context.Context, watcher *watcher.Watcher[*KafkaTopic]) context.Context { - return context.WithValue(ctx, loadersKey, newLoaders(watcher)) +func NewLoaderContext(ctx context.Context, watcher *watcher.Watcher[*KafkaTopic], logger logrus.FieldLogger) context.Context { + return context.WithValue(ctx, loadersKey, newLoaders(watcher, logger)) } func NewWatcher(ctx context.Context, mgr *watcher.Manager) *watcher.Watcher[*KafkaTopic] { @@ -38,10 +39,12 @@ func fromContext(ctx context.Context) *loaders { type loaders struct { watcher *watcher.Watcher[*KafkaTopic] + log logrus.FieldLogger } -func newLoaders(watcher *watcher.Watcher[*KafkaTopic]) *loaders { +func newLoaders(watcher *watcher.Watcher[*KafkaTopic], logger logrus.FieldLogger) *loaders { return &loaders{ watcher: watcher, + log: logger, } } diff --git a/internal/persistence/kafkatopic/queries.go b/internal/persistence/kafkatopic/queries.go index 9fb24c2ac..25f623ed4 100644 --- a/internal/persistence/kafkatopic/queries.go +++ b/internal/persistence/kafkatopic/queries.go @@ -5,6 +5,8 @@ import ( "strings" "time" + "github.com/nais/api/internal/activitylog" + "github.com/nais/api/internal/auth/authz" "github.com/nais/api/internal/graph/ident" "github.com/nais/api/internal/graph/model" "github.com/nais/api/internal/graph/pagination" @@ -75,7 +77,7 @@ func CreateKafkaCredentials(ctx context.Context, input CreateKafkaCredentialsInp "protected": true, "expiresAt": expiresAt.Format(time.RFC3339), "kafka": map[string]any{ - "pool": "nav-" + input.EnvironmentName, + "pool": "nav-" + input.EnvironmentName, // @TODO(chredvar): this will only work for Nav "secretName": secretName, }, } @@ -95,6 +97,20 @@ func CreateKafkaCredentials(ctx context.Context, input CreateKafkaCredentialsInp return nil, err } + if err = activitylog.Create(ctx, activitylog.CreateInput{ + Action: activitylog.ActivityLogEntryActionCredentialsCreated, + Actor: authz.ActorFromContext(ctx).User, + ResourceType: ActivityLogEntryResourceTypeKafkaTopic, + ResourceName: input.EnvironmentName, + EnvironmentName: &input.EnvironmentName, + TeamSlug: &input.TeamSlug, + Data: KafkaCredentialsCreatedActivityLogEntryData{ + TTL: input.TTL, + }, + }); err != nil { + fromContext(ctx).log.WithError(err).Warn("failed to create activity log entry for kafka credentials creation") + } + return &CreateKafkaCredentialsPayload{Credentials: result.(*KafkaCredentials)}, nil } diff --git a/internal/persistence/opensearch/activitylog.go b/internal/persistence/opensearch/activitylog.go index 0eb52c712..d60e27aeb 100644 --- a/internal/persistence/opensearch/activitylog.go +++ b/internal/persistence/opensearch/activitylog.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/nais/api/internal/activitylog" - "github.com/nais/api/internal/persistence/aivencredentials" servicemaintenanceal "github.com/nais/api/internal/servicemaintenance/activitylog" ) @@ -36,8 +35,22 @@ func init() { return servicemaintenanceal.ServiceMaintenanceActivityLogEntry{ GenericActivityLogEntry: entry.WithMessage("Started service maintenance"), }, nil - case aivencredentials.ActivityLogEntryActionCredentialsCreated: - return aivencredentials.GetActivityLogEntry(entry) + case activitylog.ActivityLogEntryActionCredentialsCreated: + data, err := activitylog.UnmarshalData[OpenSearchCredentialsCreatedActivityLogEntryData](entry) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal OpenSearch credentials creation activity log entry data: %w", err) + } + + msg := fmt.Sprintf("Created credentials for %q", entry.ResourceName) + if data.Permission != "" { + msg += fmt.Sprintf(" with %q permission", OpenSearchPermission(data.Permission).AivenAccess()) + } + msg += fmt.Sprintf(" (TTL: %s)", data.TTL) + + return OpenSearchCredentialsCreatedActivityLogEntry{ + GenericActivityLogEntry: entry.WithMessage(msg), + Data: data, + }, nil default: return nil, fmt.Errorf("unsupported opensearch activity log entry action: %q", entry.Action) } @@ -47,7 +60,7 @@ func init() { activitylog.RegisterFilter("OPENSEARCH_UPDATED", activitylog.ActivityLogEntryActionUpdated, ActivityLogEntryResourceTypeOpenSearch) activitylog.RegisterFilter("OPENSEARCH_DELETED", activitylog.ActivityLogEntryActionDeleted, ActivityLogEntryResourceTypeOpenSearch) activitylog.RegisterFilter("OPENSEARCH_MAINTENANCE_STARTED", servicemaintenanceal.ActivityLogEntryActionMaintenanceStarted, ActivityLogEntryResourceTypeOpenSearch) - activitylog.RegisterFilter(aivencredentials.ActivityLogActivityTypeCredentialsCreated, aivencredentials.ActivityLogEntryActionCredentialsCreated, ActivityLogEntryResourceTypeOpenSearch) + activitylog.RegisterFilter("OPENSEARCH_CREDENTIALS_CREATED", activitylog.ActivityLogEntryActionCredentialsCreated, ActivityLogEntryResourceTypeOpenSearch) } type OpenSearchCreatedActivityLogEntry struct { @@ -72,3 +85,14 @@ type OpenSearchUpdatedActivityLogEntryDataUpdatedField struct { type OpenSearchDeletedActivityLogEntry struct { activitylog.GenericActivityLogEntry } + +type OpenSearchCredentialsCreatedActivityLogEntry struct { + activitylog.GenericActivityLogEntry + + Data *OpenSearchCredentialsCreatedActivityLogEntryData `json:"data"` +} + +type OpenSearchCredentialsCreatedActivityLogEntryData struct { + Permission string `json:"permission,omitempty"` + TTL string `json:"ttl"` +} diff --git a/internal/persistence/opensearch/dataloader.go b/internal/persistence/opensearch/dataloader.go index 474d6deba..72a6ab567 100644 --- a/internal/persistence/opensearch/dataloader.go +++ b/internal/persistence/opensearch/dataloader.go @@ -52,6 +52,7 @@ type loaders struct { versionLoader *dataloadgen.Loader[*AivenDataLoaderKey, string] tenantName string aivenClient aiven.AivenClient + log logrus.FieldLogger } func newLoaders(tenantName string, watcher *watcher.Watcher[*OpenSearch], aivenClient aiven.AivenClient, logger logrus.FieldLogger) *loaders { @@ -67,6 +68,7 @@ func newLoaders(tenantName string, watcher *watcher.Watcher[*OpenSearch], aivenC tenantName: tenantName, versionLoader: dataloadgen.NewLoader(versionLoader.getVersions, loader.DefaultDataLoaderOptions...), aivenClient: aivenClient, + log: logger, } } diff --git a/internal/persistence/opensearch/models.go b/internal/persistence/opensearch/models.go index 48693e5ae..6ca38f8a3 100644 --- a/internal/persistence/opensearch/models.go +++ b/internal/persistence/opensearch/models.go @@ -33,6 +33,8 @@ type ( OpenSearchAccessEdge = pagination.Edge[*OpenSearchAccess] ) +type OpenSearchPermission = aivencredentials.CredentialPermission + type OpenSearchFilter struct { Name string `json:"name"` Environments []string `json:"environments"` @@ -675,9 +677,9 @@ type CreateOpenSearchCredentialsPayload struct { } type CreateOpenSearchCredentialsInput struct { - TeamSlug slug.Slug `json:"teamSlug"` - EnvironmentName string `json:"environmentName"` - InstanceName string `json:"instanceName"` - Permission aivencredentials.CredentialPermission `json:"permission"` - TTL string `json:"ttl"` + TeamSlug slug.Slug `json:"teamSlug"` + EnvironmentName string `json:"environmentName"` + InstanceName string `json:"instanceName"` + Permission OpenSearchPermission `json:"permission"` + TTL string `json:"ttl"` } diff --git a/internal/persistence/opensearch/queries.go b/internal/persistence/opensearch/queries.go index 4ea58893f..f29857ece 100644 --- a/internal/persistence/opensearch/queries.go +++ b/internal/persistence/opensearch/queries.go @@ -374,7 +374,23 @@ func CreateOpenSearchCredentials(ctx context.Context, input CreateOpenSearchCred if err != nil { return nil, err } - aivencredentials.LogCredentialCreation(ctx, ActivityLogEntryResourceTypeOpenSearch, req) + + err = activitylog.Create(ctx, activitylog.CreateInput{ + Action: activitylog.ActivityLogEntryActionCredentialsCreated, + Actor: authz.ActorFromContext(ctx).User, + ResourceType: ActivityLogEntryResourceTypeOpenSearch, + ResourceName: req.InstanceName, + EnvironmentName: &req.EnvironmentName, + TeamSlug: &req.TeamSlug, + Data: OpenSearchCredentialsCreatedActivityLogEntryData{ + Permission: req.Permission, + TTL: req.TTL, + }, + }) + if err != nil { + fromContext(ctx).log.WithError(err).Warn("failed to create activity log entry") + } + return &CreateOpenSearchCredentialsPayload{Credentials: result.(*OpenSearchCredentials)}, nil } diff --git a/internal/persistence/valkey/activitylog.go b/internal/persistence/valkey/activitylog.go index 2a944b10c..8c3247da7 100644 --- a/internal/persistence/valkey/activitylog.go +++ b/internal/persistence/valkey/activitylog.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/nais/api/internal/activitylog" - "github.com/nais/api/internal/persistence/aivencredentials" servicemaintenanceal "github.com/nais/api/internal/servicemaintenance/activitylog" ) @@ -37,8 +36,21 @@ func init() { return servicemaintenanceal.ServiceMaintenanceActivityLogEntry{ GenericActivityLogEntry: entry.WithMessage("Started service maintenance"), }, nil - case aivencredentials.ActivityLogEntryActionCredentialsCreated: - return aivencredentials.GetActivityLogEntry(entry) + case activitylog.ActivityLogEntryActionCredentialsCreated: + data, err := activitylog.UnmarshalData[ValkeyCredentialsCreatedActivityLogEntryData](entry) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal Valkey credentials creation activity log entry data: %w", err) + } + msg := fmt.Sprintf("Created credentials for %q", entry.ResourceName) + if data.Permission != "" { + msg += fmt.Sprintf(" with %q permission", ValkeyPermission(data.Permission).AivenAccess()) + } + msg += fmt.Sprintf(" (TTL: %s)", data.TTL) + + return ValkeyCredentialsCreatedActivityLogEntry{ + GenericActivityLogEntry: entry.WithMessage(msg), + Data: data, + }, nil default: return nil, fmt.Errorf("unsupported valkey activity log entry action: %q", entry.Action) } @@ -48,7 +60,7 @@ func init() { activitylog.RegisterFilter("VALKEY_UPDATED", activitylog.ActivityLogEntryActionUpdated, ActivityLogEntryResourceTypeValkey) activitylog.RegisterFilter("VALKEY_DELETED", activitylog.ActivityLogEntryActionDeleted, ActivityLogEntryResourceTypeValkey) activitylog.RegisterFilter("VALKEY_MAINTENANCE_STARTED", servicemaintenanceal.ActivityLogEntryActionMaintenanceStarted, ActivityLogEntryResourceTypeValkey) - activitylog.RegisterFilter(aivencredentials.ActivityLogActivityTypeCredentialsCreated, aivencredentials.ActivityLogEntryActionCredentialsCreated, ActivityLogEntryResourceTypeValkey) + activitylog.RegisterFilter("VALKEY_CREDENTIALS_CREATED", activitylog.ActivityLogEntryActionCredentialsCreated, ActivityLogEntryResourceTypeValkey) } type ValkeyCreatedActivityLogEntry struct { @@ -73,3 +85,14 @@ type ValkeyUpdatedActivityLogEntryDataUpdatedField struct { type ValkeyDeletedActivityLogEntry struct { activitylog.GenericActivityLogEntry } + +type ValkeyCredentialsCreatedActivityLogEntry struct { + activitylog.GenericActivityLogEntry + + Data *ValkeyCredentialsCreatedActivityLogEntryData `json:"data"` +} + +type ValkeyCredentialsCreatedActivityLogEntryData struct { + Permission string `json:"permission,omitempty"` + TTL string `json:"ttl"` +} diff --git a/internal/persistence/valkey/dataloader.go b/internal/persistence/valkey/dataloader.go index 81cc60a53..31f30a200 100644 --- a/internal/persistence/valkey/dataloader.go +++ b/internal/persistence/valkey/dataloader.go @@ -5,6 +5,7 @@ import ( "github.com/nais/api/internal/kubernetes/watcher" "github.com/nais/api/internal/thirdparty/aiven" + "github.com/sirupsen/logrus" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -13,8 +14,8 @@ type ctxKey int const loadersKey ctxKey = iota -func NewLoaderContext(ctx context.Context, tenantName string, valkeyWatcher *watcher.Watcher[*Valkey], aivenClient aiven.AivenClient) context.Context { - return context.WithValue(ctx, loadersKey, newLoaders(tenantName, valkeyWatcher, aivenClient)) +func NewLoaderContext(ctx context.Context, tenantName string, valkeyWatcher *watcher.Watcher[*Valkey], aivenClient aiven.AivenClient, logger logrus.FieldLogger) context.Context { + return context.WithValue(ctx, loadersKey, newLoaders(tenantName, valkeyWatcher, aivenClient, logger)) } func NewWatcher(ctx context.Context, mgr *watcher.Manager) *watcher.Watcher[*Valkey] { @@ -42,9 +43,10 @@ type loaders struct { tenantName string watcher *watcher.Watcher[*Valkey] aivenClient aiven.AivenClient + log logrus.FieldLogger } -func newLoaders(tenantName string, watcher *watcher.Watcher[*Valkey], aivenClient aiven.AivenClient) *loaders { +func newLoaders(tenantName string, watcher *watcher.Watcher[*Valkey], aivenClient aiven.AivenClient, logger logrus.FieldLogger) *loaders { client := &client{ watcher: watcher, } @@ -54,5 +56,6 @@ func newLoaders(tenantName string, watcher *watcher.Watcher[*Valkey], aivenClien tenantName: tenantName, watcher: watcher, aivenClient: aivenClient, + log: logger, } } diff --git a/internal/persistence/valkey/models.go b/internal/persistence/valkey/models.go index 5779bf9c7..2b18eb851 100644 --- a/internal/persistence/valkey/models.go +++ b/internal/persistence/valkey/models.go @@ -30,6 +30,8 @@ type ( ValkeyAccessEdge = pagination.Edge[*ValkeyAccess] ) +type ValkeyPermission = aivencredentials.CredentialPermission + type ValkeyFilter struct { Name string `json:"name"` Environments []string `json:"environments"` @@ -577,11 +579,11 @@ func (e ValkeyState) MarshalGQL(w io.Writer) { } type CreateValkeyCredentialsInput struct { - TeamSlug slug.Slug `json:"teamSlug"` - EnvironmentName string `json:"environmentName"` - InstanceName string `json:"instanceName"` - Permission aivencredentials.CredentialPermission `json:"permission"` - TTL string `json:"ttl"` + TeamSlug slug.Slug `json:"teamSlug"` + EnvironmentName string `json:"environmentName"` + InstanceName string `json:"instanceName"` + Permission ValkeyPermission `json:"permission"` + TTL string `json:"ttl"` } type ValkeyCredentials struct { diff --git a/internal/persistence/valkey/queries.go b/internal/persistence/valkey/queries.go index d46aa21f8..9d5a4ac0f 100644 --- a/internal/persistence/valkey/queries.go +++ b/internal/persistence/valkey/queries.go @@ -364,7 +364,23 @@ func CreateValkeyCredentials(ctx context.Context, input CreateValkeyCredentialsI if err != nil { return nil, err } - aivencredentials.LogCredentialCreation(ctx, ActivityLogEntryResourceTypeValkey, req) + + err = activitylog.Create(ctx, activitylog.CreateInput{ + Action: activitylog.ActivityLogEntryActionCredentialsCreated, + Actor: authz.ActorFromContext(ctx).User, + ResourceType: ActivityLogEntryResourceTypeValkey, + ResourceName: req.InstanceName, + EnvironmentName: &req.EnvironmentName, + TeamSlug: &req.TeamSlug, + Data: ValkeyCredentialsCreatedActivityLogEntryData{ + Permission: req.Permission, + TTL: req.TTL, + }, + }) + if err != nil { + fromContext(ctx).log.WithError(err).Warn("failed to create activity log entry") + } + return &CreateValkeyCredentialsPayload{Credentials: result.(*ValkeyCredentials)}, nil }