examples_test.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package elb_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/service/elb"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleELB_AddTags() {
  13. svc := elb.New(nil)
  14. params := &elb.AddTagsInput{
  15. LoadBalancerNames: []*string{ // Required
  16. aws.String("AccessPointName"), // Required
  17. // More values...
  18. },
  19. Tags: []*elb.Tag{ // Required
  20. { // Required
  21. Key: aws.String("TagKey"), // Required
  22. Value: aws.String("TagValue"),
  23. },
  24. // More values...
  25. },
  26. }
  27. resp, err := svc.AddTags(params)
  28. if err != nil {
  29. // Print the error, cast err to awserr.Error to get the Code and
  30. // Message from an error.
  31. fmt.Println(err.Error())
  32. return
  33. }
  34. // Pretty-print the response data.
  35. fmt.Println(resp)
  36. }
  37. func ExampleELB_ApplySecurityGroupsToLoadBalancer() {
  38. svc := elb.New(nil)
  39. params := &elb.ApplySecurityGroupsToLoadBalancerInput{
  40. LoadBalancerName: aws.String("AccessPointName"), // Required
  41. SecurityGroups: []*string{ // Required
  42. aws.String("SecurityGroupId"), // Required
  43. // More values...
  44. },
  45. }
  46. resp, err := svc.ApplySecurityGroupsToLoadBalancer(params)
  47. if err != nil {
  48. // Print the error, cast err to awserr.Error to get the Code and
  49. // Message from an error.
  50. fmt.Println(err.Error())
  51. return
  52. }
  53. // Pretty-print the response data.
  54. fmt.Println(resp)
  55. }
  56. func ExampleELB_AttachLoadBalancerToSubnets() {
  57. svc := elb.New(nil)
  58. params := &elb.AttachLoadBalancerToSubnetsInput{
  59. LoadBalancerName: aws.String("AccessPointName"), // Required
  60. Subnets: []*string{ // Required
  61. aws.String("SubnetId"), // Required
  62. // More values...
  63. },
  64. }
  65. resp, err := svc.AttachLoadBalancerToSubnets(params)
  66. if err != nil {
  67. // Print the error, cast err to awserr.Error to get the Code and
  68. // Message from an error.
  69. fmt.Println(err.Error())
  70. return
  71. }
  72. // Pretty-print the response data.
  73. fmt.Println(resp)
  74. }
  75. func ExampleELB_ConfigureHealthCheck() {
  76. svc := elb.New(nil)
  77. params := &elb.ConfigureHealthCheckInput{
  78. HealthCheck: &elb.HealthCheck{ // Required
  79. HealthyThreshold: aws.Int64(1), // Required
  80. Interval: aws.Int64(1), // Required
  81. Target: aws.String("HealthCheckTarget"), // Required
  82. Timeout: aws.Int64(1), // Required
  83. UnhealthyThreshold: aws.Int64(1), // Required
  84. },
  85. LoadBalancerName: aws.String("AccessPointName"), // Required
  86. }
  87. resp, err := svc.ConfigureHealthCheck(params)
  88. if err != nil {
  89. // Print the error, cast err to awserr.Error to get the Code and
  90. // Message from an error.
  91. fmt.Println(err.Error())
  92. return
  93. }
  94. // Pretty-print the response data.
  95. fmt.Println(resp)
  96. }
  97. func ExampleELB_CreateAppCookieStickinessPolicy() {
  98. svc := elb.New(nil)
  99. params := &elb.CreateAppCookieStickinessPolicyInput{
  100. CookieName: aws.String("CookieName"), // Required
  101. LoadBalancerName: aws.String("AccessPointName"), // Required
  102. PolicyName: aws.String("PolicyName"), // Required
  103. }
  104. resp, err := svc.CreateAppCookieStickinessPolicy(params)
  105. if err != nil {
  106. // Print the error, cast err to awserr.Error to get the Code and
  107. // Message from an error.
  108. fmt.Println(err.Error())
  109. return
  110. }
  111. // Pretty-print the response data.
  112. fmt.Println(resp)
  113. }
  114. func ExampleELB_CreateLBCookieStickinessPolicy() {
  115. svc := elb.New(nil)
  116. params := &elb.CreateLBCookieStickinessPolicyInput{
  117. LoadBalancerName: aws.String("AccessPointName"), // Required
  118. PolicyName: aws.String("PolicyName"), // Required
  119. CookieExpirationPeriod: aws.Int64(1),
  120. }
  121. resp, err := svc.CreateLBCookieStickinessPolicy(params)
  122. if err != nil {
  123. // Print the error, cast err to awserr.Error to get the Code and
  124. // Message from an error.
  125. fmt.Println(err.Error())
  126. return
  127. }
  128. // Pretty-print the response data.
  129. fmt.Println(resp)
  130. }
  131. func ExampleELB_CreateLoadBalancer() {
  132. svc := elb.New(nil)
  133. params := &elb.CreateLoadBalancerInput{
  134. Listeners: []*elb.Listener{ // Required
  135. { // Required
  136. InstancePort: aws.Int64(1), // Required
  137. LoadBalancerPort: aws.Int64(1), // Required
  138. Protocol: aws.String("Protocol"), // Required
  139. InstanceProtocol: aws.String("Protocol"),
  140. SSLCertificateId: aws.String("SSLCertificateId"),
  141. },
  142. // More values...
  143. },
  144. LoadBalancerName: aws.String("AccessPointName"), // Required
  145. AvailabilityZones: []*string{
  146. aws.String("AvailabilityZone"), // Required
  147. // More values...
  148. },
  149. Scheme: aws.String("LoadBalancerScheme"),
  150. SecurityGroups: []*string{
  151. aws.String("SecurityGroupId"), // Required
  152. // More values...
  153. },
  154. Subnets: []*string{
  155. aws.String("SubnetId"), // Required
  156. // More values...
  157. },
  158. Tags: []*elb.Tag{
  159. { // Required
  160. Key: aws.String("TagKey"), // Required
  161. Value: aws.String("TagValue"),
  162. },
  163. // More values...
  164. },
  165. }
  166. resp, err := svc.CreateLoadBalancer(params)
  167. if err != nil {
  168. // Print the error, cast err to awserr.Error to get the Code and
  169. // Message from an error.
  170. fmt.Println(err.Error())
  171. return
  172. }
  173. // Pretty-print the response data.
  174. fmt.Println(resp)
  175. }
  176. func ExampleELB_CreateLoadBalancerListeners() {
  177. svc := elb.New(nil)
  178. params := &elb.CreateLoadBalancerListenersInput{
  179. Listeners: []*elb.Listener{ // Required
  180. { // Required
  181. InstancePort: aws.Int64(1), // Required
  182. LoadBalancerPort: aws.Int64(1), // Required
  183. Protocol: aws.String("Protocol"), // Required
  184. InstanceProtocol: aws.String("Protocol"),
  185. SSLCertificateId: aws.String("SSLCertificateId"),
  186. },
  187. // More values...
  188. },
  189. LoadBalancerName: aws.String("AccessPointName"), // Required
  190. }
  191. resp, err := svc.CreateLoadBalancerListeners(params)
  192. if err != nil {
  193. // Print the error, cast err to awserr.Error to get the Code and
  194. // Message from an error.
  195. fmt.Println(err.Error())
  196. return
  197. }
  198. // Pretty-print the response data.
  199. fmt.Println(resp)
  200. }
  201. func ExampleELB_CreateLoadBalancerPolicy() {
  202. svc := elb.New(nil)
  203. params := &elb.CreateLoadBalancerPolicyInput{
  204. LoadBalancerName: aws.String("AccessPointName"), // Required
  205. PolicyName: aws.String("PolicyName"), // Required
  206. PolicyTypeName: aws.String("PolicyTypeName"), // Required
  207. PolicyAttributes: []*elb.PolicyAttribute{
  208. { // Required
  209. AttributeName: aws.String("AttributeName"),
  210. AttributeValue: aws.String("AttributeValue"),
  211. },
  212. // More values...
  213. },
  214. }
  215. resp, err := svc.CreateLoadBalancerPolicy(params)
  216. if err != nil {
  217. // Print the error, cast err to awserr.Error to get the Code and
  218. // Message from an error.
  219. fmt.Println(err.Error())
  220. return
  221. }
  222. // Pretty-print the response data.
  223. fmt.Println(resp)
  224. }
  225. func ExampleELB_DeleteLoadBalancer() {
  226. svc := elb.New(nil)
  227. params := &elb.DeleteLoadBalancerInput{
  228. LoadBalancerName: aws.String("AccessPointName"), // Required
  229. }
  230. resp, err := svc.DeleteLoadBalancer(params)
  231. if err != nil {
  232. // Print the error, cast err to awserr.Error to get the Code and
  233. // Message from an error.
  234. fmt.Println(err.Error())
  235. return
  236. }
  237. // Pretty-print the response data.
  238. fmt.Println(resp)
  239. }
  240. func ExampleELB_DeleteLoadBalancerListeners() {
  241. svc := elb.New(nil)
  242. params := &elb.DeleteLoadBalancerListenersInput{
  243. LoadBalancerName: aws.String("AccessPointName"), // Required
  244. LoadBalancerPorts: []*int64{ // Required
  245. aws.Int64(1), // Required
  246. // More values...
  247. },
  248. }
  249. resp, err := svc.DeleteLoadBalancerListeners(params)
  250. if err != nil {
  251. // Print the error, cast err to awserr.Error to get the Code and
  252. // Message from an error.
  253. fmt.Println(err.Error())
  254. return
  255. }
  256. // Pretty-print the response data.
  257. fmt.Println(resp)
  258. }
  259. func ExampleELB_DeleteLoadBalancerPolicy() {
  260. svc := elb.New(nil)
  261. params := &elb.DeleteLoadBalancerPolicyInput{
  262. LoadBalancerName: aws.String("AccessPointName"), // Required
  263. PolicyName: aws.String("PolicyName"), // Required
  264. }
  265. resp, err := svc.DeleteLoadBalancerPolicy(params)
  266. if err != nil {
  267. // Print the error, cast err to awserr.Error to get the Code and
  268. // Message from an error.
  269. fmt.Println(err.Error())
  270. return
  271. }
  272. // Pretty-print the response data.
  273. fmt.Println(resp)
  274. }
  275. func ExampleELB_DeregisterInstancesFromLoadBalancer() {
  276. svc := elb.New(nil)
  277. params := &elb.DeregisterInstancesFromLoadBalancerInput{
  278. Instances: []*elb.Instance{ // Required
  279. { // Required
  280. InstanceId: aws.String("InstanceId"),
  281. },
  282. // More values...
  283. },
  284. LoadBalancerName: aws.String("AccessPointName"), // Required
  285. }
  286. resp, err := svc.DeregisterInstancesFromLoadBalancer(params)
  287. if err != nil {
  288. // Print the error, cast err to awserr.Error to get the Code and
  289. // Message from an error.
  290. fmt.Println(err.Error())
  291. return
  292. }
  293. // Pretty-print the response data.
  294. fmt.Println(resp)
  295. }
  296. func ExampleELB_DescribeInstanceHealth() {
  297. svc := elb.New(nil)
  298. params := &elb.DescribeInstanceHealthInput{
  299. LoadBalancerName: aws.String("AccessPointName"), // Required
  300. Instances: []*elb.Instance{
  301. { // Required
  302. InstanceId: aws.String("InstanceId"),
  303. },
  304. // More values...
  305. },
  306. }
  307. resp, err := svc.DescribeInstanceHealth(params)
  308. if err != nil {
  309. // Print the error, cast err to awserr.Error to get the Code and
  310. // Message from an error.
  311. fmt.Println(err.Error())
  312. return
  313. }
  314. // Pretty-print the response data.
  315. fmt.Println(resp)
  316. }
  317. func ExampleELB_DescribeLoadBalancerAttributes() {
  318. svc := elb.New(nil)
  319. params := &elb.DescribeLoadBalancerAttributesInput{
  320. LoadBalancerName: aws.String("AccessPointName"), // Required
  321. }
  322. resp, err := svc.DescribeLoadBalancerAttributes(params)
  323. if err != nil {
  324. // Print the error, cast err to awserr.Error to get the Code and
  325. // Message from an error.
  326. fmt.Println(err.Error())
  327. return
  328. }
  329. // Pretty-print the response data.
  330. fmt.Println(resp)
  331. }
  332. func ExampleELB_DescribeLoadBalancerPolicies() {
  333. svc := elb.New(nil)
  334. params := &elb.DescribeLoadBalancerPoliciesInput{
  335. LoadBalancerName: aws.String("AccessPointName"),
  336. PolicyNames: []*string{
  337. aws.String("PolicyName"), // Required
  338. // More values...
  339. },
  340. }
  341. resp, err := svc.DescribeLoadBalancerPolicies(params)
  342. if err != nil {
  343. // Print the error, cast err to awserr.Error to get the Code and
  344. // Message from an error.
  345. fmt.Println(err.Error())
  346. return
  347. }
  348. // Pretty-print the response data.
  349. fmt.Println(resp)
  350. }
  351. func ExampleELB_DescribeLoadBalancerPolicyTypes() {
  352. svc := elb.New(nil)
  353. params := &elb.DescribeLoadBalancerPolicyTypesInput{
  354. PolicyTypeNames: []*string{
  355. aws.String("PolicyTypeName"), // Required
  356. // More values...
  357. },
  358. }
  359. resp, err := svc.DescribeLoadBalancerPolicyTypes(params)
  360. if err != nil {
  361. // Print the error, cast err to awserr.Error to get the Code and
  362. // Message from an error.
  363. fmt.Println(err.Error())
  364. return
  365. }
  366. // Pretty-print the response data.
  367. fmt.Println(resp)
  368. }
  369. func ExampleELB_DescribeLoadBalancers() {
  370. svc := elb.New(nil)
  371. params := &elb.DescribeLoadBalancersInput{
  372. LoadBalancerNames: []*string{
  373. aws.String("AccessPointName"), // Required
  374. // More values...
  375. },
  376. Marker: aws.String("Marker"),
  377. PageSize: aws.Int64(1),
  378. }
  379. resp, err := svc.DescribeLoadBalancers(params)
  380. if err != nil {
  381. // Print the error, cast err to awserr.Error to get the Code and
  382. // Message from an error.
  383. fmt.Println(err.Error())
  384. return
  385. }
  386. // Pretty-print the response data.
  387. fmt.Println(resp)
  388. }
  389. func ExampleELB_DescribeTags() {
  390. svc := elb.New(nil)
  391. params := &elb.DescribeTagsInput{
  392. LoadBalancerNames: []*string{ // Required
  393. aws.String("AccessPointName"), // Required
  394. // More values...
  395. },
  396. }
  397. resp, err := svc.DescribeTags(params)
  398. if err != nil {
  399. // Print the error, cast err to awserr.Error to get the Code and
  400. // Message from an error.
  401. fmt.Println(err.Error())
  402. return
  403. }
  404. // Pretty-print the response data.
  405. fmt.Println(resp)
  406. }
  407. func ExampleELB_DetachLoadBalancerFromSubnets() {
  408. svc := elb.New(nil)
  409. params := &elb.DetachLoadBalancerFromSubnetsInput{
  410. LoadBalancerName: aws.String("AccessPointName"), // Required
  411. Subnets: []*string{ // Required
  412. aws.String("SubnetId"), // Required
  413. // More values...
  414. },
  415. }
  416. resp, err := svc.DetachLoadBalancerFromSubnets(params)
  417. if err != nil {
  418. // Print the error, cast err to awserr.Error to get the Code and
  419. // Message from an error.
  420. fmt.Println(err.Error())
  421. return
  422. }
  423. // Pretty-print the response data.
  424. fmt.Println(resp)
  425. }
  426. func ExampleELB_DisableAvailabilityZonesForLoadBalancer() {
  427. svc := elb.New(nil)
  428. params := &elb.DisableAvailabilityZonesForLoadBalancerInput{
  429. AvailabilityZones: []*string{ // Required
  430. aws.String("AvailabilityZone"), // Required
  431. // More values...
  432. },
  433. LoadBalancerName: aws.String("AccessPointName"), // Required
  434. }
  435. resp, err := svc.DisableAvailabilityZonesForLoadBalancer(params)
  436. if err != nil {
  437. // Print the error, cast err to awserr.Error to get the Code and
  438. // Message from an error.
  439. fmt.Println(err.Error())
  440. return
  441. }
  442. // Pretty-print the response data.
  443. fmt.Println(resp)
  444. }
  445. func ExampleELB_EnableAvailabilityZonesForLoadBalancer() {
  446. svc := elb.New(nil)
  447. params := &elb.EnableAvailabilityZonesForLoadBalancerInput{
  448. AvailabilityZones: []*string{ // Required
  449. aws.String("AvailabilityZone"), // Required
  450. // More values...
  451. },
  452. LoadBalancerName: aws.String("AccessPointName"), // Required
  453. }
  454. resp, err := svc.EnableAvailabilityZonesForLoadBalancer(params)
  455. if err != nil {
  456. // Print the error, cast err to awserr.Error to get the Code and
  457. // Message from an error.
  458. fmt.Println(err.Error())
  459. return
  460. }
  461. // Pretty-print the response data.
  462. fmt.Println(resp)
  463. }
  464. func ExampleELB_ModifyLoadBalancerAttributes() {
  465. svc := elb.New(nil)
  466. params := &elb.ModifyLoadBalancerAttributesInput{
  467. LoadBalancerAttributes: &elb.LoadBalancerAttributes{ // Required
  468. AccessLog: &elb.AccessLog{
  469. Enabled: aws.Bool(true), // Required
  470. EmitInterval: aws.Int64(1),
  471. S3BucketName: aws.String("S3BucketName"),
  472. S3BucketPrefix: aws.String("AccessLogPrefix"),
  473. },
  474. AdditionalAttributes: []*elb.AdditionalAttribute{
  475. { // Required
  476. Key: aws.String("StringVal"),
  477. Value: aws.String("StringVal"),
  478. },
  479. // More values...
  480. },
  481. ConnectionDraining: &elb.ConnectionDraining{
  482. Enabled: aws.Bool(true), // Required
  483. Timeout: aws.Int64(1),
  484. },
  485. ConnectionSettings: &elb.ConnectionSettings{
  486. IdleTimeout: aws.Int64(1), // Required
  487. },
  488. CrossZoneLoadBalancing: &elb.CrossZoneLoadBalancing{
  489. Enabled: aws.Bool(true), // Required
  490. },
  491. },
  492. LoadBalancerName: aws.String("AccessPointName"), // Required
  493. }
  494. resp, err := svc.ModifyLoadBalancerAttributes(params)
  495. if err != nil {
  496. // Print the error, cast err to awserr.Error to get the Code and
  497. // Message from an error.
  498. fmt.Println(err.Error())
  499. return
  500. }
  501. // Pretty-print the response data.
  502. fmt.Println(resp)
  503. }
  504. func ExampleELB_RegisterInstancesWithLoadBalancer() {
  505. svc := elb.New(nil)
  506. params := &elb.RegisterInstancesWithLoadBalancerInput{
  507. Instances: []*elb.Instance{ // Required
  508. { // Required
  509. InstanceId: aws.String("InstanceId"),
  510. },
  511. // More values...
  512. },
  513. LoadBalancerName: aws.String("AccessPointName"), // Required
  514. }
  515. resp, err := svc.RegisterInstancesWithLoadBalancer(params)
  516. if err != nil {
  517. // Print the error, cast err to awserr.Error to get the Code and
  518. // Message from an error.
  519. fmt.Println(err.Error())
  520. return
  521. }
  522. // Pretty-print the response data.
  523. fmt.Println(resp)
  524. }
  525. func ExampleELB_RemoveTags() {
  526. svc := elb.New(nil)
  527. params := &elb.RemoveTagsInput{
  528. LoadBalancerNames: []*string{ // Required
  529. aws.String("AccessPointName"), // Required
  530. // More values...
  531. },
  532. Tags: []*elb.TagKeyOnly{ // Required
  533. { // Required
  534. Key: aws.String("TagKey"),
  535. },
  536. // More values...
  537. },
  538. }
  539. resp, err := svc.RemoveTags(params)
  540. if err != nil {
  541. // Print the error, cast err to awserr.Error to get the Code and
  542. // Message from an error.
  543. fmt.Println(err.Error())
  544. return
  545. }
  546. // Pretty-print the response data.
  547. fmt.Println(resp)
  548. }
  549. func ExampleELB_SetLoadBalancerListenerSSLCertificate() {
  550. svc := elb.New(nil)
  551. params := &elb.SetLoadBalancerListenerSSLCertificateInput{
  552. LoadBalancerName: aws.String("AccessPointName"), // Required
  553. LoadBalancerPort: aws.Int64(1), // Required
  554. SSLCertificateId: aws.String("SSLCertificateId"), // Required
  555. }
  556. resp, err := svc.SetLoadBalancerListenerSSLCertificate(params)
  557. if err != nil {
  558. // Print the error, cast err to awserr.Error to get the Code and
  559. // Message from an error.
  560. fmt.Println(err.Error())
  561. return
  562. }
  563. // Pretty-print the response data.
  564. fmt.Println(resp)
  565. }
  566. func ExampleELB_SetLoadBalancerPoliciesForBackendServer() {
  567. svc := elb.New(nil)
  568. params := &elb.SetLoadBalancerPoliciesForBackendServerInput{
  569. InstancePort: aws.Int64(1), // Required
  570. LoadBalancerName: aws.String("AccessPointName"), // Required
  571. PolicyNames: []*string{ // Required
  572. aws.String("PolicyName"), // Required
  573. // More values...
  574. },
  575. }
  576. resp, err := svc.SetLoadBalancerPoliciesForBackendServer(params)
  577. if err != nil {
  578. // Print the error, cast err to awserr.Error to get the Code and
  579. // Message from an error.
  580. fmt.Println(err.Error())
  581. return
  582. }
  583. // Pretty-print the response data.
  584. fmt.Println(resp)
  585. }
  586. func ExampleELB_SetLoadBalancerPoliciesOfListener() {
  587. svc := elb.New(nil)
  588. params := &elb.SetLoadBalancerPoliciesOfListenerInput{
  589. LoadBalancerName: aws.String("AccessPointName"), // Required
  590. LoadBalancerPort: aws.Int64(1), // Required
  591. PolicyNames: []*string{ // Required
  592. aws.String("PolicyName"), // Required
  593. // More values...
  594. },
  595. }
  596. resp, err := svc.SetLoadBalancerPoliciesOfListener(params)
  597. if err != nil {
  598. // Print the error, cast err to awserr.Error to get the Code and
  599. // Message from an error.
  600. fmt.Println(err.Error())
  601. return
  602. }
  603. // Pretty-print the response data.
  604. fmt.Println(resp)
  605. }