examples_test.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958
  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/aws/session"
  9. "github.com/aws/aws-sdk-go/service/ecs"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleECS_CreateCluster() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := ecs.New(sess)
  20. params := &ecs.CreateClusterInput{
  21. ClusterName: aws.String("String"),
  22. }
  23. resp, err := svc.CreateCluster(params)
  24. if err != nil {
  25. // Print the error, cast err to awserr.Error to get the Code and
  26. // Message from an error.
  27. fmt.Println(err.Error())
  28. return
  29. }
  30. // Pretty-print the response data.
  31. fmt.Println(resp)
  32. }
  33. func ExampleECS_CreateService() {
  34. sess, err := session.NewSession()
  35. if err != nil {
  36. fmt.Println("failed to create session,", err)
  37. return
  38. }
  39. svc := ecs.New(sess)
  40. params := &ecs.CreateServiceInput{
  41. DesiredCount: aws.Int64(1), // Required
  42. ServiceName: aws.String("String"), // Required
  43. TaskDefinition: aws.String("String"), // Required
  44. ClientToken: aws.String("String"),
  45. Cluster: aws.String("String"),
  46. DeploymentConfiguration: &ecs.DeploymentConfiguration{
  47. MaximumPercent: aws.Int64(1),
  48. MinimumHealthyPercent: aws.Int64(1),
  49. },
  50. LoadBalancers: []*ecs.LoadBalancer{
  51. { // Required
  52. ContainerName: aws.String("String"),
  53. ContainerPort: aws.Int64(1),
  54. LoadBalancerName: aws.String("String"),
  55. TargetGroupArn: aws.String("String"),
  56. },
  57. // More values...
  58. },
  59. Role: aws.String("String"),
  60. }
  61. resp, err := svc.CreateService(params)
  62. if err != nil {
  63. // Print the error, cast err to awserr.Error to get the Code and
  64. // Message from an error.
  65. fmt.Println(err.Error())
  66. return
  67. }
  68. // Pretty-print the response data.
  69. fmt.Println(resp)
  70. }
  71. func ExampleECS_DeleteCluster() {
  72. sess, err := session.NewSession()
  73. if err != nil {
  74. fmt.Println("failed to create session,", err)
  75. return
  76. }
  77. svc := ecs.New(sess)
  78. params := &ecs.DeleteClusterInput{
  79. Cluster: aws.String("String"), // Required
  80. }
  81. resp, err := svc.DeleteCluster(params)
  82. if err != nil {
  83. // Print the error, cast err to awserr.Error to get the Code and
  84. // Message from an error.
  85. fmt.Println(err.Error())
  86. return
  87. }
  88. // Pretty-print the response data.
  89. fmt.Println(resp)
  90. }
  91. func ExampleECS_DeleteService() {
  92. sess, err := session.NewSession()
  93. if err != nil {
  94. fmt.Println("failed to create session,", err)
  95. return
  96. }
  97. svc := ecs.New(sess)
  98. params := &ecs.DeleteServiceInput{
  99. Service: aws.String("String"), // Required
  100. Cluster: aws.String("String"),
  101. }
  102. resp, err := svc.DeleteService(params)
  103. if err != nil {
  104. // Print the error, cast err to awserr.Error to get the Code and
  105. // Message from an error.
  106. fmt.Println(err.Error())
  107. return
  108. }
  109. // Pretty-print the response data.
  110. fmt.Println(resp)
  111. }
  112. func ExampleECS_DeregisterContainerInstance() {
  113. sess, err := session.NewSession()
  114. if err != nil {
  115. fmt.Println("failed to create session,", err)
  116. return
  117. }
  118. svc := ecs.New(sess)
  119. params := &ecs.DeregisterContainerInstanceInput{
  120. ContainerInstance: aws.String("String"), // Required
  121. Cluster: aws.String("String"),
  122. Force: aws.Bool(true),
  123. }
  124. resp, err := svc.DeregisterContainerInstance(params)
  125. if err != nil {
  126. // Print the error, cast err to awserr.Error to get the Code and
  127. // Message from an error.
  128. fmt.Println(err.Error())
  129. return
  130. }
  131. // Pretty-print the response data.
  132. fmt.Println(resp)
  133. }
  134. func ExampleECS_DeregisterTaskDefinition() {
  135. sess, err := session.NewSession()
  136. if err != nil {
  137. fmt.Println("failed to create session,", err)
  138. return
  139. }
  140. svc := ecs.New(sess)
  141. params := &ecs.DeregisterTaskDefinitionInput{
  142. TaskDefinition: aws.String("String"), // Required
  143. }
  144. resp, err := svc.DeregisterTaskDefinition(params)
  145. if err != nil {
  146. // Print the error, cast err to awserr.Error to get the Code and
  147. // Message from an error.
  148. fmt.Println(err.Error())
  149. return
  150. }
  151. // Pretty-print the response data.
  152. fmt.Println(resp)
  153. }
  154. func ExampleECS_DescribeClusters() {
  155. sess, err := session.NewSession()
  156. if err != nil {
  157. fmt.Println("failed to create session,", err)
  158. return
  159. }
  160. svc := ecs.New(sess)
  161. params := &ecs.DescribeClustersInput{
  162. Clusters: []*string{
  163. aws.String("String"), // Required
  164. // More values...
  165. },
  166. }
  167. resp, err := svc.DescribeClusters(params)
  168. if err != nil {
  169. // Print the error, cast err to awserr.Error to get the Code and
  170. // Message from an error.
  171. fmt.Println(err.Error())
  172. return
  173. }
  174. // Pretty-print the response data.
  175. fmt.Println(resp)
  176. }
  177. func ExampleECS_DescribeContainerInstances() {
  178. sess, err := session.NewSession()
  179. if err != nil {
  180. fmt.Println("failed to create session,", err)
  181. return
  182. }
  183. svc := ecs.New(sess)
  184. params := &ecs.DescribeContainerInstancesInput{
  185. ContainerInstances: []*string{ // Required
  186. aws.String("String"), // Required
  187. // More values...
  188. },
  189. Cluster: aws.String("String"),
  190. }
  191. resp, err := svc.DescribeContainerInstances(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 ExampleECS_DescribeServices() {
  202. sess, err := session.NewSession()
  203. if err != nil {
  204. fmt.Println("failed to create session,", err)
  205. return
  206. }
  207. svc := ecs.New(sess)
  208. params := &ecs.DescribeServicesInput{
  209. Services: []*string{ // Required
  210. aws.String("String"), // Required
  211. // More values...
  212. },
  213. Cluster: aws.String("String"),
  214. }
  215. resp, err := svc.DescribeServices(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 ExampleECS_DescribeTaskDefinition() {
  226. sess, err := session.NewSession()
  227. if err != nil {
  228. fmt.Println("failed to create session,", err)
  229. return
  230. }
  231. svc := ecs.New(sess)
  232. params := &ecs.DescribeTaskDefinitionInput{
  233. TaskDefinition: aws.String("String"), // Required
  234. }
  235. resp, err := svc.DescribeTaskDefinition(params)
  236. if err != nil {
  237. // Print the error, cast err to awserr.Error to get the Code and
  238. // Message from an error.
  239. fmt.Println(err.Error())
  240. return
  241. }
  242. // Pretty-print the response data.
  243. fmt.Println(resp)
  244. }
  245. func ExampleECS_DescribeTasks() {
  246. sess, err := session.NewSession()
  247. if err != nil {
  248. fmt.Println("failed to create session,", err)
  249. return
  250. }
  251. svc := ecs.New(sess)
  252. params := &ecs.DescribeTasksInput{
  253. Tasks: []*string{ // Required
  254. aws.String("String"), // Required
  255. // More values...
  256. },
  257. Cluster: aws.String("String"),
  258. }
  259. resp, err := svc.DescribeTasks(params)
  260. if err != nil {
  261. // Print the error, cast err to awserr.Error to get the Code and
  262. // Message from an error.
  263. fmt.Println(err.Error())
  264. return
  265. }
  266. // Pretty-print the response data.
  267. fmt.Println(resp)
  268. }
  269. func ExampleECS_DiscoverPollEndpoint() {
  270. sess, err := session.NewSession()
  271. if err != nil {
  272. fmt.Println("failed to create session,", err)
  273. return
  274. }
  275. svc := ecs.New(sess)
  276. params := &ecs.DiscoverPollEndpointInput{
  277. Cluster: aws.String("String"),
  278. ContainerInstance: aws.String("String"),
  279. }
  280. resp, err := svc.DiscoverPollEndpoint(params)
  281. if err != nil {
  282. // Print the error, cast err to awserr.Error to get the Code and
  283. // Message from an error.
  284. fmt.Println(err.Error())
  285. return
  286. }
  287. // Pretty-print the response data.
  288. fmt.Println(resp)
  289. }
  290. func ExampleECS_ListClusters() {
  291. sess, err := session.NewSession()
  292. if err != nil {
  293. fmt.Println("failed to create session,", err)
  294. return
  295. }
  296. svc := ecs.New(sess)
  297. params := &ecs.ListClustersInput{
  298. MaxResults: aws.Int64(1),
  299. NextToken: aws.String("String"),
  300. }
  301. resp, err := svc.ListClusters(params)
  302. if err != nil {
  303. // Print the error, cast err to awserr.Error to get the Code and
  304. // Message from an error.
  305. fmt.Println(err.Error())
  306. return
  307. }
  308. // Pretty-print the response data.
  309. fmt.Println(resp)
  310. }
  311. func ExampleECS_ListContainerInstances() {
  312. sess, err := session.NewSession()
  313. if err != nil {
  314. fmt.Println("failed to create session,", err)
  315. return
  316. }
  317. svc := ecs.New(sess)
  318. params := &ecs.ListContainerInstancesInput{
  319. Cluster: aws.String("String"),
  320. MaxResults: aws.Int64(1),
  321. NextToken: aws.String("String"),
  322. }
  323. resp, err := svc.ListContainerInstances(params)
  324. if err != nil {
  325. // Print the error, cast err to awserr.Error to get the Code and
  326. // Message from an error.
  327. fmt.Println(err.Error())
  328. return
  329. }
  330. // Pretty-print the response data.
  331. fmt.Println(resp)
  332. }
  333. func ExampleECS_ListServices() {
  334. sess, err := session.NewSession()
  335. if err != nil {
  336. fmt.Println("failed to create session,", err)
  337. return
  338. }
  339. svc := ecs.New(sess)
  340. params := &ecs.ListServicesInput{
  341. Cluster: aws.String("String"),
  342. MaxResults: aws.Int64(1),
  343. NextToken: aws.String("String"),
  344. }
  345. resp, err := svc.ListServices(params)
  346. if err != nil {
  347. // Print the error, cast err to awserr.Error to get the Code and
  348. // Message from an error.
  349. fmt.Println(err.Error())
  350. return
  351. }
  352. // Pretty-print the response data.
  353. fmt.Println(resp)
  354. }
  355. func ExampleECS_ListTaskDefinitionFamilies() {
  356. sess, err := session.NewSession()
  357. if err != nil {
  358. fmt.Println("failed to create session,", err)
  359. return
  360. }
  361. svc := ecs.New(sess)
  362. params := &ecs.ListTaskDefinitionFamiliesInput{
  363. FamilyPrefix: aws.String("String"),
  364. MaxResults: aws.Int64(1),
  365. NextToken: aws.String("String"),
  366. Status: aws.String("TaskDefinitionFamilyStatus"),
  367. }
  368. resp, err := svc.ListTaskDefinitionFamilies(params)
  369. if err != nil {
  370. // Print the error, cast err to awserr.Error to get the Code and
  371. // Message from an error.
  372. fmt.Println(err.Error())
  373. return
  374. }
  375. // Pretty-print the response data.
  376. fmt.Println(resp)
  377. }
  378. func ExampleECS_ListTaskDefinitions() {
  379. sess, err := session.NewSession()
  380. if err != nil {
  381. fmt.Println("failed to create session,", err)
  382. return
  383. }
  384. svc := ecs.New(sess)
  385. params := &ecs.ListTaskDefinitionsInput{
  386. FamilyPrefix: aws.String("String"),
  387. MaxResults: aws.Int64(1),
  388. NextToken: aws.String("String"),
  389. Sort: aws.String("SortOrder"),
  390. Status: aws.String("TaskDefinitionStatus"),
  391. }
  392. resp, err := svc.ListTaskDefinitions(params)
  393. if err != nil {
  394. // Print the error, cast err to awserr.Error to get the Code and
  395. // Message from an error.
  396. fmt.Println(err.Error())
  397. return
  398. }
  399. // Pretty-print the response data.
  400. fmt.Println(resp)
  401. }
  402. func ExampleECS_ListTasks() {
  403. sess, err := session.NewSession()
  404. if err != nil {
  405. fmt.Println("failed to create session,", err)
  406. return
  407. }
  408. svc := ecs.New(sess)
  409. params := &ecs.ListTasksInput{
  410. Cluster: aws.String("String"),
  411. ContainerInstance: aws.String("String"),
  412. DesiredStatus: aws.String("DesiredStatus"),
  413. Family: aws.String("String"),
  414. MaxResults: aws.Int64(1),
  415. NextToken: aws.String("String"),
  416. ServiceName: aws.String("String"),
  417. StartedBy: aws.String("String"),
  418. }
  419. resp, err := svc.ListTasks(params)
  420. if err != nil {
  421. // Print the error, cast err to awserr.Error to get the Code and
  422. // Message from an error.
  423. fmt.Println(err.Error())
  424. return
  425. }
  426. // Pretty-print the response data.
  427. fmt.Println(resp)
  428. }
  429. func ExampleECS_RegisterContainerInstance() {
  430. sess, err := session.NewSession()
  431. if err != nil {
  432. fmt.Println("failed to create session,", err)
  433. return
  434. }
  435. svc := ecs.New(sess)
  436. params := &ecs.RegisterContainerInstanceInput{
  437. Attributes: []*ecs.Attribute{
  438. { // Required
  439. Name: aws.String("String"), // Required
  440. Value: aws.String("String"),
  441. },
  442. // More values...
  443. },
  444. Cluster: aws.String("String"),
  445. ContainerInstanceArn: aws.String("String"),
  446. InstanceIdentityDocument: aws.String("String"),
  447. InstanceIdentityDocumentSignature: aws.String("String"),
  448. TotalResources: []*ecs.Resource{
  449. { // Required
  450. DoubleValue: aws.Float64(1.0),
  451. IntegerValue: aws.Int64(1),
  452. LongValue: aws.Int64(1),
  453. Name: aws.String("String"),
  454. StringSetValue: []*string{
  455. aws.String("String"), // Required
  456. // More values...
  457. },
  458. Type: aws.String("String"),
  459. },
  460. // More values...
  461. },
  462. VersionInfo: &ecs.VersionInfo{
  463. AgentHash: aws.String("String"),
  464. AgentVersion: aws.String("String"),
  465. DockerVersion: aws.String("String"),
  466. },
  467. }
  468. resp, err := svc.RegisterContainerInstance(params)
  469. if err != nil {
  470. // Print the error, cast err to awserr.Error to get the Code and
  471. // Message from an error.
  472. fmt.Println(err.Error())
  473. return
  474. }
  475. // Pretty-print the response data.
  476. fmt.Println(resp)
  477. }
  478. func ExampleECS_RegisterTaskDefinition() {
  479. sess, err := session.NewSession()
  480. if err != nil {
  481. fmt.Println("failed to create session,", err)
  482. return
  483. }
  484. svc := ecs.New(sess)
  485. params := &ecs.RegisterTaskDefinitionInput{
  486. ContainerDefinitions: []*ecs.ContainerDefinition{ // Required
  487. { // Required
  488. Command: []*string{
  489. aws.String("String"), // Required
  490. // More values...
  491. },
  492. Cpu: aws.Int64(1),
  493. DisableNetworking: aws.Bool(true),
  494. DnsSearchDomains: []*string{
  495. aws.String("String"), // Required
  496. // More values...
  497. },
  498. DnsServers: []*string{
  499. aws.String("String"), // Required
  500. // More values...
  501. },
  502. DockerLabels: map[string]*string{
  503. "Key": aws.String("String"), // Required
  504. // More values...
  505. },
  506. DockerSecurityOptions: []*string{
  507. aws.String("String"), // Required
  508. // More values...
  509. },
  510. EntryPoint: []*string{
  511. aws.String("String"), // Required
  512. // More values...
  513. },
  514. Environment: []*ecs.KeyValuePair{
  515. { // Required
  516. Name: aws.String("String"),
  517. Value: aws.String("String"),
  518. },
  519. // More values...
  520. },
  521. Essential: aws.Bool(true),
  522. ExtraHosts: []*ecs.HostEntry{
  523. { // Required
  524. Hostname: aws.String("String"), // Required
  525. IpAddress: aws.String("String"), // Required
  526. },
  527. // More values...
  528. },
  529. Hostname: aws.String("String"),
  530. Image: aws.String("String"),
  531. Links: []*string{
  532. aws.String("String"), // Required
  533. // More values...
  534. },
  535. LogConfiguration: &ecs.LogConfiguration{
  536. LogDriver: aws.String("LogDriver"), // Required
  537. Options: map[string]*string{
  538. "Key": aws.String("String"), // Required
  539. // More values...
  540. },
  541. },
  542. Memory: aws.Int64(1),
  543. MountPoints: []*ecs.MountPoint{
  544. { // Required
  545. ContainerPath: aws.String("String"),
  546. ReadOnly: aws.Bool(true),
  547. SourceVolume: aws.String("String"),
  548. },
  549. // More values...
  550. },
  551. Name: aws.String("String"),
  552. PortMappings: []*ecs.PortMapping{
  553. { // Required
  554. ContainerPort: aws.Int64(1),
  555. HostPort: aws.Int64(1),
  556. Protocol: aws.String("TransportProtocol"),
  557. },
  558. // More values...
  559. },
  560. Privileged: aws.Bool(true),
  561. ReadonlyRootFilesystem: aws.Bool(true),
  562. Ulimits: []*ecs.Ulimit{
  563. { // Required
  564. HardLimit: aws.Int64(1), // Required
  565. Name: aws.String("UlimitName"), // Required
  566. SoftLimit: aws.Int64(1), // Required
  567. },
  568. // More values...
  569. },
  570. User: aws.String("String"),
  571. VolumesFrom: []*ecs.VolumeFrom{
  572. { // Required
  573. ReadOnly: aws.Bool(true),
  574. SourceContainer: aws.String("String"),
  575. },
  576. // More values...
  577. },
  578. WorkingDirectory: aws.String("String"),
  579. },
  580. // More values...
  581. },
  582. Family: aws.String("String"), // Required
  583. TaskRoleArn: aws.String("String"),
  584. Volumes: []*ecs.Volume{
  585. { // Required
  586. Host: &ecs.HostVolumeProperties{
  587. SourcePath: aws.String("String"),
  588. },
  589. Name: aws.String("String"),
  590. },
  591. // More values...
  592. },
  593. }
  594. resp, err := svc.RegisterTaskDefinition(params)
  595. if err != nil {
  596. // Print the error, cast err to awserr.Error to get the Code and
  597. // Message from an error.
  598. fmt.Println(err.Error())
  599. return
  600. }
  601. // Pretty-print the response data.
  602. fmt.Println(resp)
  603. }
  604. func ExampleECS_RunTask() {
  605. sess, err := session.NewSession()
  606. if err != nil {
  607. fmt.Println("failed to create session,", err)
  608. return
  609. }
  610. svc := ecs.New(sess)
  611. params := &ecs.RunTaskInput{
  612. TaskDefinition: aws.String("String"), // Required
  613. Cluster: aws.String("String"),
  614. Count: aws.Int64(1),
  615. Overrides: &ecs.TaskOverride{
  616. ContainerOverrides: []*ecs.ContainerOverride{
  617. { // Required
  618. Command: []*string{
  619. aws.String("String"), // Required
  620. // More values...
  621. },
  622. Environment: []*ecs.KeyValuePair{
  623. { // Required
  624. Name: aws.String("String"),
  625. Value: aws.String("String"),
  626. },
  627. // More values...
  628. },
  629. Name: aws.String("String"),
  630. },
  631. // More values...
  632. },
  633. TaskRoleArn: aws.String("String"),
  634. },
  635. StartedBy: aws.String("String"),
  636. }
  637. resp, err := svc.RunTask(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 ExampleECS_StartTask() {
  648. sess, err := session.NewSession()
  649. if err != nil {
  650. fmt.Println("failed to create session,", err)
  651. return
  652. }
  653. svc := ecs.New(sess)
  654. params := &ecs.StartTaskInput{
  655. ContainerInstances: []*string{ // Required
  656. aws.String("String"), // Required
  657. // More values...
  658. },
  659. TaskDefinition: aws.String("String"), // Required
  660. Cluster: aws.String("String"),
  661. Overrides: &ecs.TaskOverride{
  662. ContainerOverrides: []*ecs.ContainerOverride{
  663. { // Required
  664. Command: []*string{
  665. aws.String("String"), // Required
  666. // More values...
  667. },
  668. Environment: []*ecs.KeyValuePair{
  669. { // Required
  670. Name: aws.String("String"),
  671. Value: aws.String("String"),
  672. },
  673. // More values...
  674. },
  675. Name: aws.String("String"),
  676. },
  677. // More values...
  678. },
  679. TaskRoleArn: aws.String("String"),
  680. },
  681. StartedBy: aws.String("String"),
  682. }
  683. resp, err := svc.StartTask(params)
  684. if err != nil {
  685. // Print the error, cast err to awserr.Error to get the Code and
  686. // Message from an error.
  687. fmt.Println(err.Error())
  688. return
  689. }
  690. // Pretty-print the response data.
  691. fmt.Println(resp)
  692. }
  693. func ExampleECS_StopTask() {
  694. sess, err := session.NewSession()
  695. if err != nil {
  696. fmt.Println("failed to create session,", err)
  697. return
  698. }
  699. svc := ecs.New(sess)
  700. params := &ecs.StopTaskInput{
  701. Task: aws.String("String"), // Required
  702. Cluster: aws.String("String"),
  703. Reason: aws.String("String"),
  704. }
  705. resp, err := svc.StopTask(params)
  706. if err != nil {
  707. // Print the error, cast err to awserr.Error to get the Code and
  708. // Message from an error.
  709. fmt.Println(err.Error())
  710. return
  711. }
  712. // Pretty-print the response data.
  713. fmt.Println(resp)
  714. }
  715. func ExampleECS_SubmitContainerStateChange() {
  716. sess, err := session.NewSession()
  717. if err != nil {
  718. fmt.Println("failed to create session,", err)
  719. return
  720. }
  721. svc := ecs.New(sess)
  722. params := &ecs.SubmitContainerStateChangeInput{
  723. Cluster: aws.String("String"),
  724. ContainerName: aws.String("String"),
  725. ExitCode: aws.Int64(1),
  726. NetworkBindings: []*ecs.NetworkBinding{
  727. { // Required
  728. BindIP: aws.String("String"),
  729. ContainerPort: aws.Int64(1),
  730. HostPort: aws.Int64(1),
  731. Protocol: aws.String("TransportProtocol"),
  732. },
  733. // More values...
  734. },
  735. Reason: aws.String("String"),
  736. Status: aws.String("String"),
  737. Task: aws.String("String"),
  738. }
  739. resp, err := svc.SubmitContainerStateChange(params)
  740. if err != nil {
  741. // Print the error, cast err to awserr.Error to get the Code and
  742. // Message from an error.
  743. fmt.Println(err.Error())
  744. return
  745. }
  746. // Pretty-print the response data.
  747. fmt.Println(resp)
  748. }
  749. func ExampleECS_SubmitTaskStateChange() {
  750. sess, err := session.NewSession()
  751. if err != nil {
  752. fmt.Println("failed to create session,", err)
  753. return
  754. }
  755. svc := ecs.New(sess)
  756. params := &ecs.SubmitTaskStateChangeInput{
  757. Cluster: aws.String("String"),
  758. Reason: aws.String("String"),
  759. Status: aws.String("String"),
  760. Task: aws.String("String"),
  761. }
  762. resp, err := svc.SubmitTaskStateChange(params)
  763. if err != nil {
  764. // Print the error, cast err to awserr.Error to get the Code and
  765. // Message from an error.
  766. fmt.Println(err.Error())
  767. return
  768. }
  769. // Pretty-print the response data.
  770. fmt.Println(resp)
  771. }
  772. func ExampleECS_UpdateContainerAgent() {
  773. sess, err := session.NewSession()
  774. if err != nil {
  775. fmt.Println("failed to create session,", err)
  776. return
  777. }
  778. svc := ecs.New(sess)
  779. params := &ecs.UpdateContainerAgentInput{
  780. ContainerInstance: aws.String("String"), // Required
  781. Cluster: aws.String("String"),
  782. }
  783. resp, err := svc.UpdateContainerAgent(params)
  784. if err != nil {
  785. // Print the error, cast err to awserr.Error to get the Code and
  786. // Message from an error.
  787. fmt.Println(err.Error())
  788. return
  789. }
  790. // Pretty-print the response data.
  791. fmt.Println(resp)
  792. }
  793. func ExampleECS_UpdateService() {
  794. sess, err := session.NewSession()
  795. if err != nil {
  796. fmt.Println("failed to create session,", err)
  797. return
  798. }
  799. svc := ecs.New(sess)
  800. params := &ecs.UpdateServiceInput{
  801. Service: aws.String("String"), // Required
  802. Cluster: aws.String("String"),
  803. DeploymentConfiguration: &ecs.DeploymentConfiguration{
  804. MaximumPercent: aws.Int64(1),
  805. MinimumHealthyPercent: aws.Int64(1),
  806. },
  807. DesiredCount: aws.Int64(1),
  808. TaskDefinition: aws.String("String"),
  809. }
  810. resp, err := svc.UpdateService(params)
  811. if err != nil {
  812. // Print the error, cast err to awserr.Error to get the Code and
  813. // Message from an error.
  814. fmt.Println(err.Error())
  815. return
  816. }
  817. // Pretty-print the response data.
  818. fmt.Println(resp)
  819. }