diff options
Diffstat (limited to 'app/graphql')
-rw-r--r-- | app/graphql/mutations/clusters/agent_tokens/revoke.rb | 35 | ||||
-rw-r--r-- | app/graphql/types/mutation_type.rb | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/app/graphql/mutations/clusters/agent_tokens/revoke.rb b/app/graphql/mutations/clusters/agent_tokens/revoke.rb new file mode 100644 index 00000000000..ca570792296 --- /dev/null +++ b/app/graphql/mutations/clusters/agent_tokens/revoke.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Mutations + module Clusters + module AgentTokens + class Revoke < BaseMutation + graphql_name 'ClusterAgentTokenRevoke' + + authorize :admin_cluster + + TokenID = ::Types::GlobalIDType[::Clusters::AgentToken] + + argument :id, TokenID, + required: true, + description: 'Global ID of the agent token that will be revoked.' + + def resolve(id:) + token = authorized_find!(id: id) + token.update(status: token.class.statuses[:revoked]) + + { errors: errors_on_object(token) } + end + + private + + def find_object(id:) + # TODO: remove this line when the compatibility layer is removed + # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 + id = TokenID.coerce_isolated_input(id) + GitlabSchema.find_by_gid(id) + end + end + end + end +end diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb index 9bba0e1bb37..c9f083efd27 100644 --- a/app/graphql/types/mutation_type.rb +++ b/app/graphql/types/mutation_type.rb @@ -36,6 +36,7 @@ module Types mount_mutation Mutations::Clusters::Agents::Delete mount_mutation Mutations::Clusters::AgentTokens::Create mount_mutation Mutations::Clusters::AgentTokens::Delete + mount_mutation Mutations::Clusters::AgentTokens::Revoke mount_mutation Mutations::Commits::Create, calls_gitaly: true mount_mutation Mutations::CustomEmoji::Create, feature_flag: :custom_emoji mount_mutation Mutations::CustomEmoji::Destroy, feature_flag: :custom_emoji |