<commit_before># providers/user.rb
#
# Author: Simple Finance <<EMAIL>>
# License: Apache License, Version 2.0
#
# Copyright 2013 Simple Finance Technology Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Creates a InfluxDB user

include InfluxDB::Helpers

def initialize(new_resource, run_context)
  super
  @client      = InfluxDB::Helpers.client(new_resource.auth_username, new_resource.auth_password, run_context)
  @username    = new_resource.username
  @password    = <PASSWORD>
  @databases   = new_resource.databases
  @permissions = new_resource.permissions
end

action :create do
  unless @password
    Chef::Log.fatal!('You must provide a password for the :create' \
                     ' action on this resource')
  end
  @databases.each do |db|
    if !@client.list_users.map { |x| x['username'] || x['name'] }.member?(@username)
      @client.create_database_user(db, @username, @password)
    end
    @permissions.each do |permission|
      @client.grant_user_privileges(db, @username, permission)
    end
  end
end

action :update do
  if @password
    @client.update_user_password(@username, @password)
  end
  @databases.each do |db|
    @permissions.each do |permission|
      @client.grant_user_privileges(@username, db, permission)
    end
  end
end

action :delete do
  if @client.list_users.map { |x| x['username'] || x['name'] }.member?(@username)
    @client.delete_user(@username)
  end
end
<commit_msg>grant_user_privileges arguments backwards<commit_after># providers/user.rb
#
# Author: Simple Finance <<EMAIL>>
# License: Apache License, Version 2.0
#
# Copyright 2013 Simple Finance Technology Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Creates a InfluxDB user

include InfluxDB::Helpers

def initialize(new_resource, run_context)
  super
  @client      = InfluxDB::Helpers.client(new_resource.auth_username, new_resource.auth_password, run_context)
  @username    = new_resource.username
  @password    = <PASSWORD>
  @databases   = new_resource.databases
  @permissions = new_resource.permissions
end

action :create do
  unless @password
    Chef::Log.fatal!('You must provide a password for the :create' \
                     ' action on this resource')
  end
  @databases.each do |db|
    if !@client.list_users.map { |x| x['username'] || x['name'] }.member?(@username)
      @client.create_database_user(db, @username, @password)
    end
    @permissions.each do |permission|
      @client.grant_user_privileges(@username, db, permission)
    end
  end
end

action :update do
  if @password
    @client.update_user_password(@username, @password)
  end
  @databases.each do |db|
    @permissions.each do |permission|
      @client.grant_user_privileges(@username, db, permission)
    end
  end
end

action :delete do
  if @client.list_users.map { |x| x['username'] || x['name'] }.member?(@username)
    @client.delete_user(@username)
  end
end

{'fraction_non_alphanumeric': 0.10117526826775677, 'fraction_numerical': 0.005109862033725089, 'mean_word_length': 4.038610038610039, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6465325', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1159, 'n_words': 382}