app_blb_client.py 126 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541
  1. # Copyright (c) 2019 Baidu.com, Inc. All Rights Reserved
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing,
  10. # software distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions
  13. # and limitations under the License.
  14. """
  15. This module provides a client class for APP BLB.
  16. """
  17. import copy
  18. import json
  19. import logging
  20. import uuid
  21. import sys
  22. from baidubce import bce_base_client
  23. from baidubce.auth import bce_v1_signer
  24. from baidubce.http import bce_http_client
  25. from baidubce.http import handler
  26. from baidubce.http import http_methods
  27. from baidubce import utils
  28. from baidubce.utils import required
  29. from baidubce import compat
  30. if sys.version < '3':
  31. reload(sys)
  32. sys.setdefaultencoding('utf-8')
  33. _logger = logging.getLogger(__name__)
  34. class AppBlbClient(bce_base_client.BceBaseClient):
  35. """
  36. APP BLB base sdk client
  37. """
  38. version = b'/v1'
  39. def __init__(self, config=None):
  40. bce_base_client.BceBaseClient.__init__(self, config)
  41. def _merge_config(self, config=None):
  42. """
  43. :param config:
  44. :type config: baidubce.BceClientConfiguration
  45. :return:
  46. """
  47. if config is None:
  48. return self.config
  49. else:
  50. new_config = copy.copy(self.config)
  51. new_config.merge_non_none_values(config)
  52. return new_config
  53. def _send_request(self, http_method, path,
  54. body=None, headers=None, params=None,
  55. config=None, body_parser=None):
  56. config = self._merge_config(config)
  57. if body_parser is None:
  58. body_parser = handler.parse_json
  59. if headers is None:
  60. headers = {b'Accept': b'*/*',
  61. b'Content-Type': b'application/json;charset=utf-8'}
  62. return bce_http_client.send_request(
  63. config, bce_v1_signer.sign, [handler.parse_error, body_parser],
  64. http_method, path, body, headers, params)
  65. @required(vpc_id=(bytes, str),
  66. subnet_id=(bytes, str))
  67. def create_app_loadbalancer(self, vpc_id, subnet_id, name=None,
  68. desc=None, client_token=None, config=None):
  69. """
  70. Create a app LoadBalancer with the specified options.
  71. :param name:
  72. the name of LoadBalancer to create
  73. :type name: string
  74. :param desc:
  75. The description of LoadBalancer
  76. :type desc: string
  77. :param vpc_id:
  78. id of vpc which the LoadBalancer belong to
  79. :type vpc_id: string
  80. :param subnet_id:
  81. id of subnet which the LoadBalancer belong to
  82. :type subnet_id: string
  83. :param client_token:
  84. If the clientToken is not specified by the user, a random String
  85. generated by default algorithm will be used.
  86. :type client_token: string
  87. :param config:
  88. :type config: baidubce.BceClientConfiguration
  89. :return:
  90. :rtype baidubce.bce_response.BceResponse
  91. """
  92. path = utils.append_uri(self.version, 'appblb')
  93. params = {}
  94. if client_token is None:
  95. params[b'clientToken'] = generate_client_token()
  96. else:
  97. params[b'clientToken'] = client_token
  98. body = {}
  99. if name is not None:
  100. body['name'] = compat.convert_to_string(name)
  101. if desc is not None:
  102. body['desc'] = compat.convert_to_string(desc)
  103. body['vpcId'] = compat.convert_to_string(vpc_id)
  104. body['subnetId'] = compat.convert_to_string(subnet_id)
  105. return self._send_request(http_methods.POST, path,
  106. body=json.dumps(body), params=params,
  107. config=config)
  108. @required(blb_id=(bytes, str))
  109. def update_app_loadbalancer(self, blb_id, name=None, desc=None,
  110. client_token=None, config=None):
  111. """
  112. Modify the special attribute to new value of the LoadBalancer
  113. owned by the user.
  114. :param name:
  115. name of LoadBalancer to describe
  116. :type name: string
  117. :param blb_id:
  118. id of LoadBalancer to describe
  119. :type blb_id: string
  120. :param desc:
  121. The description of LoadBalancer
  122. :type desc: string
  123. :param client_token:
  124. If the clientToken is not specified by the user,
  125. a random String generated by default algorithm
  126. will be used.
  127. :type client_token: string
  128. :param config:
  129. :type config: baidubce.BceClientConfiguration
  130. :return:
  131. :rtype baidubce.bce_response.BceResponse
  132. """
  133. path = utils.append_uri(self.version, 'appblb', blb_id)
  134. params = {}
  135. if client_token is None:
  136. params[b'clientToken'] = generate_client_token()
  137. else:
  138. params[b'clientToken'] = client_token
  139. body = {}
  140. if name is not None:
  141. body['name'] = compat.convert_to_string(name)
  142. if desc is not None:
  143. body['desc'] = compat.convert_to_string(desc)
  144. return self._send_request(http_methods.PUT, path, json.dumps(body),
  145. params=params, config=config)
  146. def describe_app_loadbalancers(self, address=None, name=None, blb_id=None,
  147. bcc_id=None, marker=None, max_keys=None,
  148. config=None):
  149. """
  150. Return a list of LoadBalancers
  151. :param address:
  152. Intranet service address in dotted decimal notation
  153. :type address: string
  154. :param name:
  155. name of LoadBalancer to describe
  156. :type name: string
  157. :param blb_id:
  158. id of LoadBalancer to describe
  159. :type blb_id: string
  160. :param bcc_id:
  161. bcc which bind the LoadBalancers
  162. :type bcc_id: string
  163. :param marker:
  164. The optional parameter marker specified in the original
  165. request to specify where in the results to begin listing.
  166. Together with the marker, specifies the list result
  167. which listing should begin.
  168. If the marker is not specified, the list result will
  169. listing from the first one.
  170. :type marker: string
  171. :param max_keys
  172. The optional parameter to specifies the max number of list
  173. result to return.
  174. The default value is 1000.
  175. :type max_keys: int
  176. :param config:
  177. :type config: baidubce.BceClientConfiguration
  178. :return:
  179. :rtype baidubce.bce_response.BceResponse
  180. """
  181. path = utils.append_uri(self.version, 'appblb')
  182. params = {}
  183. if address is not None:
  184. params[b'address'] = address
  185. if name is not None:
  186. params[b'name'] = name
  187. if blb_id is not None:
  188. params[b'blbId'] = blb_id
  189. if bcc_id is not None:
  190. params[b'bccId'] = bcc_id
  191. if marker is not None:
  192. params[b'marker'] = marker
  193. if max_keys is not None:
  194. params[b'maxKeys'] = max_keys
  195. return self._send_request(http_methods.GET, path,
  196. params=params, config=config)
  197. @required(blb_id=(bytes, str))
  198. def describe_app_loadbalancer_detail(self, blb_id, config=None):
  199. """
  200. Return detail imformation of specific LoadBalancer
  201. :param blb_id:
  202. id of LoadBalancer to describe
  203. :type blb_id: string
  204. :param config:
  205. :type config: baidubce.BceClientConfiguration
  206. :return:
  207. :rtype baidubce.bce_response.BceResponse
  208. """
  209. path = utils.append_uri(self.version, 'appblb', blb_id)
  210. return self._send_request(http_methods.GET, path,
  211. config=config)
  212. @required(blb_id=(bytes, str))
  213. def delete_app_loadbalancer(self, blb_id, client_token=None, config=None):
  214. """
  215. delete the LoadBalancer owned by the user.
  216. :param blb_id:
  217. id of LoadBalancer to describe
  218. :type blb_id: string
  219. :param client_token:
  220. If the clientToken is not specified by the user,
  221. a random String generated by default algorithm
  222. will be used.
  223. :type client_token: string
  224. :param config:
  225. :type config: baidubce.BceClientConfiguration
  226. :return:
  227. :rtype baidubce.bce_response.BceResponse
  228. """
  229. path = utils.append_uri(self.version, 'appblb', blb_id)
  230. params = {}
  231. if client_token is None:
  232. params[b'clientToken'] = generate_client_token()
  233. else:
  234. params[b'clientToken'] = client_token
  235. return self._send_request(http_methods.DELETE, path,
  236. params=params, config=config)
  237. """
  238. Listener API
  239. """
  240. @required(blb_id=(bytes, str),
  241. listener_port=int,
  242. scheduler=(bytes, str))
  243. def create_app_tcp_listener(self, blb_id, listener_port,
  244. scheduler, client_token=None,
  245. config=None):
  246. """
  247. Create a app tcp listener rule with the specified options.
  248. :param blb_id:
  249. the id of blb which the listener work on
  250. :type blb_id: string
  251. :param listener_port:
  252. port to be linstened owned by listener
  253. :value 1-65535
  254. :type listener_port: int
  255. :param scheduler
  256. balancing algorithm
  257. :value 'RoundRobin' or 'LeastConnection' or 'Hash'
  258. :type scheduler: string
  259. :param client_token:
  260. If the clientToken is not specified by the user, a random String
  261. generated by default algorithm will be used.
  262. :type client_token: string
  263. :param config:
  264. :type config: baidubce.BceClientConfiguration
  265. :return:
  266. :rtype baidubce.bce_response.BceResponse
  267. """
  268. path = utils.append_uri(self.version, 'appblb', blb_id, 'TCPlistener')
  269. params = {}
  270. if client_token is None:
  271. params[b'clientToken'] = generate_client_token()
  272. else:
  273. params[b'clientToken'] = client_token
  274. body = {
  275. 'listenerPort': listener_port,
  276. 'scheduler': compat.convert_to_string(scheduler)
  277. }
  278. return self._send_request(http_methods.POST, path,
  279. body=json.dumps(body), params=params,
  280. config=config)
  281. @required(blb_id=(bytes, str),
  282. listener_port=int,
  283. scheduler=(bytes, str))
  284. def create_app_udp_listener(self, blb_id, listener_port,
  285. scheduler, client_token=None,
  286. config=None):
  287. """
  288. Create a app udp listener rule with the specified options.
  289. :param blb_id:
  290. the id of blb which the listener work on
  291. :type blb_id: string
  292. :param listener_port:
  293. port to be linstened owned by listener
  294. :value 1-65535
  295. :type listener_port: int
  296. :param scheduler
  297. balancing algorithm
  298. :value 'RoundRobin' or 'LeastConnection' or 'Hash'
  299. :type scheduler: string
  300. :param client_token:
  301. If the clientToken is not specified by the user, a random String
  302. generated by default algorithm will be used.
  303. :type client_token: string
  304. :param config:
  305. :type config: baidubce.BceClientConfiguration
  306. :return:
  307. :rtype baidubce.bce_response.BceResponse
  308. """
  309. path = utils.append_uri(self.version, 'appblb', blb_id, 'UDPlistener')
  310. params = {}
  311. if client_token is None:
  312. params[b'clientToken'] = generate_client_token()
  313. else:
  314. params[b'clientToken'] = client_token
  315. body = {
  316. 'listenerPort': listener_port,
  317. 'scheduler': compat.convert_to_string(scheduler)
  318. }
  319. return self._send_request(http_methods.POST, path,
  320. body=json.dumps(body), params=params,
  321. config=config)
  322. @required(blb_id=(bytes, str), listener_port=int,
  323. scheduler=(bytes, str))
  324. def create_app_http_listener(self, blb_id, listener_port,
  325. scheduler, keep_session=None,
  326. keep_session_type=None,
  327. keep_session_timeout=None,
  328. keep_session_cookie_name=None,
  329. x_forwarded_for=None,
  330. server_timeout=None,
  331. redirect_port=None,
  332. client_token=None,
  333. config=None):
  334. """
  335. Create a app http listener rule with the specified options.
  336. :param blb_id:
  337. the id of blb which the listener work on
  338. :type blb_id: string
  339. :param listener_port:
  340. port to be linstened owned by listener
  341. :value 1-65535
  342. :type listener_port: int
  343. :param scheduler:
  344. balancing algorithm
  345. :value 'RoundRobin' or 'LeastConnection'
  346. :type scheduler: string
  347. :param keep_session:
  348. Whether to enable the session hold function,
  349. that is,the request sent by the same client will
  350. reach the same backend server
  351. :value true or false default:false
  352. :type keep_session: bool
  353. :param keep_session_type:
  354. The cookie handling method maintained by the session,
  355. valid only if the session is held open
  356. :value 'insert' or 'rewrite' default:insert
  357. :type keep_session_type: string
  358. :param keep_session_timeout:
  359. The time the cookie is kept in session (in seconds),
  360. valid only if the session is held open
  361. :value 1-15552000 default:3600
  362. :type keep_session_timeout: int
  363. :param keep_session_cookie_name:
  364. The session keeps the name of the cookie that needs to be
  365. overridden if and only if session persistence is enabled
  366. and keep_session_type="rewrite"
  367. :type keep_session_cookie_name: int
  368. :param x_forwarded_for:
  369. Whether to enable the real IP address of the client,
  370. the backend server can obtain the real address of the client
  371. through the X-Forwarded-For HTTP header.
  372. :value true or false, default: False
  373. :type x_forwarded_for: bool
  374. :param server_timeout:
  375. Backend server maximum timeout (unit: second)
  376. :value 1-3600, default: 30
  377. :type server_timeout:int
  378. :param redirect_port:
  379. Forward the request received by this listener to the
  380. HTTPS listener, which is specified by the HTTPS listener.
  381. :type redirect_port:int
  382. :param client_token:
  383. If the clientToken is not specified by the user,
  384. a random String generated by default algorithm will be used.
  385. :type client_token: string
  386. :param config:
  387. :type config: baidubce.BceClientConfiguration
  388. :return:
  389. :rtype baidubce.bce_response.BceResponse
  390. """
  391. path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPlistener')
  392. params = {}
  393. if client_token is None:
  394. params[b'clientToken'] = generate_client_token()
  395. else:
  396. params[b'clientToken'] = client_token
  397. body = {
  398. 'listenerPort': listener_port,
  399. 'scheduler': compat.convert_to_string(scheduler)}
  400. if keep_session is not None:
  401. body['keepSession'] = keep_session
  402. if keep_session_type is not None:
  403. body['keepSessionType'] = \
  404. compat.convert_to_string(keep_session_type)
  405. if keep_session_timeout is not None:
  406. body['keepSessionTimeout'] = keep_session_timeout
  407. if keep_session_cookie_name is not None:
  408. body['keepSessionCookieName'] = keep_session_cookie_name
  409. if x_forwarded_for is not None:
  410. body['xForwardedFor'] = x_forwarded_for
  411. if server_timeout is not None:
  412. body['serverTimeout'] = server_timeout
  413. if redirect_port is not None:
  414. body['redirectPort'] = redirect_port
  415. return self._send_request(http_methods.POST, path,
  416. body=json.dumps(body), params=params,
  417. config=config)
  418. @required(blb_id=(bytes, str), listener_port=int,
  419. scheduler=(bytes, str), cert_ids=list)
  420. def create_app_https_listener(self, blb_id, listener_port,
  421. scheduler, cert_ids,
  422. keep_session=None,
  423. keep_session_type=None,
  424. keep_session_timeout=None,
  425. keep_session_cookie_name=None,
  426. x_forwarded_for=None, server_timeout=None,
  427. ie6_compatible=None, encryption_type=None,
  428. encryption_protocols=None,
  429. dual_auth=None, client_certIds=None,
  430. additional_cert_domains=None,
  431. client_token=None, config=None):
  432. """
  433. Create a app https listener rule with the specified options.
  434. :param blb_id:
  435. The id of blb which the listener work on
  436. :type blb_id: string
  437. :param listener_port:
  438. port to be linstened owned by listener
  439. :value 1-65535
  440. :type listener_port: int
  441. :param scheduler:
  442. balancing algorithm
  443. :value 'RoundRobin' or 'LeastConnection'
  444. :type scheduler: string
  445. :param cert_ids:
  446. The certificate to be loaded by the listener.
  447. :type cert_ids: List<String>
  448. :param keep_session:
  449. Whether to enable the session hold function,
  450. that is, the request sent by the same client will reach the
  451. same backend server
  452. :value true or false, default: false
  453. :type keep_session: bool
  454. :param keep_session_type:
  455. The cookie handling method maintained by the session,
  456. valid only if the session is held open
  457. :value 'insert' or 'rewrite', default:insert
  458. :type keep_session_type: string
  459. :param keep_session_timeout:
  460. The time the cookie is kept in session (in seconds),
  461. valid only if the session is held open
  462. :value 1-15552000, default:3600
  463. :type keep_session_timeout: int
  464. :param keep_session_cookie_name:
  465. The session keeps the name of the cookie that needs
  466. to be overridden if and only if session persistence
  467. is enabled and keep_session_type="rewrite"
  468. :type keep_session_cookie_name: int
  469. :param x_forwarded_for:
  470. Whether to enable the real IP address of the client,
  471. the backend server can obtain the real address of the client
  472. through the X-Forwarded-For HTTP header.
  473. :value true or false, default: false
  474. :type x_forwarded_for: bool
  475. :param server_timeout:
  476. Backend server maximum timeout (unit: second)
  477. :value 1-3600, default: 30
  478. :type server_timeout: int
  479. :param ie6_compatible:
  480. compatible with IE6 HTTPS request
  481. (the protocol format is earlier SSL3.0, the security is poor)
  482. :value true or false, default: true
  483. :type ie6_compatible: bool
  484. :param encryption_type:
  485. Encryption options, support three types:
  486. compatibleIE/incompatibleIE/userDefind,
  487. corresponding to:
  488. IE-compatible encryption/disabled unsecure encryption/custom encryption,
  489. when encryptionType is valid and legitimate,
  490. ie6Compatible field transfer value will not take effect
  491. type: encryption_type:string
  492. :param encryption_protocols:
  493. When the encryptionType value is userDefind,
  494. the list of protocol types is a string list composed of four protocols:
  495. "sslv3", "tlsv10", "tlsv11", "tlsv12".
  496. type: encryption_protocols:list
  497. :param dual_auth:
  498. Whether to Open Two-way Authentication,
  499. default:false
  500. :type dual_auth: boolean
  501. :param client_certIds:
  502. When dualAuth is true, the loaded client certificate chain
  503. :type client_certIds: list
  504. :param client_token:
  505. If the clientToken is not specified by the user,
  506. a random String generated by default algorithm will be used.
  507. :type client_token: string
  508. :param additional_cert_domains:
  509. Additional domain,each element is an object that contains two attributes, namely "cert_id" and "host"
  510. :type additional_cert_domains: list
  511. :param config:
  512. :type config: baidubce.BceClientConfiguration
  513. :return
  514. :rtype baidubce.bce_response.BceResponse
  515. """
  516. path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPSlistener')
  517. params = {}
  518. if client_token is None:
  519. params[b'clientToken'] = generate_client_token()
  520. else:
  521. params[b'clientToken'] = client_token
  522. body = {
  523. 'listenerPort': listener_port,
  524. 'scheduler': compat.convert_to_string(scheduler),
  525. 'certIds': cert_ids}
  526. if keep_session is not None:
  527. body['keepSession'] = keep_session
  528. if keep_session_type is not None:
  529. body['keepSessionType'] = \
  530. compat.convert_to_string(keep_session_type)
  531. if keep_session_timeout is not None:
  532. body['keepSessionTimeout'] = keep_session_timeout
  533. if keep_session_cookie_name is not None:
  534. body['keepSessionCookieName'] = keep_session_cookie_name
  535. if x_forwarded_for is not None:
  536. body['xForwardedFor'] = x_forwarded_for
  537. if server_timeout is not None:
  538. body['serverTimeout'] = server_timeout
  539. if ie6_compatible is not None:
  540. body['ie6Compatible'] = ie6_compatible
  541. if encryption_type is not None:
  542. body['encryptionType'] = \
  543. compat.convert_to_string(encryption_type)
  544. if encryption_protocols is not None:
  545. body['encryptionProtocols'] = encryption_protocols
  546. if dual_auth is not None:
  547. body['dualAuth'] = dual_auth
  548. if client_certIds is not None:
  549. body['clientCertIds'] = client_certIds
  550. if additional_cert_domains is not None:
  551. body['additionalCertDomains'] = additional_cert_domains
  552. return self._send_request(http_methods.POST, path,
  553. body=json.dumps(body),
  554. params=params, config=config)
  555. @required(blb_id=(bytes, str), listener_port=int,
  556. scheduler=(bytes, str), cert_ids=list)
  557. def create_app_ssl_listener(self, blb_id, listener_port,
  558. scheduler, cert_ids,
  559. ie6_compatible=None,
  560. encryption_type=None,
  561. encryption_protocols=None,
  562. dual_auth=None, client_certIds=None,
  563. client_token=None, config=None):
  564. """
  565. Create a app ssl listener rule with the specified options.
  566. :param blb_id:
  567. The id of blb which the listener work on
  568. :type blb_id: string
  569. :param listener_port:
  570. port to be linstened owned by listener
  571. :value 1-65535
  572. :type listener_port: int
  573. :param scheduler:
  574. balancing algorithm
  575. :value 'RoundRobin' or 'LeastConnection'
  576. :type scheduler: string
  577. :param cert_ids:
  578. The SSL certificate to be loaded by the listener.
  579. Currently HTTPS listeners can only bind one SSL certificate.
  580. :type cert_ids: List<String>
  581. :param ie6_compatible:
  582. compatible with IE6 HTTPS request
  583. (the protocol format is earlier SSL3.0, the security is poor)
  584. :value true or false, default: true
  585. :type ie6_compatible: bool
  586. :param encryption_type:
  587. Encryption options, support three types:
  588. compatibleIE/incompatibleIE/userDefind,
  589. corresponding to:
  590. IE-compatible encryption/disabled unsecure encryption/custom encryption,
  591. when encryptionType is valid and legitimate,
  592. ie6Compatible field transfer value will not take effect
  593. type: encryption_type:string
  594. :param encryption_protocols:
  595. When the encryptionType value is userDefind,
  596. the list of protocol types is a string list composed of four protocols:
  597. "sslv3", "tlsv10", "tlsv11", "tlsv12".
  598. type: encryption_protocols:list
  599. :param dual_auth:
  600. Whether to Open Two-way Authentication,
  601. default:false
  602. :type dual_auth: boolean
  603. :param client_certIds:
  604. When dualAuth is true, the loaded client certificate chain
  605. :type client_certIds: list
  606. :param client_token:
  607. If the clientToken is not specified by the user,
  608. a random String generated by default algorithm will be used.
  609. :type client_token: string
  610. :param config:
  611. :type config: baidubce.BceClientConfiguration
  612. :return
  613. :rtype baidubce.bce_response.BceResponse
  614. """
  615. path = utils.append_uri(self.version, 'appblb', blb_id, 'SSLlistener')
  616. params = {}
  617. if client_token is None:
  618. params[b'clientToken'] = generate_client_token()
  619. else:
  620. params[b'clientToken'] = client_token
  621. body = {
  622. 'listenerPort': listener_port,
  623. 'scheduler': compat.convert_to_string(scheduler),
  624. 'certIds': cert_ids}
  625. if ie6_compatible is not None:
  626. body['ie6Compatible'] = ie6_compatible
  627. if encryption_type is not None:
  628. body['encryptionType'] = \
  629. compat.convert_to_string(encryption_type)
  630. if encryption_protocols is not None:
  631. body['encryptionProtocols'] = encryption_protocols
  632. if dual_auth is not None:
  633. body['dualAuth'] = dual_auth
  634. if client_certIds is not None:
  635. body['clientCertIds'] = client_certIds
  636. return self._send_request(http_methods.POST, path,
  637. body=json.dumps(body),
  638. params=params, config=config)
  639. @required(blb_id=(bytes, str),
  640. listener_port=int)
  641. def update_app_tcp_listener(self, blb_id, listener_port,
  642. scheduler=None,
  643. client_token=None,
  644. config=None):
  645. """
  646. update a app tcp listener rule with the specified options.
  647. :param blb_id:
  648. the id of blb which the listener work on
  649. :type blb_id:string
  650. :param listener_port:
  651. port to be linstened owned by listener
  652. :value 1-65535
  653. :type listener_port:int
  654. :param scheduler
  655. balancing algorithm
  656. :value 'RoundRobin'or'LeastConnection'or'Hash'
  657. :type scheduler:string
  658. :param client_token:
  659. If the clientToken is not specified by the user,
  660. a random String generated by default algorithm will be used.
  661. :type client_token: string
  662. :param config:
  663. :type config: baidubce.BceClientConfiguration
  664. :return:
  665. :rtype baidubce.bce_response.BceResponse
  666. """
  667. path = utils.append_uri(self.version, 'appblb', blb_id, 'TCPlistener')
  668. params = {}
  669. if client_token is None:
  670. params[b'clientToken'] = generate_client_token()
  671. else:
  672. params[b'clientToken'] = client_token
  673. params[b'listenerPort'] = listener_port
  674. body = {}
  675. if scheduler is not None:
  676. body['scheduler'] = compat.convert_to_string(scheduler)
  677. return self._send_request(http_methods.PUT, path,
  678. body=json.dumps(body), params=params,
  679. config=config)
  680. @required(blb_id=(bytes, str),
  681. listener_port=int)
  682. def update_app_udp_listener(self, blb_id, listener_port,
  683. scheduler=None, client_token=None,
  684. config=None):
  685. """
  686. update a app udp listener rule with the specified options.
  687. :param blb_id:
  688. the id of blb which the listener work on
  689. :type blb_id:string
  690. :param listener_port:
  691. port to be linstened owned by listener
  692. :value 1-65535
  693. :type listener_port:int
  694. :param scheduler
  695. balancing algorithm
  696. :value 'RoundRobin'or'LeastConnection'or'Hash'
  697. :type scheduler:string
  698. :param client_token:
  699. If the clientToken is not specified by the user,
  700. a random String generated by default algorithm will be used.
  701. :type client_token: string
  702. :param config:
  703. :type config: baidubce.BceClientConfiguration
  704. :return:
  705. :rtype baidubce.bce_response.BceResponse
  706. """
  707. path = utils.append_uri(self.version, 'appblb', blb_id, 'UDPlistener')
  708. params = {}
  709. if client_token is None:
  710. params[b'clientToken'] = generate_client_token()
  711. else:
  712. params[b'clientToken'] = client_token
  713. params[b'listenerPort'] = listener_port
  714. body = {
  715. 'scheduler': compat.convert_to_string(scheduler)
  716. }
  717. return self._send_request(http_methods.PUT, path,
  718. body=json.dumps(body),
  719. params=params, config=config)
  720. @required(blb_id=(bytes, str),
  721. listener_port=int)
  722. def update_app_http_listener(self, blb_id, listener_port,
  723. scheduler=None, keep_session=None,
  724. keep_session_type=None,
  725. keep_session_timeout=None,
  726. keep_session_cookie_name=None,
  727. x_forwarded_for=None,
  728. server_timeout=None,
  729. redirect_port=None,
  730. client_token=None,
  731. config=None):
  732. """
  733. update a app http listener rule with the specified options.
  734. :param blb_id:
  735. The id of blb which the listener work on
  736. :type blb_id: string
  737. :param listener_port:
  738. Port to be linstened owned by listener
  739. :value 1-65535
  740. :type listener_port: int
  741. :param scheduler:
  742. Balancing algorithm
  743. :value 'RoundRobin' or 'LeastConnection' or 'Hash'
  744. :type scheduler: string
  745. :param keep_session:
  746. Whether to enable the session hold function, that is,
  747. the request sent by the same client will reach the
  748. same backend server
  749. :value true or false, default:false
  750. :type keep_session: bool
  751. :param keep_session_type:
  752. The cookie handling method maintained by the session,
  753. valid only if the session is held open
  754. :value 'insert' or 'rewrite', default:insert
  755. :type keep_session_type: string
  756. :param keep_session_timeout:
  757. The time the cookie is kept in session (in seconds),
  758. valid only if the session is held open
  759. :value 1-15552000, default:3600
  760. :type keep_session_timeout: int
  761. :param keep_session_cookie_name:
  762. The session keeps the name of the cookie that needs
  763. to be overridden,if and only if session persistence is
  764. enabled and keep_session_type="rewrite"
  765. :type keep_session_cookie_name: int
  766. :param x_forwarded_for:
  767. Whether to enable the real IP address of the client,
  768. the backend server can obtain the real address of the
  769. client through the X-Forwarded-For HTTP header.
  770. :value true or false, default: false
  771. :type x_forwarded_for: bool
  772. :param server_timeout:
  773. Backend server maximum timeout (unit: second)
  774. :value 1-3600, default: 30
  775. :type server_timeout: int
  776. :param redirect_port:
  777. Forward the request received by this listener to the HTTPS
  778. listener, which is specified by the HTTPS listener.
  779. :type redirect_port: int
  780. :param client_token:
  781. If the clientToken is not specified by the user,
  782. a random String generated by default algorithm will be used.
  783. :type client_token: string
  784. :param config:
  785. :type config: baidubce.BceClientConfiguration
  786. :return:
  787. :rtype baidubce.bce_response.BceResponse
  788. """
  789. path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPlistener')
  790. params = {}
  791. if client_token is None:
  792. params[b'clientToken'] = generate_client_token()
  793. else:
  794. params[b'clientToken'] = client_token
  795. params[b'listenerPort'] = listener_port
  796. body = {}
  797. if scheduler is not None:
  798. body['scheduler'] = compat.convert_to_string(scheduler)
  799. if keep_session is not None:
  800. body['keepSession'] = keep_session
  801. if keep_session_type is not None:
  802. body['keepSessionType'] = \
  803. compat.convert_to_string(keep_session_type)
  804. if keep_session_timeout is not None:
  805. body['keepSessionTimeout'] = keep_session_timeout
  806. if keep_session_cookie_name is not None:
  807. body['keepSessionCookieName'] = keep_session_cookie_name
  808. if x_forwarded_for is not None:
  809. body['xForwardedFor'] = x_forwarded_for
  810. if server_timeout is not None:
  811. body['serverTimeout'] = server_timeout
  812. if redirect_port is not None:
  813. body['redirectPort'] = redirect_port
  814. return self._send_request(http_methods.PUT, path,
  815. body=json.dumps(body),
  816. params=params, config=config)
  817. @required(blb_id=(bytes, str), listener_port=int)
  818. def update_app_https_listener(self, blb_id, listener_port,
  819. scheduler=None,
  820. keep_session=None,
  821. keep_session_type=None,
  822. keep_session_timeout=None,
  823. keep_session_cookie_name=None,
  824. x_forwarded_for=None,
  825. server_timeout=None,
  826. cert_ids=None,
  827. ie6_compatible=None,
  828. encryption_type=None,
  829. encryption_protocols=None,
  830. dual_auth=None,
  831. client_certIds=None,
  832. additional_cert_domains=None,
  833. client_token=None,
  834. config=None):
  835. """
  836. update a app https listener rule with the specified options.
  837. :param blb_id:
  838. The id of blb which the listener work on
  839. :type blb_id: string
  840. :param listener_port:
  841. Port to be linstened owned by listener
  842. :value 1-65535
  843. :type listener_port: int
  844. :param scheduler:
  845. Balancing algorithm
  846. :value 'RoundRobin' or 'LeastConnection' or 'Hash'
  847. :type scheduler: string
  848. :param keep_session:
  849. Whether to enable the session hold function, that is, the request
  850. sent by the same client will reach the same backend server
  851. :value true or false, default: false
  852. :type keep_session: bool
  853. :param keep_session_type:
  854. The cookie handling method maintained by the session,
  855. valid only if the session is held open
  856. :value 'insert' or 'rewrite', default: insert
  857. :type keep_session_type: string
  858. :param keep_session_timeout:
  859. The time the cookie is kept in session (in seconds),
  860. valid only if the session is held open
  861. :value 1-15552000, default:3600
  862. :type keep_session_timeout: int
  863. :param keep_session_cookie_name:
  864. The session keeps the name of the cookie that needs to be
  865. overridden,if and only if session persistence is enabled and
  866. keep_session_type="rewrite"
  867. :type keep_session_cookie_name: int
  868. :param x_forwarded_for:
  869. Whether to enable the real IP address of the client,
  870. the backend server can obtain the real address of the client
  871. through the X-Forwarded-For HTTP header.
  872. :value true or false, default: False
  873. :type x_forwarded_for: bool
  874. :param server_timeout:
  875. Backend server maximum timeout (unit: second)
  876. :value 1-3600, default: 30
  877. :type server_timeout: int
  878. :param cert_ids:
  879. The SSL certificate to be loaded by the listener.
  880. Currently HTTPS listeners can only bind one SSL certificate.
  881. :type cert_ids:List<String>
  882. :param ie6_compatible:
  883. Is it compatible with IE6 HTTPS request
  884. (the protocol format is earlier SSL3.0, the security is poor)
  885. :value true or false, default: true
  886. :type ie6_compatible: bool
  887. :param encryption_type:
  888. Encryption options, support three types:
  889. compatibleIE/incompatibleIE/userDefind,
  890. corresponding to:
  891. IE-compatible encryption/disabled unsecure encryption/custom encryption,
  892. when encryptionType is valid and legitimate,
  893. ie6Compatible field transfer value will not take effect
  894. type: encryption_type:string
  895. :param encryption_protocols:
  896. When the encryptionType value is userDefind,
  897. the list of protocol types is a string list composed of four protocols:
  898. "sslv3", "tlsv10", "tlsv11", "tlsv12".
  899. type: encryption_protocols:list
  900. :param dual_auth:
  901. Whether to Open Two-way Authentication,
  902. default:false
  903. :type dual_auth: boolean
  904. :param client_certIds:
  905. When dualAuth is true, the loaded client certificate chain
  906. :type client_certIds: list
  907. :param additional_cert_domains:
  908. Additional domain name,each element is an object that contains two attributes, namely "cert_id" and "host"
  909. :type additional_cert_domains: list
  910. :param client_token:
  911. If the clientToken is not specified by the user,
  912. a random String generated by default algorithm will be used.
  913. :type client_token: string
  914. :param config:
  915. :type config: baidubce.BceClientConfiguration
  916. :return:
  917. :rtype baidubce.bce_response.BceResponse
  918. """
  919. path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPSlistener')
  920. params = {}
  921. if client_token is None:
  922. params[b'clientToken'] = generate_client_token()
  923. else:
  924. params[b'clientToken'] = client_token
  925. params[b'listenerPort'] = listener_port
  926. body = {}
  927. if scheduler is not None:
  928. body['scheduler'] = compat.convert_to_string(scheduler)
  929. if keep_session is not None:
  930. body['keepSession'] = keep_session
  931. if keep_session_type is not None:
  932. body['keepSessionType'] = \
  933. compat.convert_to_string(keep_session_type)
  934. if keep_session_timeout is not None:
  935. body['keepSessionTimeout'] = keep_session_timeout
  936. if keep_session_cookie_name is not None:
  937. body['keepSessionCookieName'] = keep_session_cookie_name
  938. if x_forwarded_for is not None:
  939. body['xForwardedFor'] = x_forwarded_for
  940. if server_timeout is not None:
  941. body['serverTimeout'] = server_timeout
  942. if cert_ids is not None:
  943. body['certIds'] = cert_ids
  944. if ie6_compatible is not None:
  945. body['compatibleIE'] = ie6_compatible
  946. if encryption_type is not None:
  947. body['encryptionType'] = \
  948. compat.convert_to_string(encryption_type)
  949. if encryption_protocols is not None:
  950. body['encryptionProtocols'] = encryption_protocols
  951. if dual_auth is not None:
  952. body['dualAuth'] = dual_auth
  953. if client_certIds is not None:
  954. body['clientCertIds'] = client_certIds
  955. if additional_cert_domains is not None:
  956. body['additionalCertDomains'] = additional_cert_domains
  957. return self._send_request(http_methods.PUT, path,
  958. body=json.dumps(body), params=params,
  959. config=config)
  960. @required(blb_id=(bytes, str), listener_port=int)
  961. def update_app_ssl_listener(self, blb_id, listener_port,
  962. scheduler=None,
  963. cert_ids=None,
  964. ie6_compatible=None,
  965. encryption_type=None,
  966. encryption_protocols=None,
  967. dual_auth=None,
  968. client_certIds=None,
  969. client_token=None,
  970. config=None):
  971. """
  972. update a app ssl listener rule with the specified options.
  973. :param blb_id:
  974. The id of blb which the listener work on
  975. :type blb_id: string
  976. :param listener_port:
  977. port to be linstened owned by listener
  978. :value 1-65535
  979. :type listener_port: int
  980. :param scheduler:
  981. balancing algorithm
  982. :value 'RoundRobin' or 'LeastConnection'
  983. :type scheduler: string
  984. :param cert_ids:
  985. The SSL certificate to be loaded by the listener.
  986. Currently HTTPS listeners can only bind one SSL certificate.
  987. :type cert_ids: List<String>
  988. :param ie6_compatible:
  989. compatible with IE6 HTTPS request
  990. (the protocol format is earlier SSL3.0, the security is poor)
  991. :value true or false, default: true
  992. :type ie6_compatible: bool
  993. :param encryption_type:
  994. Encryption options, support three types:
  995. compatibleIE/incompatibleIE/userDefind,
  996. corresponding to:
  997. IE-compatible encryption/disabled unsecure encryption/custom encryption,
  998. when encryptionType is valid and legitimate,
  999. ie6Compatible field transfer value will not take effect
  1000. type: encryption_type:string
  1001. :param encryption_protocols:
  1002. When the encryptionType value is userDefind,
  1003. the list of protocol types is a string list composed of four protocols:
  1004. "sslv3", "tlsv10", "tlsv11", "tlsv12".
  1005. type: encryption_protocols:list
  1006. :param dual_auth:
  1007. Whether to Open Two-way Authentication,
  1008. default:false
  1009. :type dual_auth: boolean
  1010. :param client_certIds:
  1011. When dualAuth is true, the loaded client certificate chain
  1012. :type client_certIds: list
  1013. :param client_token:
  1014. If the clientToken is not specified by the user,
  1015. a random String generated by default algorithm will be used.
  1016. :type client_token: string
  1017. :param config:
  1018. :type config: baidubce.BceClientConfiguration
  1019. :return
  1020. :rtype baidubce.bce_response.BceResponse
  1021. """
  1022. path = utils.append_uri(self.version, 'appblb', blb_id, 'SSLlistener')
  1023. params = {}
  1024. if client_token is None:
  1025. params[b'clientToken'] = generate_client_token()
  1026. else:
  1027. params[b'clientToken'] = client_token
  1028. params[b'listenerPort'] = listener_port
  1029. body = {}
  1030. if scheduler is not None:
  1031. body['scheduler'] = compat.convert_to_string(scheduler)
  1032. if cert_ids is not None:
  1033. body['certIds'] = cert_ids
  1034. if ie6_compatible is not None:
  1035. body['compatibleIE'] = ie6_compatible
  1036. if encryption_type is not None:
  1037. body['encryptionType'] = \
  1038. compat.convert_to_string(encryption_type)
  1039. if encryption_protocols is not None:
  1040. body['encryptionProtocols'] = encryption_protocols
  1041. if dual_auth is not None:
  1042. body['dualAuth'] = dual_auth
  1043. if client_certIds is not None:
  1044. body['clientCertIds'] = client_certIds
  1045. return self._send_request(http_methods.PUT, path,
  1046. body=json.dumps(body),
  1047. params=params, config=config)
  1048. @required(blb_id=(bytes, str))
  1049. def describe_app_tcp_listener(self, blb_id, listener_port=None,
  1050. marker=None, max_keys=None,
  1051. config=None):
  1052. """
  1053. get app tcp listeners identified by bibID
  1054. :param blb_id
  1055. the id of blb which the listener work on
  1056. :type blb_id:string
  1057. :param listener_port
  1058. The listener port to query
  1059. :type listener_port:int
  1060. :param marker
  1061. The optional parameter marker specified in the
  1062. original request to specify
  1063. where in the results to begin listing.
  1064. Together with the marker, specifies the list result
  1065. which listing should begin.
  1066. If the marker is not specified, the list result will
  1067. listing from the first one.
  1068. :type marker: string
  1069. :param max_keys
  1070. The optional parameter to specifies the max number of
  1071. list result to return.
  1072. The default value is 1000.
  1073. :type max_keys: int
  1074. :param config:
  1075. :type config: baidubce.BceClientConfiguration
  1076. :return:
  1077. :rtype baidubce.bce_response.BceResponse
  1078. """
  1079. path = utils.append_uri(self.version, 'appblb', blb_id, 'TCPlistener')
  1080. params = {}
  1081. if listener_port is not None:
  1082. params[b'listenerPort'] = listener_port
  1083. if marker is not None:
  1084. params[b'marker'] = marker
  1085. if max_keys is not None:
  1086. params[b'maxKeys'] = max_keys
  1087. return self._send_request(http_methods.GET, path,
  1088. params=params, config=config)
  1089. @required(blb_id=(bytes, str))
  1090. def describe_app_udp_listener(self, blb_id, listener_port=None,
  1091. marker=None, max_keys=None,
  1092. config=None):
  1093. """
  1094. get app udp listeners identified by bibID
  1095. :param blb_id
  1096. the id of blb which the listener work on
  1097. :type blb_id:string
  1098. :param listener_port
  1099. The listener port to query
  1100. :type listener_port:int
  1101. :param marker
  1102. The optional parameter marker specified in the original
  1103. request to specify where in the results to begin listing.
  1104. Together with the marker, specifies the list result which
  1105. listing should begin.
  1106. If the marker is not specified, the list result will
  1107. listing from the first one.
  1108. :type marker: string
  1109. :param max_keys
  1110. The optional parameter to specifies the max number of
  1111. list result to return.
  1112. The default value is 1000.
  1113. :type max_keys: int
  1114. :param config:
  1115. :type config: baidubce.BceClientConfiguration
  1116. :return:
  1117. :rtype baidubce.bce_response.BceResponse
  1118. """
  1119. path = utils.append_uri(self.version, 'appblb', blb_id, 'UDPlistener')
  1120. params = {}
  1121. if listener_port is not None:
  1122. params[b'listenerPort'] = listener_port
  1123. if marker is not None:
  1124. params[b'marker'] = marker
  1125. if max_keys is not None:
  1126. params[b'maxKeys'] = max_keys
  1127. return self._send_request(http_methods.GET, path,
  1128. params=params, config=config)
  1129. @required(blb_id=(bytes, str))
  1130. def describe_app_http_listener(self, blb_id, listener_port=None,
  1131. marker=None, max_keys=None,
  1132. config=None):
  1133. """
  1134. get app http listeners identified by bibID
  1135. :param blb_id
  1136. the id of blb which the listener work on
  1137. :type blb_id:string
  1138. :param listener_port
  1139. The listener port to query
  1140. :type listener_port:int
  1141. :param marker
  1142. The optional parameter marker specified in the original
  1143. request to specify where in the results to begin listing.
  1144. Together with the marker, specifies the list result which
  1145. listing should begin.
  1146. If the marker is not specified, the list result will listing
  1147. from the first one.
  1148. :type marker: string
  1149. :param max_keys
  1150. The optional parameter to specifies the max number of list
  1151. result to return.
  1152. The default value is 1000.
  1153. :type max_keys: int
  1154. :param config:
  1155. :type config: baidubce.BceClientConfiguration
  1156. :return:
  1157. :rtype baidubce.bce_response.BceResponse
  1158. """
  1159. path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPlistener')
  1160. params = {}
  1161. if listener_port is not None:
  1162. params[b'listenerPort'] = listener_port
  1163. if marker is not None:
  1164. params[b'marker'] = marker
  1165. if max_keys is not None:
  1166. params[b'maxKeys'] = max_keys
  1167. return self._send_request(http_methods.GET, path,
  1168. params=params, config=config)
  1169. @required(blb_id=(bytes, str))
  1170. def describe_app_https_listener(self, blb_id, listener_port=None,
  1171. marker=None, max_keys=None,
  1172. config=None):
  1173. """
  1174. get app https listeners identified by bibID
  1175. :param blb_id
  1176. the id of blb which the listener work on
  1177. :type blb_id:string
  1178. :param listener_port
  1179. The listener port to query
  1180. :type listener_port:int
  1181. :param marker
  1182. The optional parameter marker specified in the original
  1183. request to specify where in the results to begin listing.
  1184. Together with the marker, specifies the list result which
  1185. listing should begin.
  1186. If the marker is not specified, the list result will listing
  1187. from the first one.
  1188. :type marker: string
  1189. :param max_keys
  1190. The optional parameter to specifies the max number of list
  1191. result to return.
  1192. The default value is 1000.
  1193. :type max_keys: int
  1194. :param config:
  1195. :type config: baidubce.BceClientConfiguration
  1196. :return:
  1197. :rtype baidubce.bce_response.BceResponse
  1198. """
  1199. path = utils.append_uri(self.version, 'appblb', blb_id, 'HTTPSlistener')
  1200. params = {}
  1201. if listener_port is not None:
  1202. params[b'listenerPort'] = listener_port
  1203. if marker is not None:
  1204. params[b'marker'] = marker
  1205. if max_keys is not None:
  1206. params[b'maxKeys'] = max_keys
  1207. return self._send_request(http_methods.GET, path,
  1208. params=params, config=config)
  1209. @required(blb_id=(bytes, str))
  1210. def describe_app_ssl_listener(self, blb_id, listener_port=None,
  1211. marker=None, max_keys=None, config=None):
  1212. """
  1213. get app ssl listeners identified by bibID
  1214. :param blb_id
  1215. the id of blb which the listener work on
  1216. :type blb_id:string
  1217. :param listener_port
  1218. The listener port to query
  1219. :type listener_port:int
  1220. :param marker
  1221. The optional parameter marker specified in the original
  1222. request to specify where in the results to begin listing.
  1223. Together with the marker, specifies the list result which
  1224. listing should begin.
  1225. If the marker is not specified, the list result will listing
  1226. from the first one.
  1227. :type marker: string
  1228. :param max_keys
  1229. The optional parameter to specifies the max number of list
  1230. result to return.
  1231. The default value is 1000.
  1232. :type max_keys: int
  1233. :param config:
  1234. :type config: baidubce.BceClientConfiguration
  1235. :return:
  1236. :rtype baidubce.bce_response.BceResponse
  1237. """
  1238. path = utils.append_uri(self.version, 'appblb', blb_id, 'SSLlistener')
  1239. params = {}
  1240. if listener_port is not None:
  1241. params[b'listenerPort'] = listener_port
  1242. if marker is not None:
  1243. params[b'marker'] = marker
  1244. if max_keys is not None:
  1245. params[b'maxKeys'] = max_keys
  1246. return self._send_request(http_methods.GET, path,
  1247. params=params, config=config)
  1248. @required(blb_id=(bytes, str))
  1249. def describe_app_all_listener(self, blb_id, listener_port=None,
  1250. marker=None, max_keys=None, config=None):
  1251. """
  1252. get app all listeners identified by bibID
  1253. :param blb_id
  1254. the id of blb which the listener work on
  1255. :type blb_id:string
  1256. :param listener_port
  1257. The listener port to query
  1258. :type listener_port:int
  1259. :param marker
  1260. The optional parameter marker specified in the original
  1261. request to specify where in the results to begin listing.
  1262. Together with the marker, specifies the list result which
  1263. listing should begin.
  1264. If the marker is not specified, the list result will listing
  1265. from the first one.
  1266. :type marker: string
  1267. :param max_keys
  1268. The optional parameter to specifies the max number of list
  1269. result to return.
  1270. The default value is 1000.
  1271. :type max_keys: int
  1272. :param config:
  1273. :type config: baidubce.BceClientConfiguration
  1274. :return:
  1275. :rtype baidubce.bce_response.BceResponse
  1276. """
  1277. path = utils.append_uri(self.version, 'appblb', blb_id, 'listener')
  1278. params = {}
  1279. if listener_port is not None:
  1280. params[b'listenerPort'] = listener_port
  1281. if marker is not None:
  1282. params[b'marker'] = marker
  1283. if max_keys is not None:
  1284. params[b'maxKeys'] = max_keys
  1285. return self._send_request(http_methods.GET, path,
  1286. params=params, config=config)
  1287. @required(blb_id=(bytes, str),
  1288. portList=list)
  1289. def delete_app_listeners(self, blb_id, portList,
  1290. client_token=None,
  1291. config=None):
  1292. """
  1293. Release app listener under the specified LoadBalancer,
  1294. the listener is specified by listening to the port.
  1295. :param blb_id:
  1296. id of LoadBalancer
  1297. :type blb_id:string
  1298. :param portList:
  1299. The ports of listeners to be released
  1300. :type portList:list<int>
  1301. :param client_token:
  1302. If the clientToken is not specified by the user, a random String
  1303. generated by default algorithm will be used.
  1304. :type client_token: string
  1305. :param config:
  1306. :type config: baidubce.BceClientConfiguration
  1307. :return:
  1308. :rtype baidubce.bce_response.BceResponse
  1309. """
  1310. path = utils.append_uri(self.version, 'appblb', blb_id, 'listener')
  1311. params = {}
  1312. params[b'batchdelete'] = None
  1313. if client_token is None:
  1314. params[b'clientToken'] = generate_client_token()
  1315. else:
  1316. params[b'clientToken'] = client_token
  1317. body = {}
  1318. body['portList'] = portList
  1319. return self._send_request(http_methods.PUT, path,
  1320. body=json.dumps(body), params=params,
  1321. config=config)
  1322. @required(blb_id=(bytes, str),
  1323. listener_port=int,
  1324. app_policy_vos=list)
  1325. def create_policys(self, blb_id, listener_port,
  1326. app_policy_vos, client_token=None,
  1327. config=None):
  1328. """
  1329. Create policys.
  1330. :param blb_id:
  1331. the id of blb which the listener work on
  1332. :type blb_id: string
  1333. :param listener_port:
  1334. port to be linstened owned by listener
  1335. :value 1-65535
  1336. :type listener_port: int
  1337. :param app_policy_vos
  1338. policy list the listener binds.
  1339. If the listener type is TCP,
  1340. there is only one policy
  1341. and only the full match is supported.
  1342. https://cloud.baidu.com/doc/BLB/API.html#AppPolicy
  1343. :type app_policy_vos: list<AppPolicy>
  1344. :param client_token:
  1345. If the clientToken is not specified by the user, a random String
  1346. generated by default algorithm will be used.
  1347. :type client_token: string
  1348. :param config:
  1349. :type config: baidubce.BceClientConfiguration
  1350. :return:
  1351. :rtype baidubce.bce_response.BceResponse
  1352. """
  1353. path = utils.append_uri(self.version, 'appblb', blb_id, 'policys')
  1354. params = {}
  1355. if client_token is None:
  1356. params[b'clientToken'] = generate_client_token()
  1357. else:
  1358. params[b'clientToken'] = client_token
  1359. body = {
  1360. 'listenerPort': listener_port,
  1361. 'appPolicyVos': app_policy_vos
  1362. }
  1363. return self._send_request(http_methods.POST, path,
  1364. body=json.dumps(body), params=params,
  1365. config=config)
  1366. @required(blb_id=(bytes, str),
  1367. listener_port=int)
  1368. def describe_policys(self, blb_id, listener_port,
  1369. marker=None, max_keys=None,
  1370. config=None):
  1371. """
  1372. get policys
  1373. :param blb_id
  1374. the id of blb which the listener work on
  1375. :type blb_id:string
  1376. :param listener_port
  1377. The listener port used by listener
  1378. :type listener_port:int
  1379. :param marker
  1380. The optional parameter marker specified in the original
  1381. request to specify where in the results to begin listing.
  1382. Together with the marker, specifies the list result which
  1383. listing should begin.
  1384. If the marker is not specified, the list result will listing
  1385. from the first one.
  1386. :type marker: string
  1387. :param max_keys
  1388. The optional parameter to specifies the max number of list
  1389. result to return.
  1390. The default value is 1000.
  1391. :type max_keys: int
  1392. :param config:
  1393. :type config: baidubce.BceClientConfiguration
  1394. :return:
  1395. :rtype baidubce.bce_response.BceResponse
  1396. """
  1397. path = utils.append_uri(self.version, 'appblb', blb_id, 'policys')
  1398. params = {}
  1399. params[b'port'] = listener_port
  1400. if marker is not None:
  1401. params[b'marker'] = marker
  1402. if max_keys is not None:
  1403. params[b'maxKeys'] = max_keys
  1404. return self._send_request(http_methods.GET, path,
  1405. params=params, config=config)
  1406. @required(blb_id=(bytes, str),
  1407. listener_port=int,
  1408. policys_list=list)
  1409. def delete_policys(self, blb_id, listener_port,
  1410. policys_list,
  1411. client_token=None, config=None):
  1412. """
  1413. Release the listener under the specified LoadBalancer,
  1414. the listener is specified by listening to the port.
  1415. :param blb_id:
  1416. id of LoadBalancer
  1417. :type blb_id:string
  1418. :param listener_port
  1419. The listener port used by listener
  1420. :type listener_port:int
  1421. :param policys_list
  1422. All policy identifiers to be released
  1423. :type policys_list:list<str>
  1424. :param client_token:
  1425. If the clientToken is not specified by the user, a random String
  1426. generated by default algorithm will be used.
  1427. :type client_token: string
  1428. :param config:
  1429. :type config: baidubce.BceClientConfiguration
  1430. :return:
  1431. :rtype baidubce.bce_response.BceResponse
  1432. """
  1433. path = utils.append_uri(self.version, 'appblb', blb_id, 'policys')
  1434. params = {}
  1435. params[b'batchdelete'] = None
  1436. if client_token is None:
  1437. params[b'clientToken'] = generate_client_token()
  1438. else:
  1439. params[b'clientToken'] = client_token
  1440. body = {
  1441. 'port': listener_port,
  1442. 'policyIdList': policys_list
  1443. }
  1444. return self._send_request(http_methods.PUT, path,
  1445. body=json.dumps(body), params=params,
  1446. config=config)
  1447. """
  1448. ServerGroup API
  1449. """
  1450. @required(blb_id=(bytes, str))
  1451. def create_app_server_group(self, blb_id,
  1452. name=None,
  1453. desc=None,
  1454. backend_server_list=None,
  1455. client_token=None,
  1456. config=None):
  1457. """
  1458. create server group for the specified LoadBalancer,
  1459. support batch add
  1460. :param blb_id:
  1461. id of LoadBalancer
  1462. :type blb_id:string
  1463. :param name:
  1464. name of server group
  1465. :type name:string
  1466. :param desc:
  1467. description of server group
  1468. :type desc:string
  1469. :param backend_server_list
  1470. List of backend servers to be added
  1471. https://cloud.baidu.com/doc/BLB/API.html#AppBackendServer
  1472. :type backend_server_list:List<AppBackendServer>
  1473. :param client_token:
  1474. If the clientToken is not specified by the user, a random String
  1475. generated by default algorithm will be used.
  1476. :type client_token: string
  1477. :param config:
  1478. :type config: baidubce.BceClientConfiguration
  1479. :return:
  1480. :rtype baidubce.bce_response.BceResponse
  1481. """
  1482. path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroup')
  1483. params = {}
  1484. if client_token is None:
  1485. params[b'clientToken'] = generate_client_token()
  1486. else:
  1487. params[b'clientToken'] = client_token
  1488. body = {}
  1489. if name is not None:
  1490. body['name'] = compat.convert_to_string(name)
  1491. if desc is not None:
  1492. body['desc'] = compat.convert_to_string(desc)
  1493. if backend_server_list is not None:
  1494. body['backendServerList'] = backend_server_list
  1495. return self._send_request(http_methods.POST, path,
  1496. body=json.dumps(body), params=params,
  1497. config=config)
  1498. @required(blb_id=(bytes, str),
  1499. sg_id=(bytes, str))
  1500. def update_app_server_group(self, blb_id, sg_id,
  1501. name=None,
  1502. desc=None,
  1503. client_token=None,
  1504. config=None):
  1505. """
  1506. update the information of the app server group
  1507. of the specified LoadBalancer
  1508. :param blb_id:
  1509. id of LoadBalancer
  1510. :type blb_id:string
  1511. :param sg_id:
  1512. id of the server group to be updated
  1513. :type sg_id:string
  1514. :param name:
  1515. name of server group
  1516. :type name:string
  1517. :param desc:
  1518. description of server group
  1519. :type desc:string
  1520. :param client_token:
  1521. If the clientToken is not specified by the user, a random String
  1522. generated by default algorithm will be used.
  1523. :type client_token: string
  1524. :param config:
  1525. :type config: baidubce.BceClientConfiguration
  1526. :return:
  1527. :rtype baidubce.bce_response.BceResponse
  1528. """
  1529. path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroup')
  1530. params = {}
  1531. if client_token is None:
  1532. params[b'clientToken'] = generate_client_token()
  1533. else:
  1534. params[b'clientToken'] = client_token
  1535. body = {}
  1536. body['sgId'] = compat.convert_to_string(sg_id)
  1537. if name is not None:
  1538. body['name'] = compat.convert_to_string(name)
  1539. if desc is not None:
  1540. body['desc'] = compat.convert_to_string(desc)
  1541. return self._send_request(http_methods.PUT, path,
  1542. body=json.dumps(body), params=params,
  1543. config=config)
  1544. @required(blb_id=(bytes, str))
  1545. def describe_app_server_group(self, blb_id,
  1546. name=None,
  1547. exactly_match=None,
  1548. marker=None,
  1549. max_keys=None, config=None):
  1550. """
  1551. Query the imformation of app server group
  1552. of the specified LoadBalancer
  1553. :param blb_id:
  1554. Id of LoadBalancer
  1555. :type blb_id:string
  1556. :param name:
  1557. name of server group
  1558. :type name:string
  1559. :param exactly_match:
  1560. Set whether the name matches globally
  1561. :type exactly_match:boolean
  1562. :param marker:
  1563. The optional parameter marker specified in the original
  1564. request to specify where in the results to begin listing.
  1565. Together with the marker, specifies the list result which
  1566. listing should begin. If the marker is not specified,
  1567. the list result will listing from the first one.
  1568. :type marker: string
  1569. :param max_keys:
  1570. The optional parameter to specifies the max number of
  1571. list result to return.
  1572. The default value is 1000.
  1573. :type max_keys: int
  1574. :param config:
  1575. :type config: baidubce.BceClientConfiguration
  1576. :return:
  1577. :rtype baidubce.bce_response.BceResponse
  1578. """
  1579. path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroup')
  1580. params = {}
  1581. if name is not None:
  1582. params[b'name'] = name
  1583. if exactly_match is not None:
  1584. params[b'exactlyMatch'] = exactly_match
  1585. if marker is not None:
  1586. params[b'marker'] = marker
  1587. if max_keys is not None:
  1588. params[b'maxKeys'] = max_keys
  1589. return self._send_request(http_methods.GET, path, params=params,
  1590. config=config)
  1591. @required(blb_id=(bytes, str),
  1592. sg_id=(bytes, str))
  1593. def delete_app_server_group(self, blb_id, sg_id,
  1594. client_token=None,
  1595. config=None):
  1596. """
  1597. delete the app server group of the specified LoadBalancer,
  1598. :param blb_id:
  1599. id of LoadBalancer
  1600. :type blb_id:string
  1601. :param sg_id:
  1602. id of the server group to be updated
  1603. :type sg_id:string
  1604. :param client_token:
  1605. If the clientToken is not specified by the user,
  1606. a random String generated by default algorithm will be used.
  1607. :type client_token: string
  1608. :param config:
  1609. :type config: baidubce.BceClientConfiguration
  1610. :return:
  1611. :rtype baidubce.bce_response.BceResponse
  1612. """
  1613. path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroup')
  1614. params = {}
  1615. params[b'delete'] = None
  1616. if client_token is None:
  1617. params[b'clientToken'] = generate_client_token()
  1618. else:
  1619. params[b'clientToken'] = client_token
  1620. body = {}
  1621. body['sgId'] = compat.convert_to_string(sg_id)
  1622. return self._send_request(http_methods.PUT, path,
  1623. body=json.dumps(body), params=params,
  1624. config=config)
  1625. @required(blb_id=(bytes, str),
  1626. sg_id=(bytes, str), port=int,
  1627. protocol_type=(bytes, str))
  1628. def create_app_server_group_port(self, blb_id, sg_id,
  1629. port, protocol_type,
  1630. health_check=None,
  1631. health_check_port=None,
  1632. health_check_urlpath=None,
  1633. health_check_timeout_insecond=None,
  1634. health_check_interval_insecond=None,
  1635. health_check_down_retry=None,
  1636. health_check_up_retry=None,
  1637. health_check_normal_status=None,
  1638. udp_health_check_string=None,
  1639. client_token=None,
  1640. config=None):
  1641. """
  1642. create server group for the specified LoadBalancer,
  1643. support batch add
  1644. :param blb_id:
  1645. id of LoadBalancer
  1646. :type blb_id:string
  1647. :param sg_id:
  1648. id of the server group
  1649. :type sg_id:string
  1650. :param port:
  1651. Port number, integer between 1 and 65535
  1652. :type port:string
  1653. :param protocol_type:
  1654. Protocol type of listening port, "TCP"/"UDP"/"HTTP"
  1655. :type protocol_type:string
  1656. :param health_check:
  1657. Health check protocol
  1658. :value 'HTTP' or 'TCP',default:'HTTP'
  1659. :type health_check: string
  1660. :param health_check_port:
  1661. Health check port, the default is the same as port
  1662. :type health_check_port: int
  1663. :param health_check_urlpath:
  1664. Health check URI, default '/'.
  1665. Effective when the health check protocol is "HTTP"
  1666. :type health_check_urlpath: string
  1667. :param health_check_timeout_insecond:
  1668. Health check timeout (unit: second)
  1669. :value 1-60, default: 3
  1670. :type health_check_timeout_insecond: int
  1671. :param health_check_interval_insecond:
  1672. Health check interval (unit: second)
  1673. :value 1-10, default: 3
  1674. :type health_check_interval_insecond: int
  1675. :param health_check_down_retry:
  1676. The unhealthy down retry, that is, how many consecutive health
  1677. check failures, shields the backend server.
  1678. :value 2-5, default: 3
  1679. :type health_check_down_retry: int
  1680. :param health_check_up_retry:
  1681. Health up retry, that is, how many consecutive health checks
  1682. are successful, then re-use the back-end server
  1683. :value:2-5, default: 3
  1684. :type health_check_up_retry: int
  1685. :param health_check_normal_status:
  1686. The HTTP status code when the health check is normal supports
  1687. a combination of five types of status codes,
  1688. such as "http_1xx|http_2xx", Effective when the health check
  1689. protocol is "HTTP"
  1690. :value default: http_2xx|http_3xx
  1691. :type health_check_normal_status: string
  1692. :param udp_health_check_string:
  1693. The health check string for the udp listener,
  1694. it must be passed when the health check type is "UDP"
  1695. :type udp_health_check_string: string
  1696. :param client_token:
  1697. If the clientToken is not specified by the user, a random String
  1698. generated by default algorithm will be used.
  1699. :type client_token: string
  1700. :param config:
  1701. :type config: baidubce.BceClientConfiguration
  1702. :return:
  1703. :rtype baidubce.bce_response.BceResponse
  1704. """
  1705. path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroupport')
  1706. params = {}
  1707. if client_token is None:
  1708. params[b'clientToken'] = generate_client_token()
  1709. else:
  1710. params[b'clientToken'] = client_token
  1711. body = {
  1712. 'sgId': compat.convert_to_string(sg_id),
  1713. 'port': port,
  1714. 'type': compat.convert_to_string(protocol_type)
  1715. }
  1716. if health_check is not None:
  1717. body['healthCheck'] = compat.convert_to_string(health_check)
  1718. if health_check_port is not None:
  1719. body['healthCheckPort'] = health_check_port
  1720. if health_check_urlpath is not None:
  1721. body['healthCheckUrlPath'] = \
  1722. compat.convert_to_string(health_check_urlpath)
  1723. if health_check_timeout_insecond is not None:
  1724. body['healthCheckTimeoutInSecond'] = health_check_timeout_insecond
  1725. if health_check_interval_insecond is not None:
  1726. body['healthCheckIntervalInSecond'] = health_check_interval_insecond
  1727. if health_check_down_retry is not None:
  1728. body['healthCheckDownRetry'] = health_check_down_retry
  1729. if health_check_up_retry is not None:
  1730. body['healthCheckUpRetry'] = health_check_up_retry
  1731. if health_check_normal_status is not None:
  1732. body['healthCheckNormalStatus'] = \
  1733. compat.convert_to_string(health_check_normal_status)
  1734. if udp_health_check_string is not None:
  1735. body['udpHealthCheckString'] = \
  1736. compat.convert_to_string(udp_health_check_string)
  1737. return self._send_request(http_methods.POST, path,
  1738. body=json.dumps(body), params=params,
  1739. config=config)
  1740. @required(blb_id=(bytes, str),
  1741. sg_id=(bytes, str),
  1742. port_id=(bytes, str))
  1743. def update_app_server_group_port(self, blb_id, sg_id, port_id,
  1744. health_check=None,
  1745. health_check_port=None,
  1746. health_check_urlpath=None,
  1747. health_check_timeout_insecond=None,
  1748. health_check_interval_insecond=None,
  1749. health_check_down_retry=None,
  1750. health_check_up_retry=None,
  1751. health_check_normal_status=None,
  1752. udp_health_check_string=None,
  1753. client_token=None,
  1754. config=None):
  1755. """
  1756. update server group for the specified LoadBalancer,
  1757. support batch add
  1758. :param blb_id:
  1759. id of LoadBalancer
  1760. :type blb_id:string
  1761. :param sg_id:
  1762. id of the server group
  1763. :type sg_id:string
  1764. :param port_id:
  1765. The id of the server group port to be updated
  1766. :type port_id:string
  1767. :param health_check:
  1768. Health check protocol
  1769. :value 'HTTP' or 'TCP',default:'HTTP'
  1770. :type health_check: string
  1771. :param health_check_port:
  1772. Health check port, the default is the same as port
  1773. :type health_check_port: int
  1774. :param health_check_urlpath:
  1775. Health check URI, default '/'.
  1776. Effective when the health check protocol is "HTTP"
  1777. :type health_check_urlpath: string
  1778. :param health_check_timeout_insecond:
  1779. Health check timeout (unit: second)
  1780. :value 1-60, default: 3
  1781. :type health_check_timeout_insecond: int
  1782. :param health_check_interval_insecond:
  1783. Health check interval (unit: second)
  1784. :value 1-10, default: 3
  1785. :type health_check_interval_insecond: int
  1786. :param health_check_down_retry:
  1787. The unhealthy down retry, that is, how many consecutive health
  1788. check failures, shields the backend server.
  1789. :value 2-5, default: 3
  1790. :type health_check_down_retry: int
  1791. :param health_check_up_retry:
  1792. Health up retry, that is, how many consecutive health checks
  1793. are successful, then re-use the back-end server
  1794. :value:2-5, default: 3
  1795. :type health_check_up_retry: int
  1796. :param health_check_normal_status:
  1797. The HTTP status code when the health check is normal supports
  1798. a combination of five types of status codes,
  1799. such as "http_1xx|http_2xx", Effective when the health check
  1800. protocol is "HTTP"
  1801. :value default: http_2xx|http_3xx
  1802. :type health_check_normal_status: string
  1803. :param udp_health_check_string:
  1804. The health check string for the udp listener
  1805. :type udp_health_check_string: string
  1806. :param client_token:
  1807. If the clientToken is not specified by the user, a random String
  1808. generated by default algorithm will be used.
  1809. :type client_token: string
  1810. :param config:
  1811. :type config: baidubce.BceClientConfiguration
  1812. :return:
  1813. :rtype baidubce.bce_response.BceResponse
  1814. """
  1815. path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroupport')
  1816. params = {}
  1817. if client_token is None:
  1818. params[b'clientToken'] = generate_client_token()
  1819. else:
  1820. params[b'clientToken'] = client_token
  1821. body = {
  1822. 'sgId': compat.convert_to_string(sg_id),
  1823. 'portId': compat.convert_to_string(port_id)
  1824. }
  1825. if health_check is not None:
  1826. body['healthCheck'] = compat.convert_to_string(health_check)
  1827. if health_check_port is not None:
  1828. body['healthCheckPort'] = health_check_port
  1829. if health_check_urlpath is not None:
  1830. body['healthCheckUrlPath'] = \
  1831. compat.convert_to_string(health_check_urlpath)
  1832. if health_check_timeout_insecond is not None:
  1833. body['healthCheckTimeoutInSecond'] = health_check_timeout_insecond
  1834. if health_check_interval_insecond is not None:
  1835. body['healthCheckIntervalInSecond'] = health_check_interval_insecond
  1836. if health_check_down_retry is not None:
  1837. body['healthCheckDownRetry'] = health_check_down_retry
  1838. if health_check_up_retry is not None:
  1839. body['healthCheckUpRetry'] = health_check_up_retry
  1840. if health_check_normal_status is not None:
  1841. body['healthCheckNormalStatus'] = \
  1842. compat.convert_to_string(health_check_normal_status)
  1843. if udp_health_check_string is not None:
  1844. body['udpHealthCheckString'] = \
  1845. compat.convert_to_string(udp_health_check_string)
  1846. return self._send_request(http_methods.PUT, path,
  1847. body=json.dumps(body), params=params,
  1848. config=config)
  1849. @required(blb_id=(bytes, str),
  1850. sg_id=(bytes, str),
  1851. port_list=list)
  1852. def delete_app_server_group_port(self, blb_id, sg_id,
  1853. port_list,
  1854. client_token=None, config=None):
  1855. """
  1856. delete server group of the specified LoadBalancer,
  1857. :param blb_id:
  1858. id of LoadBalancer
  1859. :type blb_id:string
  1860. :param sg_id:
  1861. id of the server group
  1862. :type sg_id:string
  1863. :param port_list:
  1864. The ports of listeners to be released
  1865. :type port_list:list<string>
  1866. :param client_token:
  1867. If the clientToken is not specified by the user, a random String
  1868. generated by default algorithm will be used.
  1869. :type client_token: string
  1870. :param config:
  1871. :type config: baidubce.BceClientConfiguration
  1872. :return:
  1873. :rtype baidubce.bce_response.BceResponse
  1874. """
  1875. path = utils.append_uri(self.version, 'appblb', blb_id, 'appservergroupport')
  1876. params = {}
  1877. params[b'batchdelete'] = None
  1878. if client_token is None:
  1879. params[b'clientToken'] = generate_client_token()
  1880. else:
  1881. params[b'clientToken'] = client_token
  1882. body = {
  1883. 'sgId': compat.convert_to_string(sg_id),
  1884. 'portIdList': port_list
  1885. }
  1886. return self._send_request(http_methods.PUT, path,
  1887. body=json.dumps(body), params=params,
  1888. config=config)
  1889. @required(blb_id=(bytes, str),
  1890. sg_id=(bytes, str),
  1891. backend_server_list=list)
  1892. def create_app_blb_rs(self, blb_id, sg_id,
  1893. backend_server_list,
  1894. client_token=None,
  1895. config=None):
  1896. """
  1897. Add backend server for the specified LoadBalancer and server group,
  1898. support batch add
  1899. :param blb_id:
  1900. id of LoadBalancer
  1901. :type blb_id:string
  1902. :param sg_id:
  1903. id of the server group
  1904. :type sg_id:string
  1905. :param backend_server_list
  1906. List of backend servers to be added
  1907. https://cloud.baidu.com/doc/BLB/API.html#AppBackendServer
  1908. :type backend_server_list:List<AppBackendServer>
  1909. :param client_token:
  1910. If the clientToken is not specified by the user, a random String
  1911. generated by default algorithm will be used.
  1912. :type client_token: string
  1913. :param config:
  1914. :type config: baidubce.BceClientConfiguration
  1915. :return:
  1916. :rtype baidubce.bce_response.BceResponse
  1917. """
  1918. path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrs')
  1919. params = {}
  1920. if client_token is None:
  1921. params[b'clientToken'] = generate_client_token()
  1922. else:
  1923. params[b'clientToken'] = client_token
  1924. body = {
  1925. 'sgId': compat.convert_to_string(sg_id),
  1926. 'backendServerList': backend_server_list
  1927. }
  1928. return self._send_request(http_methods.POST, path,
  1929. body=json.dumps(body), params=params,
  1930. config=config)
  1931. @required(blb_id=(bytes, str),
  1932. sg_id=(bytes, str),
  1933. backend_server_list=list)
  1934. def update_app_blb_rs(self, blb_id, sg_id,
  1935. backend_server_list,
  1936. client_token=None,
  1937. config=None):
  1938. """
  1939. update backend server for the specified LoadBalancer and server group,
  1940. support batch update
  1941. :param blb_id:
  1942. id of LoadBalancer
  1943. :type blb_id:string
  1944. :param sg_id:
  1945. id of the server group
  1946. :type sg_id:string
  1947. :param backend_server_list
  1948. List of backend servers to be added
  1949. https://cloud.baidu.com/doc/BLB/API.html#AppBackendServer
  1950. :type backend_server_list:List<AppBackendServer>
  1951. :param client_token:
  1952. If the clientToken is not specified by the user, a random String
  1953. generated by default algorithm will be used.
  1954. :type client_token: string
  1955. :param config:
  1956. :type config: baidubce.BceClientConfiguration
  1957. :return:
  1958. :rtype baidubce.bce_response.BceResponse
  1959. """
  1960. path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrs')
  1961. params = {}
  1962. if client_token is None:
  1963. params[b'clientToken'] = generate_client_token()
  1964. else:
  1965. params[b'clientToken'] = client_token
  1966. body = {
  1967. 'sgId': compat.convert_to_string(sg_id),
  1968. 'backendServerList': backend_server_list
  1969. }
  1970. return self._send_request(http_methods.PUT, path,
  1971. body=json.dumps(body), params=params,
  1972. config=config)
  1973. @required(blb_id=(bytes, str),
  1974. sg_id=(bytes, str))
  1975. def describe_app_blb_rs(self, blb_id, sg_id,
  1976. marker=None, max_keys=None,
  1977. config=None):
  1978. """
  1979. Query the list of backend servers under the specified LoadBalancer
  1980. and server group
  1981. :param blb_id:
  1982. Id of LoadBalancer
  1983. :type blb_id:string
  1984. :param sg_id:
  1985. id of the server group
  1986. :type sg_id:string
  1987. :param marker:
  1988. The optional parameter marker specified in the original
  1989. request to specify where in the results to begin listing.
  1990. Together with the marker, specifies the list result which
  1991. listing should begin. If the marker is not specified,
  1992. the list result will listing from the first one.
  1993. :type marker: string
  1994. :param max_keys:
  1995. The optional parameter to specifies the max number of
  1996. list result to return.
  1997. The default value is 1000.
  1998. :type max_keys: int
  1999. :param config:
  2000. :type config: baidubce.BceClientConfiguration
  2001. :return:
  2002. :rtype baidubce.bce_response.BceResponse
  2003. """
  2004. path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrs')
  2005. params = {}
  2006. params[b'sgId'] = compat.convert_to_string(sg_id)
  2007. if marker is not None:
  2008. params[b'marker'] = marker
  2009. if max_keys is not None:
  2010. params[b'maxKeys'] = max_keys
  2011. return self._send_request(http_methods.GET, path, params=params,
  2012. config=config)
  2013. @required(blb_id=(bytes, str),
  2014. sg_id=(bytes, str),
  2015. backend_server_list=list)
  2016. def delete_app_blb_rs(self, blb_id, sg_id,
  2017. backend_server_list,
  2018. client_token=None,
  2019. config=None):
  2020. """
  2021. delete backend server for the specified LoadBalancer and server group,
  2022. support batch delete
  2023. :param blb_id:
  2024. id of LoadBalancer
  2025. :type blb_id:string
  2026. :param sg_id:
  2027. id of the server group
  2028. :type sg_id:string
  2029. :param backend_server_list
  2030. List of backend servers to be deleted
  2031. :type backend_server_list:List<string>
  2032. :param client_token:
  2033. If the clientToken is not specified by the user, a random String
  2034. generated by default algorithm will be used.
  2035. :type client_token: string
  2036. :param config:
  2037. :type config: baidubce.BceClientConfiguration
  2038. :return:
  2039. :rtype baidubce.bce_response.BceResponse
  2040. """
  2041. path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrs')
  2042. params = {}
  2043. params[b'batchdelete'] = None
  2044. if client_token is None:
  2045. params[b'clientToken'] = generate_client_token()
  2046. else:
  2047. params[b'clientToken'] = client_token
  2048. body = {
  2049. 'sgId': compat.convert_to_string(sg_id),
  2050. 'backendServerIdList': backend_server_list
  2051. }
  2052. return self._send_request(http_methods.PUT, path,
  2053. body=json.dumps(body), params=params,
  2054. config=config)
  2055. @required(blb_id=(bytes, str),
  2056. sg_id=(bytes, str))
  2057. def describe_rs_mount(self, blb_id, sg_id, config=None):
  2058. """
  2059. describe servers of specific server group
  2060. :param blb_id:
  2061. id of LoadBalancer
  2062. :type blb_id:string
  2063. :param sg_id:
  2064. id of the server group
  2065. :type sg_id:string
  2066. :param config:
  2067. :type config: baidubce.BceClientConfiguration
  2068. :return:
  2069. :rtype baidubce.bce_response.BceResponse
  2070. """
  2071. path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrsmount')
  2072. params = {
  2073. 'sgId': compat.convert_to_string(sg_id)
  2074. }
  2075. return self._send_request(http_methods.GET, path, params=params,
  2076. config=config)
  2077. @required(blb_id=(bytes, str),
  2078. sg_id=(bytes, str))
  2079. def describe_rs_unmount(self, blb_id, sg_id, config=None):
  2080. """
  2081. describe servers of specific server group
  2082. :param blb_id:
  2083. id of LoadBalancer
  2084. :type blb_id:string
  2085. :param sg_id:
  2086. id of the server group
  2087. :type sg_id:string
  2088. :param config:
  2089. :type config: baidubce.BceClientConfiguration
  2090. :return:
  2091. :rtype baidubce.bce_response.BceResponse
  2092. """
  2093. path = utils.append_uri(self.version, 'appblb', blb_id, 'blbrsunmount')
  2094. params = {
  2095. 'sgId': compat.convert_to_string(sg_id)
  2096. }
  2097. return self._send_request(http_methods.GET, path, params=params,
  2098. config=config)
  2099. @required(blb_id=(bytes, str))
  2100. def create_app_ip_group(self, blb_id,
  2101. name=None,
  2102. desc=None,
  2103. member_list=None,
  2104. client_token=None,
  2105. config=None):
  2106. """
  2107. create ip group for the specified LoadBalancer,
  2108. support batch add
  2109. :param blb_id:
  2110. id of LoadBalancer
  2111. :type blb_id:string
  2112. :param name:
  2113. name of ip group
  2114. :type name:string
  2115. :param desc:
  2116. description of ip group
  2117. :type desc:string
  2118. :param member_list
  2119. List of backend servers to be added
  2120. https://cloud.baidu.com/doc/BLB/API.html#AppBackendServer
  2121. :type member_list:List<AppIpGroupMemberVO>
  2122. :param client_token:
  2123. If the clientToken is not specified by the user, a random String
  2124. generated by default algorithm will be used.
  2125. :type client_token: string
  2126. :param config:
  2127. :type config: baidubce.BceClientConfiguration
  2128. :return:
  2129. :rtype baidubce.bce_response.BceResponse
  2130. """
  2131. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup')
  2132. params = {}
  2133. if client_token is None:
  2134. params[b'clientToken'] = generate_client_token()
  2135. else:
  2136. params[b'clientToken'] = client_token
  2137. body = {}
  2138. if name is not None:
  2139. body['name'] = compat.convert_to_string(name)
  2140. if desc is not None:
  2141. body['desc'] = compat.convert_to_string(desc)
  2142. if member_list is not None:
  2143. body['memberList'] = member_list
  2144. return self._send_request(http_methods.POST, path,
  2145. body=json.dumps(body), params=params,
  2146. config=config)
  2147. @required(blb_id=(bytes, str),
  2148. ip_group_id=(bytes, str))
  2149. def update_app_ip_group(self, blb_id, ip_group_id,
  2150. name=None,
  2151. desc=None,
  2152. client_token=None,
  2153. config=None):
  2154. """
  2155. update the information of the app ip group
  2156. of the specified LoadBalancer
  2157. :param blb_id:
  2158. id of LoadBalancer
  2159. :type blb_id:string
  2160. :param ip_group_id:
  2161. id of the ip group to be updated
  2162. :type ip_group_id:string
  2163. :param name:
  2164. name of server group
  2165. :type name:string
  2166. :param desc:
  2167. description of server group
  2168. :type desc:string
  2169. :param client_token:
  2170. If the clientToken is not specified by the user, a random String
  2171. generated by default algorithm will be used.
  2172. :type client_token: string
  2173. :param config:
  2174. :type config: baidubce.BceClientConfiguration
  2175. :return:
  2176. :rtype baidubce.bce_response.BceResponse
  2177. """
  2178. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup')
  2179. params = {}
  2180. if client_token is None:
  2181. params[b'clientToken'] = generate_client_token()
  2182. else:
  2183. params[b'clientToken'] = client_token
  2184. body = {}
  2185. body['ipGroupId'] = compat.convert_to_string(ip_group_id)
  2186. if name is not None:
  2187. body['name'] = compat.convert_to_string(name)
  2188. if desc is not None:
  2189. body['desc'] = compat.convert_to_string(desc)
  2190. return self._send_request(http_methods.PUT, path,
  2191. body=json.dumps(body), params=params,
  2192. config=config)
  2193. @required(blb_id=(bytes, str))
  2194. def describe_app_ip_group(self, blb_id,
  2195. name=None,
  2196. exactly_match=None,
  2197. marker=None,
  2198. max_keys=None, config=None):
  2199. """
  2200. Query the imformation of app ip group
  2201. of the specified LoadBalancer
  2202. :param blb_id:
  2203. Id of LoadBalancer
  2204. :type blb_id:string
  2205. :param name:
  2206. name of ip group
  2207. :type name:string
  2208. :param exactly_match:
  2209. Set whether the name matches globally
  2210. :type exactly_match:boolean
  2211. :param marker:
  2212. The optional parameter marker specified in the original
  2213. request to specify where in the results to begin listing.
  2214. Together with the marker, specifies the list result which
  2215. listing should begin. If the marker is not specified,
  2216. the list result will listing from the first one.
  2217. :type marker: string
  2218. :param max_keys:
  2219. The optional parameter to specifies the max number of
  2220. list result to return.
  2221. The default value is 1000.
  2222. :type max_keys: int
  2223. :param config:
  2224. :type config: baidubce.BceClientConfiguration
  2225. :return:
  2226. :rtype baidubce.bce_response.BceResponse
  2227. """
  2228. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup')
  2229. params = {}
  2230. if name is not None:
  2231. params[b'name'] = name
  2232. if exactly_match is not None:
  2233. params[b'exactlyMatch'] = exactly_match
  2234. if marker is not None:
  2235. params[b'marker'] = marker
  2236. if max_keys is not None:
  2237. params[b'maxKeys'] = max_keys
  2238. return self._send_request(http_methods.GET, path, params=params,
  2239. config=config)
  2240. @required(blb_id=(bytes, str),
  2241. ip_group_id=(bytes, str))
  2242. def delete_app_ip_group(self, blb_id, ip_group_id,
  2243. client_token=None,
  2244. config=None):
  2245. """
  2246. delete the app ip group of the specified LoadBalancer,
  2247. :param blb_id:
  2248. id of LoadBalancer
  2249. :type blb_id:string
  2250. :param ip_group_id:
  2251. id of the ip group to be updated
  2252. :type ip_group_id:string
  2253. :param client_token:
  2254. If the clientToken is not specified by the user,
  2255. a random String generated by default algorithm will be used.
  2256. :type client_token: string
  2257. :param config:
  2258. :type config: baidubce.BceClientConfiguration
  2259. :return:
  2260. :rtype baidubce.bce_response.BceResponse
  2261. """
  2262. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup')
  2263. params = {}
  2264. params[b'delete'] = None
  2265. if client_token is None:
  2266. params[b'clientToken'] = generate_client_token()
  2267. else:
  2268. params[b'clientToken'] = client_token
  2269. body = {}
  2270. body['ipGroupId'] = compat.convert_to_string(ip_group_id)
  2271. return self._send_request(http_methods.PUT, path,
  2272. body=json.dumps(body), params=params,
  2273. config=config)
  2274. @required(blb_id=(bytes, str),
  2275. ip_group_id=(bytes, str),
  2276. protocol_type=(bytes, str))
  2277. def create_app_ip_group_port(self, blb_id, ip_group_id,
  2278. protocol_type,
  2279. health_check=None,
  2280. health_check_port=None,
  2281. health_check_urlpath=None,
  2282. health_check_timeout_insecond=None,
  2283. health_check_interval_insecond=None,
  2284. health_check_down_retry=None,
  2285. health_check_up_retry=None,
  2286. health_check_normal_status=None,
  2287. udp_health_check_string=None,
  2288. client_token=None,
  2289. config=None):
  2290. """
  2291. create server group for the specified LoadBalancer,
  2292. support batch add
  2293. :param blb_id:
  2294. id of LoadBalancer
  2295. :type blb_id:string
  2296. :param ip_group_id:
  2297. id of the ip group
  2298. :type ip_group_id:string
  2299. :param protocol_type:
  2300. Protocol type of listening port, "TCP"/"UDP"/"HTTP"
  2301. :type protocol_type:string
  2302. :param health_check:
  2303. Health check protocol
  2304. :value 'HTTP' or 'TCP',default:'HTTP'
  2305. :type health_check: string
  2306. :param health_check_port:
  2307. Health check port, the default is the same as port
  2308. :type health_check_port: int
  2309. :param health_check_urlpath:
  2310. Health check URI, default '/'.
  2311. Effective when the health check protocol is "HTTP"
  2312. :type health_check_urlpath: string
  2313. :param health_check_timeout_insecond:
  2314. Health check timeout (unit: second)
  2315. :value 1-60, default: 3
  2316. :type health_check_timeout_insecond: int
  2317. :param health_check_interval_insecond:
  2318. Health check interval (unit: second)
  2319. :value 1-10, default: 3
  2320. :type health_check_interval_insecond: int
  2321. :param health_check_down_retry:
  2322. The unhealthy down retry, that is, how many consecutive health
  2323. check failures, shields the backend server.
  2324. :value 2-5, default: 3
  2325. :type health_check_down_retry: int
  2326. :param health_check_up_retry:
  2327. Health up retry, that is, how many consecutive health checks
  2328. are successful, then re-use the back-end server
  2329. :value:2-5, default: 3
  2330. :type health_check_up_retry: int
  2331. :param health_check_normal_status:
  2332. The HTTP status code when the health check is normal supports
  2333. a combination of five types of status codes,
  2334. such as "http_1xx|http_2xx", Effective when the health check
  2335. protocol is "HTTP"
  2336. :value default: http_2xx|http_3xx
  2337. :type health_check_normal_status: string
  2338. :param udp_health_check_string:
  2339. The health check string for the udp listener,
  2340. it must be passed when the health check type is "UDP"
  2341. :type udp_health_check_string: string
  2342. :param client_token:
  2343. If the clientToken is not specified by the user, a random String
  2344. generated by default algorithm will be used.
  2345. :type client_token: string
  2346. :param config:
  2347. :type config: baidubce.BceClientConfiguration
  2348. :return:
  2349. :rtype baidubce.bce_response.BceResponse
  2350. """
  2351. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup', 'backendpolicy')
  2352. params = {}
  2353. if client_token is None:
  2354. params[b'clientToken'] = generate_client_token()
  2355. else:
  2356. params[b'clientToken'] = client_token
  2357. body = {
  2358. 'ipGroupId': compat.convert_to_string(ip_group_id),
  2359. 'type': compat.convert_to_string(protocol_type)
  2360. }
  2361. if health_check is not None:
  2362. body['healthCheck'] = compat.convert_to_string(health_check)
  2363. if health_check_port is not None:
  2364. body['healthCheckPort'] = health_check_port
  2365. if health_check_urlpath is not None:
  2366. body['healthCheckUrlPath'] = \
  2367. compat.convert_to_string(health_check_urlpath)
  2368. if health_check_timeout_insecond is not None:
  2369. body['healthCheckTimeoutInSecond'] = health_check_timeout_insecond
  2370. if health_check_interval_insecond is not None:
  2371. body['healthCheckIntervalInSecond'] = health_check_interval_insecond
  2372. if health_check_down_retry is not None:
  2373. body['healthCheckDownRetry'] = health_check_down_retry
  2374. if health_check_up_retry is not None:
  2375. body['healthCheckUpRetry'] = health_check_up_retry
  2376. if health_check_normal_status is not None:
  2377. body['healthCheckNormalStatus'] = \
  2378. compat.convert_to_string(health_check_normal_status)
  2379. if udp_health_check_string is not None:
  2380. body['udpHealthCheckString'] = \
  2381. compat.convert_to_string(udp_health_check_string)
  2382. return self._send_request(http_methods.POST, path,
  2383. body=json.dumps(body), params=params,
  2384. config=config)
  2385. @required(blb_id=(bytes, str),
  2386. ip_group_id=(bytes, str),
  2387. port_id=(bytes, str))
  2388. def update_app_ip_group_port(self, blb_id, ip_group_id, port_id,
  2389. health_check=None,
  2390. health_check_port=None,
  2391. health_check_urlpath=None,
  2392. health_check_timeout_insecond=None,
  2393. health_check_interval_insecond=None,
  2394. health_check_down_retry=None,
  2395. health_check_up_retry=None,
  2396. health_check_normal_status=None,
  2397. udp_health_check_string=None,
  2398. client_token=None,
  2399. config=None):
  2400. """
  2401. update server group for the specified LoadBalancer,
  2402. support batch add
  2403. :param blb_id:
  2404. id of LoadBalancer
  2405. :type blb_id:string
  2406. :param ip_group_id:
  2407. id of the ip group
  2408. :type ip_group_id:string
  2409. :param port_id:
  2410. The id of the server group port to be updated
  2411. :type port_id:string
  2412. :param health_check:
  2413. Health check protocol
  2414. :value 'HTTP' or 'TCP',default:'HTTP'
  2415. :type health_check: string
  2416. :param health_check_port:
  2417. Health check port, the default is the same as port
  2418. :type health_check_port: int
  2419. :param health_check_urlpath:
  2420. Health check URI, default '/'.
  2421. Effective when the health check protocol is "HTTP"
  2422. :type health_check_urlpath: string
  2423. :param health_check_timeout_insecond:
  2424. Health check timeout (unit: second)
  2425. :value 1-60, default: 3
  2426. :type health_check_timeout_insecond: int
  2427. :param health_check_interval_insecond:
  2428. Health check interval (unit: second)
  2429. :value 1-10, default: 3
  2430. :type health_check_interval_insecond: int
  2431. :param health_check_down_retry:
  2432. The unhealthy down retry, that is, how many consecutive health
  2433. check failures, shields the backend server.
  2434. :value 2-5, default: 3
  2435. :type health_check_down_retry: int
  2436. :param health_check_up_retry:
  2437. Health up retry, that is, how many consecutive health checks
  2438. are successful, then re-use the back-end server
  2439. :value:2-5, default: 3
  2440. :type health_check_up_retry: int
  2441. :param health_check_normal_status:
  2442. The HTTP status code when the health check is normal supports
  2443. a combination of five types of status codes,
  2444. such as "http_1xx|http_2xx", Effective when the health check
  2445. protocol is "HTTP"
  2446. :value default: http_2xx|http_3xx
  2447. :type health_check_normal_status: string
  2448. :param udp_health_check_string:
  2449. The health check string for the udp listener
  2450. :type udp_health_check_string: string
  2451. :param client_token:
  2452. If the clientToken is not specified by the user, a random String
  2453. generated by default algorithm will be used.
  2454. :type client_token: string
  2455. :param config:
  2456. :type config: baidubce.BceClientConfiguration
  2457. :return:
  2458. :rtype baidubce.bce_response.BceResponse
  2459. """
  2460. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup', 'backendpolicy')
  2461. params = {}
  2462. if client_token is None:
  2463. params[b'clientToken'] = generate_client_token()
  2464. else:
  2465. params[b'clientToken'] = client_token
  2466. body = {
  2467. 'ipGroupId': compat.convert_to_string(ip_group_id),
  2468. 'id': compat.convert_to_string(port_id)
  2469. }
  2470. if health_check is not None:
  2471. body['healthCheck'] = compat.convert_to_string(health_check)
  2472. if health_check_port is not None:
  2473. body['healthCheckPort'] = health_check_port
  2474. if health_check_urlpath is not None:
  2475. body['healthCheckUrlPath'] = \
  2476. compat.convert_to_string(health_check_urlpath)
  2477. if health_check_timeout_insecond is not None:
  2478. body['healthCheckTimeoutInSecond'] = health_check_timeout_insecond
  2479. if health_check_interval_insecond is not None:
  2480. body['healthCheckIntervalInSecond'] = health_check_interval_insecond
  2481. if health_check_down_retry is not None:
  2482. body['healthCheckDownRetry'] = health_check_down_retry
  2483. if health_check_up_retry is not None:
  2484. body['healthCheckUpRetry'] = health_check_up_retry
  2485. if health_check_normal_status is not None:
  2486. body['healthCheckNormalStatus'] = \
  2487. compat.convert_to_string(health_check_normal_status)
  2488. if udp_health_check_string is not None:
  2489. body['udpHealthCheckString'] = \
  2490. compat.convert_to_string(udp_health_check_string)
  2491. return self._send_request(http_methods.PUT, path,
  2492. body=json.dumps(body), params=params,
  2493. config=config)
  2494. @required(blb_id=(bytes, str),
  2495. ip_group_id=(bytes, str),
  2496. port_list=list)
  2497. def delete_app_ip_group_port(self, blb_id, ip_group_id,
  2498. port_list,
  2499. client_token=None, config=None):
  2500. """
  2501. delete server group of the specified LoadBalancer,
  2502. :param blb_id:
  2503. id of LoadBalancer
  2504. :type blb_id:string
  2505. :param ip_group_id:
  2506. id of the ip group
  2507. :type ip_group_id:string
  2508. :param port_list:
  2509. The ports of listeners to be released
  2510. :type port_list:list<string>
  2511. :param client_token:
  2512. If the clientToken is not specified by the user, a random String
  2513. generated by default algorithm will be used.
  2514. :type client_token: string
  2515. :param config:
  2516. :type config: baidubce.BceClientConfiguration
  2517. :return:
  2518. :rtype baidubce.bce_response.BceResponse
  2519. """
  2520. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup', 'backendpolicy')
  2521. params = {}
  2522. if client_token is None:
  2523. params[b'clientToken'] = generate_client_token()
  2524. else:
  2525. params[b'clientToken'] = client_token
  2526. body = {
  2527. 'ipGroupId': compat.convert_to_string(ip_group_id),
  2528. 'backendPolicyIdList': port_list
  2529. }
  2530. return self._send_request(http_methods.DELETE, path,
  2531. body=json.dumps(body), params=params,
  2532. config=config)
  2533. @required(blb_id=(bytes, str),
  2534. ip_group_id=(bytes, str))
  2535. def create_app_ip_group_member(self, blb_id, ip_group_id, member_list,
  2536. name=None,
  2537. desc=None,
  2538. client_token=None,
  2539. config=None):
  2540. """
  2541. create ip group for the specified LoadBalancer,
  2542. support batch add
  2543. :param blb_id:
  2544. id of LoadBalancer
  2545. :type blb_id:string
  2546. :param ip_group_id:
  2547. id of the ip group to be updated
  2548. :type ip_group_id:string
  2549. :param member_list
  2550. List of member to be added
  2551. https://cloud.baidu.com/doc/BLB/API.html#AppBackendServer
  2552. :type member_list:List<AppIpGroupMemberVO>
  2553. :param name:
  2554. name of ip group
  2555. :type name:string
  2556. :param desc:
  2557. description of ip group
  2558. :type desc:string
  2559. :param client_token:
  2560. If the clientToken is not specified by the user, a random String
  2561. generated by default algorithm will be used.
  2562. :type client_token: string
  2563. :param config:
  2564. :type config: baidubce.BceClientConfiguration
  2565. :return:
  2566. :rtype baidubce.bce_response.BceResponse
  2567. """
  2568. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup', 'member')
  2569. params = {}
  2570. if client_token is None:
  2571. params[b'clientToken'] = generate_client_token()
  2572. else:
  2573. params[b'clientToken'] = client_token
  2574. body = {}
  2575. body['ipGroupId'] = compat.convert_to_string(ip_group_id)
  2576. body['memberList'] = member_list
  2577. if name is not None:
  2578. body['name'] = compat.convert_to_string(name)
  2579. if desc is not None:
  2580. body['desc'] = compat.convert_to_string(desc)
  2581. return self._send_request(http_methods.POST, path,
  2582. body=json.dumps(body), params=params,
  2583. config=config)
  2584. @required(blb_id=(bytes, str),
  2585. ip_group_id=(bytes, str))
  2586. def update_app_ip_group_member(self, blb_id, ip_group_id, member_list,
  2587. name=None,
  2588. desc=None,
  2589. client_token=None,
  2590. config=None):
  2591. """
  2592. update the information of the app ip group
  2593. of the specified LoadBalancer
  2594. :param blb_id:
  2595. id of LoadBalancer
  2596. :type blb_id:string
  2597. :param ip_group_id:
  2598. id of the ip group to be updated
  2599. :type ip_group_id:string
  2600. :param member_list
  2601. List of member to be updated
  2602. https://cloud.baidu.com/doc/BLB/API.html#AppBackendServer
  2603. :type member_list:List<AppIpGroupMemberVO>
  2604. :param name:
  2605. name of server group
  2606. :type name:string
  2607. :param desc:
  2608. description of server group
  2609. :type desc:string
  2610. :param client_token:
  2611. If the clientToken is not specified by the user, a random String
  2612. generated by default algorithm will be used.
  2613. :type client_token: string
  2614. :param config:
  2615. :type config: baidubce.BceClientConfiguration
  2616. :return:
  2617. :rtype baidubce.bce_response.BceResponse
  2618. """
  2619. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup', 'member')
  2620. params = {}
  2621. if client_token is None:
  2622. params[b'clientToken'] = generate_client_token()
  2623. else:
  2624. params[b'clientToken'] = client_token
  2625. body = {}
  2626. body['ipGroupId'] = compat.convert_to_string(ip_group_id)
  2627. body['memberList'] = member_list
  2628. if name is not None:
  2629. body['name'] = compat.convert_to_string(name)
  2630. if desc is not None:
  2631. body['desc'] = compat.convert_to_string(desc)
  2632. return self._send_request(http_methods.PUT, path,
  2633. body=json.dumps(body), params=params,
  2634. config=config)
  2635. @required(blb_id=(bytes, str),
  2636. ip_group_id=(bytes, str))
  2637. def delete_app_ip_group_member(self, blb_id, ip_group_id, memberid_list,
  2638. client_token=None,
  2639. config=None):
  2640. """
  2641. delete the app ip group of the specified LoadBalancer,
  2642. :param blb_id:
  2643. id of LoadBalancer
  2644. :type blb_id:string
  2645. :param ip_group_id:
  2646. id of the ip group to be updated
  2647. :type ip_group_id:string
  2648. :param memberid_list
  2649. List of memberid to be deleted
  2650. https://cloud.baidu.com/doc/BLB/API.html#AppBackendServer
  2651. :type memberid_list:List<string>
  2652. :param client_token:
  2653. If the clientToken is not specified by the user,
  2654. a random String generated by default algorithm will be used.
  2655. :type client_token: string
  2656. :param config:
  2657. :type config: baidubce.BceClientConfiguration
  2658. :return:
  2659. :rtype baidubce.bce_response.BceResponse
  2660. """
  2661. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup', 'member')
  2662. params = {}
  2663. params[b'delete'] = None
  2664. if client_token is None:
  2665. params[b'clientToken'] = generate_client_token()
  2666. else:
  2667. params[b'clientToken'] = client_token
  2668. body = {}
  2669. body['ipGroupId'] = compat.convert_to_string(ip_group_id)
  2670. body['memberIdList'] = memberid_list
  2671. return self._send_request(http_methods.PUT, path,
  2672. body=json.dumps(body), params=params,
  2673. config=config)
  2674. @required(blb_id=(bytes, str),
  2675. ip_group_id=(bytes, str))
  2676. def describe_app_ip_group_member(self, blb_id, ip_group_id,
  2677. name=None,
  2678. exactly_match=None,
  2679. marker=None,
  2680. max_keys=None, config=None):
  2681. """
  2682. Query the imformation of app ip group
  2683. of the specified LoadBalancer
  2684. :param blb_id:
  2685. Id of LoadBalancer
  2686. :type blb_id:string
  2687. :param ip_group_id:
  2688. id of the ip group to be updated
  2689. :type ip_group_id:string
  2690. :param marker:
  2691. The optional parameter marker specified in the original
  2692. request to specify where in the results to begin listing.
  2693. Together with the marker, specifies the list result which
  2694. listing should begin. If the marker is not specified,
  2695. the list result will listing from the first one.
  2696. :type marker: string
  2697. :param max_keys:
  2698. The optional parameter to specifies the max number of
  2699. list result to return.
  2700. The default value is 1000.
  2701. :type max_keys: int
  2702. :param config:
  2703. :type config: baidubce.BceClientConfiguration
  2704. :return:
  2705. :rtype baidubce.bce_response.BceResponse
  2706. """
  2707. path = utils.append_uri(self.version, 'appblb', blb_id, 'ipgroup', 'member')
  2708. params = {}
  2709. params[b'ipGroupId'] = ip_group_id
  2710. if marker is not None:
  2711. params[b'marker'] = marker
  2712. if max_keys is not None:
  2713. params[b'maxKeys'] = max_keys
  2714. return self._send_request(http_methods.GET, path, params=params,
  2715. config=config)
  2716. def generate_client_token_by_uuid():
  2717. """
  2718. The default method to generate the random string for client_token
  2719. if the optional parameter client_token is not specified by the user.
  2720. :return:
  2721. :rtype string
  2722. """
  2723. return str(uuid.uuid4())
  2724. @required(blb_id=(bytes, str),
  2725. securitygroupids=list)
  2726. def bind_app_security_groups(self, blb_id, securitygroupids,
  2727. client_token=None, config=None):
  2728. """
  2729. bind the blb security groups (application/ipv6 LoadBalancer)
  2730. :param blb_id:
  2731. id of LoadBalancer
  2732. :type blb_id:string
  2733. :param securitygroupids:
  2734. List of security group ids to be bind
  2735. :type securitygroupids:List<string>
  2736. :param client_token:
  2737. If the clientToken is not specified by the user,
  2738. a random String generated by default algorithm will be used.
  2739. :type client_token: string
  2740. :param config:
  2741. :type config: baidubce.BceClientConfiguration
  2742. :return:
  2743. :rtype baidubce.bce_response.BceResponse
  2744. """
  2745. path = utils.append_uri(self.version, 'blb', blb_id, 'securitygroup')
  2746. params = {}
  2747. params[b'bind'] = None
  2748. if client_token is None:
  2749. params[b'clientToken'] = generate_client_token()
  2750. else:
  2751. params[b'clientToken'] = client_token
  2752. body = {}
  2753. body['securityGroupIds'] = securitygroupids
  2754. return self._send_request(http_methods.PUT, path,
  2755. body=json.dumps(body), params=params,
  2756. config=config)
  2757. @required(blb_id=(bytes, str),
  2758. securitygroupids=list)
  2759. def unbind_app_security_groups(self, blb_id, securitygroupids,
  2760. client_token=None, config=None):
  2761. """
  2762. unbind the blb security groups (application/ipv6 LoadBalancer)
  2763. :param blb_id:
  2764. id of LoadBalancer
  2765. :type blb_id:string
  2766. :param securitygroupids:
  2767. List of security group ids to be bind
  2768. :type securitygroupids:List<string>
  2769. :param client_token:
  2770. If the clientToken is not specified by the user,
  2771. a random String generated by default algorithm will be used.
  2772. :type client_token: string
  2773. :param config:
  2774. :type config: baidubce.BceClientConfiguration
  2775. :return:
  2776. :rtype baidubce.bce_response.BceResponse
  2777. """
  2778. path = utils.append_uri(self.version, 'blb', blb_id, 'securitygroup')
  2779. params = {}
  2780. params[b'unbind'] = None
  2781. if client_token is None:
  2782. params[b'clientToken'] = generate_client_token()
  2783. else:
  2784. params[b'clientToken'] = client_token
  2785. body = {}
  2786. body['securityGroupIds'] = securitygroupids
  2787. return self._send_request(http_methods.PUT, path,
  2788. body=json.dumps(body), params=params,
  2789. config=config)
  2790. @required(blb_id=(bytes, str))
  2791. def describe_app_security_groups(self, blb_id,
  2792. client_token=None, config=None):
  2793. """
  2794. describe the blb security groups (application/ipv6 LoadBalancer)
  2795. :param blb_id:
  2796. id of LoadBalancer
  2797. :type blb_id:string
  2798. :param client_token:
  2799. If the clientToken is not specified by the user,
  2800. a random String generated by default algorithm will be used.
  2801. :type client_token: string
  2802. :param config:
  2803. :type config: baidubce.BceClientConfiguration
  2804. :return:
  2805. :rtype baidubce.bce_response.BceResponse
  2806. """
  2807. path = utils.append_uri(self.version, 'blb', blb_id, 'securitygroup')
  2808. params = {}
  2809. if client_token is None:
  2810. params[b'clientToken'] = generate_client_token()
  2811. else:
  2812. params[b'clientToken'] = client_token
  2813. return self._send_request(http_methods.GET, path, params=params,
  2814. config=config)
  2815. @required(blb_id=(bytes, str),
  2816. enterprisesecuritygroupids=list)
  2817. def bind_app_enterprise_security_groups(self, blb_id, enterprisesecuritygroupids,
  2818. client_token=None, config=None):
  2819. """
  2820. bind the blb enterprise security groups (application/ipv6 LoadBalancer)
  2821. :param blb_id:
  2822. id of LoadBalancer
  2823. :type blb_id:string
  2824. :param enterprisesecuritygroupids:
  2825. List of enterprise security group ids to be bind
  2826. :type enterprisesecuritygroupids:List<string>
  2827. :param client_token:
  2828. If the clientToken is not specified by the user,
  2829. a random String generated by default algorithm will be used.
  2830. :type client_token: string
  2831. :param config:
  2832. :type config: baidubce.BceClientConfiguration
  2833. :return:
  2834. :rtype baidubce.bce_response.BceResponse
  2835. """
  2836. path = utils.append_uri(self.version, 'blb', blb_id, 'enterprise', 'securitygroup')
  2837. params = {}
  2838. params[b'bind'] = None
  2839. if client_token is None:
  2840. params[b'clientToken'] = generate_client_token()
  2841. else:
  2842. params[b'clientToken'] = client_token
  2843. body = {}
  2844. body['enterpriseSecurityGroupIds'] = enterprisesecuritygroupids
  2845. return self._send_request(http_methods.PUT, path,
  2846. body=json.dumps(body), params=params,
  2847. config=config)
  2848. @required(blb_id=(bytes, str),
  2849. enterprisesecuritygroupids=list)
  2850. def unbind_app_enterprise_security_groups(self, blb_id, enterprisesecuritygroupids,
  2851. client_token=None, config=None):
  2852. """
  2853. unbind the blb enterprise security groups (application/ipv6 LoadBalancer)
  2854. :param blb_id:
  2855. id of LoadBalancer
  2856. :type blb_id:string
  2857. :param enterprisesecuritygroupids:
  2858. List of enterprise security group ids to be unbind
  2859. :type enterprisesecuritygroupids:List<string>
  2860. :param client_token:
  2861. If the clientToken is not specified by the user,
  2862. a random String generated by default algorithm will be used.
  2863. :type client_token: string
  2864. :param config:
  2865. :type config: baidubce.BceClientConfiguration
  2866. :return:
  2867. :rtype baidubce.bce_response.BceResponse
  2868. """
  2869. path = utils.append_uri(self.version, 'blb', blb_id, 'enterprise', 'securitygroup')
  2870. params = {}
  2871. params[b'unbind'] = None
  2872. if client_token is None:
  2873. params[b'clientToken'] = generate_client_token()
  2874. else:
  2875. params[b'clientToken'] = client_token
  2876. body = {}
  2877. body['enterpriseSecurityGroupIds'] = enterprisesecuritygroupids
  2878. return self._send_request(http_methods.PUT, path,
  2879. body=json.dumps(body), params=params,
  2880. config=config)
  2881. @required(blb_id=(bytes, str))
  2882. def describe_app_enterprise_security_groups(self, blb_id,
  2883. client_token=None, config=None):
  2884. """
  2885. describe the blb enterprise security groups (application/ipv6 LoadBalancer)
  2886. :param blb_id:
  2887. id of LoadBalancer
  2888. :type blb_id:string
  2889. :param client_token:
  2890. If the clientToken is not specified by the user,
  2891. a random String generated by default algorithm will be used.
  2892. :type client_token: string
  2893. :param config:
  2894. :type config: baidubce.BceClientConfiguration
  2895. :return:
  2896. :rtype baidubce.bce_response.BceResponse
  2897. """
  2898. path = utils.append_uri(self.version, 'blb', blb_id, 'enterprise', 'securitygroup')
  2899. params = {}
  2900. if client_token is None:
  2901. params[b'clientToken'] = generate_client_token()
  2902. else:
  2903. params[b'clientToken'] = client_token
  2904. return self._send_request(http_methods.GET, path, params=params,
  2905. config=config)
  2906. @required(blb_id=(bytes, str), listener_port=int, apppolicyvos=list)
  2907. def create_app_ipgroup_policys(self, blb_id, listener_port, apppolicyvos, type=None,
  2908. client_token=None, config=None):
  2909. """
  2910. create app blb ipgroup policys (application/ipv6 LoadBalancer)
  2911. :param blb_id:
  2912. id of LoadBalancer
  2913. :type blb_id:string
  2914. :param listener_port:
  2915. port of listener
  2916. :type blb_id:int
  2917. :param apppolicyvos:
  2918. binding policy list of listener
  2919. :type apppolicyvos:list
  2920. :param type:
  2921. protocol of listener
  2922. :type type:string
  2923. :param client_token:
  2924. If the clientToken is not specified by the user,
  2925. a random String generated by default algorithm will be used.
  2926. :type client_token: string
  2927. :param config:
  2928. :type config: baidubce.BceClientConfiguration
  2929. :return:
  2930. :rtype baidubce.bce_response.BceResponse
  2931. """
  2932. path = utils.append_uri(self.version, 'appblb', blb_id, 'policys')
  2933. params = {}
  2934. if client_token is None:
  2935. params[b'clientToken'] = generate_client_token()
  2936. else:
  2937. params[b'clientToken'] = client_token
  2938. body = {}
  2939. body['listenerPort'] = listener_port
  2940. if type is not None:
  2941. body['type'] = type
  2942. body['appPolicyVos'] = apppolicyvos
  2943. return self._send_request(http_methods.POST, path,
  2944. body=json.dumps(body), params=params,
  2945. config=config)
  2946. @required(blb_id=(bytes, str), port=int)
  2947. def describe_app_ipgroup_policys(self, blb_id, port, type=None, marker=None,
  2948. maxkeys=None, client_token=None, config=None):
  2949. """
  2950. describe app blb ipgroup policys (application/ipv6 LoadBalancer)
  2951. :param blb_id:
  2952. id of LoadBalancer
  2953. :type blb_id:string
  2954. :param port:
  2955. the listener port used by listener
  2956. :type port:int
  2957. :param type:
  2958. protocol of listener
  2959. :type type:string
  2960. :param marker:
  2961. The optional parameter marker specified in the original
  2962. request to specify where in the results to begin listing.
  2963. Together with the marker, specifies the list result which
  2964. listing should begin.
  2965. If the marker is not specified, the list result will listing
  2966. from the first one.
  2967. :type marker:string
  2968. :param maxkeys:
  2969. The optional parameter to specifies the max number of
  2970. list result to return.
  2971. The default value is 1000.
  2972. :type maxkeys:int
  2973. :param client_token:
  2974. If the clientToken is not specified by the user,
  2975. a random String generated by default algorithm will be used.
  2976. :type client_token: string
  2977. :param config:
  2978. :type config: baidubce.BceClientConfiguration
  2979. :return:
  2980. :rtype baidubce.bce_response.BceResponse
  2981. """
  2982. path = utils.append_uri(self.version, 'appblb', blb_id, 'policys')
  2983. params = {}
  2984. params[b'port'] = port
  2985. if type is not None:
  2986. params[b'type'] = type
  2987. if marker is not None:
  2988. params[b'marker'] = marker
  2989. if maxkeys is not None:
  2990. params[b'maxKeys'] = maxkeys
  2991. if client_token is None:
  2992. params[b'clientToken'] = generate_client_token()
  2993. else:
  2994. params[b'clientToken'] = client_token
  2995. return self._send_request(http_methods.GET, path, params=params,
  2996. config=config)
  2997. generate_client_token = generate_client_token_by_uuid