summaryrefslogtreecommitdiff
path: root/app/graphql/mutations
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations')
-rw-r--r--app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb9
-rw-r--r--app/graphql/mutations/custom_emoji/destroy.rb36
-rw-r--r--app/graphql/mutations/customer_relations/organizations/create.rb53
-rw-r--r--app/graphql/mutations/customer_relations/organizations/update.rb52
-rw-r--r--app/graphql/mutations/dependency_proxy/image_ttl_group_policy/update.rb54
5 files changed, 202 insertions, 2 deletions
diff --git a/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb b/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb
index d943816089f..c4f91d0c15c 100644
--- a/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb
+++ b/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb
@@ -8,13 +8,18 @@ module Mutations
ADMIN_MESSAGE = 'You must be an admin to use this mutation'
- Gitlab::ApplicationContext::KNOWN_KEYS.each do |key|
+ ::Gitlab::ApplicationContext::KNOWN_KEYS.each do |key|
argument key,
GraphQL::Types::String,
required: false,
- description: "Delete jobs matching #{key} in the context metadata"
+ description: "Delete jobs matching #{key} in the context metadata."
end
+ argument ::Gitlab::SidekiqQueue::WORKER_KEY,
+ GraphQL::Types::String,
+ required: false,
+ description: 'Delete jobs with the given worker class.'
+
argument :queue_name,
GraphQL::Types::String,
required: true,
diff --git a/app/graphql/mutations/custom_emoji/destroy.rb b/app/graphql/mutations/custom_emoji/destroy.rb
new file mode 100644
index 00000000000..863b8152cc7
--- /dev/null
+++ b/app/graphql/mutations/custom_emoji/destroy.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+module Mutations
+ module CustomEmoji
+ class Destroy < BaseMutation
+ graphql_name 'DestroyCustomEmoji'
+
+ authorize :delete_custom_emoji
+
+ field :custom_emoji,
+ Types::CustomEmojiType,
+ null: true,
+ description: 'Deleted custom emoji.'
+
+ argument :id, ::Types::GlobalIDType[::CustomEmoji],
+ required: true,
+ description: 'Global ID of the custom emoji to destroy.'
+
+ def resolve(id:)
+ custom_emoji = authorized_find!(id: id)
+
+ custom_emoji.destroy!
+
+ {
+ custom_emoji: custom_emoji
+ }
+ end
+
+ private
+
+ def find_object(id:)
+ GitlabSchema.object_from_id(id, expected_type: ::CustomEmoji)
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/customer_relations/organizations/create.rb b/app/graphql/mutations/customer_relations/organizations/create.rb
new file mode 100644
index 00000000000..3fa7b0327ca
--- /dev/null
+++ b/app/graphql/mutations/customer_relations/organizations/create.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+module Mutations
+ module CustomerRelations
+ module Organizations
+ class Create < BaseMutation
+ include ResolvesIds
+ include Gitlab::Graphql::Authorize::AuthorizeResource
+
+ graphql_name 'CustomerRelationsOrganizationCreate'
+
+ field :organization,
+ Types::CustomerRelations::OrganizationType,
+ null: true,
+ description: 'Organization after the mutation.'
+
+ argument :group_id, ::Types::GlobalIDType[::Group],
+ required: true,
+ description: 'Group for the organization.'
+
+ argument :name,
+ GraphQL::Types::String,
+ required: true,
+ description: 'Name of the organization.'
+
+ argument :default_rate,
+ GraphQL::Types::Float,
+ required: false,
+ description: 'Standard billing rate for the organization.'
+
+ argument :description,
+ GraphQL::Types::String,
+ required: false,
+ description: 'Description or notes for the organization.'
+
+ authorize :admin_organization
+
+ def resolve(args)
+ group = authorized_find!(id: args[:group_id])
+
+ raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature disabled' unless Feature.enabled?(:customer_relations, group, default_enabled: :yaml)
+
+ result = ::CustomerRelations::Organizations::CreateService.new(group: group, current_user: current_user, params: args).execute
+ { organization: result.payload, errors: result.errors }
+ end
+
+ def find_object(id:)
+ GitlabSchema.object_from_id(id, expected_type: ::Group)
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/customer_relations/organizations/update.rb b/app/graphql/mutations/customer_relations/organizations/update.rb
new file mode 100644
index 00000000000..c6ae62193f9
--- /dev/null
+++ b/app/graphql/mutations/customer_relations/organizations/update.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+module Mutations
+ module CustomerRelations
+ module Organizations
+ class Update < Mutations::BaseMutation
+ include ResolvesIds
+
+ graphql_name 'CustomerRelationsOrganizationUpdate'
+
+ authorize :admin_organization
+
+ field :organization,
+ Types::CustomerRelations::OrganizationType,
+ null: false,
+ description: 'Organization after the mutation.'
+
+ argument :id, ::Types::GlobalIDType[::CustomerRelations::Organization],
+ required: true,
+ description: 'Global ID of the organization.'
+
+ argument :name,
+ GraphQL::Types::String,
+ required: false,
+ description: 'Name of the organization.'
+
+ argument :default_rate,
+ GraphQL::Types::Float,
+ required: false,
+ description: 'Standard billing rate for the organization.'
+
+ argument :description,
+ GraphQL::Types::String,
+ required: false,
+ description: 'Description or notes for the organization.'
+
+ def resolve(args)
+ organization = ::Gitlab::Graphql::Lazy.force(GitlabSchema.object_from_id(args.delete(:id), expected_type: ::CustomerRelations::Organization))
+ raise_resource_not_available_error! unless organization
+
+ group = organization.group
+ raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature disabled' unless Feature.enabled?(:customer_relations, group, default_enabled: :yaml)
+
+ authorize!(group)
+
+ result = ::CustomerRelations::Organizations::UpdateService.new(group: group, current_user: current_user, params: args).execute(organization)
+ { organization: result.payload, errors: result.errors }
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/dependency_proxy/image_ttl_group_policy/update.rb b/app/graphql/mutations/dependency_proxy/image_ttl_group_policy/update.rb
new file mode 100644
index 00000000000..a5eb114b2da
--- /dev/null
+++ b/app/graphql/mutations/dependency_proxy/image_ttl_group_policy/update.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+module Mutations
+ module DependencyProxy
+ module ImageTtlGroupPolicy
+ class Update < Mutations::BaseMutation
+ include Mutations::ResolvesGroup
+
+ graphql_name 'UpdateDependencyProxyImageTtlGroupPolicy'
+
+ authorize :admin_dependency_proxy
+
+ argument :group_path,
+ GraphQL::Types::ID,
+ required: true,
+ description: 'Group path for the group dependency proxy image TTL policy.'
+
+ argument :enabled,
+ GraphQL::Types::Boolean,
+ required: false,
+ description: copy_field_description(Types::DependencyProxy::ImageTtlGroupPolicyType, :enabled)
+
+ argument :ttl,
+ GraphQL::Types::Int,
+ required: false,
+ description: copy_field_description(Types::DependencyProxy::ImageTtlGroupPolicyType, :ttl)
+
+ field :dependency_proxy_image_ttl_policy,
+ Types::DependencyProxy::ImageTtlGroupPolicyType,
+ null: true,
+ description: 'Group image TTL policy after mutation.'
+
+ def resolve(group_path:, **args)
+ group = authorized_find!(group_path: group_path)
+
+ result = ::DependencyProxy::ImageTtlGroupPolicies::UpdateService
+ .new(container: group, current_user: current_user, params: args)
+ .execute
+
+ {
+ dependency_proxy_image_ttl_policy: result.payload[:dependency_proxy_image_ttl_policy],
+ errors: result.errors
+ }
+ end
+
+ private
+
+ def find_object(group_path:)
+ resolve_group(full_path: group_path)
+ end
+ end
+ end
+ end
+end