Class: Types::Ci::JobTokenScope::AllowlistEntryType

Inherits:
BaseObject
  • Object
show all
Defined in:
app/graphql/types/ci/job_token_scope/allowlist_entry_type.rb

Overview

rubocop: disable Graphql/AuthorizeTypes – Authorization is handled by parent class

Instance Method Summary collapse

Methods inherited from BaseObject

accepts, assignable?, authorization, authorization_scopes, authorize, authorized?, #current_user, #id

Methods included from Gitlab::Graphql::Present

#present, #unpresented

Instance Method Details

#directionObject



57
58
59
60
61
62
63
64
# File 'app/graphql/types/ci/job_token_scope/allowlist_entry_type.rb', line 57

def direction
  case object
  when ::Ci::JobToken::ProjectScopeLink
    object.direction
  when ::Ci::JobToken::GroupScopeLink
    'inbound'
  end
end

#job_token_policiesObject



66
67
68
69
70
# File 'app/graphql/types/ci/job_token_scope/allowlist_entry_type.rb', line 66

def job_token_policies
  return unless Feature.enabled?(:add_policies_to_ci_job_token, object.source_project)

  object.job_token_policies&.map(&:to_sym)
end

#source_projectObject



44
45
46
# File 'app/graphql/types/ci/job_token_scope/allowlist_entry_type.rb', line 44

def source_project
  Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.source_project_id).find
end

#targetObject



48
49
50
51
52
53
54
55
# File 'app/graphql/types/ci/job_token_scope/allowlist_entry_type.rb', line 48

def target
  case object
  when ::Ci::JobToken::ProjectScopeLink
    Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.target_project_id).find
  when ::Ci::JobToken::GroupScopeLink
    Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, object.target_group_id).find
  end
end