xml 与InterSystemsCaché合作开发Digital Ocean

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 与InterSystemsCaché合作开发Digital Ocean相关的知识,希望对你有一定的参考价值。

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2015.2 (Build 664U)" ts="2016-04-05 13:01:04">
<Class name="DO.Utils">
<Super>%CSP.REST</Super>
<TimeChanged>64013,44584.975713</TimeChanged>
<TimeCreated>64013,41190.502637</TimeCreated>

<Parameter name="KEY">
<Description>
Your API token</Description>
<Default>1</Default>
</Parameter>

<Parameter name="IDLIST">
<Description>
Comma-separated list of droplet id's</Description>
<Default>111111,222222</Default>
</Parameter>

<Parameter name="SSLConfig">
<Description>
SSL configuration name</Description>
<Default>DO</Default>
</Parameter>

<XData name="UrlMap">
<XMLNamespace>http://www.intersystems.com/urlmap</XMLNamespace>
<Data><![CDATA[
<Routes>

<Route Url="/action/:dropletid/:action" Method="GET" Call="Action"/>
</Routes>
]]></Data>
</XData>

<Method name="Info">
<Description>
Do ##class(DO.Utils).Info()</Description>
<ClassMethod>1</ClassMethod>
<Implementation><![CDATA[
	Set Request = ##class(%Net.HttpRequest).%New()
	Set Request.Server = "api.digitalocean.com"
	Set Request.Https = 1
	Set Request.SSLConfiguration = ..#SSLConfig
	Do Request.SetHeader("Authorization","Bearer " _ ..#KEY)
	Set Request.Location = "/v2/droplets"
	Do Request.SetParam("page",2)
	Do Request.Get("",2)
]]></Implementation>
</Method>

<Method name="Action">
<Description>
Do ##class(DO.Utils).Action()</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>Id=-1,Action="reboot"</FormalSpec>
<Implementation><![CDATA[
	Return:((Action'="reboot") && (Action'="power_cycle")) $$$ERROR($$$GeneralError, "Availible actions are ""reboot"" or ""power_cycle""")
	Return:(..#IDLIST '[ Id) $$$ERROR($$$GeneralError, "This is not an approved ID")
	
	Set Request = ##class(%Net.HttpRequest).%New()
	Set Request.Server = "api.digitalocean.com"
	Set Request.Https = 1
	Set Request.SSLConfiguration = ..#SSLConfig
	Set Request.ContentType = "application/json"
	Do Request.SetHeader("Authorization","Bearer " _ ..#KEY)
	Set Request.Location = "/v2/droplets/" _ Id _ "/actions"
	
	Set Body = ##class(%ZEN.proxyObject).%New()
	Set Body.type = Action
	Do ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(Request.EntityBody, Body)	
	
	Set st =  Request.Post("")
	Return:$$$ISERR(st) st
	Set Data = Request.HttpResponse.Data
	Write Data.Read($$$MaxCacheInt)
	Return $$$OK
]]></Implementation>
</Method>
</Class>
</Export>

以上是关于xml 与InterSystemsCaché合作开发Digital Ocean的主要内容,如果未能解决你的问题,请参考以下文章

InterSystemsCaché:如何计算表中列表中值的遭遇? [关闭]

day23-xml解析

day23-xml解析

day23-xml解析

day23-xml解析

day23-xml解析