examples_test.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package elbv2_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/aws/session"
  9. "github.com/aws/aws-sdk-go/service/elbv2"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleELBV2_AddTags() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := elbv2.New(sess)
  20. params := &elbv2.AddTagsInput{
  21. ResourceArns: []*string{ // Required
  22. aws.String("ResourceArn"), // Required
  23. // More values...
  24. },
  25. Tags: []*elbv2.Tag{ // Required
  26. { // Required
  27. Key: aws.String("TagKey"), // Required
  28. Value: aws.String("TagValue"),
  29. },
  30. // More values...
  31. },
  32. }
  33. resp, err := svc.AddTags(params)
  34. if err != nil {
  35. // Print the error, cast err to awserr.Error to get the Code and
  36. // Message from an error.
  37. fmt.Println(err.Error())
  38. return
  39. }
  40. // Pretty-print the response data.
  41. fmt.Println(resp)
  42. }
  43. func ExampleELBV2_CreateListener() {
  44. sess, err := session.NewSession()
  45. if err != nil {
  46. fmt.Println("failed to create session,", err)
  47. return
  48. }
  49. svc := elbv2.New(sess)
  50. params := &elbv2.CreateListenerInput{
  51. DefaultActions: []*elbv2.Action{ // Required
  52. { // Required
  53. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  54. Type: aws.String("ActionTypeEnum"), // Required
  55. },
  56. // More values...
  57. },
  58. LoadBalancerArn: aws.String("LoadBalancerArn"), // Required
  59. Port: aws.Int64(1), // Required
  60. Protocol: aws.String("ProtocolEnum"), // Required
  61. Certificates: []*elbv2.Certificate{
  62. { // Required
  63. CertificateArn: aws.String("CertificateArn"),
  64. },
  65. // More values...
  66. },
  67. SslPolicy: aws.String("SslPolicyName"),
  68. }
  69. resp, err := svc.CreateListener(params)
  70. if err != nil {
  71. // Print the error, cast err to awserr.Error to get the Code and
  72. // Message from an error.
  73. fmt.Println(err.Error())
  74. return
  75. }
  76. // Pretty-print the response data.
  77. fmt.Println(resp)
  78. }
  79. func ExampleELBV2_CreateLoadBalancer() {
  80. sess, err := session.NewSession()
  81. if err != nil {
  82. fmt.Println("failed to create session,", err)
  83. return
  84. }
  85. svc := elbv2.New(sess)
  86. params := &elbv2.CreateLoadBalancerInput{
  87. Name: aws.String("LoadBalancerName"), // Required
  88. Subnets: []*string{ // Required
  89. aws.String("SubnetId"), // Required
  90. // More values...
  91. },
  92. Scheme: aws.String("LoadBalancerSchemeEnum"),
  93. SecurityGroups: []*string{
  94. aws.String("SecurityGroupId"), // Required
  95. // More values...
  96. },
  97. Tags: []*elbv2.Tag{
  98. { // Required
  99. Key: aws.String("TagKey"), // Required
  100. Value: aws.String("TagValue"),
  101. },
  102. // More values...
  103. },
  104. }
  105. resp, err := svc.CreateLoadBalancer(params)
  106. if err != nil {
  107. // Print the error, cast err to awserr.Error to get the Code and
  108. // Message from an error.
  109. fmt.Println(err.Error())
  110. return
  111. }
  112. // Pretty-print the response data.
  113. fmt.Println(resp)
  114. }
  115. func ExampleELBV2_CreateRule() {
  116. sess, err := session.NewSession()
  117. if err != nil {
  118. fmt.Println("failed to create session,", err)
  119. return
  120. }
  121. svc := elbv2.New(sess)
  122. params := &elbv2.CreateRuleInput{
  123. Actions: []*elbv2.Action{ // Required
  124. { // Required
  125. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  126. Type: aws.String("ActionTypeEnum"), // Required
  127. },
  128. // More values...
  129. },
  130. Conditions: []*elbv2.RuleCondition{ // Required
  131. { // Required
  132. Field: aws.String("ConditionFieldName"),
  133. Values: []*string{
  134. aws.String("StringValue"), // Required
  135. // More values...
  136. },
  137. },
  138. // More values...
  139. },
  140. ListenerArn: aws.String("ListenerArn"), // Required
  141. Priority: aws.Int64(1), // Required
  142. }
  143. resp, err := svc.CreateRule(params)
  144. if err != nil {
  145. // Print the error, cast err to awserr.Error to get the Code and
  146. // Message from an error.
  147. fmt.Println(err.Error())
  148. return
  149. }
  150. // Pretty-print the response data.
  151. fmt.Println(resp)
  152. }
  153. func ExampleELBV2_CreateTargetGroup() {
  154. sess, err := session.NewSession()
  155. if err != nil {
  156. fmt.Println("failed to create session,", err)
  157. return
  158. }
  159. svc := elbv2.New(sess)
  160. params := &elbv2.CreateTargetGroupInput{
  161. Name: aws.String("TargetGroupName"), // Required
  162. Port: aws.Int64(1), // Required
  163. Protocol: aws.String("ProtocolEnum"), // Required
  164. VpcId: aws.String("VpcId"), // Required
  165. HealthCheckIntervalSeconds: aws.Int64(1),
  166. HealthCheckPath: aws.String("Path"),
  167. HealthCheckPort: aws.String("HealthCheckPort"),
  168. HealthCheckProtocol: aws.String("ProtocolEnum"),
  169. HealthCheckTimeoutSeconds: aws.Int64(1),
  170. HealthyThresholdCount: aws.Int64(1),
  171. Matcher: &elbv2.Matcher{
  172. HttpCode: aws.String("HttpCode"), // Required
  173. },
  174. UnhealthyThresholdCount: aws.Int64(1),
  175. }
  176. resp, err := svc.CreateTargetGroup(params)
  177. if err != nil {
  178. // Print the error, cast err to awserr.Error to get the Code and
  179. // Message from an error.
  180. fmt.Println(err.Error())
  181. return
  182. }
  183. // Pretty-print the response data.
  184. fmt.Println(resp)
  185. }
  186. func ExampleELBV2_DeleteListener() {
  187. sess, err := session.NewSession()
  188. if err != nil {
  189. fmt.Println("failed to create session,", err)
  190. return
  191. }
  192. svc := elbv2.New(sess)
  193. params := &elbv2.DeleteListenerInput{
  194. ListenerArn: aws.String("ListenerArn"), // Required
  195. }
  196. resp, err := svc.DeleteListener(params)
  197. if err != nil {
  198. // Print the error, cast err to awserr.Error to get the Code and
  199. // Message from an error.
  200. fmt.Println(err.Error())
  201. return
  202. }
  203. // Pretty-print the response data.
  204. fmt.Println(resp)
  205. }
  206. func ExampleELBV2_DeleteLoadBalancer() {
  207. sess, err := session.NewSession()
  208. if err != nil {
  209. fmt.Println("failed to create session,", err)
  210. return
  211. }
  212. svc := elbv2.New(sess)
  213. params := &elbv2.DeleteLoadBalancerInput{
  214. LoadBalancerArn: aws.String("LoadBalancerArn"), // Required
  215. }
  216. resp, err := svc.DeleteLoadBalancer(params)
  217. if err != nil {
  218. // Print the error, cast err to awserr.Error to get the Code and
  219. // Message from an error.
  220. fmt.Println(err.Error())
  221. return
  222. }
  223. // Pretty-print the response data.
  224. fmt.Println(resp)
  225. }
  226. func ExampleELBV2_DeleteRule() {
  227. sess, err := session.NewSession()
  228. if err != nil {
  229. fmt.Println("failed to create session,", err)
  230. return
  231. }
  232. svc := elbv2.New(sess)
  233. params := &elbv2.DeleteRuleInput{
  234. RuleArn: aws.String("RuleArn"), // Required
  235. }
  236. resp, err := svc.DeleteRule(params)
  237. if err != nil {
  238. // Print the error, cast err to awserr.Error to get the Code and
  239. // Message from an error.
  240. fmt.Println(err.Error())
  241. return
  242. }
  243. // Pretty-print the response data.
  244. fmt.Println(resp)
  245. }
  246. func ExampleELBV2_DeleteTargetGroup() {
  247. sess, err := session.NewSession()
  248. if err != nil {
  249. fmt.Println("failed to create session,", err)
  250. return
  251. }
  252. svc := elbv2.New(sess)
  253. params := &elbv2.DeleteTargetGroupInput{
  254. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  255. }
  256. resp, err := svc.DeleteTargetGroup(params)
  257. if err != nil {
  258. // Print the error, cast err to awserr.Error to get the Code and
  259. // Message from an error.
  260. fmt.Println(err.Error())
  261. return
  262. }
  263. // Pretty-print the response data.
  264. fmt.Println(resp)
  265. }
  266. func ExampleELBV2_DeregisterTargets() {
  267. sess, err := session.NewSession()
  268. if err != nil {
  269. fmt.Println("failed to create session,", err)
  270. return
  271. }
  272. svc := elbv2.New(sess)
  273. params := &elbv2.DeregisterTargetsInput{
  274. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  275. Targets: []*elbv2.TargetDescription{ // Required
  276. { // Required
  277. Id: aws.String("TargetId"), // Required
  278. Port: aws.Int64(1),
  279. },
  280. // More values...
  281. },
  282. }
  283. resp, err := svc.DeregisterTargets(params)
  284. if err != nil {
  285. // Print the error, cast err to awserr.Error to get the Code and
  286. // Message from an error.
  287. fmt.Println(err.Error())
  288. return
  289. }
  290. // Pretty-print the response data.
  291. fmt.Println(resp)
  292. }
  293. func ExampleELBV2_DescribeListeners() {
  294. sess, err := session.NewSession()
  295. if err != nil {
  296. fmt.Println("failed to create session,", err)
  297. return
  298. }
  299. svc := elbv2.New(sess)
  300. params := &elbv2.DescribeListenersInput{
  301. ListenerArns: []*string{
  302. aws.String("ListenerArn"), // Required
  303. // More values...
  304. },
  305. LoadBalancerArn: aws.String("LoadBalancerArn"),
  306. Marker: aws.String("Marker"),
  307. PageSize: aws.Int64(1),
  308. }
  309. resp, err := svc.DescribeListeners(params)
  310. if err != nil {
  311. // Print the error, cast err to awserr.Error to get the Code and
  312. // Message from an error.
  313. fmt.Println(err.Error())
  314. return
  315. }
  316. // Pretty-print the response data.
  317. fmt.Println(resp)
  318. }
  319. func ExampleELBV2_DescribeLoadBalancerAttributes() {
  320. sess, err := session.NewSession()
  321. if err != nil {
  322. fmt.Println("failed to create session,", err)
  323. return
  324. }
  325. svc := elbv2.New(sess)
  326. params := &elbv2.DescribeLoadBalancerAttributesInput{
  327. LoadBalancerArn: aws.String("LoadBalancerArn"), // Required
  328. }
  329. resp, err := svc.DescribeLoadBalancerAttributes(params)
  330. if err != nil {
  331. // Print the error, cast err to awserr.Error to get the Code and
  332. // Message from an error.
  333. fmt.Println(err.Error())
  334. return
  335. }
  336. // Pretty-print the response data.
  337. fmt.Println(resp)
  338. }
  339. func ExampleELBV2_DescribeLoadBalancers() {
  340. sess, err := session.NewSession()
  341. if err != nil {
  342. fmt.Println("failed to create session,", err)
  343. return
  344. }
  345. svc := elbv2.New(sess)
  346. params := &elbv2.DescribeLoadBalancersInput{
  347. LoadBalancerArns: []*string{
  348. aws.String("LoadBalancerArn"), // Required
  349. // More values...
  350. },
  351. Marker: aws.String("Marker"),
  352. Names: []*string{
  353. aws.String("LoadBalancerName"), // Required
  354. // More values...
  355. },
  356. PageSize: aws.Int64(1),
  357. }
  358. resp, err := svc.DescribeLoadBalancers(params)
  359. if err != nil {
  360. // Print the error, cast err to awserr.Error to get the Code and
  361. // Message from an error.
  362. fmt.Println(err.Error())
  363. return
  364. }
  365. // Pretty-print the response data.
  366. fmt.Println(resp)
  367. }
  368. func ExampleELBV2_DescribeRules() {
  369. sess, err := session.NewSession()
  370. if err != nil {
  371. fmt.Println("failed to create session,", err)
  372. return
  373. }
  374. svc := elbv2.New(sess)
  375. params := &elbv2.DescribeRulesInput{
  376. ListenerArn: aws.String("ListenerArn"),
  377. RuleArns: []*string{
  378. aws.String("RuleArn"), // Required
  379. // More values...
  380. },
  381. }
  382. resp, err := svc.DescribeRules(params)
  383. if err != nil {
  384. // Print the error, cast err to awserr.Error to get the Code and
  385. // Message from an error.
  386. fmt.Println(err.Error())
  387. return
  388. }
  389. // Pretty-print the response data.
  390. fmt.Println(resp)
  391. }
  392. func ExampleELBV2_DescribeSSLPolicies() {
  393. sess, err := session.NewSession()
  394. if err != nil {
  395. fmt.Println("failed to create session,", err)
  396. return
  397. }
  398. svc := elbv2.New(sess)
  399. params := &elbv2.DescribeSSLPoliciesInput{
  400. Marker: aws.String("Marker"),
  401. Names: []*string{
  402. aws.String("SslPolicyName"), // Required
  403. // More values...
  404. },
  405. PageSize: aws.Int64(1),
  406. }
  407. resp, err := svc.DescribeSSLPolicies(params)
  408. if err != nil {
  409. // Print the error, cast err to awserr.Error to get the Code and
  410. // Message from an error.
  411. fmt.Println(err.Error())
  412. return
  413. }
  414. // Pretty-print the response data.
  415. fmt.Println(resp)
  416. }
  417. func ExampleELBV2_DescribeTags() {
  418. sess, err := session.NewSession()
  419. if err != nil {
  420. fmt.Println("failed to create session,", err)
  421. return
  422. }
  423. svc := elbv2.New(sess)
  424. params := &elbv2.DescribeTagsInput{
  425. ResourceArns: []*string{ // Required
  426. aws.String("ResourceArn"), // Required
  427. // More values...
  428. },
  429. }
  430. resp, err := svc.DescribeTags(params)
  431. if err != nil {
  432. // Print the error, cast err to awserr.Error to get the Code and
  433. // Message from an error.
  434. fmt.Println(err.Error())
  435. return
  436. }
  437. // Pretty-print the response data.
  438. fmt.Println(resp)
  439. }
  440. func ExampleELBV2_DescribeTargetGroupAttributes() {
  441. sess, err := session.NewSession()
  442. if err != nil {
  443. fmt.Println("failed to create session,", err)
  444. return
  445. }
  446. svc := elbv2.New(sess)
  447. params := &elbv2.DescribeTargetGroupAttributesInput{
  448. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  449. }
  450. resp, err := svc.DescribeTargetGroupAttributes(params)
  451. if err != nil {
  452. // Print the error, cast err to awserr.Error to get the Code and
  453. // Message from an error.
  454. fmt.Println(err.Error())
  455. return
  456. }
  457. // Pretty-print the response data.
  458. fmt.Println(resp)
  459. }
  460. func ExampleELBV2_DescribeTargetGroups() {
  461. sess, err := session.NewSession()
  462. if err != nil {
  463. fmt.Println("failed to create session,", err)
  464. return
  465. }
  466. svc := elbv2.New(sess)
  467. params := &elbv2.DescribeTargetGroupsInput{
  468. LoadBalancerArn: aws.String("LoadBalancerArn"),
  469. Marker: aws.String("Marker"),
  470. Names: []*string{
  471. aws.String("TargetGroupName"), // Required
  472. // More values...
  473. },
  474. PageSize: aws.Int64(1),
  475. TargetGroupArns: []*string{
  476. aws.String("TargetGroupArn"), // Required
  477. // More values...
  478. },
  479. }
  480. resp, err := svc.DescribeTargetGroups(params)
  481. if err != nil {
  482. // Print the error, cast err to awserr.Error to get the Code and
  483. // Message from an error.
  484. fmt.Println(err.Error())
  485. return
  486. }
  487. // Pretty-print the response data.
  488. fmt.Println(resp)
  489. }
  490. func ExampleELBV2_DescribeTargetHealth() {
  491. sess, err := session.NewSession()
  492. if err != nil {
  493. fmt.Println("failed to create session,", err)
  494. return
  495. }
  496. svc := elbv2.New(sess)
  497. params := &elbv2.DescribeTargetHealthInput{
  498. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  499. Targets: []*elbv2.TargetDescription{
  500. { // Required
  501. Id: aws.String("TargetId"), // Required
  502. Port: aws.Int64(1),
  503. },
  504. // More values...
  505. },
  506. }
  507. resp, err := svc.DescribeTargetHealth(params)
  508. if err != nil {
  509. // Print the error, cast err to awserr.Error to get the Code and
  510. // Message from an error.
  511. fmt.Println(err.Error())
  512. return
  513. }
  514. // Pretty-print the response data.
  515. fmt.Println(resp)
  516. }
  517. func ExampleELBV2_ModifyListener() {
  518. sess, err := session.NewSession()
  519. if err != nil {
  520. fmt.Println("failed to create session,", err)
  521. return
  522. }
  523. svc := elbv2.New(sess)
  524. params := &elbv2.ModifyListenerInput{
  525. ListenerArn: aws.String("ListenerArn"), // Required
  526. Certificates: []*elbv2.Certificate{
  527. { // Required
  528. CertificateArn: aws.String("CertificateArn"),
  529. },
  530. // More values...
  531. },
  532. DefaultActions: []*elbv2.Action{
  533. { // Required
  534. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  535. Type: aws.String("ActionTypeEnum"), // Required
  536. },
  537. // More values...
  538. },
  539. Port: aws.Int64(1),
  540. Protocol: aws.String("ProtocolEnum"),
  541. SslPolicy: aws.String("SslPolicyName"),
  542. }
  543. resp, err := svc.ModifyListener(params)
  544. if err != nil {
  545. // Print the error, cast err to awserr.Error to get the Code and
  546. // Message from an error.
  547. fmt.Println(err.Error())
  548. return
  549. }
  550. // Pretty-print the response data.
  551. fmt.Println(resp)
  552. }
  553. func ExampleELBV2_ModifyLoadBalancerAttributes() {
  554. sess, err := session.NewSession()
  555. if err != nil {
  556. fmt.Println("failed to create session,", err)
  557. return
  558. }
  559. svc := elbv2.New(sess)
  560. params := &elbv2.ModifyLoadBalancerAttributesInput{
  561. Attributes: []*elbv2.LoadBalancerAttribute{ // Required
  562. { // Required
  563. Key: aws.String("LoadBalancerAttributeKey"),
  564. Value: aws.String("LoadBalancerAttributeValue"),
  565. },
  566. // More values...
  567. },
  568. LoadBalancerArn: aws.String("LoadBalancerArn"), // Required
  569. }
  570. resp, err := svc.ModifyLoadBalancerAttributes(params)
  571. if err != nil {
  572. // Print the error, cast err to awserr.Error to get the Code and
  573. // Message from an error.
  574. fmt.Println(err.Error())
  575. return
  576. }
  577. // Pretty-print the response data.
  578. fmt.Println(resp)
  579. }
  580. func ExampleELBV2_ModifyRule() {
  581. sess, err := session.NewSession()
  582. if err != nil {
  583. fmt.Println("failed to create session,", err)
  584. return
  585. }
  586. svc := elbv2.New(sess)
  587. params := &elbv2.ModifyRuleInput{
  588. RuleArn: aws.String("RuleArn"), // Required
  589. Actions: []*elbv2.Action{
  590. { // Required
  591. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  592. Type: aws.String("ActionTypeEnum"), // Required
  593. },
  594. // More values...
  595. },
  596. Conditions: []*elbv2.RuleCondition{
  597. { // Required
  598. Field: aws.String("ConditionFieldName"),
  599. Values: []*string{
  600. aws.String("StringValue"), // Required
  601. // More values...
  602. },
  603. },
  604. // More values...
  605. },
  606. }
  607. resp, err := svc.ModifyRule(params)
  608. if err != nil {
  609. // Print the error, cast err to awserr.Error to get the Code and
  610. // Message from an error.
  611. fmt.Println(err.Error())
  612. return
  613. }
  614. // Pretty-print the response data.
  615. fmt.Println(resp)
  616. }
  617. func ExampleELBV2_ModifyTargetGroup() {
  618. sess, err := session.NewSession()
  619. if err != nil {
  620. fmt.Println("failed to create session,", err)
  621. return
  622. }
  623. svc := elbv2.New(sess)
  624. params := &elbv2.ModifyTargetGroupInput{
  625. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  626. HealthCheckIntervalSeconds: aws.Int64(1),
  627. HealthCheckPath: aws.String("Path"),
  628. HealthCheckPort: aws.String("HealthCheckPort"),
  629. HealthCheckProtocol: aws.String("ProtocolEnum"),
  630. HealthCheckTimeoutSeconds: aws.Int64(1),
  631. HealthyThresholdCount: aws.Int64(1),
  632. Matcher: &elbv2.Matcher{
  633. HttpCode: aws.String("HttpCode"), // Required
  634. },
  635. UnhealthyThresholdCount: aws.Int64(1),
  636. }
  637. resp, err := svc.ModifyTargetGroup(params)
  638. if err != nil {
  639. // Print the error, cast err to awserr.Error to get the Code and
  640. // Message from an error.
  641. fmt.Println(err.Error())
  642. return
  643. }
  644. // Pretty-print the response data.
  645. fmt.Println(resp)
  646. }
  647. func ExampleELBV2_ModifyTargetGroupAttributes() {
  648. sess, err := session.NewSession()
  649. if err != nil {
  650. fmt.Println("failed to create session,", err)
  651. return
  652. }
  653. svc := elbv2.New(sess)
  654. params := &elbv2.ModifyTargetGroupAttributesInput{
  655. Attributes: []*elbv2.TargetGroupAttribute{ // Required
  656. { // Required
  657. Key: aws.String("TargetGroupAttributeKey"),
  658. Value: aws.String("TargetGroupAttributeValue"),
  659. },
  660. // More values...
  661. },
  662. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  663. }
  664. resp, err := svc.ModifyTargetGroupAttributes(params)
  665. if err != nil {
  666. // Print the error, cast err to awserr.Error to get the Code and
  667. // Message from an error.
  668. fmt.Println(err.Error())
  669. return
  670. }
  671. // Pretty-print the response data.
  672. fmt.Println(resp)
  673. }
  674. func ExampleELBV2_RegisterTargets() {
  675. sess, err := session.NewSession()
  676. if err != nil {
  677. fmt.Println("failed to create session,", err)
  678. return
  679. }
  680. svc := elbv2.New(sess)
  681. params := &elbv2.RegisterTargetsInput{
  682. TargetGroupArn: aws.String("TargetGroupArn"), // Required
  683. Targets: []*elbv2.TargetDescription{ // Required
  684. { // Required
  685. Id: aws.String("TargetId"), // Required
  686. Port: aws.Int64(1),
  687. },
  688. // More values...
  689. },
  690. }
  691. resp, err := svc.RegisterTargets(params)
  692. if err != nil {
  693. // Print the error, cast err to awserr.Error to get the Code and
  694. // Message from an error.
  695. fmt.Println(err.Error())
  696. return
  697. }
  698. // Pretty-print the response data.
  699. fmt.Println(resp)
  700. }
  701. func ExampleELBV2_RemoveTags() {
  702. sess, err := session.NewSession()
  703. if err != nil {
  704. fmt.Println("failed to create session,", err)
  705. return
  706. }
  707. svc := elbv2.New(sess)
  708. params := &elbv2.RemoveTagsInput{
  709. ResourceArns: []*string{ // Required
  710. aws.String("ResourceArn"), // Required
  711. // More values...
  712. },
  713. TagKeys: []*string{ // Required
  714. aws.String("TagKey"), // Required
  715. // More values...
  716. },
  717. }
  718. resp, err := svc.RemoveTags(params)
  719. if err != nil {
  720. // Print the error, cast err to awserr.Error to get the Code and
  721. // Message from an error.
  722. fmt.Println(err.Error())
  723. return
  724. }
  725. // Pretty-print the response data.
  726. fmt.Println(resp)
  727. }
  728. func ExampleELBV2_SetRulePriorities() {
  729. sess, err := session.NewSession()
  730. if err != nil {
  731. fmt.Println("failed to create session,", err)
  732. return
  733. }
  734. svc := elbv2.New(sess)
  735. params := &elbv2.SetRulePrioritiesInput{
  736. RulePriorities: []*elbv2.RulePriorityPair{ // Required
  737. { // Required
  738. Priority: aws.Int64(1),
  739. RuleArn: aws.String("RuleArn"),
  740. },
  741. // More values...
  742. },
  743. }
  744. resp, err := svc.SetRulePriorities(params)
  745. if err != nil {
  746. // Print the error, cast err to awserr.Error to get the Code and
  747. // Message from an error.
  748. fmt.Println(err.Error())
  749. return
  750. }
  751. // Pretty-print the response data.
  752. fmt.Println(resp)
  753. }
  754. func ExampleELBV2_SetSecurityGroups() {
  755. sess, err := session.NewSession()
  756. if err != nil {
  757. fmt.Println("failed to create session,", err)
  758. return
  759. }
  760. svc := elbv2.New(sess)
  761. params := &elbv2.SetSecurityGroupsInput{
  762. LoadBalancerArn: aws.String("LoadBalancerArn"), // Required
  763. SecurityGroups: []*string{ // Required
  764. aws.String("SecurityGroupId"), // Required
  765. // More values...
  766. },
  767. }
  768. resp, err := svc.SetSecurityGroups(params)
  769. if err != nil {
  770. // Print the error, cast err to awserr.Error to get the Code and
  771. // Message from an error.
  772. fmt.Println(err.Error())
  773. return
  774. }
  775. // Pretty-print the response data.
  776. fmt.Println(resp)
  777. }
  778. func ExampleELBV2_SetSubnets() {
  779. sess, err := session.NewSession()
  780. if err != nil {
  781. fmt.Println("failed to create session,", err)
  782. return
  783. }
  784. svc := elbv2.New(sess)
  785. params := &elbv2.SetSubnetsInput{
  786. LoadBalancerArn: aws.String("LoadBalancerArn"), // Required
  787. Subnets: []*string{ // Required
  788. aws.String("SubnetId"), // Required
  789. // More values...
  790. },
  791. }
  792. resp, err := svc.SetSubnets(params)
  793. if err != nil {
  794. // Print the error, cast err to awserr.Error to get the Code and
  795. // Message from an error.
  796. fmt.Println(err.Error())
  797. return
  798. }
  799. // Pretty-print the response data.
  800. fmt.Println(resp)
  801. }