From 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 20 Sep 2021 13:18:24 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-3-stable-ee --- .../mutations/admin/sidekiq_queues/delete_jobs.rb | 9 +++- app/graphql/mutations/custom_emoji/destroy.rb | 36 +++++++++++++++ .../customer_relations/organizations/create.rb | 53 +++++++++++++++++++++ .../customer_relations/organizations/update.rb | 52 +++++++++++++++++++++ .../image_ttl_group_policy/update.rb | 54 ++++++++++++++++++++++ 5 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 app/graphql/mutations/custom_emoji/destroy.rb create mode 100644 app/graphql/mutations/customer_relations/organizations/create.rb create mode 100644 app/graphql/mutations/customer_relations/organizations/update.rb create mode 100644 app/graphql/mutations/dependency_proxy/image_ttl_group_policy/update.rb (limited to 'app/graphql/mutations') 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 -- cgit v1.2.3