###########################################################################
# CLOUD SERVER API DOCUMENTATION
#
# Name: listHddsServer
# Language: Perl
#
# Description: returns information about the SSD of the server
###########################################################################
use strict;
use LWP::UserAgent;
use URI::Escape;
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 _listHddsServer
{	
	my ($id) = @_;
	my $_command = $url ."/servers/" .$id ."/hardware/hdds";
	my $_method = 'GET';

	#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');
	
	#Get the response
	my $response = $ua->request($request);

	if($response)
	{
		#Get the response and close the handlers
		print $response->headers()->as_string ."\n";
		return $response->content;
		$response->close;
		$request->close;
	}
	else
	{
		#Get the error and close the handlers
		return "Http Error Code: ", $response->code, "\n";
		$request->close;
	}	
}

#Parameters
my $id = "{YOUR_SERVER_ID}"; # e.g.: "5340033E7FBBC308BC329414A0DF3C20"

#Information 
print _listHddsServer($id);