examples_test.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package ecs_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/ecs"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleECS_CreateCluster() {
  13. svc := ecs.New(nil)
  14. params := &ecs.CreateClusterInput{
  15. ClusterName: aws.String("String"),
  16. }
  17. resp, err := svc.CreateCluster(params)
  18. if err != nil {
  19. // Print the error, cast err to awserr.Error to get the Code and
  20. // Message from an error.
  21. fmt.Println(err.Error())
  22. return
  23. }
  24. // Pretty-print the response data.
  25. fmt.Println(resp)
  26. }
  27. func ExampleECS_CreateService() {
  28. svc := ecs.New(nil)
  29. params := &ecs.CreateServiceInput{
  30. DesiredCount: aws.Int64(1), // Required
  31. ServiceName: aws.String("String"), // Required
  32. TaskDefinition: aws.String("String"), // Required
  33. ClientToken: aws.String("String"),
  34. Cluster: aws.String("String"),
  35. LoadBalancers: []*ecs.LoadBalancer{
  36. { // Required
  37. ContainerName: aws.String("String"),
  38. ContainerPort: aws.Int64(1),
  39. LoadBalancerName: aws.String("String"),
  40. },
  41. // More values...
  42. },
  43. Role: aws.String("String"),
  44. }
  45. resp, err := svc.CreateService(params)
  46. if err != nil {
  47. // Print the error, cast err to awserr.Error to get the Code and
  48. // Message from an error.
  49. fmt.Println(err.Error())
  50. return
  51. }
  52. // Pretty-print the response data.
  53. fmt.Println(resp)
  54. }
  55. func ExampleECS_DeleteCluster() {
  56. svc := ecs.New(nil)
  57. params := &ecs.DeleteClusterInput{
  58. Cluster: aws.String("String"), // Required
  59. }
  60. resp, err := svc.DeleteCluster(params)
  61. if err != nil {
  62. // Print the error, cast err to awserr.Error to get the Code and
  63. // Message from an error.
  64. fmt.Println(err.Error())
  65. return
  66. }
  67. // Pretty-print the response data.
  68. fmt.Println(resp)
  69. }
  70. func ExampleECS_DeleteService() {
  71. svc := ecs.New(nil)
  72. params := &ecs.DeleteServiceInput{
  73. Service: aws.String("String"), // Required
  74. Cluster: aws.String("String"),
  75. }
  76. resp, err := svc.DeleteService(params)
  77. if err != nil {
  78. // Print the error, cast err to awserr.Error to get the Code and
  79. // Message from an error.
  80. fmt.Println(err.Error())
  81. return
  82. }
  83. // Pretty-print the response data.
  84. fmt.Println(resp)
  85. }
  86. func ExampleECS_DeregisterContainerInstance() {
  87. svc := ecs.New(nil)
  88. params := &ecs.DeregisterContainerInstanceInput{
  89. ContainerInstance: aws.String("String"), // Required
  90. Cluster: aws.String("String"),
  91. Force: aws.Bool(true),
  92. }
  93. resp, err := svc.DeregisterContainerInstance(params)
  94. if err != nil {
  95. // Print the error, cast err to awserr.Error to get the Code and
  96. // Message from an error.
  97. fmt.Println(err.Error())
  98. return
  99. }
  100. // Pretty-print the response data.
  101. fmt.Println(resp)
  102. }
  103. func ExampleECS_DeregisterTaskDefinition() {
  104. svc := ecs.New(nil)
  105. params := &ecs.DeregisterTaskDefinitionInput{
  106. TaskDefinition: aws.String("String"), // Required
  107. }
  108. resp, err := svc.DeregisterTaskDefinition(params)
  109. if err != nil {
  110. // Print the error, cast err to awserr.Error to get the Code and
  111. // Message from an error.
  112. fmt.Println(err.Error())
  113. return
  114. }
  115. // Pretty-print the response data.
  116. fmt.Println(resp)
  117. }
  118. func ExampleECS_DescribeClusters() {
  119. svc := ecs.New(nil)
  120. params := &ecs.DescribeClustersInput{
  121. Clusters: []*string{
  122. aws.String("String"), // Required
  123. // More values...
  124. },
  125. }
  126. resp, err := svc.DescribeClusters(params)
  127. if err != nil {
  128. // Print the error, cast err to awserr.Error to get the Code and
  129. // Message from an error.
  130. fmt.Println(err.Error())
  131. return
  132. }
  133. // Pretty-print the response data.
  134. fmt.Println(resp)
  135. }
  136. func ExampleECS_DescribeContainerInstances() {
  137. svc := ecs.New(nil)
  138. params := &ecs.DescribeContainerInstancesInput{
  139. ContainerInstances: []*string{ // Required
  140. aws.String("String"), // Required
  141. // More values...
  142. },
  143. Cluster: aws.String("String"),
  144. }
  145. resp, err := svc.DescribeContainerInstances(params)
  146. if err != nil {
  147. // Print the error, cast err to awserr.Error to get the Code and
  148. // Message from an error.
  149. fmt.Println(err.Error())
  150. return
  151. }
  152. // Pretty-print the response data.
  153. fmt.Println(resp)
  154. }
  155. func ExampleECS_DescribeServices() {
  156. svc := ecs.New(nil)
  157. params := &ecs.DescribeServicesInput{
  158. Services: []*string{ // Required
  159. aws.String("String"), // Required
  160. // More values...
  161. },
  162. Cluster: aws.String("String"),
  163. }
  164. resp, err := svc.DescribeServices(params)
  165. if err != nil {
  166. // Print the error, cast err to awserr.Error to get the Code and
  167. // Message from an error.
  168. fmt.Println(err.Error())
  169. return
  170. }
  171. // Pretty-print the response data.
  172. fmt.Println(resp)
  173. }
  174. func ExampleECS_DescribeTaskDefinition() {
  175. svc := ecs.New(nil)
  176. params := &ecs.DescribeTaskDefinitionInput{
  177. TaskDefinition: aws.String("String"), // Required
  178. }
  179. resp, err := svc.DescribeTaskDefinition(params)
  180. if err != nil {
  181. // Print the error, cast err to awserr.Error to get the Code and
  182. // Message from an error.
  183. fmt.Println(err.Error())
  184. return
  185. }
  186. // Pretty-print the response data.
  187. fmt.Println(resp)
  188. }
  189. func ExampleECS_DescribeTasks() {
  190. svc := ecs.New(nil)
  191. params := &ecs.DescribeTasksInput{
  192. Tasks: []*string{ // Required
  193. aws.String("String"), // Required
  194. // More values...
  195. },
  196. Cluster: aws.String("String"),
  197. }
  198. resp, err := svc.DescribeTasks(params)
  199. if err != nil {
  200. // Print the error, cast err to awserr.Error to get the Code and
  201. // Message from an error.
  202. fmt.Println(err.Error())
  203. return
  204. }
  205. // Pretty-print the response data.
  206. fmt.Println(resp)
  207. }
  208. func ExampleECS_DiscoverPollEndpoint() {
  209. svc := ecs.New(nil)
  210. params := &ecs.DiscoverPollEndpointInput{
  211. Cluster: aws.String("String"),
  212. ContainerInstance: aws.String("String"),
  213. }
  214. resp, err := svc.DiscoverPollEndpoint(params)
  215. if err != nil {
  216. // Print the error, cast err to awserr.Error to get the Code and
  217. // Message from an error.
  218. fmt.Println(err.Error())
  219. return
  220. }
  221. // Pretty-print the response data.
  222. fmt.Println(resp)
  223. }
  224. func ExampleECS_ListClusters() {
  225. svc := ecs.New(nil)
  226. params := &ecs.ListClustersInput{
  227. MaxResults: aws.Int64(1),
  228. NextToken: aws.String("String"),
  229. }
  230. resp, err := svc.ListClusters(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 ExampleECS_ListContainerInstances() {
  241. svc := ecs.New(nil)
  242. params := &ecs.ListContainerInstancesInput{
  243. Cluster: aws.String("String"),
  244. MaxResults: aws.Int64(1),
  245. NextToken: aws.String("String"),
  246. }
  247. resp, err := svc.ListContainerInstances(params)
  248. if err != nil {
  249. // Print the error, cast err to awserr.Error to get the Code and
  250. // Message from an error.
  251. fmt.Println(err.Error())
  252. return
  253. }
  254. // Pretty-print the response data.
  255. fmt.Println(resp)
  256. }
  257. func ExampleECS_ListServices() {
  258. svc := ecs.New(nil)
  259. params := &ecs.ListServicesInput{
  260. Cluster: aws.String("String"),
  261. MaxResults: aws.Int64(1),
  262. NextToken: aws.String("String"),
  263. }
  264. resp, err := svc.ListServices(params)
  265. if err != nil {
  266. // Print the error, cast err to awserr.Error to get the Code and
  267. // Message from an error.
  268. fmt.Println(err.Error())
  269. return
  270. }
  271. // Pretty-print the response data.
  272. fmt.Println(resp)
  273. }
  274. func ExampleECS_ListTaskDefinitionFamilies() {
  275. svc := ecs.New(nil)
  276. params := &ecs.ListTaskDefinitionFamiliesInput{
  277. FamilyPrefix: aws.String("String"),
  278. MaxResults: aws.Int64(1),
  279. NextToken: aws.String("String"),
  280. }
  281. resp, err := svc.ListTaskDefinitionFamilies(params)
  282. if err != nil {
  283. // Print the error, cast err to awserr.Error to get the Code and
  284. // Message from an error.
  285. fmt.Println(err.Error())
  286. return
  287. }
  288. // Pretty-print the response data.
  289. fmt.Println(resp)
  290. }
  291. func ExampleECS_ListTaskDefinitions() {
  292. svc := ecs.New(nil)
  293. params := &ecs.ListTaskDefinitionsInput{
  294. FamilyPrefix: aws.String("String"),
  295. MaxResults: aws.Int64(1),
  296. NextToken: aws.String("String"),
  297. Sort: aws.String("SortOrder"),
  298. Status: aws.String("TaskDefinitionStatus"),
  299. }
  300. resp, err := svc.ListTaskDefinitions(params)
  301. if err != nil {
  302. // Print the error, cast err to awserr.Error to get the Code and
  303. // Message from an error.
  304. fmt.Println(err.Error())
  305. return
  306. }
  307. // Pretty-print the response data.
  308. fmt.Println(resp)
  309. }
  310. func ExampleECS_ListTasks() {
  311. svc := ecs.New(nil)
  312. params := &ecs.ListTasksInput{
  313. Cluster: aws.String("String"),
  314. ContainerInstance: aws.String("String"),
  315. DesiredStatus: aws.String("DesiredStatus"),
  316. Family: aws.String("String"),
  317. MaxResults: aws.Int64(1),
  318. NextToken: aws.String("String"),
  319. ServiceName: aws.String("String"),
  320. StartedBy: aws.String("String"),
  321. }
  322. resp, err := svc.ListTasks(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 ExampleECS_RegisterContainerInstance() {
  333. svc := ecs.New(nil)
  334. params := &ecs.RegisterContainerInstanceInput{
  335. Cluster: aws.String("String"),
  336. ContainerInstanceArn: aws.String("String"),
  337. InstanceIdentityDocument: aws.String("String"),
  338. InstanceIdentityDocumentSignature: aws.String("String"),
  339. TotalResources: []*ecs.Resource{
  340. { // Required
  341. DoubleValue: aws.Float64(1.0),
  342. IntegerValue: aws.Int64(1),
  343. LongValue: aws.Int64(1),
  344. Name: aws.String("String"),
  345. StringSetValue: []*string{
  346. aws.String("String"), // Required
  347. // More values...
  348. },
  349. Type: aws.String("String"),
  350. },
  351. // More values...
  352. },
  353. VersionInfo: &ecs.VersionInfo{
  354. AgentHash: aws.String("String"),
  355. AgentVersion: aws.String("String"),
  356. DockerVersion: aws.String("String"),
  357. },
  358. }
  359. resp, err := svc.RegisterContainerInstance(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 ExampleECS_RegisterTaskDefinition() {
  370. svc := ecs.New(nil)
  371. params := &ecs.RegisterTaskDefinitionInput{
  372. ContainerDefinitions: []*ecs.ContainerDefinition{ // Required
  373. { // Required
  374. Command: []*string{
  375. aws.String("String"), // Required
  376. // More values...
  377. },
  378. Cpu: aws.Int64(1),
  379. EntryPoint: []*string{
  380. aws.String("String"), // Required
  381. // More values...
  382. },
  383. Environment: []*ecs.KeyValuePair{
  384. { // Required
  385. Name: aws.String("String"),
  386. Value: aws.String("String"),
  387. },
  388. // More values...
  389. },
  390. Essential: aws.Bool(true),
  391. Image: aws.String("String"),
  392. Links: []*string{
  393. aws.String("String"), // Required
  394. // More values...
  395. },
  396. Memory: aws.Int64(1),
  397. MountPoints: []*ecs.MountPoint{
  398. { // Required
  399. ContainerPath: aws.String("String"),
  400. ReadOnly: aws.Bool(true),
  401. SourceVolume: aws.String("String"),
  402. },
  403. // More values...
  404. },
  405. Name: aws.String("String"),
  406. PortMappings: []*ecs.PortMapping{
  407. { // Required
  408. ContainerPort: aws.Int64(1),
  409. HostPort: aws.Int64(1),
  410. Protocol: aws.String("TransportProtocol"),
  411. },
  412. // More values...
  413. },
  414. VolumesFrom: []*ecs.VolumeFrom{
  415. { // Required
  416. ReadOnly: aws.Bool(true),
  417. SourceContainer: aws.String("String"),
  418. },
  419. // More values...
  420. },
  421. },
  422. // More values...
  423. },
  424. Family: aws.String("String"), // Required
  425. Volumes: []*ecs.Volume{
  426. { // Required
  427. Host: &ecs.HostVolumeProperties{
  428. SourcePath: aws.String("String"),
  429. },
  430. Name: aws.String("String"),
  431. },
  432. // More values...
  433. },
  434. }
  435. resp, err := svc.RegisterTaskDefinition(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 ExampleECS_RunTask() {
  446. svc := ecs.New(nil)
  447. params := &ecs.RunTaskInput{
  448. TaskDefinition: aws.String("String"), // Required
  449. Cluster: aws.String("String"),
  450. Count: aws.Int64(1),
  451. Overrides: &ecs.TaskOverride{
  452. ContainerOverrides: []*ecs.ContainerOverride{
  453. { // Required
  454. Command: []*string{
  455. aws.String("String"), // Required
  456. // More values...
  457. },
  458. Environment: []*ecs.KeyValuePair{
  459. { // Required
  460. Name: aws.String("String"),
  461. Value: aws.String("String"),
  462. },
  463. // More values...
  464. },
  465. Name: aws.String("String"),
  466. },
  467. // More values...
  468. },
  469. },
  470. StartedBy: aws.String("String"),
  471. }
  472. resp, err := svc.RunTask(params)
  473. if err != nil {
  474. // Print the error, cast err to awserr.Error to get the Code and
  475. // Message from an error.
  476. fmt.Println(err.Error())
  477. return
  478. }
  479. // Pretty-print the response data.
  480. fmt.Println(resp)
  481. }
  482. func ExampleECS_StartTask() {
  483. svc := ecs.New(nil)
  484. params := &ecs.StartTaskInput{
  485. ContainerInstances: []*string{ // Required
  486. aws.String("String"), // Required
  487. // More values...
  488. },
  489. TaskDefinition: aws.String("String"), // Required
  490. Cluster: aws.String("String"),
  491. Overrides: &ecs.TaskOverride{
  492. ContainerOverrides: []*ecs.ContainerOverride{
  493. { // Required
  494. Command: []*string{
  495. aws.String("String"), // Required
  496. // More values...
  497. },
  498. Environment: []*ecs.KeyValuePair{
  499. { // Required
  500. Name: aws.String("String"),
  501. Value: aws.String("String"),
  502. },
  503. // More values...
  504. },
  505. Name: aws.String("String"),
  506. },
  507. // More values...
  508. },
  509. },
  510. StartedBy: aws.String("String"),
  511. }
  512. resp, err := svc.StartTask(params)
  513. if err != nil {
  514. // Print the error, cast err to awserr.Error to get the Code and
  515. // Message from an error.
  516. fmt.Println(err.Error())
  517. return
  518. }
  519. // Pretty-print the response data.
  520. fmt.Println(resp)
  521. }
  522. func ExampleECS_StopTask() {
  523. svc := ecs.New(nil)
  524. params := &ecs.StopTaskInput{
  525. Task: aws.String("String"), // Required
  526. Cluster: aws.String("String"),
  527. }
  528. resp, err := svc.StopTask(params)
  529. if err != nil {
  530. // Print the error, cast err to awserr.Error to get the Code and
  531. // Message from an error.
  532. fmt.Println(err.Error())
  533. return
  534. }
  535. // Pretty-print the response data.
  536. fmt.Println(resp)
  537. }
  538. func ExampleECS_SubmitContainerStateChange() {
  539. svc := ecs.New(nil)
  540. params := &ecs.SubmitContainerStateChangeInput{
  541. Cluster: aws.String("String"),
  542. ContainerName: aws.String("String"),
  543. ExitCode: aws.Int64(1),
  544. NetworkBindings: []*ecs.NetworkBinding{
  545. { // Required
  546. BindIP: aws.String("String"),
  547. ContainerPort: aws.Int64(1),
  548. HostPort: aws.Int64(1),
  549. Protocol: aws.String("TransportProtocol"),
  550. },
  551. // More values...
  552. },
  553. Reason: aws.String("String"),
  554. Status: aws.String("String"),
  555. Task: aws.String("String"),
  556. }
  557. resp, err := svc.SubmitContainerStateChange(params)
  558. if err != nil {
  559. // Print the error, cast err to awserr.Error to get the Code and
  560. // Message from an error.
  561. fmt.Println(err.Error())
  562. return
  563. }
  564. // Pretty-print the response data.
  565. fmt.Println(resp)
  566. }
  567. func ExampleECS_SubmitTaskStateChange() {
  568. svc := ecs.New(nil)
  569. params := &ecs.SubmitTaskStateChangeInput{
  570. Cluster: aws.String("String"),
  571. Reason: aws.String("String"),
  572. Status: aws.String("String"),
  573. Task: aws.String("String"),
  574. }
  575. resp, err := svc.SubmitTaskStateChange(params)
  576. if err != nil {
  577. // Print the error, cast err to awserr.Error to get the Code and
  578. // Message from an error.
  579. fmt.Println(err.Error())
  580. return
  581. }
  582. // Pretty-print the response data.
  583. fmt.Println(resp)
  584. }
  585. func ExampleECS_UpdateContainerAgent() {
  586. svc := ecs.New(nil)
  587. params := &ecs.UpdateContainerAgentInput{
  588. ContainerInstance: aws.String("String"), // Required
  589. Cluster: aws.String("String"),
  590. }
  591. resp, err := svc.UpdateContainerAgent(params)
  592. if err != nil {
  593. // Print the error, cast err to awserr.Error to get the Code and
  594. // Message from an error.
  595. fmt.Println(err.Error())
  596. return
  597. }
  598. // Pretty-print the response data.
  599. fmt.Println(resp)
  600. }
  601. func ExampleECS_UpdateService() {
  602. svc := ecs.New(nil)
  603. params := &ecs.UpdateServiceInput{
  604. Service: aws.String("String"), // Required
  605. Cluster: aws.String("String"),
  606. DesiredCount: aws.Int64(1),
  607. TaskDefinition: aws.String("String"),
  608. }
  609. resp, err := svc.UpdateService(params)
  610. if err != nil {
  611. // Print the error, cast err to awserr.Error to get the Code and
  612. // Message from an error.
  613. fmt.Println(err.Error())
  614. return
  615. }
  616. // Pretty-print the response data.
  617. fmt.Println(resp)
  618. }