class Chef::Knife::IonoscloudShareCreate
Attributes
description[R]
required_options[R]
Public Class Methods
new(args = [])
click to toggle source
Calls superclass method
# File lib/chef/knife/ionoscloud_share_create.rb, line 32 def initialize(args = []) super(args) @description = 'Adds a specific resource share to a group and optionally allows the setting of permissions '\ 'for that resource. As an example, you might use this to grant permissions to use an image '\ 'or snapshot to a specific group.' @required_options = [:group_id, :resource_id, :ionoscloud_username, :ionoscloud_password] end
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/ionoscloud_share_create.rb, line 41 def run $stdout.sync = true handle_extra_config validate_required_params(@required_options, config) print "#{ui.color('Sharing Resource...', :magenta)}" user_management_api = Ionoscloud::UserManagementApi.new(api_client) share, _, headers = user_management_api.um_groups_shares_post_with_http_info( config[:group_id], config[:resource_id], { properties: { editPrivilege: config[:edit_privilege], sharePrivilege: config[:share_privilege], }.compact, }, ) dot = ui.color('.', :magenta) api_client.wait_for { print dot; is_done? get_request_id headers } puts "\n" puts "#{ui.color('ID', :cyan)}: #{share.id}" puts "#{ui.color('Edit Privilege', :cyan)}: #{share.properties.edit_privilege.to_s}" puts "#{ui.color('Share Privilege', :cyan)}: #{share.properties.share_privilege.to_s}" puts 'done' end