This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Virtual_Guest has a built in for item prices using getUpgradeItemPrices. This is a shortcut for iterating through the packages by hand and will only return valid upgrade items for the VSI. See https://gist.github.com/sl-will/6868575de6dc7263968f for more information on working with orders and products and https://gist.github.com/sl-will/e3274c68e0e9f5eafcd1 for general REST usage. | |
curl -s -H 'Accept: application/json' https://$APIUSER:$APIKEY@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/11111/getUpgradeItemPrices?objectMask=categories.categoryCode;currentPriceFlag;hourlyRecurringFee;id;recurringFee | |
For RAM, these have the categoryCode of "ram" and item.keyName and item.description describe the amount. 2GB, for example, would be item 1645: | |
{ | |
"categories": [ | |
{ | |
"categoryCode": "ram" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# Pulling credentials from ENV, or set as hard values | |
$apiUser = $ENV{APIUSER}; | |
$apiKey = $ENV{APIKEY}; | |
$soapUrl= $ENV{APISOAPURL}; | |
# Use the path to the SoftLayer API and include it | |
use lib $ENV{APIPERLINCLUDE}; | |
use SoftLayer::API::SOAP; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create an NS record using an existing ID for Dns_Domain | |
# http://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain/createNsRecord | |
require 'softlayer_api' | |
username = 'your-username' | |
api_key = 'yourlongapikey' | |
dns_domain = SoftLayer::Service.new('SoftLayer_Dns_Domain', :username => username, :api_key => api_key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: tab = 2 spaces | |
import SoftLayer | |
from pprint import pprint as pp | |
# Set apikey and apiuser per your API credentials | |
apiuser='Your API User' | |
apikey='Your API Key' | |
# Initiate the client and authenticate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code will append a firewall to the end of the rules chain for a standard (per server) firewall. | |
username = 'your username' | |
apikey = 'your apikey' | |
# The firewall of the ID, can be found with an object mask of firewallServiceComponent.id on SoftLayer_Hardware or SoftLayer_Virtual_Guest data type | |
# For example, SoftLayer_Account::getVirtualGuests with a mask of id and firewallServiceComponent for a full list | |
firewall_id = 123456 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The below commands will get the basic information used in ordering products | |
# All calls are assumed with an env variable of $APIUSER and $APIKEY for the API username and key | |
# The following examples can be piped to Python for better formatting, for example: | |
# curl api.softlayer.com/args | python -m json.tool | less | |
# Related gist for integrating with scripting https://gist.github.com/sl-will/e3274c68e0e9f5eafcd1 | |
# Get a list of all datacenter locations, optionally with the region adding "groups.name" to the object mask | |
# Returns array [ {"id":int, "longName":string} ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script provides a basic command line shortcut for testing API calls using the SoftLayer RESTful API | |
# Note that using object masks uses semicolons which either must be escaped or the whole call wrapped in quotes | |
# Can pipe out to Python for better JSON formatting using: | python -m json.tool | |
# Requires curl. Usage (with "api" as script name): | |
# ./api SoftLayer_Class_Name/123456/editObject.json -X POST -d '{json object}' | |
# ./api "SoftLayer_Class_Name/getObjects.json?objectMask=myMask.description;myMask.id;id" | |
# Fill these two variables in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
username = 'your username' | |
api_key = 'your api key' | |
virtual_guest_id = 000000 | |
# Get the monitoring agents for virtual_guest_id | |
virtual_guest = SoftLayer::Service.new('SoftLayer_Virtual_Guest', :username => username, :api_key => api_key) | |
# For the sake of simplicity, we are just using the first entry, otherwise we would iterate through it |