Skip to content

Commit

Permalink
feat: add service accounts to app card
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan-chaturvedi committed Oct 26, 2024
1 parent 7fd2a7a commit 86180d5
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 95 deletions.
100 changes: 52 additions & 48 deletions backend/backend/graphene/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,54 @@ class Meta:
)


class ServiceAccountHandlerType(DjangoObjectType):
class Meta:
model = ServiceAccountHandler
fields = "__all__"


class ServiceAccountTokenType(DjangoObjectType):
class Meta:
model = ServiceAccountToken
fields = "__all__"


class MemberType(graphene.Enum):
USER = "user"
SERVICE = "service"


class ServiceAccountType(DjangoObjectType):

third_party_auth_enabled = graphene.Boolean()
handlers = graphene.List(ServiceAccountHandlerType)
tokens = graphene.List(ServiceAccountTokenType)

class Meta:
model = ServiceAccount
fields = (
"id",
"name",
"role",
"apps",
"identity_key",
"created_at",
"updated_at",
)

def resolve_third_party_auth_enabled(self, info):
return (
self.server_wrapped_keyring is not None
and self.server_wrapped_recovery is not None
)

def resolve_handlers(self, info):
return ServiceAccountHandler.objects.filter(service_account=self)

def resolve_tokens(self, info):
return ServiceAccountToken.objects.filter(service_account=self)


class ProviderType(graphene.ObjectType):
id = graphene.String(required=True)
name = graphene.String(required=True)
Expand Down Expand Up @@ -322,6 +370,7 @@ def resolve_syncs(self, info):
class AppType(DjangoObjectType):
environments = graphene.NonNull(graphene.List(EnvironmentType))
members = graphene.NonNull(graphene.List(OrganisationMemberType))
service_accounts = graphene.NonNull(graphene.List(ServiceAccountType))

class Meta:
model = App
Expand Down Expand Up @@ -357,6 +406,9 @@ def resolve_environments(self, info):
def resolve_members(self, info):
return self.members.filter(deleted_at=None)

def resolve_service_accounts(self, info):
return self.service_accounts.filter(deleted_at=None)


class EnvironmentKeyType(DjangoObjectType):
class Meta:
Expand Down Expand Up @@ -460,54 +512,6 @@ class Meta:
)


class ServiceAccountHandlerType(DjangoObjectType):
class Meta:
model = ServiceAccountHandler
fields = "__all__"


class ServiceAccountTokenType(DjangoObjectType):
class Meta:
model = ServiceAccountToken
fields = "__all__"


class MemberType(graphene.Enum):
USER = "user"
SERVICE = "service"


class ServiceAccountType(DjangoObjectType):

third_party_auth_enabled = graphene.Boolean()
handlers = graphene.List(ServiceAccountHandlerType)
tokens = graphene.List(ServiceAccountTokenType)

class Meta:
model = ServiceAccount
fields = (
"id",
"name",
"role",
"apps",
"identity_key",
"created_at",
"updated_at",
)

def resolve_third_party_auth_enabled(self, info):
return (
self.server_wrapped_keyring is not None
and self.server_wrapped_recovery is not None
)

def resolve_handlers(self, info):
return ServiceAccountHandler.objects.filter(service_account=self)

def resolve_tokens(self, info):
return ServiceAccountToken.objects.filter(service_account=self)


