BaremetalService.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  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. "net/url"
  20. "strconv"
  21. )
  22. type AddBaremetalPxeKickStartServerParams struct {
  23. p map[string]interface{}
  24. }
  25. func (p *AddBaremetalPxeKickStartServerParams) toURLValues() url.Values {
  26. u := url.Values{}
  27. if p.p == nil {
  28. return u
  29. }
  30. if v, found := p.p["password"]; found {
  31. u.Set("password", v.(string))
  32. }
  33. if v, found := p.p["physicalnetworkid"]; found {
  34. u.Set("physicalnetworkid", v.(string))
  35. }
  36. if v, found := p.p["podid"]; found {
  37. u.Set("podid", v.(string))
  38. }
  39. if v, found := p.p["pxeservertype"]; found {
  40. u.Set("pxeservertype", v.(string))
  41. }
  42. if v, found := p.p["tftpdir"]; found {
  43. u.Set("tftpdir", v.(string))
  44. }
  45. if v, found := p.p["url"]; found {
  46. u.Set("url", v.(string))
  47. }
  48. if v, found := p.p["username"]; found {
  49. u.Set("username", v.(string))
  50. }
  51. return u
  52. }
  53. func (p *AddBaremetalPxeKickStartServerParams) SetPassword(v string) {
  54. if p.p == nil {
  55. p.p = make(map[string]interface{})
  56. }
  57. p.p["password"] = v
  58. return
  59. }
  60. func (p *AddBaremetalPxeKickStartServerParams) SetPhysicalnetworkid(v string) {
  61. if p.p == nil {
  62. p.p = make(map[string]interface{})
  63. }
  64. p.p["physicalnetworkid"] = v
  65. return
  66. }
  67. func (p *AddBaremetalPxeKickStartServerParams) SetPodid(v string) {
  68. if p.p == nil {
  69. p.p = make(map[string]interface{})
  70. }
  71. p.p["podid"] = v
  72. return
  73. }
  74. func (p *AddBaremetalPxeKickStartServerParams) SetPxeservertype(v string) {
  75. if p.p == nil {
  76. p.p = make(map[string]interface{})
  77. }
  78. p.p["pxeservertype"] = v
  79. return
  80. }
  81. func (p *AddBaremetalPxeKickStartServerParams) SetTftpdir(v string) {
  82. if p.p == nil {
  83. p.p = make(map[string]interface{})
  84. }
  85. p.p["tftpdir"] = v
  86. return
  87. }
  88. func (p *AddBaremetalPxeKickStartServerParams) SetUrl(v string) {
  89. if p.p == nil {
  90. p.p = make(map[string]interface{})
  91. }
  92. p.p["url"] = v
  93. return
  94. }
  95. func (p *AddBaremetalPxeKickStartServerParams) SetUsername(v string) {
  96. if p.p == nil {
  97. p.p = make(map[string]interface{})
  98. }
  99. p.p["username"] = v
  100. return
  101. }
  102. // You should always use this function to get a new AddBaremetalPxeKickStartServerParams instance,
  103. // as then you are sure you have configured all required params
  104. func (s *BaremetalService) NewAddBaremetalPxeKickStartServerParams(password string, physicalnetworkid string, pxeservertype string, tftpdir string, url string, username string) *AddBaremetalPxeKickStartServerParams {
  105. p := &AddBaremetalPxeKickStartServerParams{}
  106. p.p = make(map[string]interface{})
  107. p.p["password"] = password
  108. p.p["physicalnetworkid"] = physicalnetworkid
  109. p.p["pxeservertype"] = pxeservertype
  110. p.p["tftpdir"] = tftpdir
  111. p.p["url"] = url
  112. p.p["username"] = username
  113. return p
  114. }
  115. // add a baremetal pxe server
  116. func (s *BaremetalService) AddBaremetalPxeKickStartServer(p *AddBaremetalPxeKickStartServerParams) (*AddBaremetalPxeKickStartServerResponse, error) {
  117. resp, err := s.cs.newRequest("addBaremetalPxeKickStartServer", p.toURLValues())
  118. if err != nil {
  119. return nil, err
  120. }
  121. var r AddBaremetalPxeKickStartServerResponse
  122. if err := json.Unmarshal(resp, &r); err != nil {
  123. return nil, err
  124. }
  125. // If we have a async client, we need to wait for the async result
  126. if s.cs.async {
  127. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  128. if err != nil {
  129. if err == AsyncTimeoutErr {
  130. return &r, err
  131. }
  132. return nil, err
  133. }
  134. b, err = getRawValue(b)
  135. if err != nil {
  136. return nil, err
  137. }
  138. if err := json.Unmarshal(b, &r); err != nil {
  139. return nil, err
  140. }
  141. }
  142. return &r, nil
  143. }
  144. type AddBaremetalPxeKickStartServerResponse struct {
  145. JobID string `json:"jobid,omitempty"`
  146. Tftpdir string `json:"tftpdir,omitempty"`
  147. }
  148. type AddBaremetalPxePingServerParams struct {
  149. p map[string]interface{}
  150. }
  151. func (p *AddBaremetalPxePingServerParams) toURLValues() url.Values {
  152. u := url.Values{}
  153. if p.p == nil {
  154. return u
  155. }
  156. if v, found := p.p["password"]; found {
  157. u.Set("password", v.(string))
  158. }
  159. if v, found := p.p["physicalnetworkid"]; found {
  160. u.Set("physicalnetworkid", v.(string))
  161. }
  162. if v, found := p.p["pingcifspassword"]; found {
  163. u.Set("pingcifspassword", v.(string))
  164. }
  165. if v, found := p.p["pingcifsusername"]; found {
  166. u.Set("pingcifsusername", v.(string))
  167. }
  168. if v, found := p.p["pingdir"]; found {
  169. u.Set("pingdir", v.(string))
  170. }
  171. if v, found := p.p["pingstorageserverip"]; found {
  172. u.Set("pingstorageserverip", v.(string))
  173. }
  174. if v, found := p.p["podid"]; found {
  175. u.Set("podid", v.(string))
  176. }
  177. if v, found := p.p["pxeservertype"]; found {
  178. u.Set("pxeservertype", v.(string))
  179. }
  180. if v, found := p.p["tftpdir"]; found {
  181. u.Set("tftpdir", v.(string))
  182. }
  183. if v, found := p.p["url"]; found {
  184. u.Set("url", v.(string))
  185. }
  186. if v, found := p.p["username"]; found {
  187. u.Set("username", v.(string))
  188. }
  189. return u
  190. }
  191. func (p *AddBaremetalPxePingServerParams) SetPassword(v string) {
  192. if p.p == nil {
  193. p.p = make(map[string]interface{})
  194. }
  195. p.p["password"] = v
  196. return
  197. }
  198. func (p *AddBaremetalPxePingServerParams) SetPhysicalnetworkid(v string) {
  199. if p.p == nil {
  200. p.p = make(map[string]interface{})
  201. }
  202. p.p["physicalnetworkid"] = v
  203. return
  204. }
  205. func (p *AddBaremetalPxePingServerParams) SetPingcifspassword(v string) {
  206. if p.p == nil {
  207. p.p = make(map[string]interface{})
  208. }
  209. p.p["pingcifspassword"] = v
  210. return
  211. }
  212. func (p *AddBaremetalPxePingServerParams) SetPingcifsusername(v string) {
  213. if p.p == nil {
  214. p.p = make(map[string]interface{})
  215. }
  216. p.p["pingcifsusername"] = v
  217. return
  218. }
  219. func (p *AddBaremetalPxePingServerParams) SetPingdir(v string) {
  220. if p.p == nil {
  221. p.p = make(map[string]interface{})
  222. }
  223. p.p["pingdir"] = v
  224. return
  225. }
  226. func (p *AddBaremetalPxePingServerParams) SetPingstorageserverip(v string) {
  227. if p.p == nil {
  228. p.p = make(map[string]interface{})
  229. }
  230. p.p["pingstorageserverip"] = v
  231. return
  232. }
  233. func (p *AddBaremetalPxePingServerParams) SetPodid(v string) {
  234. if p.p == nil {
  235. p.p = make(map[string]interface{})
  236. }
  237. p.p["podid"] = v
  238. return
  239. }
  240. func (p *AddBaremetalPxePingServerParams) SetPxeservertype(v string) {
  241. if p.p == nil {
  242. p.p = make(map[string]interface{})
  243. }
  244. p.p["pxeservertype"] = v
  245. return
  246. }
  247. func (p *AddBaremetalPxePingServerParams) SetTftpdir(v string) {
  248. if p.p == nil {
  249. p.p = make(map[string]interface{})
  250. }
  251. p.p["tftpdir"] = v
  252. return
  253. }
  254. func (p *AddBaremetalPxePingServerParams) SetUrl(v string) {
  255. if p.p == nil {
  256. p.p = make(map[string]interface{})
  257. }
  258. p.p["url"] = v
  259. return
  260. }
  261. func (p *AddBaremetalPxePingServerParams) SetUsername(v string) {
  262. if p.p == nil {
  263. p.p = make(map[string]interface{})
  264. }
  265. p.p["username"] = v
  266. return
  267. }
  268. // You should always use this function to get a new AddBaremetalPxePingServerParams instance,
  269. // as then you are sure you have configured all required params
  270. func (s *BaremetalService) NewAddBaremetalPxePingServerParams(password string, physicalnetworkid string, pingdir string, pingstorageserverip string, pxeservertype string, tftpdir string, url string, username string) *AddBaremetalPxePingServerParams {
  271. p := &AddBaremetalPxePingServerParams{}
  272. p.p = make(map[string]interface{})
  273. p.p["password"] = password
  274. p.p["physicalnetworkid"] = physicalnetworkid
  275. p.p["pingdir"] = pingdir
  276. p.p["pingstorageserverip"] = pingstorageserverip
  277. p.p["pxeservertype"] = pxeservertype
  278. p.p["tftpdir"] = tftpdir
  279. p.p["url"] = url
  280. p.p["username"] = username
  281. return p
  282. }
  283. // add a baremetal ping pxe server
  284. func (s *BaremetalService) AddBaremetalPxePingServer(p *AddBaremetalPxePingServerParams) (*AddBaremetalPxePingServerResponse, error) {
  285. resp, err := s.cs.newRequest("addBaremetalPxePingServer", p.toURLValues())
  286. if err != nil {
  287. return nil, err
  288. }
  289. var r AddBaremetalPxePingServerResponse
  290. if err := json.Unmarshal(resp, &r); err != nil {
  291. return nil, err
  292. }
  293. // If we have a async client, we need to wait for the async result
  294. if s.cs.async {
  295. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  296. if err != nil {
  297. if err == AsyncTimeoutErr {
  298. return &r, err
  299. }
  300. return nil, err
  301. }
  302. b, err = getRawValue(b)
  303. if err != nil {
  304. return nil, err
  305. }
  306. if err := json.Unmarshal(b, &r); err != nil {
  307. return nil, err
  308. }
  309. }
  310. return &r, nil
  311. }
  312. type AddBaremetalPxePingServerResponse struct {
  313. JobID string `json:"jobid,omitempty"`
  314. Pingdir string `json:"pingdir,omitempty"`
  315. Pingstorageserverip string `json:"pingstorageserverip,omitempty"`
  316. Tftpdir string `json:"tftpdir,omitempty"`
  317. }
  318. type AddBaremetalDhcpParams struct {
  319. p map[string]interface{}
  320. }
  321. func (p *AddBaremetalDhcpParams) toURLValues() url.Values {
  322. u := url.Values{}
  323. if p.p == nil {
  324. return u
  325. }
  326. if v, found := p.p["dhcpservertype"]; found {
  327. u.Set("dhcpservertype", v.(string))
  328. }
  329. if v, found := p.p["password"]; found {
  330. u.Set("password", v.(string))
  331. }
  332. if v, found := p.p["physicalnetworkid"]; found {
  333. u.Set("physicalnetworkid", v.(string))
  334. }
  335. if v, found := p.p["url"]; found {
  336. u.Set("url", v.(string))
  337. }
  338. if v, found := p.p["username"]; found {
  339. u.Set("username", v.(string))
  340. }
  341. return u
  342. }
  343. func (p *AddBaremetalDhcpParams) SetDhcpservertype(v string) {
  344. if p.p == nil {
  345. p.p = make(map[string]interface{})
  346. }
  347. p.p["dhcpservertype"] = v
  348. return
  349. }
  350. func (p *AddBaremetalDhcpParams) SetPassword(v string) {
  351. if p.p == nil {
  352. p.p = make(map[string]interface{})
  353. }
  354. p.p["password"] = v
  355. return
  356. }
  357. func (p *AddBaremetalDhcpParams) SetPhysicalnetworkid(v string) {
  358. if p.p == nil {
  359. p.p = make(map[string]interface{})
  360. }
  361. p.p["physicalnetworkid"] = v
  362. return
  363. }
  364. func (p *AddBaremetalDhcpParams) SetUrl(v string) {
  365. if p.p == nil {
  366. p.p = make(map[string]interface{})
  367. }
  368. p.p["url"] = v
  369. return
  370. }
  371. func (p *AddBaremetalDhcpParams) SetUsername(v string) {
  372. if p.p == nil {
  373. p.p = make(map[string]interface{})
  374. }
  375. p.p["username"] = v
  376. return
  377. }
  378. // You should always use this function to get a new AddBaremetalDhcpParams instance,
  379. // as then you are sure you have configured all required params
  380. func (s *BaremetalService) NewAddBaremetalDhcpParams(dhcpservertype string, password string, physicalnetworkid string, url string, username string) *AddBaremetalDhcpParams {
  381. p := &AddBaremetalDhcpParams{}
  382. p.p = make(map[string]interface{})
  383. p.p["dhcpservertype"] = dhcpservertype
  384. p.p["password"] = password
  385. p.p["physicalnetworkid"] = physicalnetworkid
  386. p.p["url"] = url
  387. p.p["username"] = username
  388. return p
  389. }
  390. // adds a baremetal dhcp server
  391. func (s *BaremetalService) AddBaremetalDhcp(p *AddBaremetalDhcpParams) (*AddBaremetalDhcpResponse, error) {
  392. resp, err := s.cs.newRequest("addBaremetalDhcp", p.toURLValues())
  393. if err != nil {
  394. return nil, err
  395. }
  396. var r AddBaremetalDhcpResponse
  397. if err := json.Unmarshal(resp, &r); err != nil {
  398. return nil, err
  399. }
  400. // If we have a async client, we need to wait for the async result
  401. if s.cs.async {
  402. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  403. if err != nil {
  404. if err == AsyncTimeoutErr {
  405. return &r, err
  406. }
  407. return nil, err
  408. }
  409. b, err = getRawValue(b)
  410. if err != nil {
  411. return nil, err
  412. }
  413. if err := json.Unmarshal(b, &r); err != nil {
  414. return nil, err
  415. }
  416. }
  417. return &r, nil
  418. }
  419. type AddBaremetalDhcpResponse struct {
  420. JobID string `json:"jobid,omitempty"`
  421. Dhcpservertype string `json:"dhcpservertype,omitempty"`
  422. Id string `json:"id,omitempty"`
  423. Physicalnetworkid string `json:"physicalnetworkid,omitempty"`
  424. Provider string `json:"provider,omitempty"`
  425. Url string `json:"url,omitempty"`
  426. }
  427. type ListBaremetalDhcpParams struct {
  428. p map[string]interface{}
  429. }
  430. func (p *ListBaremetalDhcpParams) toURLValues() url.Values {
  431. u := url.Values{}
  432. if p.p == nil {
  433. return u
  434. }
  435. if v, found := p.p["dhcpservertype"]; found {
  436. u.Set("dhcpservertype", v.(string))
  437. }
  438. if v, found := p.p["id"]; found {
  439. vv := strconv.FormatInt(v.(int64), 10)
  440. u.Set("id", vv)
  441. }
  442. if v, found := p.p["keyword"]; found {
  443. u.Set("keyword", v.(string))
  444. }
  445. if v, found := p.p["page"]; found {
  446. vv := strconv.Itoa(v.(int))
  447. u.Set("page", vv)
  448. }
  449. if v, found := p.p["pagesize"]; found {
  450. vv := strconv.Itoa(v.(int))
  451. u.Set("pagesize", vv)
  452. }
  453. if v, found := p.p["physicalnetworkid"]; found {
  454. u.Set("physicalnetworkid", v.(string))
  455. }
  456. return u
  457. }
  458. func (p *ListBaremetalDhcpParams) SetDhcpservertype(v string) {
  459. if p.p == nil {
  460. p.p = make(map[string]interface{})
  461. }
  462. p.p["dhcpservertype"] = v
  463. return
  464. }
  465. func (p *ListBaremetalDhcpParams) SetId(v int64) {
  466. if p.p == nil {
  467. p.p = make(map[string]interface{})
  468. }
  469. p.p["id"] = v
  470. return
  471. }
  472. func (p *ListBaremetalDhcpParams) SetKeyword(v string) {
  473. if p.p == nil {
  474. p.p = make(map[string]interface{})
  475. }
  476. p.p["keyword"] = v
  477. return
  478. }
  479. func (p *ListBaremetalDhcpParams) SetPage(v int) {
  480. if p.p == nil {
  481. p.p = make(map[string]interface{})
  482. }
  483. p.p["page"] = v
  484. return
  485. }
  486. func (p *ListBaremetalDhcpParams) SetPagesize(v int) {
  487. if p.p == nil {
  488. p.p = make(map[string]interface{})
  489. }
  490. p.p["pagesize"] = v
  491. return
  492. }
  493. func (p *ListBaremetalDhcpParams) SetPhysicalnetworkid(v string) {
  494. if p.p == nil {
  495. p.p = make(map[string]interface{})
  496. }
  497. p.p["physicalnetworkid"] = v
  498. return
  499. }
  500. // You should always use this function to get a new ListBaremetalDhcpParams instance,
  501. // as then you are sure you have configured all required params
  502. func (s *BaremetalService) NewListBaremetalDhcpParams(physicalnetworkid string) *ListBaremetalDhcpParams {
  503. p := &ListBaremetalDhcpParams{}
  504. p.p = make(map[string]interface{})
  505. p.p["physicalnetworkid"] = physicalnetworkid
  506. return p
  507. }
  508. // list baremetal dhcp servers
  509. func (s *BaremetalService) ListBaremetalDhcp(p *ListBaremetalDhcpParams) (*ListBaremetalDhcpResponse, error) {
  510. resp, err := s.cs.newRequest("listBaremetalDhcp", p.toURLValues())
  511. if err != nil {
  512. return nil, err
  513. }
  514. var r ListBaremetalDhcpResponse
  515. if err := json.Unmarshal(resp, &r); err != nil {
  516. return nil, err
  517. }
  518. return &r, nil
  519. }
  520. type ListBaremetalDhcpResponse struct {
  521. Count int `json:"count"`
  522. BaremetalDhcp []*BaremetalDhcp `json:"baremetaldhcp"`
  523. }
  524. type BaremetalDhcp struct {
  525. Dhcpservertype string `json:"dhcpservertype,omitempty"`
  526. Id string `json:"id,omitempty"`
  527. Physicalnetworkid string `json:"physicalnetworkid,omitempty"`
  528. Provider string `json:"provider,omitempty"`
  529. Url string `json:"url,omitempty"`
  530. }
  531. type ListBaremetalPxeServersParams struct {
  532. p map[string]interface{}
  533. }
  534. func (p *ListBaremetalPxeServersParams) toURLValues() url.Values {
  535. u := url.Values{}
  536. if p.p == nil {
  537. return u
  538. }
  539. if v, found := p.p["id"]; found {
  540. vv := strconv.FormatInt(v.(int64), 10)
  541. u.Set("id", vv)
  542. }
  543. if v, found := p.p["keyword"]; found {
  544. u.Set("keyword", v.(string))
  545. }
  546. if v, found := p.p["page"]; found {
  547. vv := strconv.Itoa(v.(int))
  548. u.Set("page", vv)
  549. }
  550. if v, found := p.p["pagesize"]; found {
  551. vv := strconv.Itoa(v.(int))
  552. u.Set("pagesize", vv)
  553. }
  554. if v, found := p.p["physicalnetworkid"]; found {
  555. u.Set("physicalnetworkid", v.(string))
  556. }
  557. return u
  558. }
  559. func (p *ListBaremetalPxeServersParams) SetId(v int64) {
  560. if p.p == nil {
  561. p.p = make(map[string]interface{})
  562. }
  563. p.p["id"] = v
  564. return
  565. }
  566. func (p *ListBaremetalPxeServersParams) SetKeyword(v string) {
  567. if p.p == nil {
  568. p.p = make(map[string]interface{})
  569. }
  570. p.p["keyword"] = v
  571. return
  572. }
  573. func (p *ListBaremetalPxeServersParams) SetPage(v int) {
  574. if p.p == nil {
  575. p.p = make(map[string]interface{})
  576. }
  577. p.p["page"] = v
  578. return
  579. }
  580. func (p *ListBaremetalPxeServersParams) SetPagesize(v int) {
  581. if p.p == nil {
  582. p.p = make(map[string]interface{})
  583. }
  584. p.p["pagesize"] = v
  585. return
  586. }
  587. func (p *ListBaremetalPxeServersParams) SetPhysicalnetworkid(v string) {
  588. if p.p == nil {
  589. p.p = make(map[string]interface{})
  590. }
  591. p.p["physicalnetworkid"] = v
  592. return
  593. }
  594. // You should always use this function to get a new ListBaremetalPxeServersParams instance,
  595. // as then you are sure you have configured all required params
  596. func (s *BaremetalService) NewListBaremetalPxeServersParams(physicalnetworkid string) *ListBaremetalPxeServersParams {
  597. p := &ListBaremetalPxeServersParams{}
  598. p.p = make(map[string]interface{})
  599. p.p["physicalnetworkid"] = physicalnetworkid
  600. return p
  601. }
  602. // list baremetal pxe server
  603. func (s *BaremetalService) ListBaremetalPxeServers(p *ListBaremetalPxeServersParams) (*ListBaremetalPxeServersResponse, error) {
  604. resp, err := s.cs.newRequest("listBaremetalPxeServers", p.toURLValues())
  605. if err != nil {
  606. return nil, err
  607. }
  608. var r ListBaremetalPxeServersResponse
  609. if err := json.Unmarshal(resp, &r); err != nil {
  610. return nil, err
  611. }
  612. return &r, nil
  613. }
  614. type ListBaremetalPxeServersResponse struct {
  615. Count int `json:"count"`
  616. BaremetalPxeServers []*BaremetalPxeServer `json:"baremetalpxeserver"`
  617. }
  618. type BaremetalPxeServer struct {
  619. Id string `json:"id,omitempty"`
  620. Physicalnetworkid string `json:"physicalnetworkid,omitempty"`
  621. Provider string `json:"provider,omitempty"`
  622. Url string `json:"url,omitempty"`
  623. }
  624. type AddBaremetalRctParams struct {
  625. p map[string]interface{}
  626. }
  627. func (p *AddBaremetalRctParams) toURLValues() url.Values {
  628. u := url.Values{}
  629. if p.p == nil {
  630. return u
  631. }
  632. if v, found := p.p["baremetalrcturl"]; found {
  633. u.Set("baremetalrcturl", v.(string))
  634. }
  635. return u
  636. }
  637. func (p *AddBaremetalRctParams) SetBaremetalrcturl(v string) {
  638. if p.p == nil {
  639. p.p = make(map[string]interface{})
  640. }
  641. p.p["baremetalrcturl"] = v
  642. return
  643. }
  644. // You should always use this function to get a new AddBaremetalRctParams instance,
  645. // as then you are sure you have configured all required params
  646. func (s *BaremetalService) NewAddBaremetalRctParams(baremetalrcturl string) *AddBaremetalRctParams {
  647. p := &AddBaremetalRctParams{}
  648. p.p = make(map[string]interface{})
  649. p.p["baremetalrcturl"] = baremetalrcturl
  650. return p
  651. }
  652. // adds baremetal rack configuration text
  653. func (s *BaremetalService) AddBaremetalRct(p *AddBaremetalRctParams) (*AddBaremetalRctResponse, error) {
  654. resp, err := s.cs.newRequest("addBaremetalRct", p.toURLValues())
  655. if err != nil {
  656. return nil, err
  657. }
  658. var r AddBaremetalRctResponse
  659. if err := json.Unmarshal(resp, &r); err != nil {
  660. return nil, err
  661. }
  662. // If we have a async client, we need to wait for the async result
  663. if s.cs.async {
  664. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  665. if err != nil {
  666. if err == AsyncTimeoutErr {
  667. return &r, err
  668. }
  669. return nil, err
  670. }
  671. b, err = getRawValue(b)
  672. if err != nil {
  673. return nil, err
  674. }
  675. if err := json.Unmarshal(b, &r); err != nil {
  676. return nil, err
  677. }
  678. }
  679. return &r, nil
  680. }
  681. type AddBaremetalRctResponse struct {
  682. JobID string `json:"jobid,omitempty"`
  683. Id string `json:"id,omitempty"`
  684. Url string `json:"url,omitempty"`
  685. }
  686. type DeleteBaremetalRctParams struct {
  687. p map[string]interface{}
  688. }
  689. func (p *DeleteBaremetalRctParams) toURLValues() url.Values {
  690. u := url.Values{}
  691. if p.p == nil {
  692. return u
  693. }
  694. if v, found := p.p["id"]; found {
  695. u.Set("id", v.(string))
  696. }
  697. return u
  698. }
  699. func (p *DeleteBaremetalRctParams) SetId(v string) {
  700. if p.p == nil {
  701. p.p = make(map[string]interface{})
  702. }
  703. p.p["id"] = v
  704. return
  705. }
  706. // You should always use this function to get a new DeleteBaremetalRctParams instance,
  707. // as then you are sure you have configured all required params
  708. func (s *BaremetalService) NewDeleteBaremetalRctParams(id string) *DeleteBaremetalRctParams {
  709. p := &DeleteBaremetalRctParams{}
  710. p.p = make(map[string]interface{})
  711. p.p["id"] = id
  712. return p
  713. }
  714. // deletes baremetal rack configuration text
  715. func (s *BaremetalService) DeleteBaremetalRct(p *DeleteBaremetalRctParams) (*DeleteBaremetalRctResponse, error) {
  716. resp, err := s.cs.newRequest("deleteBaremetalRct", p.toURLValues())
  717. if err != nil {
  718. return nil, err
  719. }
  720. var r DeleteBaremetalRctResponse
  721. if err := json.Unmarshal(resp, &r); err != nil {
  722. return nil, err
  723. }
  724. // If we have a async client, we need to wait for the async result
  725. if s.cs.async {
  726. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  727. if err != nil {
  728. if err == AsyncTimeoutErr {
  729. return &r, err
  730. }
  731. return nil, err
  732. }
  733. if err := json.Unmarshal(b, &r); err != nil {
  734. return nil, err
  735. }
  736. }
  737. return &r, nil
  738. }
  739. type DeleteBaremetalRctResponse struct {
  740. JobID string `json:"jobid,omitempty"`
  741. Displaytext string `json:"displaytext,omitempty"`
  742. Success bool `json:"success,omitempty"`
  743. }
  744. type ListBaremetalRctParams struct {
  745. p map[string]interface{}
  746. }
  747. func (p *ListBaremetalRctParams) toURLValues() url.Values {
  748. u := url.Values{}
  749. if p.p == nil {
  750. return u
  751. }
  752. if v, found := p.p["keyword"]; found {
  753. u.Set("keyword", v.(string))
  754. }
  755. if v, found := p.p["page"]; found {
  756. vv := strconv.Itoa(v.(int))
  757. u.Set("page", vv)
  758. }
  759. if v, found := p.p["pagesize"]; found {
  760. vv := strconv.Itoa(v.(int))
  761. u.Set("pagesize", vv)
  762. }
  763. return u
  764. }
  765. func (p *ListBaremetalRctParams) SetKeyword(v string) {
  766. if p.p == nil {
  767. p.p = make(map[string]interface{})
  768. }
  769. p.p["keyword"] = v
  770. return
  771. }
  772. func (p *ListBaremetalRctParams) SetPage(v int) {
  773. if p.p == nil {
  774. p.p = make(map[string]interface{})
  775. }
  776. p.p["page"] = v
  777. return
  778. }
  779. func (p *ListBaremetalRctParams) SetPagesize(v int) {
  780. if p.p == nil {
  781. p.p = make(map[string]interface{})
  782. }
  783. p.p["pagesize"] = v
  784. return
  785. }
  786. // You should always use this function to get a new ListBaremetalRctParams instance,
  787. // as then you are sure you have configured all required params
  788. func (s *BaremetalService) NewListBaremetalRctParams() *ListBaremetalRctParams {
  789. p := &ListBaremetalRctParams{}
  790. p.p = make(map[string]interface{})
  791. return p
  792. }
  793. // list baremetal rack configuration
  794. func (s *BaremetalService) ListBaremetalRct(p *ListBaremetalRctParams) (*ListBaremetalRctResponse, error) {
  795. resp, err := s.cs.newRequest("listBaremetalRct", p.toURLValues())
  796. if err != nil {
  797. return nil, err
  798. }
  799. var r ListBaremetalRctResponse
  800. if err := json.Unmarshal(resp, &r); err != nil {
  801. return nil, err
  802. }
  803. return &r, nil
  804. }
  805. type ListBaremetalRctResponse struct {
  806. Count int `json:"count"`
  807. BaremetalRct []*BaremetalRct `json:"baremetalrct"`
  808. }
  809. type BaremetalRct struct {
  810. Id string `json:"id,omitempty"`
  811. Url string `json:"url,omitempty"`
  812. }