Sha256: 3cfb752a36f620271e4c1ef19af9d4e0d8800e356bc1574c2d65e1061299023f

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

module Mutations
  module OvalPolicies
    class Create < ::Mutations::BaseMutation
      description 'Creates a new OVAL Policy'
      graphql_name 'CreateOvalPolicyMutation'

      resource_class ::ForemanOpenscap::OvalPolicy

      argument :name, String
      argument :description, String, required: false
      argument :period, String
      argument :weekday, String, required: false
      argument :day_of_month, Integer, required: false
      argument :cron_line, String, required: false
      argument :oval_content_id, Integer, required: true
      argument :hostgroup_ids, [Integer], required: false

      field :oval_policy, Types::OvalPolicy, 'The new OVAL Policy.', null: true
      field :check_collection, [Types::OvalCheck], 'A collection of checks to detect OVAL policy configuration error', null: false

      def resolve(hostgroup_ids:, **params)
        policy = ::ForemanOpenscap::OvalPolicy.new params
        validate_object(policy)
        authorize!(policy, :create)
        check_collection = ::ForemanOpenscap::Oval::Configure.new.assign(policy, hostgroup_ids, ::Hostgroup)
        {
          :oval_policy => policy,
          :check_collection => check_collection.checks
        }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
foreman_openscap-8.0.0 app/graphql/mutations/oval_policies/create.rb
foreman_openscap-7.1.1 app/graphql/mutations/oval_policies/create.rb
foreman_openscap-7.1.0 app/graphql/mutations/oval_policies/create.rb
foreman_openscap-7.0.0 app/graphql/mutations/oval_policies/create.rb
foreman_openscap-6.0.0 app/graphql/mutations/oval_policies/create.rb
foreman_openscap-5.2.3 app/graphql/mutations/oval_policies/create.rb
foreman_openscap-5.2.2 app/graphql/mutations/oval_policies/create.rb
foreman_openscap-5.1.1 app/graphql/mutations/oval_policies/create.rb
foreman_openscap-5.2.1 app/graphql/mutations/oval_policies/create.rb
foreman_openscap-5.2.0 app/graphql/mutations/oval_policies/create.rb