Home > Cloud Cruiser 3 > REST API reference > Example code > PowerShell

PowerShell

Get resource by ID

The following example PowerShell script snippet fetches the resource information for the resource with the headerId of 10021.

$url = "http://localhost:8080/rest/v1/resources/resource/10021"
$http_request = New‐Object ‐ComObject Msxml2.XMLHTTP
$http_request.open('GET', $url, $false, 'username', 'password')
$http_request.setRequestHeader("Content‐type", "application/xml")
$http_request.send()
$http_request.statusText
$http_request.responseText

Create resource

The following example creates a new resource.

$resource = '<?xml version="1.0" encoding="UTF‐8"?>
  <resourceInfo xmlns="http://www.cloudcruiser.com/webservices/v1/Resource">
    <name>myTestPs‐res‐2</name>
    <group><name>TestGroup‐1</name></group>
    <hidden>false</hidden>
    <allocated>true</allocated>
    <resourceType>STANDARD</resourceType>
    <rateType>PRICE</rateType>
    <unitsDecimals>4</unitsDecimals>
    <rateDecimals>4</rateDecimals>
    <numericType>INTEGER</numericType>
    <unitDesc>operations</unitDesc>
    <ratePlan id="1">
      <name>default</name>
      <revision>
        <ratePlanName>default</ratePlanName>
        <startDate year="2000" month="1" day="1"/>
        <endDate year="2999" month="12" day="31"/>
        <chargeInterval>DAILY</chargeInterval>
        <detail>
          <rate currencyCode="usd">
            <variableCharge>0.62</variableCharge>
          </rate>
        </detail>
      </revision>
    </ratePlan>
  </resourceInfo>'
$url = "http://localhost:8080/rest/v1/resources/resource"
$http_request = New‐Object ‐ComObject Msxml2.XMLHTTP
$http_request.open('POST', $url, $false, 'username', 'password')
$http_request.setRequestHeader("Content‐type", "application/xml")
$http_request.setRequestHeader("Accept", "application/xml")
$http_request.send($resource)
$http_request.statusText
$http_request.responseText
Last modified

Tags

This page has no custom tags.

Classifications

This page has no classifications.
© Copyright 2018 Hewlett Packard Enterprise Development LP