class SecretFolderType(DjangoObjectType):
folder_count = graphene.Int()
secret_count = graphene.Int()
Expand Down
4 changes: 2 additions & 2 deletions frontend/apollo/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const documents = {
"query GetAppActivityChart($appId: ID!, $period: TimeRange) {\n appActivityChart(appId: $appId, period: $period) {\n index\n date\n data\n }\n}": types.GetAppActivityChartDocument,
"query GetAppDetail($organisationId: ID!, $appId: ID!) {\n apps(organisationId: $organisationId, appId: $appId) {\n id\n name\n identityKey\n createdAt\n appToken\n appSeed\n appVersion\n sseEnabled\n }\n}": types.GetAppDetailDocument,
"query GetAppKmsLogs($appId: ID!, $start: BigInt, $end: BigInt) {\n logs(appId: $appId, start: $start, end: $end) {\n kms {\n id\n timestamp\n phaseNode\n eventType\n ipAddress\n country\n city\n phSize\n }\n }\n kmsLogsCount(appId: $appId)\n}": types.GetAppKmsLogsDocument,
"query GetApps($organisationId: ID!, $appId: ID) {\n apps(organisationId: $organisationId, appId: $appId) {\n id\n name\n identityKey\n createdAt\n sseEnabled\n members {\n id\n email\n fullName\n avatarUrl\n }\n environments {\n id\n name\n envType\n syncs {\n id\n serviceInfo {\n id\n name\n provider {\n id\n name\n }\n }\n status\n }\n }\n }\n}": types.GetAppsDocument,
"query GetApps($organisationId: ID!, $appId: ID) {\n apps(organisationId: $organisationId, appId: $appId) {\n id\n name\n identityKey\n createdAt\n sseEnabled\n members {\n id\n email\n fullName\n avatarUrl\n }\n serviceAccounts {\n id\n name\n }\n environments {\n id\n name\n envType\n syncs {\n id\n serviceInfo {\n id\n name\n provider {\n id\n name\n }\n }\n status\n }\n }\n }\n}": types.GetAppsDocument,
"query GetDashboard($organisationId: ID!) {\n apps(organisationId: $organisationId) {\n id\n sseEnabled\n }\n userTokens(organisationId: $organisationId) {\n id\n }\n organisationInvites(orgId: $organisationId) {\n id\n }\n organisationMembers(organisationId: $organisationId, role: null) {\n id\n }\n savedCredentials(orgId: $organisationId) {\n id\n }\n syncs(orgId: $organisationId) {\n id\n }\n}": types.GetDashboardDocument,
"query GetOrganisations {\n organisations {\n id\n name\n identityKey\n createdAt\n plan\n planDetail {\n name\n maxUsers\n maxApps\n maxEnvsPerApp\n userCount\n appCount\n }\n role {\n name\n description\n color\n permissions\n }\n memberId\n keyring\n recovery\n }\n}": types.GetOrganisationsDocument,
"query CheckOrganisationNameAvailability($name: String!) {\n organisationNameAvailable(name: $name)\n}": types.CheckOrganisationNameAvailabilityDocument,
Expand Down Expand Up @@ -389,7 +389,7 @@ export function graphql(source: "query GetAppKmsLogs($appId: ID!, $start: BigInt
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "query GetApps($organisationId: ID!, $appId: ID) {\n apps(organisationId: $organisationId, appId: $appId) {\n id\n name\n identityKey\n createdAt\n sseEnabled\n members {\n id\n email\n fullName\n avatarUrl\n }\n environments {\n id\n name\n envType\n syncs {\n id\n serviceInfo {\n id\n name\n provider {\n id\n name\n }\n }\n status\n }\n }\n }\n}"): (typeof documents)["query GetApps($organisationId: ID!, $appId: ID) {\n apps(organisationId: $organisationId, appId: $appId) {\n id\n name\n identityKey\n createdAt\n sseEnabled\n members {\n id\n email\n fullName\n avatarUrl\n }\n environments {\n id\n name\n envType\n syncs {\n id\n serviceInfo {\n id\n name\n provider {\n id\n name\n }\n }\n status\n }\n }\n }\n}"];
export function graphql(source: "query GetApps($organisationId: ID!, $appId: ID) {\n apps(organisationId: $organisationId, appId: $appId) {\n id\n name\n identityKey\n createdAt\n sseEnabled\n members {\n id\n email\n fullName\n avatarUrl\n }\n serviceAccounts {\n id\n name\n }\n environments {\n id\n name\n envType\n syncs {\n id\n serviceInfo {\n id\n name\n provider {\n id\n name\n }\n }\n status\n }\n }\n }\n}"): (typeof documents)["query GetApps($organisationId: ID!, $appId: ID) {\n apps(organisationId: $organisationId, appId: $appId) {\n id\n name\n identityKey\n createdAt\n sseEnabled\n members {\n id\n email\n fullName\n avatarUrl\n }\n serviceAccounts {\n id\n name\n }\n environments {\n id\n name\n envType\n syncs {\n id\n serviceInfo {\n id\n name\n provider {\n id\n name\n }\n }\n status\n }\n }\n }\n}"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
Expand Down
Loading

0 comments on commit 86180d5

Please sign in to comment.