NetworkACLService.go 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459
  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 CreateNetworkACLParams struct {
  25. p map[string]interface{}
  26. }
  27. func (p *CreateNetworkACLParams) toURLValues() url.Values {
  28. u := url.Values{}
  29. if p.p == nil {
  30. return u
  31. }
  32. if v, found := p.p["aclid"]; found {
  33. u.Set("aclid", v.(string))
  34. }
  35. if v, found := p.p["action"]; found {
  36. u.Set("action", v.(string))
  37. }
  38. if v, found := p.p["cidrlist"]; found {
  39. vv := strings.Join(v.([]string), ",")
  40. u.Set("cidrlist", vv)
  41. }
  42. if v, found := p.p["endport"]; found {
  43. vv := strconv.Itoa(v.(int))
  44. u.Set("endport", vv)
  45. }
  46. if v, found := p.p["fordisplay"]; found {
  47. vv := strconv.FormatBool(v.(bool))
  48. u.Set("fordisplay", vv)
  49. }
  50. if v, found := p.p["icmpcode"]; found {
  51. vv := strconv.Itoa(v.(int))
  52. u.Set("icmpcode", vv)
  53. }
  54. if v, found := p.p["icmptype"]; found {
  55. vv := strconv.Itoa(v.(int))
  56. u.Set("icmptype", vv)
  57. }
  58. if v, found := p.p["networkid"]; found {
  59. u.Set("networkid", v.(string))
  60. }
  61. if v, found := p.p["number"]; found {
  62. vv := strconv.Itoa(v.(int))
  63. u.Set("number", vv)
  64. }
  65. if v, found := p.p["protocol"]; found {
  66. u.Set("protocol", v.(string))
  67. }
  68. if v, found := p.p["startport"]; found {
  69. vv := strconv.Itoa(v.(int))
  70. u.Set("startport", vv)
  71. }
  72. if v, found := p.p["traffictype"]; found {
  73. u.Set("traffictype", v.(string))
  74. }
  75. return u
  76. }
  77. func (p *CreateNetworkACLParams) SetAclid(v string) {
  78. if p.p == nil {
  79. p.p = make(map[string]interface{})
  80. }
  81. p.p["aclid"] = v
  82. return
  83. }
  84. func (p *CreateNetworkACLParams) SetAction(v string) {
  85. if p.p == nil {
  86. p.p = make(map[string]interface{})
  87. }
  88. p.p["action"] = v
  89. return
  90. }
  91. func (p *CreateNetworkACLParams) SetCidrlist(v []string) {
  92. if p.p == nil {
  93. p.p = make(map[string]interface{})
  94. }
  95. p.p["cidrlist"] = v
  96. return
  97. }
  98. func (p *CreateNetworkACLParams) SetEndport(v int) {
  99. if p.p == nil {
  100. p.p = make(map[string]interface{})
  101. }
  102. p.p["endport"] = v
  103. return
  104. }
  105. func (p *CreateNetworkACLParams) SetFordisplay(v bool) {
  106. if p.p == nil {
  107. p.p = make(map[string]interface{})
  108. }
  109. p.p["fordisplay"] = v
  110. return
  111. }
  112. func (p *CreateNetworkACLParams) SetIcmpcode(v int) {
  113. if p.p == nil {
  114. p.p = make(map[string]interface{})
  115. }
  116. p.p["icmpcode"] = v
  117. return
  118. }
  119. func (p *CreateNetworkACLParams) SetIcmptype(v int) {
  120. if p.p == nil {
  121. p.p = make(map[string]interface{})
  122. }
  123. p.p["icmptype"] = v
  124. return
  125. }
  126. func (p *CreateNetworkACLParams) SetNetworkid(v string) {
  127. if p.p == nil {
  128. p.p = make(map[string]interface{})
  129. }
  130. p.p["networkid"] = v
  131. return
  132. }
  133. func (p *CreateNetworkACLParams) SetNumber(v int) {
  134. if p.p == nil {
  135. p.p = make(map[string]interface{})
  136. }
  137. p.p["number"] = v
  138. return
  139. }
  140. func (p *CreateNetworkACLParams) SetProtocol(v string) {
  141. if p.p == nil {
  142. p.p = make(map[string]interface{})
  143. }
  144. p.p["protocol"] = v
  145. return
  146. }
  147. func (p *CreateNetworkACLParams) SetStartport(v int) {
  148. if p.p == nil {
  149. p.p = make(map[string]interface{})
  150. }
  151. p.p["startport"] = v
  152. return
  153. }
  154. func (p *CreateNetworkACLParams) SetTraffictype(v string) {
  155. if p.p == nil {
  156. p.p = make(map[string]interface{})
  157. }
  158. p.p["traffictype"] = v
  159. return
  160. }
  161. // You should always use this function to get a new CreateNetworkACLParams instance,
  162. // as then you are sure you have configured all required params
  163. func (s *NetworkACLService) NewCreateNetworkACLParams(protocol string) *CreateNetworkACLParams {
  164. p := &CreateNetworkACLParams{}
  165. p.p = make(map[string]interface{})
  166. p.p["protocol"] = protocol
  167. return p
  168. }
  169. // Creates a ACL rule in the given network (the network has to belong to VPC)
  170. func (s *NetworkACLService) CreateNetworkACL(p *CreateNetworkACLParams) (*CreateNetworkACLResponse, error) {
  171. resp, err := s.cs.newRequest("createNetworkACL", p.toURLValues())
  172. if err != nil {
  173. return nil, err
  174. }
  175. var r CreateNetworkACLResponse
  176. if err := json.Unmarshal(resp, &r); err != nil {
  177. return nil, err
  178. }
  179. // If we have a async client, we need to wait for the async result
  180. if s.cs.async {
  181. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  182. if err != nil {
  183. if err == AsyncTimeoutErr {
  184. return &r, err
  185. }
  186. return nil, err
  187. }
  188. b, err = getRawValue(b)
  189. if err != nil {
  190. return nil, err
  191. }
  192. if err := json.Unmarshal(b, &r); err != nil {
  193. return nil, err
  194. }
  195. }
  196. return &r, nil
  197. }
  198. type CreateNetworkACLResponse struct {
  199. JobID string `json:"jobid,omitempty"`
  200. Aclid string `json:"aclid,omitempty"`
  201. Action string `json:"action,omitempty"`
  202. Cidrlist string `json:"cidrlist,omitempty"`
  203. Endport string `json:"endport,omitempty"`
  204. Fordisplay bool `json:"fordisplay,omitempty"`
  205. Icmpcode int `json:"icmpcode,omitempty"`
  206. Icmptype int `json:"icmptype,omitempty"`
  207. Id string `json:"id,omitempty"`
  208. Number int `json:"number,omitempty"`
  209. Protocol string `json:"protocol,omitempty"`
  210. Startport string `json:"startport,omitempty"`
  211. State string `json:"state,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. Traffictype string `json:"traffictype,omitempty"`
  225. }
  226. type UpdateNetworkACLItemParams struct {
  227. p map[string]interface{}
  228. }
  229. func (p *UpdateNetworkACLItemParams) toURLValues() url.Values {
  230. u := url.Values{}
  231. if p.p == nil {
  232. return u
  233. }
  234. if v, found := p.p["action"]; found {
  235. u.Set("action", v.(string))
  236. }
  237. if v, found := p.p["cidrlist"]; found {
  238. vv := strings.Join(v.([]string), ",")
  239. u.Set("cidrlist", vv)
  240. }
  241. if v, found := p.p["customid"]; found {
  242. u.Set("customid", v.(string))
  243. }
  244. if v, found := p.p["endport"]; found {
  245. vv := strconv.Itoa(v.(int))
  246. u.Set("endport", vv)
  247. }
  248. if v, found := p.p["fordisplay"]; found {
  249. vv := strconv.FormatBool(v.(bool))
  250. u.Set("fordisplay", vv)
  251. }
  252. if v, found := p.p["icmpcode"]; found {
  253. vv := strconv.Itoa(v.(int))
  254. u.Set("icmpcode", vv)
  255. }
  256. if v, found := p.p["icmptype"]; found {
  257. vv := strconv.Itoa(v.(int))
  258. u.Set("icmptype", vv)
  259. }
  260. if v, found := p.p["id"]; found {
  261. u.Set("id", v.(string))
  262. }
  263. if v, found := p.p["number"]; found {
  264. vv := strconv.Itoa(v.(int))
  265. u.Set("number", vv)
  266. }
  267. if v, found := p.p["protocol"]; found {
  268. u.Set("protocol", v.(string))
  269. }
  270. if v, found := p.p["startport"]; found {
  271. vv := strconv.Itoa(v.(int))
  272. u.Set("startport", vv)
  273. }
  274. if v, found := p.p["traffictype"]; found {
  275. u.Set("traffictype", v.(string))
  276. }
  277. return u
  278. }
  279. func (p *UpdateNetworkACLItemParams) SetAction(v string) {
  280. if p.p == nil {
  281. p.p = make(map[string]interface{})
  282. }
  283. p.p["action"] = v
  284. return
  285. }
  286. func (p *UpdateNetworkACLItemParams) SetCidrlist(v []string) {
  287. if p.p == nil {
  288. p.p = make(map[string]interface{})
  289. }
  290. p.p["cidrlist"] = v
  291. return
  292. }
  293. func (p *UpdateNetworkACLItemParams) SetCustomid(v string) {
  294. if p.p == nil {
  295. p.p = make(map[string]interface{})
  296. }
  297. p.p["customid"] = v
  298. return
  299. }
  300. func (p *UpdateNetworkACLItemParams) SetEndport(v int) {
  301. if p.p == nil {
  302. p.p = make(map[string]interface{})
  303. }
  304. p.p["endport"] = v
  305. return
  306. }
  307. func (p *UpdateNetworkACLItemParams) SetFordisplay(v bool) {
  308. if p.p == nil {
  309. p.p = make(map[string]interface{})
  310. }
  311. p.p["fordisplay"] = v
  312. return
  313. }
  314. func (p *UpdateNetworkACLItemParams) SetIcmpcode(v int) {
  315. if p.p == nil {
  316. p.p = make(map[string]interface{})
  317. }
  318. p.p["icmpcode"] = v
  319. return
  320. }
  321. func (p *UpdateNetworkACLItemParams) SetIcmptype(v int) {
  322. if p.p == nil {
  323. p.p = make(map[string]interface{})
  324. }
  325. p.p["icmptype"] = v
  326. return
  327. }
  328. func (p *UpdateNetworkACLItemParams) SetId(v string) {
  329. if p.p == nil {
  330. p.p = make(map[string]interface{})
  331. }
  332. p.p["id"] = v
  333. return
  334. }
  335. func (p *UpdateNetworkACLItemParams) SetNumber(v int) {
  336. if p.p == nil {
  337. p.p = make(map[string]interface{})
  338. }
  339. p.p["number"] = v
  340. return
  341. }
  342. func (p *UpdateNetworkACLItemParams) SetProtocol(v string) {
  343. if p.p == nil {
  344. p.p = make(map[string]interface{})
  345. }
  346. p.p["protocol"] = v
  347. return
  348. }
  349. func (p *UpdateNetworkACLItemParams) SetStartport(v int) {
  350. if p.p == nil {
  351. p.p = make(map[string]interface{})
  352. }
  353. p.p["startport"] = v
  354. return
  355. }
  356. func (p *UpdateNetworkACLItemParams) SetTraffictype(v string) {
  357. if p.p == nil {
  358. p.p = make(map[string]interface{})
  359. }
  360. p.p["traffictype"] = v
  361. return
  362. }
  363. // You should always use this function to get a new UpdateNetworkACLItemParams instance,
  364. // as then you are sure you have configured all required params
  365. func (s *NetworkACLService) NewUpdateNetworkACLItemParams(id string) *UpdateNetworkACLItemParams {
  366. p := &UpdateNetworkACLItemParams{}
  367. p.p = make(map[string]interface{})
  368. p.p["id"] = id
  369. return p
  370. }
  371. // Updates ACL item with specified ID
  372. func (s *NetworkACLService) UpdateNetworkACLItem(p *UpdateNetworkACLItemParams) (*UpdateNetworkACLItemResponse, error) {
  373. resp, err := s.cs.newRequest("updateNetworkACLItem", p.toURLValues())
  374. if err != nil {
  375. return nil, err
  376. }
  377. var r UpdateNetworkACLItemResponse
  378. if err := json.Unmarshal(resp, &r); err != nil {
  379. return nil, err
  380. }
  381. // If we have a async client, we need to wait for the async result
  382. if s.cs.async {
  383. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  384. if err != nil {
  385. if err == AsyncTimeoutErr {
  386. return &r, err
  387. }
  388. return nil, err
  389. }
  390. b, err = getRawValue(b)
  391. if err != nil {
  392. return nil, err
  393. }
  394. if err := json.Unmarshal(b, &r); err != nil {
  395. return nil, err
  396. }
  397. }
  398. return &r, nil
  399. }
  400. type UpdateNetworkACLItemResponse struct {
  401. JobID string `json:"jobid,omitempty"`
  402. Aclid string `json:"aclid,omitempty"`
  403. Action string `json:"action,omitempty"`
  404. Cidrlist string `json:"cidrlist,omitempty"`
  405. Endport string `json:"endport,omitempty"`
  406. Fordisplay bool `json:"fordisplay,omitempty"`
  407. Icmpcode int `json:"icmpcode,omitempty"`
  408. Icmptype int `json:"icmptype,omitempty"`
  409. Id string `json:"id,omitempty"`
  410. Number int `json:"number,omitempty"`
  411. Protocol string `json:"protocol,omitempty"`
  412. Startport string `json:"startport,omitempty"`
  413. State string `json:"state,omitempty"`
  414. Tags []struct {
  415. Account string `json:"account,omitempty"`
  416. Customer string `json:"customer,omitempty"`
  417. Domain string `json:"domain,omitempty"`
  418. Domainid string `json:"domainid,omitempty"`
  419. Key string `json:"key,omitempty"`
  420. Project string `json:"project,omitempty"`
  421. Projectid string `json:"projectid,omitempty"`
  422. Resourceid string `json:"resourceid,omitempty"`
  423. Resourcetype string `json:"resourcetype,omitempty"`
  424. Value string `json:"value,omitempty"`
  425. } `json:"tags,omitempty"`
  426. Traffictype string `json:"traffictype,omitempty"`
  427. }
  428. type DeleteNetworkACLParams struct {
  429. p map[string]interface{}
  430. }
  431. func (p *DeleteNetworkACLParams) toURLValues() url.Values {
  432. u := url.Values{}
  433. if p.p == nil {
  434. return u
  435. }
  436. if v, found := p.p["id"]; found {
  437. u.Set("id", v.(string))
  438. }
  439. return u
  440. }
  441. func (p *DeleteNetworkACLParams) SetId(v string) {
  442. if p.p == nil {
  443. p.p = make(map[string]interface{})
  444. }
  445. p.p["id"] = v
  446. return
  447. }
  448. // You should always use this function to get a new DeleteNetworkACLParams instance,
  449. // as then you are sure you have configured all required params
  450. func (s *NetworkACLService) NewDeleteNetworkACLParams(id string) *DeleteNetworkACLParams {
  451. p := &DeleteNetworkACLParams{}
  452. p.p = make(map[string]interface{})
  453. p.p["id"] = id
  454. return p
  455. }
  456. // Deletes a network ACL
  457. func (s *NetworkACLService) DeleteNetworkACL(p *DeleteNetworkACLParams) (*DeleteNetworkACLResponse, error) {
  458. resp, err := s.cs.newRequest("deleteNetworkACL", p.toURLValues())
  459. if err != nil {
  460. return nil, err
  461. }
  462. var r DeleteNetworkACLResponse
  463. if err := json.Unmarshal(resp, &r); err != nil {
  464. return nil, err
  465. }
  466. // If we have a async client, we need to wait for the async result
  467. if s.cs.async {
  468. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  469. if err != nil {
  470. if err == AsyncTimeoutErr {
  471. return &r, err
  472. }
  473. return nil, err
  474. }
  475. if err := json.Unmarshal(b, &r); err != nil {
  476. return nil, err
  477. }
  478. }
  479. return &r, nil
  480. }
  481. type DeleteNetworkACLResponse struct {
  482. JobID string `json:"jobid,omitempty"`
  483. Displaytext string `json:"displaytext,omitempty"`
  484. Success bool `json:"success,omitempty"`
  485. }
  486. type ListNetworkACLsParams struct {
  487. p map[string]interface{}
  488. }
  489. func (p *ListNetworkACLsParams) toURLValues() url.Values {
  490. u := url.Values{}
  491. if p.p == nil {
  492. return u
  493. }
  494. if v, found := p.p["account"]; found {
  495. u.Set("account", v.(string))
  496. }
  497. if v, found := p.p["aclid"]; found {
  498. u.Set("aclid", v.(string))
  499. }
  500. if v, found := p.p["action"]; found {
  501. u.Set("action", v.(string))
  502. }
  503. if v, found := p.p["domainid"]; found {
  504. u.Set("domainid", v.(string))
  505. }
  506. if v, found := p.p["fordisplay"]; found {
  507. vv := strconv.FormatBool(v.(bool))
  508. u.Set("fordisplay", vv)
  509. }
  510. if v, found := p.p["id"]; found {
  511. u.Set("id", v.(string))
  512. }
  513. if v, found := p.p["isrecursive"]; found {
  514. vv := strconv.FormatBool(v.(bool))
  515. u.Set("isrecursive", vv)
  516. }
  517. if v, found := p.p["keyword"]; found {
  518. u.Set("keyword", v.(string))
  519. }
  520. if v, found := p.p["listall"]; found {
  521. vv := strconv.FormatBool(v.(bool))
  522. u.Set("listall", vv)
  523. }
  524. if v, found := p.p["networkid"]; found {
  525. u.Set("networkid", v.(string))
  526. }
  527. if v, found := p.p["page"]; found {
  528. vv := strconv.Itoa(v.(int))
  529. u.Set("page", vv)
  530. }
  531. if v, found := p.p["pagesize"]; found {
  532. vv := strconv.Itoa(v.(int))
  533. u.Set("pagesize", vv)
  534. }
  535. if v, found := p.p["projectid"]; found {
  536. u.Set("projectid", v.(string))
  537. }
  538. if v, found := p.p["protocol"]; found {
  539. u.Set("protocol", v.(string))
  540. }
  541. if v, found := p.p["tags"]; found {
  542. i := 0
  543. for k, vv := range v.(map[string]string) {
  544. u.Set(fmt.Sprintf("tags[%d].key", i), k)
  545. u.Set(fmt.Sprintf("tags[%d].value", i), vv)
  546. i++
  547. }
  548. }
  549. if v, found := p.p["traffictype"]; found {
  550. u.Set("traffictype", v.(string))
  551. }
  552. return u
  553. }
  554. func (p *ListNetworkACLsParams) SetAccount(v string) {
  555. if p.p == nil {
  556. p.p = make(map[string]interface{})
  557. }
  558. p.p["account"] = v
  559. return
  560. }
  561. func (p *ListNetworkACLsParams) SetAclid(v string) {
  562. if p.p == nil {
  563. p.p = make(map[string]interface{})
  564. }
  565. p.p["aclid"] = v
  566. return
  567. }
  568. func (p *ListNetworkACLsParams) SetAction(v string) {
  569. if p.p == nil {
  570. p.p = make(map[string]interface{})
  571. }
  572. p.p["action"] = v
  573. return
  574. }
  575. func (p *ListNetworkACLsParams) SetDomainid(v string) {
  576. if p.p == nil {
  577. p.p = make(map[string]interface{})
  578. }
  579. p.p["domainid"] = v
  580. return
  581. }
  582. func (p *ListNetworkACLsParams) SetFordisplay(v bool) {
  583. if p.p == nil {
  584. p.p = make(map[string]interface{})
  585. }
  586. p.p["fordisplay"] = v
  587. return
  588. }
  589. func (p *ListNetworkACLsParams) SetId(v string) {
  590. if p.p == nil {
  591. p.p = make(map[string]interface{})
  592. }
  593. p.p["id"] = v
  594. return
  595. }
  596. func (p *ListNetworkACLsParams) SetIsrecursive(v bool) {
  597. if p.p == nil {
  598. p.p = make(map[string]interface{})
  599. }
  600. p.p["isrecursive"] = v
  601. return
  602. }
  603. func (p *ListNetworkACLsParams) SetKeyword(v string) {
  604. if p.p == nil {
  605. p.p = make(map[string]interface{})
  606. }
  607. p.p["keyword"] = v
  608. return
  609. }
  610. func (p *ListNetworkACLsParams) SetListall(v bool) {
  611. if p.p == nil {
  612. p.p = make(map[string]interface{})
  613. }
  614. p.p["listall"] = v
  615. return
  616. }
  617. func (p *ListNetworkACLsParams) SetNetworkid(v string) {
  618. if p.p == nil {
  619. p.p = make(map[string]interface{})
  620. }
  621. p.p["networkid"] = v
  622. return
  623. }
  624. func (p *ListNetworkACLsParams) SetPage(v int) {
  625. if p.p == nil {
  626. p.p = make(map[string]interface{})
  627. }
  628. p.p["page"] = v
  629. return
  630. }
  631. func (p *ListNetworkACLsParams) SetPagesize(v int) {
  632. if p.p == nil {
  633. p.p = make(map[string]interface{})
  634. }
  635. p.p["pagesize"] = v
  636. return
  637. }
  638. func (p *ListNetworkACLsParams) SetProjectid(v string) {
  639. if p.p == nil {
  640. p.p = make(map[string]interface{})
  641. }
  642. p.p["projectid"] = v
  643. return
  644. }
  645. func (p *ListNetworkACLsParams) SetProtocol(v string) {
  646. if p.p == nil {
  647. p.p = make(map[string]interface{})
  648. }
  649. p.p["protocol"] = v
  650. return
  651. }
  652. func (p *ListNetworkACLsParams) SetTags(v map[string]string) {
  653. if p.p == nil {
  654. p.p = make(map[string]interface{})
  655. }
  656. p.p["tags"] = v
  657. return
  658. }
  659. func (p *ListNetworkACLsParams) SetTraffictype(v string) {
  660. if p.p == nil {
  661. p.p = make(map[string]interface{})
  662. }
  663. p.p["traffictype"] = v
  664. return
  665. }
  666. // You should always use this function to get a new ListNetworkACLsParams instance,
  667. // as then you are sure you have configured all required params
  668. func (s *NetworkACLService) NewListNetworkACLsParams() *ListNetworkACLsParams {
  669. p := &ListNetworkACLsParams{}
  670. p.p = make(map[string]interface{})
  671. return p
  672. }
  673. // This is a courtesy helper function, which in some cases may not work as expected!
  674. func (s *NetworkACLService) GetNetworkACLByID(id string, opts ...OptionFunc) (*NetworkACL, int, error) {
  675. p := &ListNetworkACLsParams{}
  676. p.p = make(map[string]interface{})
  677. p.p["id"] = id
  678. for _, fn := range opts {
  679. if err := fn(s.cs, p); err != nil {
  680. return nil, -1, err
  681. }
  682. }
  683. l, err := s.ListNetworkACLs(p)
  684. if err != nil {
  685. if strings.Contains(err.Error(), fmt.Sprintf(
  686. "Invalid parameter id value=%s due to incorrect long value format, "+
  687. "or entity does not exist", id)) {
  688. return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
  689. }
  690. return nil, -1, err
  691. }
  692. if l.Count == 0 {
  693. return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
  694. }
  695. if l.Count == 1 {
  696. return l.NetworkACLs[0], l.Count, nil
  697. }
  698. return nil, l.Count, fmt.Errorf("There is more then one result for NetworkACL UUID: %s!", id)
  699. }
  700. // Lists all network ACL items
  701. func (s *NetworkACLService) ListNetworkACLs(p *ListNetworkACLsParams) (*ListNetworkACLsResponse, error) {
  702. resp, err := s.cs.newRequest("listNetworkACLs", p.toURLValues())
  703. if err != nil {
  704. return nil, err
  705. }
  706. var r ListNetworkACLsResponse
  707. if err := json.Unmarshal(resp, &r); err != nil {
  708. return nil, err
  709. }
  710. return &r, nil
  711. }
  712. type ListNetworkACLsResponse struct {
  713. Count int `json:"count"`
  714. NetworkACLs []*NetworkACL `json:"networkacl"`
  715. }
  716. type NetworkACL struct {
  717. Aclid string `json:"aclid,omitempty"`
  718. Action string `json:"action,omitempty"`
  719. Cidrlist string `json:"cidrlist,omitempty"`
  720. Endport string `json:"endport,omitempty"`
  721. Fordisplay bool `json:"fordisplay,omitempty"`
  722. Icmpcode int `json:"icmpcode,omitempty"`
  723. Icmptype int `json:"icmptype,omitempty"`
  724. Id string `json:"id,omitempty"`
  725. Number int `json:"number,omitempty"`
  726. Protocol string `json:"protocol,omitempty"`
  727. Startport string `json:"startport,omitempty"`
  728. State string `json:"state,omitempty"`
  729. Tags []struct {
  730. Account string `json:"account,omitempty"`
  731. Customer string `json:"customer,omitempty"`
  732. Domain string `json:"domain,omitempty"`
  733. Domainid string `json:"domainid,omitempty"`
  734. Key string `json:"key,omitempty"`
  735. Project string `json:"project,omitempty"`
  736. Projectid string `json:"projectid,omitempty"`
  737. Resourceid string `json:"resourceid,omitempty"`
  738. Resourcetype string `json:"resourcetype,omitempty"`
  739. Value string `json:"value,omitempty"`
  740. } `json:"tags,omitempty"`
  741. Traffictype string `json:"traffictype,omitempty"`
  742. }
  743. type CreateNetworkACLListParams struct {
  744. p map[string]interface{}
  745. }
  746. func (p *CreateNetworkACLListParams) toURLValues() url.Values {
  747. u := url.Values{}
  748. if p.p == nil {
  749. return u
  750. }
  751. if v, found := p.p["description"]; found {
  752. u.Set("description", v.(string))
  753. }
  754. if v, found := p.p["fordisplay"]; found {
  755. vv := strconv.FormatBool(v.(bool))
  756. u.Set("fordisplay", vv)
  757. }
  758. if v, found := p.p["name"]; found {
  759. u.Set("name", v.(string))
  760. }
  761. if v, found := p.p["vpcid"]; found {
  762. u.Set("vpcid", v.(string))
  763. }
  764. return u
  765. }
  766. func (p *CreateNetworkACLListParams) SetDescription(v string) {
  767. if p.p == nil {
  768. p.p = make(map[string]interface{})
  769. }
  770. p.p["description"] = v
  771. return
  772. }
  773. func (p *CreateNetworkACLListParams) SetFordisplay(v bool) {
  774. if p.p == nil {
  775. p.p = make(map[string]interface{})
  776. }
  777. p.p["fordisplay"] = v
  778. return
  779. }
  780. func (p *CreateNetworkACLListParams) SetName(v string) {
  781. if p.p == nil {
  782. p.p = make(map[string]interface{})
  783. }
  784. p.p["name"] = v
  785. return
  786. }
  787. func (p *CreateNetworkACLListParams) SetVpcid(v string) {
  788. if p.p == nil {
  789. p.p = make(map[string]interface{})
  790. }
  791. p.p["vpcid"] = v
  792. return
  793. }
  794. // You should always use this function to get a new CreateNetworkACLListParams instance,
  795. // as then you are sure you have configured all required params
  796. func (s *NetworkACLService) NewCreateNetworkACLListParams(name string, vpcid string) *CreateNetworkACLListParams {
  797. p := &CreateNetworkACLListParams{}
  798. p.p = make(map[string]interface{})
  799. p.p["name"] = name
  800. p.p["vpcid"] = vpcid
  801. return p
  802. }
  803. // Creates a network ACL for the given VPC
  804. func (s *NetworkACLService) CreateNetworkACLList(p *CreateNetworkACLListParams) (*CreateNetworkACLListResponse, error) {
  805. resp, err := s.cs.newRequest("createNetworkACLList", p.toURLValues())
  806. if err != nil {
  807. return nil, err
  808. }
  809. var r CreateNetworkACLListResponse
  810. if err := json.Unmarshal(resp, &r); err != nil {
  811. return nil, err
  812. }
  813. // If we have a async client, we need to wait for the async result
  814. if s.cs.async {
  815. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  816. if err != nil {
  817. if err == AsyncTimeoutErr {
  818. return &r, err
  819. }
  820. return nil, err
  821. }
  822. b, err = getRawValue(b)
  823. if err != nil {
  824. return nil, err
  825. }
  826. if err := json.Unmarshal(b, &r); err != nil {
  827. return nil, err
  828. }
  829. }
  830. return &r, nil
  831. }
  832. type CreateNetworkACLListResponse struct {
  833. JobID string `json:"jobid,omitempty"`
  834. Description string `json:"description,omitempty"`
  835. Fordisplay bool `json:"fordisplay,omitempty"`
  836. Id string `json:"id,omitempty"`
  837. Name string `json:"name,omitempty"`
  838. Vpcid string `json:"vpcid,omitempty"`
  839. }
  840. type DeleteNetworkACLListParams struct {
  841. p map[string]interface{}
  842. }
  843. func (p *DeleteNetworkACLListParams) toURLValues() url.Values {
  844. u := url.Values{}
  845. if p.p == nil {
  846. return u
  847. }
  848. if v, found := p.p["id"]; found {
  849. u.Set("id", v.(string))
  850. }
  851. return u
  852. }
  853. func (p *DeleteNetworkACLListParams) SetId(v string) {
  854. if p.p == nil {
  855. p.p = make(map[string]interface{})
  856. }
  857. p.p["id"] = v
  858. return
  859. }
  860. // You should always use this function to get a new DeleteNetworkACLListParams instance,
  861. // as then you are sure you have configured all required params
  862. func (s *NetworkACLService) NewDeleteNetworkACLListParams(id string) *DeleteNetworkACLListParams {
  863. p := &DeleteNetworkACLListParams{}
  864. p.p = make(map[string]interface{})
  865. p.p["id"] = id
  866. return p
  867. }
  868. // Deletes a network ACL
  869. func (s *NetworkACLService) DeleteNetworkACLList(p *DeleteNetworkACLListParams) (*DeleteNetworkACLListResponse, error) {
  870. resp, err := s.cs.newRequest("deleteNetworkACLList", p.toURLValues())
  871. if err != nil {
  872. return nil, err
  873. }
  874. var r DeleteNetworkACLListResponse
  875. if err := json.Unmarshal(resp, &r); err != nil {
  876. return nil, err
  877. }
  878. // If we have a async client, we need to wait for the async result
  879. if s.cs.async {
  880. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  881. if err != nil {
  882. if err == AsyncTimeoutErr {
  883. return &r, err
  884. }
  885. return nil, err
  886. }
  887. if err := json.Unmarshal(b, &r); err != nil {
  888. return nil, err
  889. }
  890. }
  891. return &r, nil
  892. }
  893. type DeleteNetworkACLListResponse struct {
  894. JobID string `json:"jobid,omitempty"`
  895. Displaytext string `json:"displaytext,omitempty"`
  896. Success bool `json:"success,omitempty"`
  897. }
  898. type ReplaceNetworkACLListParams struct {
  899. p map[string]interface{}
  900. }
  901. func (p *ReplaceNetworkACLListParams) toURLValues() url.Values {
  902. u := url.Values{}
  903. if p.p == nil {
  904. return u
  905. }
  906. if v, found := p.p["aclid"]; found {
  907. u.Set("aclid", v.(string))
  908. }
  909. if v, found := p.p["gatewayid"]; found {
  910. u.Set("gatewayid", v.(string))
  911. }
  912. if v, found := p.p["networkid"]; found {
  913. u.Set("networkid", v.(string))
  914. }
  915. return u
  916. }
  917. func (p *ReplaceNetworkACLListParams) SetAclid(v string) {
  918. if p.p == nil {
  919. p.p = make(map[string]interface{})
  920. }
  921. p.p["aclid"] = v
  922. return
  923. }
  924. func (p *ReplaceNetworkACLListParams) SetGatewayid(v string) {
  925. if p.p == nil {
  926. p.p = make(map[string]interface{})
  927. }
  928. p.p["gatewayid"] = v
  929. return
  930. }
  931. func (p *ReplaceNetworkACLListParams) SetNetworkid(v string) {
  932. if p.p == nil {
  933. p.p = make(map[string]interface{})
  934. }
  935. p.p["networkid"] = v
  936. return
  937. }
  938. // You should always use this function to get a new ReplaceNetworkACLListParams instance,
  939. // as then you are sure you have configured all required params
  940. func (s *NetworkACLService) NewReplaceNetworkACLListParams(aclid string) *ReplaceNetworkACLListParams {
  941. p := &ReplaceNetworkACLListParams{}
  942. p.p = make(map[string]interface{})
  943. p.p["aclid"] = aclid
  944. return p
  945. }
  946. // Replaces ACL associated with a network or private gateway
  947. func (s *NetworkACLService) ReplaceNetworkACLList(p *ReplaceNetworkACLListParams) (*ReplaceNetworkACLListResponse, error) {
  948. resp, err := s.cs.newRequest("replaceNetworkACLList", p.toURLValues())
  949. if err != nil {
  950. return nil, err
  951. }
  952. var r ReplaceNetworkACLListResponse
  953. if err := json.Unmarshal(resp, &r); err != nil {
  954. return nil, err
  955. }
  956. // If we have a async client, we need to wait for the async result
  957. if s.cs.async {
  958. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  959. if err != nil {
  960. if err == AsyncTimeoutErr {
  961. return &r, err
  962. }
  963. return nil, err
  964. }
  965. if err := json.Unmarshal(b, &r); err != nil {
  966. return nil, err
  967. }
  968. }
  969. return &r, nil
  970. }
  971. type ReplaceNetworkACLListResponse struct {
  972. JobID string `json:"jobid,omitempty"`
  973. Displaytext string `json:"displaytext,omitempty"`
  974. Success bool `json:"success,omitempty"`
  975. }
  976. type ListNetworkACLListsParams struct {
  977. p map[string]interface{}
  978. }
  979. func (p *ListNetworkACLListsParams) toURLValues() url.Values {
  980. u := url.Values{}
  981. if p.p == nil {
  982. return u
  983. }
  984. if v, found := p.p["account"]; found {
  985. u.Set("account", v.(string))
  986. }
  987. if v, found := p.p["domainid"]; found {
  988. u.Set("domainid", v.(string))
  989. }
  990. if v, found := p.p["fordisplay"]; found {
  991. vv := strconv.FormatBool(v.(bool))
  992. u.Set("fordisplay", vv)
  993. }
  994. if v, found := p.p["id"]; found {
  995. u.Set("id", v.(string))
  996. }
  997. if v, found := p.p["isrecursive"]; found {
  998. vv := strconv.FormatBool(v.(bool))
  999. u.Set("isrecursive", vv)
  1000. }
  1001. if v, found := p.p["keyword"]; found {
  1002. u.Set("keyword", v.(string))
  1003. }
  1004. if v, found := p.p["listall"]; found {
  1005. vv := strconv.FormatBool(v.(bool))
  1006. u.Set("listall", vv)
  1007. }
  1008. if v, found := p.p["name"]; found {
  1009. u.Set("name", v.(string))
  1010. }
  1011. if v, found := p.p["networkid"]; found {
  1012. u.Set("networkid", v.(string))
  1013. }
  1014. if v, found := p.p["page"]; found {
  1015. vv := strconv.Itoa(v.(int))
  1016. u.Set("page", vv)
  1017. }
  1018. if v, found := p.p["pagesize"]; found {
  1019. vv := strconv.Itoa(v.(int))
  1020. u.Set("pagesize", vv)
  1021. }
  1022. if v, found := p.p["projectid"]; found {
  1023. u.Set("projectid", v.(string))
  1024. }
  1025. if v, found := p.p["vpcid"]; found {
  1026. u.Set("vpcid", v.(string))
  1027. }
  1028. return u
  1029. }
  1030. func (p *ListNetworkACLListsParams) SetAccount(v string) {
  1031. if p.p == nil {
  1032. p.p = make(map[string]interface{})
  1033. }
  1034. p.p["account"] = v
  1035. return
  1036. }
  1037. func (p *ListNetworkACLListsParams) SetDomainid(v string) {
  1038. if p.p == nil {
  1039. p.p = make(map[string]interface{})
  1040. }
  1041. p.p["domainid"] = v
  1042. return
  1043. }
  1044. func (p *ListNetworkACLListsParams) SetFordisplay(v bool) {
  1045. if p.p == nil {
  1046. p.p = make(map[string]interface{})
  1047. }
  1048. p.p["fordisplay"] = v
  1049. return
  1050. }
  1051. func (p *ListNetworkACLListsParams) SetId(v string) {
  1052. if p.p == nil {
  1053. p.p = make(map[string]interface{})
  1054. }
  1055. p.p["id"] = v
  1056. return
  1057. }
  1058. func (p *ListNetworkACLListsParams) SetIsrecursive(v bool) {
  1059. if p.p == nil {
  1060. p.p = make(map[string]interface{})
  1061. }
  1062. p.p["isrecursive"] = v
  1063. return
  1064. }
  1065. func (p *ListNetworkACLListsParams) SetKeyword(v string) {
  1066. if p.p == nil {
  1067. p.p = make(map[string]interface{})
  1068. }
  1069. p.p["keyword"] = v
  1070. return
  1071. }
  1072. func (p *ListNetworkACLListsParams) SetListall(v bool) {
  1073. if p.p == nil {
  1074. p.p = make(map[string]interface{})
  1075. }
  1076. p.p["listall"] = v
  1077. return
  1078. }
  1079. func (p *ListNetworkACLListsParams) SetName(v string) {
  1080. if p.p == nil {
  1081. p.p = make(map[string]interface{})
  1082. }
  1083. p.p["name"] = v
  1084. return
  1085. }
  1086. func (p *ListNetworkACLListsParams) SetNetworkid(v string) {
  1087. if p.p == nil {
  1088. p.p = make(map[string]interface{})
  1089. }
  1090. p.p["networkid"] = v
  1091. return
  1092. }
  1093. func (p *ListNetworkACLListsParams) SetPage(v int) {
  1094. if p.p == nil {
  1095. p.p = make(map[string]interface{})
  1096. }
  1097. p.p["page"] = v
  1098. return
  1099. }
  1100. func (p *ListNetworkACLListsParams) SetPagesize(v int) {
  1101. if p.p == nil {
  1102. p.p = make(map[string]interface{})
  1103. }
  1104. p.p["pagesize"] = v
  1105. return
  1106. }
  1107. func (p *ListNetworkACLListsParams) SetProjectid(v string) {
  1108. if p.p == nil {
  1109. p.p = make(map[string]interface{})
  1110. }
  1111. p.p["projectid"] = v
  1112. return
  1113. }
  1114. func (p *ListNetworkACLListsParams) SetVpcid(v string) {
  1115. if p.p == nil {
  1116. p.p = make(map[string]interface{})
  1117. }
  1118. p.p["vpcid"] = v
  1119. return
  1120. }
  1121. // You should always use this function to get a new ListNetworkACLListsParams instance,
  1122. // as then you are sure you have configured all required params
  1123. func (s *NetworkACLService) NewListNetworkACLListsParams() *ListNetworkACLListsParams {
  1124. p := &ListNetworkACLListsParams{}
  1125. p.p = make(map[string]interface{})
  1126. return p
  1127. }
  1128. // This is a courtesy helper function, which in some cases may not work as expected!
  1129. func (s *NetworkACLService) GetNetworkACLListID(name string, opts ...OptionFunc) (string, int, error) {
  1130. p := &ListNetworkACLListsParams{}
  1131. p.p = make(map[string]interface{})
  1132. p.p["name"] = name
  1133. for _, fn := range opts {
  1134. if err := fn(s.cs, p); err != nil {
  1135. return "", -1, err
  1136. }
  1137. }
  1138. l, err := s.ListNetworkACLLists(p)
  1139. if err != nil {
  1140. return "", -1, err
  1141. }
  1142. if l.Count == 0 {
  1143. return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
  1144. }
  1145. if l.Count == 1 {
  1146. return l.NetworkACLLists[0].Id, l.Count, nil
  1147. }
  1148. if l.Count > 1 {
  1149. for _, v := range l.NetworkACLLists {
  1150. if v.Name == name {
  1151. return v.Id, l.Count, nil
  1152. }
  1153. }
  1154. }
  1155. return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
  1156. }
  1157. // This is a courtesy helper function, which in some cases may not work as expected!
  1158. func (s *NetworkACLService) GetNetworkACLListByName(name string, opts ...OptionFunc) (*NetworkACLList, int, error) {
  1159. id, count, err := s.GetNetworkACLListID(name, opts...)
  1160. if err != nil {
  1161. return nil, count, err
  1162. }
  1163. r, count, err := s.GetNetworkACLListByID(id, opts...)
  1164. if err != nil {
  1165. return nil, count, err
  1166. }
  1167. return r, count, nil
  1168. }
  1169. // This is a courtesy helper function, which in some cases may not work as expected!
  1170. func (s *NetworkACLService) GetNetworkACLListByID(id string, opts ...OptionFunc) (*NetworkACLList, int, error) {
  1171. p := &ListNetworkACLListsParams{}
  1172. p.p = make(map[string]interface{})
  1173. p.p["id"] = id
  1174. for _, fn := range opts {
  1175. if err := fn(s.cs, p); err != nil {
  1176. return nil, -1, err
  1177. }
  1178. }
  1179. l, err := s.ListNetworkACLLists(p)
  1180. if err != nil {
  1181. if strings.Contains(err.Error(), fmt.Sprintf(
  1182. "Invalid parameter id value=%s due to incorrect long value format, "+
  1183. "or entity does not exist", id)) {
  1184. return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
  1185. }
  1186. return nil, -1, err
  1187. }
  1188. if l.Count == 0 {
  1189. return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
  1190. }
  1191. if l.Count == 1 {
  1192. return l.NetworkACLLists[0], l.Count, nil
  1193. }
  1194. return nil, l.Count, fmt.Errorf("There is more then one result for NetworkACLList UUID: %s!", id)
  1195. }
  1196. // Lists all network ACLs
  1197. func (s *NetworkACLService) ListNetworkACLLists(p *ListNetworkACLListsParams) (*ListNetworkACLListsResponse, error) {
  1198. resp, err := s.cs.newRequest("listNetworkACLLists", p.toURLValues())
  1199. if err != nil {
  1200. return nil, err
  1201. }
  1202. var r ListNetworkACLListsResponse
  1203. if err := json.Unmarshal(resp, &r); err != nil {
  1204. return nil, err
  1205. }
  1206. return &r, nil
  1207. }
  1208. type ListNetworkACLListsResponse struct {
  1209. Count int `json:"count"`
  1210. NetworkACLLists []*NetworkACLList `json:"networkacllist"`
  1211. }
  1212. type NetworkACLList struct {
  1213. Description string `json:"description,omitempty"`
  1214. Fordisplay bool `json:"fordisplay,omitempty"`
  1215. Id string `json:"id,omitempty"`
  1216. Name string `json:"name,omitempty"`
  1217. Vpcid string `json:"vpcid,omitempty"`
  1218. }
  1219. type UpdateNetworkACLListParams struct {
  1220. p map[string]interface{}
  1221. }
  1222. func (p *UpdateNetworkACLListParams) toURLValues() url.Values {
  1223. u := url.Values{}
  1224. if p.p == nil {
  1225. return u
  1226. }
  1227. if v, found := p.p["customid"]; found {
  1228. u.Set("customid", v.(string))
  1229. }
  1230. if v, found := p.p["fordisplay"]; found {
  1231. vv := strconv.FormatBool(v.(bool))
  1232. u.Set("fordisplay", vv)
  1233. }
  1234. if v, found := p.p["id"]; found {
  1235. u.Set("id", v.(string))
  1236. }
  1237. return u
  1238. }
  1239. func (p *UpdateNetworkACLListParams) SetCustomid(v string) {
  1240. if p.p == nil {
  1241. p.p = make(map[string]interface{})
  1242. }
  1243. p.p["customid"] = v
  1244. return
  1245. }
  1246. func (p *UpdateNetworkACLListParams) SetFordisplay(v bool) {
  1247. if p.p == nil {
  1248. p.p = make(map[string]interface{})
  1249. }
  1250. p.p["fordisplay"] = v
  1251. return
  1252. }
  1253. func (p *UpdateNetworkACLListParams) SetId(v string) {
  1254. if p.p == nil {
  1255. p.p = make(map[string]interface{})
  1256. }
  1257. p.p["id"] = v
  1258. return
  1259. }
  1260. // You should always use this function to get a new UpdateNetworkACLListParams instance,
  1261. // as then you are sure you have configured all required params
  1262. func (s *NetworkACLService) NewUpdateNetworkACLListParams(id string) *UpdateNetworkACLListParams {
  1263. p := &UpdateNetworkACLListParams{}
  1264. p.p = make(map[string]interface{})
  1265. p.p["id"] = id
  1266. return p
  1267. }
  1268. // Updates network ACL list
  1269. func (s *NetworkACLService) UpdateNetworkACLList(p *UpdateNetworkACLListParams) (*UpdateNetworkACLListResponse, error) {
  1270. resp, err := s.cs.newRequest("updateNetworkACLList", p.toURLValues())
  1271. if err != nil {
  1272. return nil, err
  1273. }
  1274. var r UpdateNetworkACLListResponse
  1275. if err := json.Unmarshal(resp, &r); err != nil {
  1276. return nil, err
  1277. }
  1278. // If we have a async client, we need to wait for the async result
  1279. if s.cs.async {
  1280. b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
  1281. if err != nil {
  1282. if err == AsyncTimeoutErr {
  1283. return &r, err
  1284. }
  1285. return nil, err
  1286. }
  1287. if err := json.Unmarshal(b, &r); err != nil {
  1288. return nil, err
  1289. }
  1290. }
  1291. return &r, nil
  1292. }
  1293. type UpdateNetworkACLListResponse struct {
  1294. JobID string `json:"jobid,omitempty"`
  1295. Displaytext string `json:"displaytext,omitempty"`
  1296. Success bool `json:"success,omitempty"`
  1297. }