class Chef::Knife::IonoscloudUserCreate
Attributes
description[R]
required_options[R]
Public Class Methods
new(args = [])
click to toggle source
Calls superclass method
# File lib/chef/knife/ionoscloud_user_create.rb, line 41 def initialize(args = []) super(args) @description = 'Creates a new user under a particular contract. **Please Note**: The password set '\ 'here cannot be updated through the API currently. It is recommended that a new user '\ 'log into the DCD and change their password.' @required_options = [:firstname, :lastname, :email, :password, :ionoscloud_username, :ionoscloud_password] end
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/ionoscloud_user_create.rb, line 50 def run $stdout.sync = true handle_extra_config validate_required_params(@required_options, config) print "#{ui.color('Creating user...', :magenta)}" user_management_api = Ionoscloud::UserManagementApi.new(api_client) user, _, headers = user_management_api.um_users_post_with_http_info({ properties: { firstname: config[:firstname], lastname: config[:lastname], email: config[:email], password: config[:password], administrator: config[:administrator], forceSecAuth: config[:force_sec_auth], }.compact, }) dot = ui.color('.', :magenta) api_client.wait_for { print dot; is_done? get_request_id headers } puts "\n" puts "#{ui.color('ID', :cyan)}: #{user.id}" puts "#{ui.color('Firstname', :cyan)}: #{user.properties.firstname}" puts "#{ui.color('Lastname', :cyan)}: #{user.properties.lastname}" puts "#{ui.color('Email', :cyan)}: #{user.properties.email}" puts "#{ui.color('Administrator', :cyan)}: #{user.properties.administrator.to_s}" puts "#{ui.color('2-Factor Auth', :cyan)}: #{user.properties.force_sec_auth.to_s}" puts 'done' end