###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: setAccessSharedStorage
# Language: Perl
#
# Description: this functions configure the password for accessing to
# shared storages from servers
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
use JSON;
require Http::Request::Common;

#ID access to API
my $TOKEN = "{YOUR_API_TOKEN}"; # e.g.: "f03c3c76cc853ee690b879909c9c6f2a"
my $url = "https://cloudpanel-api.ionos.com/v1";

sub _setAccessSharedStorages
{
	my ($content) = @_;
	my $_command = $url ."/shared_storages/access";
	my $_method = 'PUT';

	#Create the request
	my $ua = LWP::UserAgent->new;
	my $request = HTTP::Request->new($_method => $_command);
	$request->header('X-TOKEN' => $TOKEN);
	$request->content_type('application/json');
	
	#Add additional parameters
	$request->content_type('application/json');
	$request->content($content);

	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		print $response->headers()->as_string ."\n";
		return $response->content;
	}
	else
	{
		return "Http Error Code: ", $response->code, "\n";
	}			
}

#Parameters
my $password = "password";

#Create a JSON with all parameters
my %_query = ("password" => $password);
my $query = encode_json \%_query;

print _setAccessSharedStorages($query); 