diff --git a/lib/puppet/provider/elasticsearch_license/ruby.rb b/lib/puppet/provider/elasticsearch_license/ruby.rb deleted file mode 100644 index 5f2c3d25..00000000 --- a/lib/puppet/provider/elasticsearch_license/ruby.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -require 'puppet/provider/elastic_rest' - -Puppet::Type.type(:elasticsearch_pipeline).provide( - :ruby, - parent: Puppet::Provider::ElasticREST, - metadata: :content, - api_uri: '_license?acknowledge=true' -) do - desc 'A REST API based provider to manage Elasticsearch licenses.' - - mk_resource_methods -end diff --git a/lib/puppet/provider/elasticsearch_license/xpack.rb b/lib/puppet/provider/elasticsearch_license/xpack.rb new file mode 100644 index 00000000..283f1893 --- /dev/null +++ b/lib/puppet/provider/elasticsearch_license/xpack.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'puppet/provider/elastic_rest' + +Puppet::Type.type(:elasticsearch_license).provide( + :ruby, + parent: Puppet::Provider::ElasticREST, + metadata: :content, + metadata_pipeline: [ + ->(data) { Puppet_X::Elastic.deep_to_s data }, + ->(data) { Puppet_X::Elastic.deep_to_i data } + ], + api_uri: '_license', + query_string: { + 'acknowledge' => 'true' + } +) do + desc 'A REST API based provider to manage Elasticsearch licenses.' + + mk_resource_methods + + def self.process_body(body) + JSON.parse(body).map do |object_name, api_object| + { + :name => object_name, + :ensure => :present, + metadata => { 'licenses' => process_metadata(api_object) }, + :provider => name + } + end + end +end