diff options
Diffstat (limited to 'app/graphql/mutations/dependency_proxy')
-rw-r--r-- | app/graphql/mutations/dependency_proxy/image_ttl_group_policy/update.rb | 54 |
1 files changed, 54 insertions, 0 deletions
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 |