From 4dc8fbda55aeab8ed0a2ee99b730e9c4a8437c6c Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Fri, 2 Jan 2026 17:03:00 +0100 Subject: [PATCH] Remove iam unused types Signed-off-by: Bryan Frimin --- pkg/server/api/connect/v1/schema.graphql | 49 --- pkg/server/api/connect/v1/schema/schema.go | 409 --------------------- pkg/server/api/connect/v1/types/types.go | 267 -------------- 3 files changed, 725 deletions(-) diff --git a/pkg/server/api/connect/v1/schema.graphql b/pkg/server/api/connect/v1/schema.graphql index 90b7589d3..86560b30f 100644 --- a/pkg/server/api/connect/v1/schema.graphql +++ b/pkg/server/api/connect/v1/schema.graphql @@ -292,13 +292,6 @@ type PersonalAPIKey implements Node { @session(required: PRESENT) } -type Application { - id: ApplicationId! - name: String! - description: String! - availableAccessLevels: [AccessLevel!]! -} - type SAMLConfiguration implements Node { id: ID! emailDomain: String! @@ -332,28 +325,6 @@ type SSOAvailability { organizationId: ID } -enum ApplicationId { - CONSOLE - COMPLIANCE - RISK - VENDOR - DOCUMENTS - TRUST_CENTER - SETTINGS - API -} - -enum AccessLevel { - READ - WRITE - ADMIN -} - -enum PrincipalType { - IDENTITY - SERVICE_ACCOUNT -} - enum InvitationStatus @goModel(model: "go.probo.inc/probo/pkg/coredata.InvitationStatus") { PENDING @@ -377,22 +348,6 @@ enum SAMLEnforcementPolicy ) } -enum TokenScope { - READ_ORGANIZATION - WRITE_ORGANIZATION - READ_COMPLIANCE - WRITE_COMPLIANCE - READ_RISK - WRITE_RISK - READ_VENDOR - WRITE_VENDOR - READ_DOCUMENTS - WRITE_DOCUMENTS - READ_TRUST_CENTER - WRITE_TRUST_CENTER - ADMIN -} - enum ReauthenticationReason { SESSION_EXPIRED SENSITIVE_ACTION @@ -723,10 +678,6 @@ type AssumeOrganizationSessionPayload { result: AssumeOrganizationSessionResult! } -type DeactivateAccountPayload { - success: Boolean! -} - type RevokeSessionPayload { success: Boolean! } diff --git a/pkg/server/api/connect/v1/schema/schema.go b/pkg/server/api/connect/v1/schema/schema.go index 53dc9f903..f964bfedd 100644 --- a/pkg/server/api/connect/v1/schema/schema.go +++ b/pkg/server/api/connect/v1/schema/schema.go @@ -73,13 +73,6 @@ type ComplexityRoot struct { MembershipEdge func(childComplexity int) int } - Application struct { - AvailableAccessLevels func(childComplexity int) int - Description func(childComplexity int) int - ID func(childComplexity int) int - Name func(childComplexity int) int - } - AssumeOrganizationSessionPayload struct { Result func(childComplexity int) int } @@ -106,10 +99,6 @@ type ComplexityRoot struct { SamlConfigurationEdge func(childComplexity int) int } - DeactivateAccountPayload struct { - Success func(childComplexity int) int - } - DeleteInvitationPayload struct { DeletedInvitationID func(childComplexity int) int } @@ -534,31 +523,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.AcceptInvitationPayload.MembershipEdge(childComplexity), true - case "Application.availableAccessLevels": - if e.complexity.Application.AvailableAccessLevels == nil { - break - } - - return e.complexity.Application.AvailableAccessLevels(childComplexity), true - case "Application.description": - if e.complexity.Application.Description == nil { - break - } - - return e.complexity.Application.Description(childComplexity), true - case "Application.id": - if e.complexity.Application.ID == nil { - break - } - - return e.complexity.Application.ID(childComplexity), true - case "Application.name": - if e.complexity.Application.Name == nil { - break - } - - return e.complexity.Application.Name(childComplexity), true - case "AssumeOrganizationSessionPayload.result": if e.complexity.AssumeOrganizationSessionPayload.Result == nil { break @@ -613,13 +577,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.CreateSAMLConfigurationPayload.SamlConfigurationEdge(childComplexity), true - case "DeactivateAccountPayload.success": - if e.complexity.DeactivateAccountPayload.Success == nil { - break - } - - return e.complexity.DeactivateAccountPayload.Success(childComplexity), true - case "DeleteInvitationPayload.deletedInvitationId": if e.complexity.DeleteInvitationPayload.DeletedInvitationID == nil { break @@ -2299,13 +2256,6 @@ type PersonalAPIKey implements Node { @session(required: PRESENT) } -type Application { - id: ApplicationId! - name: String! - description: String! - availableAccessLevels: [AccessLevel!]! -} - type SAMLConfiguration implements Node { id: ID! emailDomain: String! @@ -2339,28 +2289,6 @@ type SSOAvailability { organizationId: ID } -enum ApplicationId { - CONSOLE - COMPLIANCE - RISK - VENDOR - DOCUMENTS - TRUST_CENTER - SETTINGS - API -} - -enum AccessLevel { - READ - WRITE - ADMIN -} - -enum PrincipalType { - IDENTITY - SERVICE_ACCOUNT -} - enum InvitationStatus @goModel(model: "go.probo.inc/probo/pkg/coredata.InvitationStatus") { PENDING @@ -2384,22 +2312,6 @@ enum SAMLEnforcementPolicy ) } -enum TokenScope { - READ_ORGANIZATION - WRITE_ORGANIZATION - READ_COMPLIANCE - WRITE_COMPLIANCE - READ_RISK - WRITE_RISK - READ_VENDOR - WRITE_VENDOR - READ_DOCUMENTS - WRITE_DOCUMENTS - READ_TRUST_CENTER - WRITE_TRUST_CENTER - ADMIN -} - enum ReauthenticationReason { SESSION_EXPIRED SENSITIVE_ACTION @@ -2730,10 +2642,6 @@ type AssumeOrganizationSessionPayload { result: AssumeOrganizationSessionResult! } -type DeactivateAccountPayload { - success: Boolean! -} - type RevokeSessionPayload { success: Boolean! } @@ -3502,122 +3410,6 @@ func (ec *executionContext) fieldContext_AcceptInvitationPayload_membershipEdge( return fc, nil } -func (ec *executionContext) _Application_id(ctx context.Context, field graphql.CollectedField, obj *types.Application) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Application_id, - func(ctx context.Context) (any, error) { - return obj.ID, nil - }, - nil, - ec.marshalNApplicationId2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐApplicationID, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Application_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Application", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ApplicationId does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Application_name(ctx context.Context, field graphql.CollectedField, obj *types.Application) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Application_name, - func(ctx context.Context) (any, error) { - return obj.Name, nil - }, - nil, - ec.marshalNString2string, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Application_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Application", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Application_description(ctx context.Context, field graphql.CollectedField, obj *types.Application) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Application_description, - func(ctx context.Context) (any, error) { - return obj.Description, nil - }, - nil, - ec.marshalNString2string, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Application_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Application", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Application_availableAccessLevels(ctx context.Context, field graphql.CollectedField, obj *types.Application) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Application_availableAccessLevels, - func(ctx context.Context) (any, error) { - return obj.AvailableAccessLevels, nil - }, - nil, - ec.marshalNAccessLevel2ᚕgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐAccessLevelᚄ, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Application_availableAccessLevels(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Application", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type AccessLevel does not have child fields") - }, - } - return fc, nil -} - func (ec *executionContext) _AssumeOrganizationSessionPayload_result(ctx context.Context, field graphql.CollectedField, obj *types.AssumeOrganizationSessionPayload) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -3900,35 +3692,6 @@ func (ec *executionContext) fieldContext_CreateSAMLConfigurationPayload_samlConf return fc, nil } -func (ec *executionContext) _DeactivateAccountPayload_success(ctx context.Context, field graphql.CollectedField, obj *types.DeactivateAccountPayload) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_DeactivateAccountPayload_success, - func(ctx context.Context) (any, error) { - return obj.Success, nil - }, - nil, - ec.marshalNBoolean2bool, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_DeactivateAccountPayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "DeactivateAccountPayload", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - func (ec *executionContext) _DeleteInvitationPayload_deletedInvitationId(ctx context.Context, field graphql.CollectedField, obj *types.DeleteInvitationPayload) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -13544,60 +13307,6 @@ func (ec *executionContext) _AcceptInvitationPayload(ctx context.Context, sel as return out } -var applicationImplementors = []string{"Application"} - -func (ec *executionContext) _Application(ctx context.Context, sel ast.SelectionSet, obj *types.Application) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, applicationImplementors) - - 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("Application") - case "id": - out.Values[i] = ec._Application_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "name": - out.Values[i] = ec._Application_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "description": - out.Values[i] = ec._Application_description(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "availableAccessLevels": - out.Values[i] = ec._Application_availableAccessLevels(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(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - var assumeOrganizationSessionPayloadImplementors = []string{"AssumeOrganizationSessionPayload"} func (ec *executionContext) _AssumeOrganizationSessionPayload(ctx context.Context, sel ast.SelectionSet, obj *types.AssumeOrganizationSessionPayload) graphql.Marshaler { @@ -13839,45 +13548,6 @@ func (ec *executionContext) _CreateSAMLConfigurationPayload(ctx context.Context, return out } -var deactivateAccountPayloadImplementors = []string{"DeactivateAccountPayload"} - -func (ec *executionContext) _DeactivateAccountPayload(ctx context.Context, sel ast.SelectionSet, obj *types.DeactivateAccountPayload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, deactivateAccountPayloadImplementors) - - 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("DeactivateAccountPayload") - case "success": - out.Values[i] = ec._DeactivateAccountPayload_success(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(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - var deleteInvitationPayloadImplementors = []string{"DeleteInvitationPayload"} func (ec *executionContext) _DeleteInvitationPayload(ctx context.Context, sel ast.SelectionSet, obj *types.DeleteInvitationPayload) graphql.Marshaler { @@ -17476,85 +17146,6 @@ func (ec *executionContext) unmarshalNAcceptInvitationInput2goᚗproboᚗincᚋp return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNAccessLevel2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐAccessLevel(ctx context.Context, v any) (types.AccessLevel, error) { - var res types.AccessLevel - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNAccessLevel2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐAccessLevel(ctx context.Context, sel ast.SelectionSet, v types.AccessLevel) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalNAccessLevel2ᚕgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐAccessLevelᚄ(ctx context.Context, v any) ([]types.AccessLevel, error) { - var vSlice []any - vSlice = graphql.CoerceList(v) - var err error - res := make([]types.AccessLevel, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNAccessLevel2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐAccessLevel(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalNAccessLevel2ᚕgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐAccessLevelᚄ(ctx context.Context, sel ast.SelectionSet, v []types.AccessLevel) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAccessLevel2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐAccessLevel(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalNApplicationId2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐApplicationID(ctx context.Context, v any) (types.ApplicationID, error) { - var res types.ApplicationID - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNApplicationId2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐApplicationID(ctx context.Context, sel ast.SelectionSet, v types.ApplicationID) graphql.Marshaler { - return v -} - func (ec *executionContext) unmarshalNAssumeOrganizationSessionInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconnectᚋv1ᚋtypesᚐAssumeOrganizationSessionInput(ctx context.Context, v any) (types.AssumeOrganizationSessionInput, error) { res, err := ec.unmarshalInputAssumeOrganizationSessionInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) diff --git a/pkg/server/api/connect/v1/types/types.go b/pkg/server/api/connect/v1/types/types.go index 82b4c5e8d..aa01503de 100644 --- a/pkg/server/api/connect/v1/types/types.go +++ b/pkg/server/api/connect/v1/types/types.go @@ -33,13 +33,6 @@ type AcceptInvitationPayload struct { MembershipEdge *MembershipEdge `json:"membershipEdge"` } -type Application struct { - ID ApplicationID `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - AvailableAccessLevels []AccessLevel `json:"availableAccessLevels"` -} - type AssumeOrganizationSessionInput struct { OrganizationID gid.GID `json:"organizationId"` } @@ -101,10 +94,6 @@ type CreateSAMLConfigurationPayload struct { SamlConfigurationEdge *SAMLConfigurationEdge `json:"samlConfigurationEdge"` } -type DeactivateAccountPayload struct { - Success bool `json:"success"` -} - type DeleteInvitationInput struct { OrganizationID gid.GID `json:"organizationId"` InvitationID gid.GID `json:"invitationId"` @@ -485,185 +474,6 @@ type VerifyEmailPayload struct { Success bool `json:"success"` } -type AccessLevel string - -const ( - AccessLevelRead AccessLevel = "READ" - AccessLevelWrite AccessLevel = "WRITE" - AccessLevelAdmin AccessLevel = "ADMIN" -) - -var AllAccessLevel = []AccessLevel{ - AccessLevelRead, - AccessLevelWrite, - AccessLevelAdmin, -} - -func (e AccessLevel) IsValid() bool { - switch e { - case AccessLevelRead, AccessLevelWrite, AccessLevelAdmin: - return true - } - return false -} - -func (e AccessLevel) String() string { - return string(e) -} - -func (e *AccessLevel) UnmarshalGQL(v any) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("enums must be strings") - } - - *e = AccessLevel(str) - if !e.IsValid() { - return fmt.Errorf("%s is not a valid AccessLevel", str) - } - return nil -} - -func (e AccessLevel) MarshalGQL(w io.Writer) { - fmt.Fprint(w, strconv.Quote(e.String())) -} - -func (e *AccessLevel) UnmarshalJSON(b []byte) error { - s, err := strconv.Unquote(string(b)) - if err != nil { - return err - } - return e.UnmarshalGQL(s) -} - -func (e AccessLevel) MarshalJSON() ([]byte, error) { - var buf bytes.Buffer - e.MarshalGQL(&buf) - return buf.Bytes(), nil -} - -type ApplicationID string - -const ( - ApplicationIDConsole ApplicationID = "CONSOLE" - ApplicationIDCompliance ApplicationID = "COMPLIANCE" - ApplicationIDRisk ApplicationID = "RISK" - ApplicationIDVendor ApplicationID = "VENDOR" - ApplicationIDDocuments ApplicationID = "DOCUMENTS" - ApplicationIDTrustCenter ApplicationID = "TRUST_CENTER" - ApplicationIDSettings ApplicationID = "SETTINGS" - ApplicationIDAPI ApplicationID = "API" -) - -var AllApplicationID = []ApplicationID{ - ApplicationIDConsole, - ApplicationIDCompliance, - ApplicationIDRisk, - ApplicationIDVendor, - ApplicationIDDocuments, - ApplicationIDTrustCenter, - ApplicationIDSettings, - ApplicationIDAPI, -} - -func (e ApplicationID) IsValid() bool { - switch e { - case ApplicationIDConsole, ApplicationIDCompliance, ApplicationIDRisk, ApplicationIDVendor, ApplicationIDDocuments, ApplicationIDTrustCenter, ApplicationIDSettings, ApplicationIDAPI: - return true - } - return false -} - -func (e ApplicationID) String() string { - return string(e) -} - -func (e *ApplicationID) UnmarshalGQL(v any) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("enums must be strings") - } - - *e = ApplicationID(str) - if !e.IsValid() { - return fmt.Errorf("%s is not a valid ApplicationId", str) - } - return nil -} - -func (e ApplicationID) MarshalGQL(w io.Writer) { - fmt.Fprint(w, strconv.Quote(e.String())) -} - -func (e *ApplicationID) UnmarshalJSON(b []byte) error { - s, err := strconv.Unquote(string(b)) - if err != nil { - return err - } - return e.UnmarshalGQL(s) -} - -func (e ApplicationID) MarshalJSON() ([]byte, error) { - var buf bytes.Buffer - e.MarshalGQL(&buf) - return buf.Bytes(), nil -} - -type PrincipalType string - -const ( - PrincipalTypeIdentity PrincipalType = "IDENTITY" - PrincipalTypeServiceAccount PrincipalType = "SERVICE_ACCOUNT" -) - -var AllPrincipalType = []PrincipalType{ - PrincipalTypeIdentity, - PrincipalTypeServiceAccount, -} - -func (e PrincipalType) IsValid() bool { - switch e { - case PrincipalTypeIdentity, PrincipalTypeServiceAccount: - return true - } - return false -} - -func (e PrincipalType) String() string { - return string(e) -} - -func (e *PrincipalType) UnmarshalGQL(v any) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("enums must be strings") - } - - *e = PrincipalType(str) - if !e.IsValid() { - return fmt.Errorf("%s is not a valid PrincipalType", str) - } - return nil -} - -func (e PrincipalType) MarshalGQL(w io.Writer) { - fmt.Fprint(w, strconv.Quote(e.String())) -} - -func (e *PrincipalType) UnmarshalJSON(b []byte) error { - s, err := strconv.Unquote(string(b)) - if err != nil { - return err - } - return e.UnmarshalGQL(s) -} - -func (e PrincipalType) MarshalJSON() ([]byte, error) { - var buf bytes.Buffer - e.MarshalGQL(&buf) - return buf.Bytes(), nil -} - type ReauthenticationReason string const ( @@ -777,80 +587,3 @@ func (e SessionRequirement) MarshalJSON() ([]byte, error) { e.MarshalGQL(&buf) return buf.Bytes(), nil } - -type TokenScope string - -const ( - TokenScopeReadOrganization TokenScope = "READ_ORGANIZATION" - TokenScopeWriteOrganization TokenScope = "WRITE_ORGANIZATION" - TokenScopeReadCompliance TokenScope = "READ_COMPLIANCE" - TokenScopeWriteCompliance TokenScope = "WRITE_COMPLIANCE" - TokenScopeReadRisk TokenScope = "READ_RISK" - TokenScopeWriteRisk TokenScope = "WRITE_RISK" - TokenScopeReadVendor TokenScope = "READ_VENDOR" - TokenScopeWriteVendor TokenScope = "WRITE_VENDOR" - TokenScopeReadDocuments TokenScope = "READ_DOCUMENTS" - TokenScopeWriteDocuments TokenScope = "WRITE_DOCUMENTS" - TokenScopeReadTrustCenter TokenScope = "READ_TRUST_CENTER" - TokenScopeWriteTrustCenter TokenScope = "WRITE_TRUST_CENTER" - TokenScopeAdmin TokenScope = "ADMIN" -) - -var AllTokenScope = []TokenScope{ - TokenScopeReadOrganization, - TokenScopeWriteOrganization, - TokenScopeReadCompliance, - TokenScopeWriteCompliance, - TokenScopeReadRisk, - TokenScopeWriteRisk, - TokenScopeReadVendor, - TokenScopeWriteVendor, - TokenScopeReadDocuments, - TokenScopeWriteDocuments, - TokenScopeReadTrustCenter, - TokenScopeWriteTrustCenter, - TokenScopeAdmin, -} - -func (e TokenScope) IsValid() bool { - switch e { - case TokenScopeReadOrganization, TokenScopeWriteOrganization, TokenScopeReadCompliance, TokenScopeWriteCompliance, TokenScopeReadRisk, TokenScopeWriteRisk, TokenScopeReadVendor, TokenScopeWriteVendor, TokenScopeReadDocuments, TokenScopeWriteDocuments, TokenScopeReadTrustCenter, TokenScopeWriteTrustCenter, TokenScopeAdmin: - return true - } - return false -} - -func (e TokenScope) String() string { - return string(e) -} - -func (e *TokenScope) UnmarshalGQL(v any) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("enums must be strings") - } - - *e = TokenScope(str) - if !e.IsValid() { - return fmt.Errorf("%s is not a valid TokenScope", str) - } - return nil -} - -func (e TokenScope) MarshalGQL(w io.Writer) { - fmt.Fprint(w, strconv.Quote(e.String())) -} - -func (e *TokenScope) UnmarshalJSON(b []byte) error { - s, err := strconv.Unquote(string(b)) - if err != nil { - return err - } - return e.UnmarshalGQL(s) -} - -func (e TokenScope) MarshalJSON() ([]byte, error) { - var buf bytes.Buffer - e.MarshalGQL(&buf) - return buf.Bytes(), nil -}