ISOService.go 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945
  1. //
  2. // Copyright 2016, Sander van Harmelen
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. package cloudstack
  17. import (
  18. "encoding/json"
  19. "fmt"
  20. "net/url"
  21. "strconv"
  22. "strings"
  23. )
  24. type AttachIsoParams struct {
  25. p map[string]interface{}
  26. }
  27. func (p *AttachIsoParams) toURLValues() url.Values {
  28. u := url.Values{}
  29. if p.p == nil {
  30. return u
  31. }
  32. if v, found := p.p["id"]; found {
  33. u.Set("id", v.(string))
  34. }
  35. if v, found := p.p["virtualmachineid"]; found {
  36. u.Set("virtualmachineid", v.(string))
  37. }
  38. return u
  39. }
  40. func (p *AttachIsoParams) SetId(v string) {
  41. if p.p == nil {
  42. p.p = make(map[string]interface{})
  43. }
  44. p.p["id"] = v
  45. return
  46. }
  47. func (p *AttachIsoParams) SetVirtualmachineid(v string) {
  48. if p.p == nil {
  49. p.p = make(map[string]interface{})
  50. }
  51. p.p["virtualmachineid"] = v
  52. return
  53. }
  54. // You should always use this function to get a new AttachIsoParams instance,
  55. // as then you are sure you have configured all required params
  56. func (s *ISOService) NewAttachIsoParams(id string, virtualmachineid string) *AttachIsoParams {
  57. p := &AttachIsoParams{}
  58. p.p = make(map[string]interface{})
  59. p.p["id"] = id
  60. p.p["virtualmachineid"] = virtualmachineid
  61. return p
  62. }
  63. // Attaches an ISO to a virtual machine.
  64. func (s *ISOService) AttachIso(p *AttachIsoParams) (*AttachIsoResponse, error) {
  65. resp, err := s.cs.newRequest("attachIso", p.toURLValues())
  66. if err != nil {
  67. return nil, err
  68. }
  69. var r AttachIsoResponse
  70. if err := json.Unmarshal(resp, &r); err != nil {
  71. return nil, err
  72. }
  73. // If we have a async client, we need to wait for the async result
  74. if s.cs.async {
  75. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  76. if err != nil {
  77. if err == AsyncTimeoutErr {
  78. return &r, err
  79. }
  80. return nil, err
  81. }
  82. b, err = getRawValue(b)
  83. if err != nil {
  84. return nil, err
  85. }
  86. if err := json.Unmarshal(b, &r); err != nil {
  87. return nil, err
  88. }
  89. }
  90. return &r, nil
  91. }
  92. type AttachIsoResponse struct {
  93. JobID string `json:"jobid,omitempty"`
  94. Account string `json:"account,omitempty"`
  95. Affinitygroup []struct {
  96. Account string `json:"account,omitempty"`
  97. Description string `json:"description,omitempty"`
  98. Domain string `json:"domain,omitempty"`
  99. Domainid string `json:"domainid,omitempty"`
  100. Id string `json:"id,omitempty"`
  101. Name string `json:"name,omitempty"`
  102. Project string `json:"project,omitempty"`
  103. Projectid string `json:"projectid,omitempty"`
  104. Type string `json:"type,omitempty"`
  105. VirtualmachineIds []string `json:"virtualmachineIds,omitempty"`
  106. } `json:"affinitygroup,omitempty"`
  107. Cpunumber int `json:"cpunumber,omitempty"`
  108. Cpuspeed int `json:"cpuspeed,omitempty"`
  109. Cpuused string `json:"cpuused,omitempty"`
  110. Created string `json:"created,omitempty"`
  111. Details map[string]string `json:"details,omitempty"`
  112. Diskioread int64 `json:"diskioread,omitempty"`
  113. Diskiowrite int64 `json:"diskiowrite,omitempty"`
  114. Diskkbsread int64 `json:"diskkbsread,omitempty"`
  115. Diskkbswrite int64 `json:"diskkbswrite,omitempty"`
  116. Diskofferingid string `json:"diskofferingid,omitempty"`
  117. Diskofferingname string `json:"diskofferingname,omitempty"`
  118. Displayname string `json:"displayname,omitempty"`
  119. Displayvm bool `json:"displayvm,omitempty"`
  120. Domain string `json:"domain,omitempty"`
  121. Domainid string `json:"domainid,omitempty"`
  122. Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"`
  123. Group string `json:"group,omitempty"`
  124. Groupid string `json:"groupid,omitempty"`
  125. Guestosid string `json:"guestosid,omitempty"`
  126. Haenable bool `json:"haenable,omitempty"`
  127. Hostid string `json:"hostid,omitempty"`
  128. Hostname string `json:"hostname,omitempty"`
  129. Hypervisor string `json:"hypervisor,omitempty"`
  130. Id string `json:"id,omitempty"`
  131. Instancename string `json:"instancename,omitempty"`
  132. Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"`
  133. Isodisplaytext string `json:"isodisplaytext,omitempty"`
  134. Isoid string `json:"isoid,omitempty"`
  135. Isoname string `json:"isoname,omitempty"`
  136. Keypair string `json:"keypair,omitempty"`
  137. Memory int `json:"memory,omitempty"`
  138. Name string `json:"name,omitempty"`
  139. Networkkbsread int64 `json:"networkkbsread,omitempty"`
  140. Networkkbswrite int64 `json:"networkkbswrite,omitempty"`
  141. Nic []struct {
  142. Broadcasturi string `json:"broadcasturi,omitempty"`
  143. Deviceid string `json:"deviceid,omitempty"`
  144. Gateway string `json:"gateway,omitempty"`
  145. Id string `json:"id,omitempty"`
  146. Ip6address string `json:"ip6address,omitempty"`
  147. Ip6cidr string `json:"ip6cidr,omitempty"`
  148. Ip6gateway string `json:"ip6gateway,omitempty"`
  149. Ipaddress string `json:"ipaddress,omitempty"`
  150. Isdefault bool `json:"isdefault,omitempty"`
  151. Isolationuri string `json:"isolationuri,omitempty"`
  152. Macaddress string `json:"macaddress,omitempty"`
  153. Netmask string `json:"netmask,omitempty"`
  154. Networkid string `json:"networkid,omitempty"`
  155. Networkname string `json:"networkname,omitempty"`
  156. Secondaryip []struct {
  157. Id string `json:"id,omitempty"`
  158. Ipaddress string `json:"ipaddress,omitempty"`
  159. } `json:"secondaryip,omitempty"`
  160. Traffictype string `json:"traffictype,omitempty"`
  161. Type string `json:"type,omitempty"`
  162. Virtualmachineid string `json:"virtualmachineid,omitempty"`
  163. } `json:"nic,omitempty"`
  164. Ostypeid int64 `json:"ostypeid,omitempty"`
  165. Password string `json:"password,omitempty"`
  166. Passwordenabled bool `json:"passwordenabled,omitempty"`
  167. Project string `json:"project,omitempty"`
  168. Projectid string `json:"projectid,omitempty"`
  169. Publicip string `json:"publicip,omitempty"`
  170. Publicipid string `json:"publicipid,omitempty"`
  171. Rootdeviceid int64 `json:"rootdeviceid,omitempty"`
  172. Rootdevicetype string `json:"rootdevicetype,omitempty"`
  173. Securitygroup []struct {
  174. Account string `json:"account,omitempty"`
  175. Description string `json:"description,omitempty"`
  176. Domain string `json:"domain,omitempty"`
  177. Domainid string `json:"domainid,omitempty"`
  178. Egressrule []struct {
  179. Account string `json:"account,omitempty"`
  180. Cidr string `json:"cidr,omitempty"`
  181. Endport int `json:"endport,omitempty"`
  182. Icmpcode int `json:"icmpcode,omitempty"`
  183. Icmptype int `json:"icmptype,omitempty"`
  184. Protocol string `json:"protocol,omitempty"`
  185. Ruleid string `json:"ruleid,omitempty"`
  186. Securitygroupname string `json:"securitygroupname,omitempty"`
  187. Startport int `json:"startport,omitempty"`
  188. Tags []struct {
  189. Account string `json:"account,omitempty"`
  190. Customer string `json:"customer,omitempty"`
  191. Domain string `json:"domain,omitempty"`
  192. Domainid string `json:"domainid,omitempty"`
  193. Key string `json:"key,omitempty"`
  194. Project string `json:"project,omitempty"`
  195. Projectid string `json:"projectid,omitempty"`
  196. Resourceid string `json:"resourceid,omitempty"`
  197. Resourcetype string `json:"resourcetype,omitempty"`
  198. Value string `json:"value,omitempty"`
  199. } `json:"tags,omitempty"`
  200. } `json:"egressrule,omitempty"`
  201. Id string `json:"id,omitempty"`
  202. Ingressrule []struct {
  203. Account string `json:"account,omitempty"`
  204. Cidr string `json:"cidr,omitempty"`
  205. Endport int `json:"endport,omitempty"`
  206. Icmpcode int `json:"icmpcode,omitempty"`
  207. Icmptype int `json:"icmptype,omitempty"`
  208. Protocol string `json:"protocol,omitempty"`
  209. Ruleid string `json:"ruleid,omitempty"`
  210. Securitygroupname string `json:"securitygroupname,omitempty"`
  211. Startport int `json:"startport,omitempty"`
  212. Tags []struct {
  213. Account string `json:"account,omitempty"`
  214. Customer string `json:"customer,omitempty"`
  215. Domain string `json:"domain,omitempty"`
  216. Domainid string `json:"domainid,omitempty"`
  217. Key string `json:"key,omitempty"`
  218. Project string `json:"project,omitempty"`
  219. Projectid string `json:"projectid,omitempty"`
  220. Resourceid string `json:"resourceid,omitempty"`
  221. Resourcetype string `json:"resourcetype,omitempty"`
  222. Value string `json:"value,omitempty"`
  223. } `json:"tags,omitempty"`
  224. } `json:"ingressrule,omitempty"`
  225. Name string `json:"name,omitempty"`
  226. Project string `json:"project,omitempty"`
  227. Projectid string `json:"projectid,omitempty"`
  228. Tags []struct {
  229. Account string `json:"account,omitempty"`
  230. Customer string `json:"customer,omitempty"`
  231. Domain string `json:"domain,omitempty"`
  232. Domainid string `json:"domainid,omitempty"`
  233. Key string `json:"key,omitempty"`
  234. Project string `json:"project,omitempty"`
  235. Projectid string `json:"projectid,omitempty"`
  236. Resourceid string `json:"resourceid,omitempty"`
  237. Resourcetype string `json:"resourcetype,omitempty"`
  238. Value string `json:"value,omitempty"`
  239. } `json:"tags,omitempty"`
  240. Virtualmachinecount int `json:"virtualmachinecount,omitempty"`
  241. Virtualmachineids []string `json:"virtualmachineids,omitempty"`
  242. } `json:"securitygroup,omitempty"`
  243. Serviceofferingid string `json:"serviceofferingid,omitempty"`
  244. Serviceofferingname string `json:"serviceofferingname,omitempty"`
  245. Servicestate string `json:"servicestate,omitempty"`
  246. State string `json:"state,omitempty"`
  247. Tags []struct {
  248. Account string `json:"account,omitempty"`
  249. Customer string `json:"customer,omitempty"`
  250. Domain string `json:"domain,omitempty"`
  251. Domainid string `json:"domainid,omitempty"`
  252. Key string `json:"key,omitempty"`
  253. Project string `json:"project,omitempty"`
  254. Projectid string `json:"projectid,omitempty"`
  255. Resourceid string `json:"resourceid,omitempty"`
  256. Resourcetype string `json:"resourcetype,omitempty"`
  257. Value string `json:"value,omitempty"`
  258. } `json:"tags,omitempty"`
  259. Templatedisplaytext string `json:"templatedisplaytext,omitempty"`
  260. Templateid string `json:"templateid,omitempty"`
  261. Templatename string `json:"templatename,omitempty"`
  262. Userid string `json:"userid,omitempty"`
  263. Username string `json:"username,omitempty"`
  264. Vgpu string `json:"vgpu,omitempty"`
  265. Zoneid string `json:"zoneid,omitempty"`
  266. Zonename string `json:"zonename,omitempty"`
  267. }
  268. type DetachIsoParams struct {
  269. p map[string]interface{}
  270. }
  271. func (p *DetachIsoParams) toURLValues() url.Values {
  272. u := url.Values{}
  273. if p.p == nil {
  274. return u
  275. }
  276. if v, found := p.p["virtualmachineid"]; found {
  277. u.Set("virtualmachineid", v.(string))
  278. }
  279. return u
  280. }
  281. func (p *DetachIsoParams) SetVirtualmachineid(v string) {
  282. if p.p == nil {
  283. p.p = make(map[string]interface{})
  284. }
  285. p.p["virtualmachineid"] = v
  286. return
  287. }
  288. // You should always use this function to get a new DetachIsoParams instance,
  289. // as then you are sure you have configured all required params
  290. func (s *ISOService) NewDetachIsoParams(virtualmachineid string) *DetachIsoParams {
  291. p := &DetachIsoParams{}
  292. p.p = make(map[string]interface{})
  293. p.p["virtualmachineid"] = virtualmachineid
  294. return p
  295. }
  296. // Detaches any ISO file (if any) currently attached to a virtual machine.
  297. func (s *ISOService) DetachIso(p *DetachIsoParams) (*DetachIsoResponse, error) {
  298. resp, err := s.cs.newRequest("detachIso", p.toURLValues())
  299. if err != nil {
  300. return nil, err
  301. }
  302. var r DetachIsoResponse
  303. if err := json.Unmarshal(resp, &r); err != nil {
  304. return nil, err
  305. }
  306. // If we have a async client, we need to wait for the async result
  307. if s.cs.async {
  308. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  309. if err != nil {
  310. if err == AsyncTimeoutErr {
  311. return &r, err
  312. }
  313. return nil, err
  314. }
  315. b, err = getRawValue(b)
  316. if err != nil {
  317. return nil, err
  318. }
  319. if err := json.Unmarshal(b, &r); err != nil {
  320. return nil, err
  321. }
  322. }
  323. return &r, nil
  324. }
  325. type DetachIsoResponse struct {
  326. JobID string `json:"jobid,omitempty"`
  327. Account string `json:"account,omitempty"`
  328. Affinitygroup []struct {
  329. Account string `json:"account,omitempty"`
  330. Description string `json:"description,omitempty"`
  331. Domain string `json:"domain,omitempty"`
  332. Domainid string `json:"domainid,omitempty"`
  333. Id string `json:"id,omitempty"`
  334. Name string `json:"name,omitempty"`
  335. Project string `json:"project,omitempty"`
  336. Projectid string `json:"projectid,omitempty"`
  337. Type string `json:"type,omitempty"`
  338. VirtualmachineIds []string `json:"virtualmachineIds,omitempty"`
  339. } `json:"affinitygroup,omitempty"`
  340. Cpunumber int `json:"cpunumber,omitempty"`
  341. Cpuspeed int `json:"cpuspeed,omitempty"`
  342. Cpuused string `json:"cpuused,omitempty"`
  343. Created string `json:"created,omitempty"`
  344. Details map[string]string `json:"details,omitempty"`
  345. Diskioread int64 `json:"diskioread,omitempty"`
  346. Diskiowrite int64 `json:"diskiowrite,omitempty"`
  347. Diskkbsread int64 `json:"diskkbsread,omitempty"`
  348. Diskkbswrite int64 `json:"diskkbswrite,omitempty"`
  349. Diskofferingid string `json:"diskofferingid,omitempty"`
  350. Diskofferingname string `json:"diskofferingname,omitempty"`
  351. Displayname string `json:"displayname,omitempty"`
  352. Displayvm bool `json:"displayvm,omitempty"`
  353. Domain string `json:"domain,omitempty"`
  354. Domainid string `json:"domainid,omitempty"`
  355. Forvirtualnetwork bool `json:"forvirtualnetwork,omitempty"`
  356. Group string `json:"group,omitempty"`
  357. Groupid string `json:"groupid,omitempty"`
  358. Guestosid string `json:"guestosid,omitempty"`
  359. Haenable bool `json:"haenable,omitempty"`
  360. Hostid string `json:"hostid,omitempty"`
  361. Hostname string `json:"hostname,omitempty"`
  362. Hypervisor string `json:"hypervisor,omitempty"`
  363. Id string `json:"id,omitempty"`
  364. Instancename string `json:"instancename,omitempty"`
  365. Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"`
  366. Isodisplaytext string `json:"isodisplaytext,omitempty"`
  367. Isoid string `json:"isoid,omitempty"`
  368. Isoname string `json:"isoname,omitempty"`
  369. Keypair string `json:"keypair,omitempty"`
  370. Memory int `json:"memory,omitempty"`
  371. Name string `json:"name,omitempty"`
  372. Networkkbsread int64 `json:"networkkbsread,omitempty"`
  373. Networkkbswrite int64 `json:"networkkbswrite,omitempty"`
  374. Nic []struct {
  375. Broadcasturi string `json:"broadcasturi,omitempty"`
  376. Deviceid string `json:"deviceid,omitempty"`
  377. Gateway string `json:"gateway,omitempty"`
  378. Id string `json:"id,omitempty"`
  379. Ip6address string `json:"ip6address,omitempty"`
  380. Ip6cidr string `json:"ip6cidr,omitempty"`
  381. Ip6gateway string `json:"ip6gateway,omitempty"`
  382. Ipaddress string `json:"ipaddress,omitempty"`
  383. Isdefault bool `json:"isdefault,omitempty"`
  384. Isolationuri string `json:"isolationuri,omitempty"`
  385. Macaddress string `json:"macaddress,omitempty"`
  386. Netmask string `json:"netmask,omitempty"`
  387. Networkid string `json:"networkid,omitempty"`
  388. Networkname string `json:"networkname,omitempty"`
  389. Secondaryip []struct {
  390. Id string `json:"id,omitempty"`
  391. Ipaddress string `json:"ipaddress,omitempty"`
  392. } `json:"secondaryip,omitempty"`
  393. Traffictype string `json:"traffictype,omitempty"`
  394. Type string `json:"type,omitempty"`
  395. Virtualmachineid string `json:"virtualmachineid,omitempty"`
  396. } `json:"nic,omitempty"`
  397. Ostypeid int64 `json:"ostypeid,omitempty"`
  398. Password string `json:"password,omitempty"`
  399. Passwordenabled bool `json:"passwordenabled,omitempty"`
  400. Project string `json:"project,omitempty"`
  401. Projectid string `json:"projectid,omitempty"`
  402. Publicip string `json:"publicip,omitempty"`
  403. Publicipid string `json:"publicipid,omitempty"`
  404. Rootdeviceid int64 `json:"rootdeviceid,omitempty"`
  405. Rootdevicetype string `json:"rootdevicetype,omitempty"`
  406. Securitygroup []struct {
  407. Account string `json:"account,omitempty"`
  408. Description string `json:"description,omitempty"`
  409. Domain string `json:"domain,omitempty"`
  410. Domainid string `json:"domainid,omitempty"`
  411. Egressrule []struct {
  412. Account string `json:"account,omitempty"`
  413. Cidr string `json:"cidr,omitempty"`
  414. Endport int `json:"endport,omitempty"`
  415. Icmpcode int `json:"icmpcode,omitempty"`
  416. Icmptype int `json:"icmptype,omitempty"`
  417. Protocol string `json:"protocol,omitempty"`
  418. Ruleid string `json:"ruleid,omitempty"`
  419. Securitygroupname string `json:"securitygroupname,omitempty"`
  420. Startport int `json:"startport,omitempty"`
  421. Tags []struct {
  422. Account string `json:"account,omitempty"`
  423. Customer string `json:"customer,omitempty"`
  424. Domain string `json:"domain,omitempty"`
  425. Domainid string `json:"domainid,omitempty"`
  426. Key string `json:"key,omitempty"`
  427. Project string `json:"project,omitempty"`
  428. Projectid string `json:"projectid,omitempty"`
  429. Resourceid string `json:"resourceid,omitempty"`
  430. Resourcetype string `json:"resourcetype,omitempty"`
  431. Value string `json:"value,omitempty"`
  432. } `json:"tags,omitempty"`
  433. } `json:"egressrule,omitempty"`
  434. Id string `json:"id,omitempty"`
  435. Ingressrule []struct {
  436. Account string `json:"account,omitempty"`
  437. Cidr string `json:"cidr,omitempty"`
  438. Endport int `json:"endport,omitempty"`
  439. Icmpcode int `json:"icmpcode,omitempty"`
  440. Icmptype int `json:"icmptype,omitempty"`
  441. Protocol string `json:"protocol,omitempty"`
  442. Ruleid string `json:"ruleid,omitempty"`
  443. Securitygroupname string `json:"securitygroupname,omitempty"`
  444. Startport int `json:"startport,omitempty"`
  445. Tags []struct {
  446. Account string `json:"account,omitempty"`
  447. Customer string `json:"customer,omitempty"`
  448. Domain string `json:"domain,omitempty"`
  449. Domainid string `json:"domainid,omitempty"`
  450. Key string `json:"key,omitempty"`
  451. Project string `json:"project,omitempty"`
  452. Projectid string `json:"projectid,omitempty"`
  453. Resourceid string `json:"resourceid,omitempty"`
  454. Resourcetype string `json:"resourcetype,omitempty"`
  455. Value string `json:"value,omitempty"`
  456. } `json:"tags,omitempty"`
  457. } `json:"ingressrule,omitempty"`
  458. Name string `json:"name,omitempty"`
  459. Project string `json:"project,omitempty"`
  460. Projectid string `json:"projectid,omitempty"`
  461. Tags []struct {
  462. Account string `json:"account,omitempty"`
  463. Customer string `json:"customer,omitempty"`
  464. Domain string `json:"domain,omitempty"`
  465. Domainid string `json:"domainid,omitempty"`
  466. Key string `json:"key,omitempty"`
  467. Project string `json:"project,omitempty"`
  468. Projectid string `json:"projectid,omitempty"`
  469. Resourceid string `json:"resourceid,omitempty"`
  470. Resourcetype string `json:"resourcetype,omitempty"`
  471. Value string `json:"value,omitempty"`
  472. } `json:"tags,omitempty"`
  473. Virtualmachinecount int `json:"virtualmachinecount,omitempty"`
  474. Virtualmachineids []string `json:"virtualmachineids,omitempty"`
  475. } `json:"securitygroup,omitempty"`
  476. Serviceofferingid string `json:"serviceofferingid,omitempty"`
  477. Serviceofferingname string `json:"serviceofferingname,omitempty"`
  478. Servicestate string `json:"servicestate,omitempty"`
  479. State string `json:"state,omitempty"`
  480. Tags []struct {
  481. Account string `json:"account,omitempty"`
  482. Customer string `json:"customer,omitempty"`
  483. Domain string `json:"domain,omitempty"`
  484. Domainid string `json:"domainid,omitempty"`
  485. Key string `json:"key,omitempty"`
  486. Project string `json:"project,omitempty"`
  487. Projectid string `json:"projectid,omitempty"`
  488. Resourceid string `json:"resourceid,omitempty"`
  489. Resourcetype string `json:"resourcetype,omitempty"`
  490. Value string `json:"value,omitempty"`
  491. } `json:"tags,omitempty"`
  492. Templatedisplaytext string `json:"templatedisplaytext,omitempty"`
  493. Templateid string `json:"templateid,omitempty"`
  494. Templatename string `json:"templatename,omitempty"`
  495. Userid string `json:"userid,omitempty"`
  496. Username string `json:"username,omitempty"`
  497. Vgpu string `json:"vgpu,omitempty"`
  498. Zoneid string `json:"zoneid,omitempty"`
  499. Zonename string `json:"zonename,omitempty"`
  500. }
  501. type ListIsosParams struct {
  502. p map[string]interface{}
  503. }
  504. func (p *ListIsosParams) toURLValues() url.Values {
  505. u := url.Values{}
  506. if p.p == nil {
  507. return u
  508. }
  509. if v, found := p.p["account"]; found {
  510. u.Set("account", v.(string))
  511. }
  512. if v, found := p.p["bootable"]; found {
  513. vv := strconv.FormatBool(v.(bool))
  514. u.Set("bootable", vv)
  515. }
  516. if v, found := p.p["domainid"]; found {
  517. u.Set("domainid", v.(string))
  518. }
  519. if v, found := p.p["hypervisor"]; found {
  520. u.Set("hypervisor", v.(string))
  521. }
  522. if v, found := p.p["id"]; found {
  523. u.Set("id", v.(string))
  524. }
  525. if v, found := p.p["isofilter"]; found {
  526. u.Set("isofilter", v.(string))
  527. }
  528. if v, found := p.p["ispublic"]; found {
  529. vv := strconv.FormatBool(v.(bool))
  530. u.Set("ispublic", vv)
  531. }
  532. if v, found := p.p["isready"]; found {
  533. vv := strconv.FormatBool(v.(bool))
  534. u.Set("isready", vv)
  535. }
  536. if v, found := p.p["isrecursive"]; found {
  537. vv := strconv.FormatBool(v.(bool))
  538. u.Set("isrecursive", vv)
  539. }
  540. if v, found := p.p["keyword"]; found {
  541. u.Set("keyword", v.(string))
  542. }
  543. if v, found := p.p["listall"]; found {
  544. vv := strconv.FormatBool(v.(bool))
  545. u.Set("listall", vv)
  546. }
  547. if v, found := p.p["name"]; found {
  548. u.Set("name", v.(string))
  549. }
  550. if v, found := p.p["page"]; found {
  551. vv := strconv.Itoa(v.(int))
  552. u.Set("page", vv)
  553. }
  554. if v, found := p.p["pagesize"]; found {
  555. vv := strconv.Itoa(v.(int))
  556. u.Set("pagesize", vv)
  557. }
  558. if v, found := p.p["projectid"]; found {
  559. u.Set("projectid", v.(string))
  560. }
  561. if v, found := p.p["showremoved"]; found {
  562. vv := strconv.FormatBool(v.(bool))
  563. u.Set("showremoved", vv)
  564. }
  565. if v, found := p.p["tags"]; found {
  566. i := 0
  567. for k, vv := range v.(map[string]string) {
  568. u.Set(fmt.Sprintf("tags[%d].key", i), k)
  569. u.Set(fmt.Sprintf("tags[%d].value", i), vv)
  570. i++
  571. }
  572. }
  573. if v, found := p.p["zoneid"]; found {
  574. u.Set("zoneid", v.(string))
  575. }
  576. return u
  577. }
  578. func (p *ListIsosParams) SetAccount(v string) {
  579. if p.p == nil {
  580. p.p = make(map[string]interface{})
  581. }
  582. p.p["account"] = v
  583. return
  584. }
  585. func (p *ListIsosParams) SetBootable(v bool) {
  586. if p.p == nil {
  587. p.p = make(map[string]interface{})
  588. }
  589. p.p["bootable"] = v
  590. return
  591. }
  592. func (p *ListIsosParams) SetDomainid(v string) {
  593. if p.p == nil {
  594. p.p = make(map[string]interface{})
  595. }
  596. p.p["domainid"] = v
  597. return
  598. }
  599. func (p *ListIsosParams) SetHypervisor(v string) {
  600. if p.p == nil {
  601. p.p = make(map[string]interface{})
  602. }
  603. p.p["hypervisor"] = v
  604. return
  605. }
  606. func (p *ListIsosParams) SetId(v string) {
  607. if p.p == nil {
  608. p.p = make(map[string]interface{})
  609. }
  610. p.p["id"] = v
  611. return
  612. }
  613. func (p *ListIsosParams) SetIsofilter(v string) {
  614. if p.p == nil {
  615. p.p = make(map[string]interface{})
  616. }
  617. p.p["isofilter"] = v
  618. return
  619. }
  620. func (p *ListIsosParams) SetIspublic(v bool) {
  621. if p.p == nil {
  622. p.p = make(map[string]interface{})
  623. }
  624. p.p["ispublic"] = v
  625. return
  626. }
  627. func (p *ListIsosParams) SetIsready(v bool) {
  628. if p.p == nil {
  629. p.p = make(map[string]interface{})
  630. }
  631. p.p["isready"] = v
  632. return
  633. }
  634. func (p *ListIsosParams) SetIsrecursive(v bool) {
  635. if p.p == nil {
  636. p.p = make(map[string]interface{})
  637. }
  638. p.p["isrecursive"] = v
  639. return
  640. }
  641. func (p *ListIsosParams) SetKeyword(v string) {
  642. if p.p == nil {
  643. p.p = make(map[string]interface{})
  644. }
  645. p.p["keyword"] = v
  646. return
  647. }
  648. func (p *ListIsosParams) SetListall(v bool) {
  649. if p.p == nil {
  650. p.p = make(map[string]interface{})
  651. }
  652. p.p["listall"] = v
  653. return
  654. }
  655. func (p *ListIsosParams) SetName(v string) {
  656. if p.p == nil {
  657. p.p = make(map[string]interface{})
  658. }
  659. p.p["name"] = v
  660. return
  661. }
  662. func (p *ListIsosParams) SetPage(v int) {
  663. if p.p == nil {
  664. p.p = make(map[string]interface{})
  665. }
  666. p.p["page"] = v
  667. return
  668. }
  669. func (p *ListIsosParams) SetPagesize(v int) {
  670. if p.p == nil {
  671. p.p = make(map[string]interface{})
  672. }
  673. p.p["pagesize"] = v
  674. return
  675. }
  676. func (p *ListIsosParams) SetProjectid(v string) {
  677. if p.p == nil {
  678. p.p = make(map[string]interface{})
  679. }
  680. p.p["projectid"] = v
  681. return
  682. }
  683. func (p *ListIsosParams) SetShowremoved(v bool) {
  684. if p.p == nil {
  685. p.p = make(map[string]interface{})
  686. }
  687. p.p["showremoved"] = v
  688. return
  689. }
  690. func (p *ListIsosParams) SetTags(v map[string]string) {
  691. if p.p == nil {
  692. p.p = make(map[string]interface{})
  693. }
  694. p.p["tags"] = v
  695. return
  696. }
  697. func (p *ListIsosParams) SetZoneid(v string) {
  698. if p.p == nil {
  699. p.p = make(map[string]interface{})
  700. }
  701. p.p["zoneid"] = v
  702. return
  703. }
  704. // You should always use this function to get a new ListIsosParams instance,
  705. // as then you are sure you have configured all required params
  706. func (s *ISOService) NewListIsosParams() *ListIsosParams {
  707. p := &ListIsosParams{}
  708. p.p = make(map[string]interface{})
  709. return p
  710. }
  711. // This is a courtesy helper function, which in some cases may not work as expected!
  712. func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string, opts ...OptionFunc) (string, int, error) {
  713. p := &ListIsosParams{}
  714. p.p = make(map[string]interface{})
  715. p.p["name"] = name
  716. p.p["isofilter"] = isofilter
  717. p.p["zoneid"] = zoneid
  718. for _, fn := range opts {
  719. if err := fn(s.cs, p); err != nil {
  720. return "", -1, err
  721. }
  722. }
  723. l, err := s.ListIsos(p)
  724. if err != nil {
  725. return "", -1, err
  726. }
  727. if l.Count == 0 {
  728. return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
  729. }
  730. if l.Count == 1 {
  731. return l.Isos[0].Id, l.Count, nil
  732. }
  733. if l.Count > 1 {
  734. for _, v := range l.Isos {
  735. if v.Name == name {
  736. return v.Id, l.Count, nil
  737. }
  738. }
  739. }
  740. return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
  741. }
  742. // This is a courtesy helper function, which in some cases may not work as expected!
  743. func (s *ISOService) GetIsoByName(name string, isofilter string, zoneid string, opts ...OptionFunc) (*Iso, int, error) {
  744. id, count, err := s.GetIsoID(name, isofilter, zoneid, opts...)
  745. if err != nil {
  746. return nil, count, err
  747. }
  748. r, count, err := s.GetIsoByID(id, opts...)
  749. if err != nil {
  750. return nil, count, err
  751. }
  752. return r, count, nil
  753. }
  754. // This is a courtesy helper function, which in some cases may not work as expected!
  755. func (s *ISOService) GetIsoByID(id string, opts ...OptionFunc) (*Iso, int, error) {
  756. p := &ListIsosParams{}
  757. p.p = make(map[string]interface{})
  758. p.p["id"] = id
  759. for _, fn := range opts {
  760. if err := fn(s.cs, p); err != nil {
  761. return nil, -1, err
  762. }
  763. }
  764. l, err := s.ListIsos(p)
  765. if err != nil {
  766. if strings.Contains(err.Error(), fmt.Sprintf(
  767. "Invalid parameter id value=%s due to incorrect long value format, "+
  768. "or entity does not exist", id)) {
  769. return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
  770. }
  771. return nil, -1, err
  772. }
  773. if l.Count == 0 {
  774. return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
  775. }
  776. if l.Count == 1 {
  777. return l.Isos[0], l.Count, nil
  778. }
  779. return nil, l.Count, fmt.Errorf("There is more then one result for Iso UUID: %s!", id)
  780. }
  781. // Lists all available ISO files.
  782. func (s *ISOService) ListIsos(p *ListIsosParams) (*ListIsosResponse, error) {
  783. resp, err := s.cs.newRequest("listIsos", p.toURLValues())
  784. if err != nil {
  785. return nil, err
  786. }
  787. var r ListIsosResponse
  788. if err := json.Unmarshal(resp, &r); err != nil {
  789. return nil, err
  790. }
  791. return &r, nil
  792. }
  793. type ListIsosResponse struct {
  794. Count int `json:"count"`
  795. Isos []*Iso `json:"iso"`
  796. }
  797. type Iso struct {
  798. Account string `json:"account,omitempty"`
  799. Accountid string `json:"accountid,omitempty"`
  800. Bootable bool `json:"bootable,omitempty"`
  801. Checksum string `json:"checksum,omitempty"`
  802. Created string `json:"created,omitempty"`
  803. CrossZones bool `json:"crossZones,omitempty"`
  804. Details map[string]string `json:"details,omitempty"`
  805. Displaytext string `json:"displaytext,omitempty"`
  806. Domain string `json:"domain,omitempty"`
  807. Domainid string `json:"domainid,omitempty"`
  808. Format string `json:"format,omitempty"`
  809. Hostid string `json:"hostid,omitempty"`
  810. Hostname string `json:"hostname,omitempty"`
  811. Hypervisor string `json:"hypervisor,omitempty"`
  812. Id string `json:"id,omitempty"`
  813. Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"`
  814. Isextractable bool `json:"isextractable,omitempty"`
  815. Isfeatured bool `json:"isfeatured,omitempty"`
  816. Ispublic bool `json:"ispublic,omitempty"`
  817. Isready bool `json:"isready,omitempty"`
  818. Name string `json:"name,omitempty"`
  819. Ostypeid string `json:"ostypeid,omitempty"`
  820. Ostypename string `json:"ostypename,omitempty"`
  821. Passwordenabled bool `json:"passwordenabled,omitempty"`
  822. Project string `json:"project,omitempty"`
  823. Projectid string `json:"projectid,omitempty"`
  824. Removed string `json:"removed,omitempty"`
  825. Size int64 `json:"size,omitempty"`
  826. Sourcetemplateid string `json:"sourcetemplateid,omitempty"`
  827. Sshkeyenabled bool `json:"sshkeyenabled,omitempty"`
  828. Status string `json:"status,omitempty"`
  829. Tags []struct {
  830. Account string `json:"account,omitempty"`
  831. Customer string `json:"customer,omitempty"`
  832. Domain string `json:"domain,omitempty"`
  833. Domainid string `json:"domainid,omitempty"`
  834. Key string `json:"key,omitempty"`
  835. Project string `json:"project,omitempty"`
  836. Projectid string `json:"projectid,omitempty"`
  837. Resourceid string `json:"resourceid,omitempty"`
  838. Resourcetype string `json:"resourcetype,omitempty"`
  839. Value string `json:"value,omitempty"`
  840. } `json:"tags,omitempty"`
  841. Templatetag string `json:"templatetag,omitempty"`
  842. Templatetype string `json:"templatetype,omitempty"`
  843. Zoneid string `json:"zoneid,omitempty"`
  844. Zonename string `json:"zonename,omitempty"`
  845. }
  846. type RegisterIsoParams struct {
  847. p map[string]interface{}
  848. }
  849. func (p *RegisterIsoParams) toURLValues() url.Values {
  850. u := url.Values{}
  851. if p.p == nil {
  852. return u
  853. }
  854. if v, found := p.p["account"]; found {
  855. u.Set("account", v.(string))
  856. }
  857. if v, found := p.p["bootable"]; found {
  858. vv := strconv.FormatBool(v.(bool))
  859. u.Set("bootable", vv)
  860. }
  861. if v, found := p.p["checksum"]; found {
  862. u.Set("checksum", v.(string))
  863. }
  864. if v, found := p.p["displaytext"]; found {
  865. u.Set("displaytext", v.(string))
  866. }
  867. if v, found := p.p["domainid"]; found {
  868. u.Set("domainid", v.(string))
  869. }
  870. if v, found := p.p["imagestoreuuid"]; found {
  871. u.Set("imagestoreuuid", v.(string))
  872. }
  873. if v, found := p.p["isdynamicallyscalable"]; found {
  874. vv := strconv.FormatBool(v.(bool))
  875. u.Set("isdynamicallyscalable", vv)
  876. }
  877. if v, found := p.p["isextractable"]; found {
  878. vv := strconv.FormatBool(v.(bool))
  879. u.Set("isextractable", vv)
  880. }
  881. if v, found := p.p["isfeatured"]; found {
  882. vv := strconv.FormatBool(v.(bool))
  883. u.Set("isfeatured", vv)
  884. }
  885. if v, found := p.p["ispublic"]; found {
  886. vv := strconv.FormatBool(v.(bool))
  887. u.Set("ispublic", vv)
  888. }
  889. if v, found := p.p["name"]; found {
  890. u.Set("name", v.(string))
  891. }
  892. if v, found := p.p["ostypeid"]; found {
  893. u.Set("ostypeid", v.(string))
  894. }
  895. if v, found := p.p["projectid"]; found {
  896. u.Set("projectid", v.(string))
  897. }
  898. if v, found := p.p["url"]; found {
  899. u.Set("url", v.(string))
  900. }
  901. if v, found := p.p["zoneid"]; found {
  902. u.Set("zoneid", v.(string))
  903. }
  904. return u
  905. }
  906. func (p *RegisterIsoParams) SetAccount(v string) {
  907. if p.p == nil {
  908. p.p = make(map[string]interface{})
  909. }
  910. p.p["account"] = v
  911. return
  912. }
  913. func (p *RegisterIsoParams) SetBootable(v bool) {
  914. if p.p == nil {
  915. p.p = make(map[string]interface{})
  916. }
  917. p.p["bootable"] = v
  918. return
  919. }
  920. func (p *RegisterIsoParams) SetChecksum(v string) {
  921. if p.p == nil {
  922. p.p = make(map[string]interface{})
  923. }
  924. p.p["checksum"] = v
  925. return
  926. }
  927. func (p *RegisterIsoParams) SetDisplaytext(v string) {
  928. if p.p == nil {
  929. p.p = make(map[string]interface{})
  930. }
  931. p.p["displaytext"] = v
  932. return
  933. }
  934. func (p *RegisterIsoParams) SetDomainid(v string) {
  935. if p.p == nil {
  936. p.p = make(map[string]interface{})
  937. }
  938. p.p["domainid"] = v
  939. return
  940. }
  941. func (p *RegisterIsoParams) SetImagestoreuuid(v string) {
  942. if p.p == nil {
  943. p.p = make(map[string]interface{})
  944. }
  945. p.p["imagestoreuuid"] = v
  946. return
  947. }
  948. func (p *RegisterIsoParams) SetIsdynamicallyscalable(v bool) {
  949. if p.p == nil {
  950. p.p = make(map[string]interface{})
  951. }
  952. p.p["isdynamicallyscalable"] = v
  953. return
  954. }
  955. func (p *RegisterIsoParams) SetIsextractable(v bool) {
  956. if p.p == nil {
  957. p.p = make(map[string]interface{})
  958. }
  959. p.p["isextractable"] = v
  960. return
  961. }
  962. func (p *RegisterIsoParams) SetIsfeatured(v bool) {
  963. if p.p == nil {
  964. p.p = make(map[string]interface{})
  965. }
  966. p.p["isfeatured"] = v
  967. return
  968. }
  969. func (p *RegisterIsoParams) SetIspublic(v bool) {
  970. if p.p == nil {
  971. p.p = make(map[string]interface{})
  972. }
  973. p.p["ispublic"] = v
  974. return
  975. }
  976. func (p *RegisterIsoParams) SetName(v string) {
  977. if p.p == nil {
  978. p.p = make(map[string]interface{})
  979. }
  980. p.p["name"] = v
  981. return
  982. }
  983. func (p *RegisterIsoParams) SetOstypeid(v string) {
  984. if p.p == nil {
  985. p.p = make(map[string]interface{})
  986. }
  987. p.p["ostypeid"] = v
  988. return
  989. }
  990. func (p *RegisterIsoParams) SetProjectid(v string) {
  991. if p.p == nil {
  992. p.p = make(map[string]interface{})
  993. }
  994. p.p["projectid"] = v
  995. return
  996. }
  997. func (p *RegisterIsoParams) SetUrl(v string) {
  998. if p.p == nil {
  999. p.p = make(map[string]interface{})
  1000. }
  1001. p.p["url"] = v
  1002. return
  1003. }
  1004. func (p *RegisterIsoParams) SetZoneid(v string) {
  1005. if p.p == nil {
  1006. p.p = make(map[string]interface{})
  1007. }
  1008. p.p["zoneid"] = v
  1009. return
  1010. }
  1011. // You should always use this function to get a new RegisterIsoParams instance,
  1012. // as then you are sure you have configured all required params
  1013. func (s *ISOService) NewRegisterIsoParams(displaytext string, name string, url string, zoneid string) *RegisterIsoParams {
  1014. p := &RegisterIsoParams{}
  1015. p.p = make(map[string]interface{})
  1016. p.p["displaytext"] = displaytext
  1017. p.p["name"] = name
  1018. p.p["url"] = url
  1019. p.p["zoneid"] = zoneid
  1020. return p
  1021. }
  1022. // Registers an existing ISO into the CloudStack Cloud.
  1023. func (s *ISOService) RegisterIso(p *RegisterIsoParams) (*RegisterIsoResponse, error) {
  1024. resp, err := s.cs.newRequest("registerIso", p.toURLValues())
  1025. if err != nil {
  1026. return nil, err
  1027. }
  1028. var r RegisterIsoResponse
  1029. if err := json.Unmarshal(resp, &r); err != nil {
  1030. return nil, err
  1031. }
  1032. return &r, nil
  1033. }
  1034. type RegisterIsoResponse struct {
  1035. Account string `json:"account,omitempty"`
  1036. Accountid string `json:"accountid,omitempty"`
  1037. Bootable bool `json:"bootable,omitempty"`
  1038. Checksum string `json:"checksum,omitempty"`
  1039. Created string `json:"created,omitempty"`
  1040. CrossZones bool `json:"crossZones,omitempty"`
  1041. Details map[string]string `json:"details,omitempty"`
  1042. Displaytext string `json:"displaytext,omitempty"`
  1043. Domain string `json:"domain,omitempty"`
  1044. Domainid string `json:"domainid,omitempty"`
  1045. Format string `json:"format,omitempty"`
  1046. Hostid string `json:"hostid,omitempty"`
  1047. Hostname string `json:"hostname,omitempty"`
  1048. Hypervisor string `json:"hypervisor,omitempty"`
  1049. Id string `json:"id,omitempty"`
  1050. Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"`
  1051. Isextractable bool `json:"isextractable,omitempty"`
  1052. Isfeatured bool `json:"isfeatured,omitempty"`
  1053. Ispublic bool `json:"ispublic,omitempty"`
  1054. Isready bool `json:"isready,omitempty"`
  1055. Name string `json:"name,omitempty"`
  1056. Ostypeid string `json:"ostypeid,omitempty"`
  1057. Ostypename string `json:"ostypename,omitempty"`
  1058. Passwordenabled bool `json:"passwordenabled,omitempty"`
  1059. Project string `json:"project,omitempty"`
  1060. Projectid string `json:"projectid,omitempty"`
  1061. Removed string `json:"removed,omitempty"`
  1062. Size int64 `json:"size,omitempty"`
  1063. Sourcetemplateid string `json:"sourcetemplateid,omitempty"`
  1064. Sshkeyenabled bool `json:"sshkeyenabled,omitempty"`
  1065. Status string `json:"status,omitempty"`
  1066. Tags []struct {
  1067. Account string `json:"account,omitempty"`
  1068. Customer string `json:"customer,omitempty"`
  1069. Domain string `json:"domain,omitempty"`
  1070. Domainid string `json:"domainid,omitempty"`
  1071. Key string `json:"key,omitempty"`
  1072. Project string `json:"project,omitempty"`
  1073. Projectid string `json:"projectid,omitempty"`
  1074. Resourceid string `json:"resourceid,omitempty"`
  1075. Resourcetype string `json:"resourcetype,omitempty"`
  1076. Value string `json:"value,omitempty"`
  1077. } `json:"tags,omitempty"`
  1078. Templatetag string `json:"templatetag,omitempty"`
  1079. Templatetype string `json:"templatetype,omitempty"`
  1080. Zoneid string `json:"zoneid,omitempty"`
  1081. Zonename string `json:"zonename,omitempty"`
  1082. }
  1083. type UpdateIsoParams struct {
  1084. p map[string]interface{}
  1085. }
  1086. func (p *UpdateIsoParams) toURLValues() url.Values {
  1087. u := url.Values{}
  1088. if p.p == nil {
  1089. return u
  1090. }
  1091. if v, found := p.p["bootable"]; found {
  1092. vv := strconv.FormatBool(v.(bool))
  1093. u.Set("bootable", vv)
  1094. }
  1095. if v, found := p.p["details"]; found {
  1096. i := 0
  1097. for k, vv := range v.(map[string]string) {
  1098. u.Set(fmt.Sprintf("details[%d].key", i), k)
  1099. u.Set(fmt.Sprintf("details[%d].value", i), vv)
  1100. i++
  1101. }
  1102. }
  1103. if v, found := p.p["displaytext"]; found {
  1104. u.Set("displaytext", v.(string))
  1105. }
  1106. if v, found := p.p["format"]; found {
  1107. u.Set("format", v.(string))
  1108. }
  1109. if v, found := p.p["id"]; found {
  1110. u.Set("id", v.(string))
  1111. }
  1112. if v, found := p.p["isdynamicallyscalable"]; found {
  1113. vv := strconv.FormatBool(v.(bool))
  1114. u.Set("isdynamicallyscalable", vv)
  1115. }
  1116. if v, found := p.p["isrouting"]; found {
  1117. vv := strconv.FormatBool(v.(bool))
  1118. u.Set("isrouting", vv)
  1119. }
  1120. if v, found := p.p["name"]; found {
  1121. u.Set("name", v.(string))
  1122. }
  1123. if v, found := p.p["ostypeid"]; found {
  1124. u.Set("ostypeid", v.(string))
  1125. }
  1126. if v, found := p.p["passwordenabled"]; found {
  1127. vv := strconv.FormatBool(v.(bool))
  1128. u.Set("passwordenabled", vv)
  1129. }
  1130. if v, found := p.p["requireshvm"]; found {
  1131. vv := strconv.FormatBool(v.(bool))
  1132. u.Set("requireshvm", vv)
  1133. }
  1134. if v, found := p.p["sortkey"]; found {
  1135. vv := strconv.Itoa(v.(int))
  1136. u.Set("sortkey", vv)
  1137. }
  1138. return u
  1139. }
  1140. func (p *UpdateIsoParams) SetBootable(v bool) {
  1141. if p.p == nil {
  1142. p.p = make(map[string]interface{})
  1143. }
  1144. p.p["bootable"] = v
  1145. return
  1146. }
  1147. func (p *UpdateIsoParams) SetDetails(v map[string]string) {
  1148. if p.p == nil {
  1149. p.p = make(map[string]interface{})
  1150. }
  1151. p.p["details"] = v
  1152. return
  1153. }
  1154. func (p *UpdateIsoParams) SetDisplaytext(v string) {
  1155. if p.p == nil {
  1156. p.p = make(map[string]interface{})
  1157. }
  1158. p.p["displaytext"] = v
  1159. return
  1160. }
  1161. func (p *UpdateIsoParams) SetFormat(v string) {
  1162. if p.p == nil {
  1163. p.p = make(map[string]interface{})
  1164. }
  1165. p.p["format"] = v
  1166. return
  1167. }
  1168. func (p *UpdateIsoParams) SetId(v string) {
  1169. if p.p == nil {
  1170. p.p = make(map[string]interface{})
  1171. }
  1172. p.p["id"] = v
  1173. return
  1174. }
  1175. func (p *UpdateIsoParams) SetIsdynamicallyscalable(v bool) {
  1176. if p.p == nil {
  1177. p.p = make(map[string]interface{})
  1178. }
  1179. p.p["isdynamicallyscalable"] = v
  1180. return
  1181. }
  1182. func (p *UpdateIsoParams) SetIsrouting(v bool) {
  1183. if p.p == nil {
  1184. p.p = make(map[string]interface{})
  1185. }
  1186. p.p["isrouting"] = v
  1187. return
  1188. }
  1189. func (p *UpdateIsoParams) SetName(v string) {
  1190. if p.p == nil {
  1191. p.p = make(map[string]interface{})
  1192. }
  1193. p.p["name"] = v
  1194. return
  1195. }
  1196. func (p *UpdateIsoParams) SetOstypeid(v string) {
  1197. if p.p == nil {
  1198. p.p = make(map[string]interface{})
  1199. }
  1200. p.p["ostypeid"] = v
  1201. return
  1202. }
  1203. func (p *UpdateIsoParams) SetPasswordenabled(v bool) {
  1204. if p.p == nil {
  1205. p.p = make(map[string]interface{})
  1206. }
  1207. p.p["passwordenabled"] = v
  1208. return
  1209. }
  1210. func (p *UpdateIsoParams) SetRequireshvm(v bool) {
  1211. if p.p == nil {
  1212. p.p = make(map[string]interface{})
  1213. }
  1214. p.p["requireshvm"] = v
  1215. return
  1216. }
  1217. func (p *UpdateIsoParams) SetSortkey(v int) {
  1218. if p.p == nil {
  1219. p.p = make(map[string]interface{})
  1220. }
  1221. p.p["sortkey"] = v
  1222. return
  1223. }
  1224. // You should always use this function to get a new UpdateIsoParams instance,
  1225. // as then you are sure you have configured all required params
  1226. func (s *ISOService) NewUpdateIsoParams(id string) *UpdateIsoParams {
  1227. p := &UpdateIsoParams{}
  1228. p.p = make(map[string]interface{})
  1229. p.p["id"] = id
  1230. return p
  1231. }
  1232. // Updates an ISO file.
  1233. func (s *ISOService) UpdateIso(p *UpdateIsoParams) (*UpdateIsoResponse, error) {
  1234. resp, err := s.cs.newRequest("updateIso", p.toURLValues())
  1235. if err != nil {
  1236. return nil, err
  1237. }
  1238. var r UpdateIsoResponse
  1239. if err := json.Unmarshal(resp, &r); err != nil {
  1240. return nil, err
  1241. }
  1242. return &r, nil
  1243. }
  1244. type UpdateIsoResponse struct {
  1245. Account string `json:"account,omitempty"`
  1246. Accountid string `json:"accountid,omitempty"`
  1247. Bootable bool `json:"bootable,omitempty"`
  1248. Checksum string `json:"checksum,omitempty"`
  1249. Created string `json:"created,omitempty"`
  1250. CrossZones bool `json:"crossZones,omitempty"`
  1251. Details map[string]string `json:"details,omitempty"`
  1252. Displaytext string `json:"displaytext,omitempty"`
  1253. Domain string `json:"domain,omitempty"`
  1254. Domainid string `json:"domainid,omitempty"`
  1255. Format string `json:"format,omitempty"`
  1256. Hostid string `json:"hostid,omitempty"`
  1257. Hostname string `json:"hostname,omitempty"`
  1258. Hypervisor string `json:"hypervisor,omitempty"`
  1259. Id string `json:"id,omitempty"`
  1260. Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"`
  1261. Isextractable bool `json:"isextractable,omitempty"`
  1262. Isfeatured bool `json:"isfeatured,omitempty"`
  1263. Ispublic bool `json:"ispublic,omitempty"`
  1264. Isready bool `json:"isready,omitempty"`
  1265. Name string `json:"name,omitempty"`
  1266. Ostypeid string `json:"ostypeid,omitempty"`
  1267. Ostypename string `json:"ostypename,omitempty"`
  1268. Passwordenabled bool `json:"passwordenabled,omitempty"`
  1269. Project string `json:"project,omitempty"`
  1270. Projectid string `json:"projectid,omitempty"`
  1271. Removed string `json:"removed,omitempty"`
  1272. Size int64 `json:"size,omitempty"`
  1273. Sourcetemplateid string `json:"sourcetemplateid,omitempty"`
  1274. Sshkeyenabled bool `json:"sshkeyenabled,omitempty"`
  1275. Status string `json:"status,omitempty"`
  1276. Tags []struct {
  1277. Account string `json:"account,omitempty"`
  1278. Customer string `json:"customer,omitempty"`
  1279. Domain string `json:"domain,omitempty"`
  1280. Domainid string `json:"domainid,omitempty"`
  1281. Key string `json:"key,omitempty"`
  1282. Project string `json:"project,omitempty"`
  1283. Projectid string `json:"projectid,omitempty"`
  1284. Resourceid string `json:"resourceid,omitempty"`
  1285. Resourcetype string `json:"resourcetype,omitempty"`
  1286. Value string `json:"value,omitempty"`
  1287. } `json:"tags,omitempty"`
  1288. Templatetag string `json:"templatetag,omitempty"`
  1289. Templatetype string `json:"templatetype,omitempty"`
  1290. Zoneid string `json:"zoneid,omitempty"`
  1291. Zonename string `json:"zonename,omitempty"`
  1292. }
  1293. type DeleteIsoParams struct {
  1294. p map[string]interface{}
  1295. }
  1296. func (p *DeleteIsoParams) toURLValues() url.Values {
  1297. u := url.Values{}
  1298. if p.p == nil {
  1299. return u
  1300. }
  1301. if v, found := p.p["id"]; found {
  1302. u.Set("id", v.(string))
  1303. }
  1304. if v, found := p.p["zoneid"]; found {
  1305. u.Set("zoneid", v.(string))
  1306. }
  1307. return u
  1308. }
  1309. func (p *DeleteIsoParams) SetId(v string) {
  1310. if p.p == nil {
  1311. p.p = make(map[string]interface{})
  1312. }
  1313. p.p["id"] = v
  1314. return
  1315. }
  1316. func (p *DeleteIsoParams) SetZoneid(v string) {
  1317. if p.p == nil {
  1318. p.p = make(map[string]interface{})
  1319. }
  1320. p.p["zoneid"] = v
  1321. return
  1322. }
  1323. // You should always use this function to get a new DeleteIsoParams instance,
  1324. // as then you are sure you have configured all required params
  1325. func (s *ISOService) NewDeleteIsoParams(id string) *DeleteIsoParams {
  1326. p := &DeleteIsoParams{}
  1327. p.p = make(map[string]interface{})
  1328. p.p["id"] = id
  1329. return p
  1330. }
  1331. // Deletes an ISO file.
  1332. func (s *ISOService) DeleteIso(p *DeleteIsoParams) (*DeleteIsoResponse, error) {
  1333. resp, err := s.cs.newRequest("deleteIso", p.toURLValues())
  1334. if err != nil {
  1335. return nil, err
  1336. }
  1337. var r DeleteIsoResponse
  1338. if err := json.Unmarshal(resp, &r); err != nil {
  1339. return nil, err
  1340. }
  1341. // If we have a async client, we need to wait for the async result
  1342. if s.cs.async {
  1343. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  1344. if err != nil {
  1345. if err == AsyncTimeoutErr {
  1346. return &r, err
  1347. }
  1348. return nil, err
  1349. }
  1350. if err := json.Unmarshal(b, &r); err != nil {
  1351. return nil, err
  1352. }
  1353. }
  1354. return &r, nil
  1355. }
  1356. type DeleteIsoResponse struct {
  1357. JobID string `json:"jobid,omitempty"`
  1358. Displaytext string `json:"displaytext,omitempty"`
  1359. Success bool `json:"success,omitempty"`
  1360. }
  1361. type CopyIsoParams struct {
  1362. p map[string]interface{}
  1363. }
  1364. func (p *CopyIsoParams) toURLValues() url.Values {
  1365. u := url.Values{}
  1366. if p.p == nil {
  1367. return u
  1368. }
  1369. if v, found := p.p["destzoneid"]; found {
  1370. u.Set("destzoneid", v.(string))
  1371. }
  1372. if v, found := p.p["id"]; found {
  1373. u.Set("id", v.(string))
  1374. }
  1375. if v, found := p.p["sourcezoneid"]; found {
  1376. u.Set("sourcezoneid", v.(string))
  1377. }
  1378. return u
  1379. }
  1380. func (p *CopyIsoParams) SetDestzoneid(v string) {
  1381. if p.p == nil {
  1382. p.p = make(map[string]interface{})
  1383. }
  1384. p.p["destzoneid"] = v
  1385. return
  1386. }
  1387. func (p *CopyIsoParams) SetId(v string) {
  1388. if p.p == nil {
  1389. p.p = make(map[string]interface{})
  1390. }
  1391. p.p["id"] = v
  1392. return
  1393. }
  1394. func (p *CopyIsoParams) SetSourcezoneid(v string) {
  1395. if p.p == nil {
  1396. p.p = make(map[string]interface{})
  1397. }
  1398. p.p["sourcezoneid"] = v
  1399. return
  1400. }
  1401. // You should always use this function to get a new CopyIsoParams instance,
  1402. // as then you are sure you have configured all required params
  1403. func (s *ISOService) NewCopyIsoParams(destzoneid string, id string) *CopyIsoParams {
  1404. p := &CopyIsoParams{}
  1405. p.p = make(map[string]interface{})
  1406. p.p["destzoneid"] = destzoneid
  1407. p.p["id"] = id
  1408. return p
  1409. }
  1410. // Copies an ISO from one zone to another.
  1411. func (s *ISOService) CopyIso(p *CopyIsoParams) (*CopyIsoResponse, error) {
  1412. resp, err := s.cs.newRequest("copyIso", p.toURLValues())
  1413. if err != nil {
  1414. return nil, err
  1415. }
  1416. var r CopyIsoResponse
  1417. if err := json.Unmarshal(resp, &r); err != nil {
  1418. return nil, err
  1419. }
  1420. // If we have a async client, we need to wait for the async result
  1421. if s.cs.async {
  1422. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  1423. if err != nil {
  1424. if err == AsyncTimeoutErr {
  1425. return &r, err
  1426. }
  1427. return nil, err
  1428. }
  1429. b, err = getRawValue(b)
  1430. if err != nil {
  1431. return nil, err
  1432. }
  1433. if err := json.Unmarshal(b, &r); err != nil {
  1434. return nil, err
  1435. }
  1436. }
  1437. return &r, nil
  1438. }
  1439. type CopyIsoResponse struct {
  1440. JobID string `json:"jobid,omitempty"`
  1441. Account string `json:"account,omitempty"`
  1442. Accountid string `json:"accountid,omitempty"`
  1443. Bootable bool `json:"bootable,omitempty"`
  1444. Checksum string `json:"checksum,omitempty"`
  1445. Created string `json:"created,omitempty"`
  1446. CrossZones bool `json:"crossZones,omitempty"`
  1447. Details map[string]string `json:"details,omitempty"`
  1448. Displaytext string `json:"displaytext,omitempty"`
  1449. Domain string `json:"domain,omitempty"`
  1450. Domainid string `json:"domainid,omitempty"`
  1451. Format string `json:"format,omitempty"`
  1452. Hostid string `json:"hostid,omitempty"`
  1453. Hostname string `json:"hostname,omitempty"`
  1454. Hypervisor string `json:"hypervisor,omitempty"`
  1455. Id string `json:"id,omitempty"`
  1456. Isdynamicallyscalable bool `json:"isdynamicallyscalable,omitempty"`
  1457. Isextractable bool `json:"isextractable,omitempty"`
  1458. Isfeatured bool `json:"isfeatured,omitempty"`
  1459. Ispublic bool `json:"ispublic,omitempty"`
  1460. Isready bool `json:"isready,omitempty"`
  1461. Name string `json:"name,omitempty"`
  1462. Ostypeid string `json:"ostypeid,omitempty"`
  1463. Ostypename string `json:"ostypename,omitempty"`
  1464. Passwordenabled bool `json:"passwordenabled,omitempty"`
  1465. Project string `json:"project,omitempty"`
  1466. Projectid string `json:"projectid,omitempty"`
  1467. Removed string `json:"removed,omitempty"`
  1468. Size int64 `json:"size,omitempty"`
  1469. Sourcetemplateid string `json:"sourcetemplateid,omitempty"`
  1470. Sshkeyenabled bool `json:"sshkeyenabled,omitempty"`
  1471. Status string `json:"status,omitempty"`
  1472. Tags []struct {
  1473. Account string `json:"account,omitempty"`
  1474. Customer string `json:"customer,omitempty"`
  1475. Domain string `json:"domain,omitempty"`
  1476. Domainid string `json:"domainid,omitempty"`
  1477. Key string `json:"key,omitempty"`
  1478. Project string `json:"project,omitempty"`
  1479. Projectid string `json:"projectid,omitempty"`
  1480. Resourceid string `json:"resourceid,omitempty"`
  1481. Resourcetype string `json:"resourcetype,omitempty"`
  1482. Value string `json:"value,omitempty"`
  1483. } `json:"tags,omitempty"`
  1484. Templatetag string `json:"templatetag,omitempty"`
  1485. Templatetype string `json:"templatetype,omitempty"`
  1486. Zoneid string `json:"zoneid,omitempty"`
  1487. Zonename string `json:"zonename,omitempty"`
  1488. }
  1489. type UpdateIsoPermissionsParams struct {
  1490. p map[string]interface{}
  1491. }
  1492. func (p *UpdateIsoPermissionsParams) toURLValues() url.Values {
  1493. u := url.Values{}
  1494. if p.p == nil {
  1495. return u
  1496. }
  1497. if v, found := p.p["accounts"]; found {
  1498. vv := strings.Join(v.([]string), ",")
  1499. u.Set("accounts", vv)
  1500. }
  1501. if v, found := p.p["id"]; found {
  1502. u.Set("id", v.(string))
  1503. }
  1504. if v, found := p.p["isextractable"]; found {
  1505. vv := strconv.FormatBool(v.(bool))
  1506. u.Set("isextractable", vv)
  1507. }
  1508. if v, found := p.p["isfeatured"]; found {
  1509. vv := strconv.FormatBool(v.(bool))
  1510. u.Set("isfeatured", vv)
  1511. }
  1512. if v, found := p.p["ispublic"]; found {
  1513. vv := strconv.FormatBool(v.(bool))
  1514. u.Set("ispublic", vv)
  1515. }
  1516. if v, found := p.p["op"]; found {
  1517. u.Set("op", v.(string))
  1518. }
  1519. if v, found := p.p["projectids"]; found {
  1520. vv := strings.Join(v.([]string), ",")
  1521. u.Set("projectids", vv)
  1522. }
  1523. return u
  1524. }
  1525. func (p *UpdateIsoPermissionsParams) SetAccounts(v []string) {
  1526. if p.p == nil {
  1527. p.p = make(map[string]interface{})
  1528. }
  1529. p.p["accounts"] = v
  1530. return
  1531. }
  1532. func (p *UpdateIsoPermissionsParams) SetId(v string) {
  1533. if p.p == nil {
  1534. p.p = make(map[string]interface{})
  1535. }
  1536. p.p["id"] = v
  1537. return
  1538. }
  1539. func (p *UpdateIsoPermissionsParams) SetIsextractable(v bool) {
  1540. if p.p == nil {
  1541. p.p = make(map[string]interface{})
  1542. }
  1543. p.p["isextractable"] = v
  1544. return
  1545. }
  1546. func (p *UpdateIsoPermissionsParams) SetIsfeatured(v bool) {
  1547. if p.p == nil {
  1548. p.p = make(map[string]interface{})
  1549. }
  1550. p.p["isfeatured"] = v
  1551. return
  1552. }
  1553. func (p *UpdateIsoPermissionsParams) SetIspublic(v bool) {
  1554. if p.p == nil {
  1555. p.p = make(map[string]interface{})
  1556. }
  1557. p.p["ispublic"] = v
  1558. return
  1559. }
  1560. func (p *UpdateIsoPermissionsParams) SetOp(v string) {
  1561. if p.p == nil {
  1562. p.p = make(map[string]interface{})
  1563. }
  1564. p.p["op"] = v
  1565. return
  1566. }
  1567. func (p *UpdateIsoPermissionsParams) SetProjectids(v []string) {
  1568. if p.p == nil {
  1569. p.p = make(map[string]interface{})
  1570. }
  1571. p.p["projectids"] = v
  1572. return
  1573. }
  1574. // You should always use this function to get a new UpdateIsoPermissionsParams instance,
  1575. // as then you are sure you have configured all required params
  1576. func (s *ISOService) NewUpdateIsoPermissionsParams(id string) *UpdateIsoPermissionsParams {
  1577. p := &UpdateIsoPermissionsParams{}
  1578. p.p = make(map[string]interface{})
  1579. p.p["id"] = id
  1580. return p
  1581. }
  1582. // Updates ISO permissions
  1583. func (s *ISOService) UpdateIsoPermissions(p *UpdateIsoPermissionsParams) (*UpdateIsoPermissionsResponse, error) {
  1584. resp, err := s.cs.newRequest("updateIsoPermissions", p.toURLValues())
  1585. if err != nil {
  1586. return nil, err
  1587. }
  1588. var r UpdateIsoPermissionsResponse
  1589. if err := json.Unmarshal(resp, &r); err != nil {
  1590. return nil, err
  1591. }
  1592. return &r, nil
  1593. }
  1594. type UpdateIsoPermissionsResponse struct {
  1595. Displaytext string `json:"displaytext,omitempty"`
  1596. Success string `json:"success,omitempty"`
  1597. }
  1598. type ListIsoPermissionsParams struct {
  1599. p map[string]interface{}
  1600. }
  1601. func (p *ListIsoPermissionsParams) toURLValues() url.Values {
  1602. u := url.Values{}
  1603. if p.p == nil {
  1604. return u
  1605. }
  1606. if v, found := p.p["id"]; found {
  1607. u.Set("id", v.(string))
  1608. }
  1609. return u
  1610. }
  1611. func (p *ListIsoPermissionsParams) SetId(v string) {
  1612. if p.p == nil {
  1613. p.p = make(map[string]interface{})
  1614. }
  1615. p.p["id"] = v
  1616. return
  1617. }
  1618. // You should always use this function to get a new ListIsoPermissionsParams instance,
  1619. // as then you are sure you have configured all required params
  1620. func (s *ISOService) NewListIsoPermissionsParams(id string) *ListIsoPermissionsParams {
  1621. p := &ListIsoPermissionsParams{}
  1622. p.p = make(map[string]interface{})
  1623. p.p["id"] = id
  1624. return p
  1625. }
  1626. // This is a courtesy helper function, which in some cases may not work as expected!
  1627. func (s *ISOService) GetIsoPermissionByID(id string, opts ...OptionFunc) (*IsoPermission, int, error) {
  1628. p := &ListIsoPermissionsParams{}
  1629. p.p = make(map[string]interface{})
  1630. p.p["id"] = id
  1631. for _, fn := range opts {
  1632. if err := fn(s.cs, p); err != nil {
  1633. return nil, -1, err
  1634. }
  1635. }
  1636. l, err := s.ListIsoPermissions(p)
  1637. if err != nil {
  1638. if strings.Contains(err.Error(), fmt.Sprintf(
  1639. "Invalid parameter id value=%s due to incorrect long value format, "+
  1640. "or entity does not exist", id)) {
  1641. return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
  1642. }
  1643. return nil, -1, err
  1644. }
  1645. if l.Count == 0 {
  1646. return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
  1647. }
  1648. if l.Count == 1 {
  1649. return l.IsoPermissions[0], l.Count, nil
  1650. }
  1651. return nil, l.Count, fmt.Errorf("There is more then one result for IsoPermission UUID: %s!", id)
  1652. }
  1653. // List iso visibility and all accounts that have permissions to view this iso.
  1654. func (s *ISOService) ListIsoPermissions(p *ListIsoPermissionsParams) (*ListIsoPermissionsResponse, error) {
  1655. resp, err := s.cs.newRequest("listIsoPermissions", p.toURLValues())
  1656. if err != nil {
  1657. return nil, err
  1658. }
  1659. var r ListIsoPermissionsResponse
  1660. if err := json.Unmarshal(resp, &r); err != nil {
  1661. return nil, err
  1662. }
  1663. return &r, nil
  1664. }
  1665. type ListIsoPermissionsResponse struct {
  1666. Count int `json:"count"`
  1667. IsoPermissions []*IsoPermission `json:"isopermission"`
  1668. }
  1669. type IsoPermission struct {
  1670. Account []string `json:"account,omitempty"`
  1671. Domainid string `json:"domainid,omitempty"`
  1672. Id string `json:"id,omitempty"`
  1673. Ispublic bool `json:"ispublic,omitempty"`
  1674. Projectids []string `json:"projectids,omitempty"`
  1675. }
  1676. type ExtractIsoParams struct {
  1677. p map[string]interface{}
  1678. }
  1679. func (p *ExtractIsoParams) toURLValues() url.Values {
  1680. u := url.Values{}
  1681. if p.p == nil {
  1682. return u
  1683. }
  1684. if v, found := p.p["id"]; found {
  1685. u.Set("id", v.(string))
  1686. }
  1687. if v, found := p.p["mode"]; found {
  1688. u.Set("mode", v.(string))
  1689. }
  1690. if v, found := p.p["url"]; found {
  1691. u.Set("url", v.(string))
  1692. }
  1693. if v, found := p.p["zoneid"]; found {
  1694. u.Set("zoneid", v.(string))
  1695. }
  1696. return u
  1697. }
  1698. func (p *ExtractIsoParams) SetId(v string) {
  1699. if p.p == nil {
  1700. p.p = make(map[string]interface{})
  1701. }
  1702. p.p["id"] = v
  1703. return
  1704. }
  1705. func (p *ExtractIsoParams) SetMode(v string) {
  1706. if p.p == nil {
  1707. p.p = make(map[string]interface{})
  1708. }
  1709. p.p["mode"] = v
  1710. return
  1711. }
  1712. func (p *ExtractIsoParams) SetUrl(v string) {
  1713. if p.p == nil {
  1714. p.p = make(map[string]interface{})
  1715. }
  1716. p.p["url"] = v
  1717. return
  1718. }
  1719. func (p *ExtractIsoParams) SetZoneid(v string) {
  1720. if p.p == nil {
  1721. p.p = make(map[string]interface{})
  1722. }
  1723. p.p["zoneid"] = v
  1724. return
  1725. }
  1726. // You should always use this function to get a new ExtractIsoParams instance,
  1727. // as then you are sure you have configured all required params
  1728. func (s *ISOService) NewExtractIsoParams(id string, mode string) *ExtractIsoParams {
  1729. p := &ExtractIsoParams{}
  1730. p.p = make(map[string]interface{})
  1731. p.p["id"] = id
  1732. p.p["mode"] = mode
  1733. return p
  1734. }
  1735. // Extracts an ISO
  1736. func (s *ISOService) ExtractIso(p *ExtractIsoParams) (*ExtractIsoResponse, error) {
  1737. resp, err := s.cs.newRequest("extractIso", p.toURLValues())
  1738. if err != nil {
  1739. return nil, err
  1740. }
  1741. var r ExtractIsoResponse
  1742. if err := json.Unmarshal(resp, &r); err != nil {
  1743. return nil, err
  1744. }
  1745. // If we have a async client, we need to wait for the async result
  1746. if s.cs.async {
  1747. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  1748. if err != nil {
  1749. if err == AsyncTimeoutErr {
  1750. return &r, err
  1751. }
  1752. return nil, err
  1753. }
  1754. b, err = getRawValue(b)
  1755. if err != nil {
  1756. return nil, err
  1757. }
  1758. if err := json.Unmarshal(b, &r); err != nil {
  1759. return nil, err
  1760. }
  1761. }
  1762. return &r, nil
  1763. }
  1764. type ExtractIsoResponse struct {
  1765. JobID string `json:"jobid,omitempty"`
  1766. Accountid string `json:"accountid,omitempty"`
  1767. Created string `json:"created,omitempty"`
  1768. ExtractId string `json:"extractId,omitempty"`
  1769. ExtractMode string `json:"extractMode,omitempty"`
  1770. Id string `json:"id,omitempty"`
  1771. Name string `json:"name,omitempty"`
  1772. Resultstring string `json:"resultstring,omitempty"`
  1773. State string `json:"state,omitempty"`
  1774. Status string `json:"status,omitempty"`
  1775. Storagetype string `json:"storagetype,omitempty"`
  1776. Uploadpercentage int `json:"uploadpercentage,omitempty"`
  1777. Url string `json:"url,omitempty"`
  1778. Zoneid string `json:"zoneid,omitempty"`
  1779. Zonename string `json:"zonename,omitempty"`
  1780. }