Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Ruby Examples

Web API Categories

ASN.1
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks

Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
NTLM
OAuth1
OAuth2
Office365
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Ruby) EC2 Reboot Instances

Demonstrates how to send a request to reboot Amazon EC2 instances.

For more information, see https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RebootInstances.html

Chilkat Ruby Downloads

Ruby Library for Linux and MAC OS X

require 'chilkat'

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

rest = Chilkat::CkRest.new()

# Connect to the Amazon AWS server.
# such as https://ec2.amazonaws.com/
bTls = true
port = 443
bAutoReconnect = true
success = rest.Connect("ec2.us-west-2.amazonaws.com",port,bTls,bAutoReconnect)

# Provide AWS credentials for the REST call.
authAws = Chilkat::CkAuthAws.new()
authAws.put_AccessKey("AWS_ACCESS_KEY")
authAws.put_SecretKey("AWS_SECRET_KEY")
# the region should match our URL above..
authAws.put_Region("us-west-2")
authAws.put_ServiceName("ec2")

rest.SetAuthAws(authAws)

rest.AddQueryParam("Action","RebootInstances")
rest.AddQueryParam("Version","2016-11-15")
rest.AddQueryParam("DryRun","true")
rest.AddQueryParam("InstanceId.1","i-999719995399c9999")

responseXml = rest.fullRequestNoBody("GET","/")
if (rest.get_LastMethodSuccess() != true)
    print rest.lastErrorText() + "\n";
    exit
end

# A successful response will have a status code equal to 200.
if (rest.get_ResponseStatusCode() != 200)
    print "response status code = " + rest.get_ResponseStatusCode().to_s() + "\n";
    print "response status text = " + rest.responseStatusText() + "\n";
    print "response header: " + rest.responseHeader() + "\n";
    print "response body: " + responseXml + "\n";
    exit
end

# Examine the successful XML response.
xml = Chilkat::CkXml.new()
xml.LoadXml(responseXml)
print xml.getXml() + "\n";

 

© 2000-2020 Chilkat Software, Inc. All Rights Reserved.