examples_test.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960
  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. MemoryReservation: aws.Int64(1),
  544. MountPoints: []*ecs.MountPoint{
  545. { // Required
  546. ContainerPath: aws.String("String"),
  547. ReadOnly: aws.Bool(true),
  548. SourceVolume: aws.String("String"),
  549. },
  550. // More values...
  551. },
  552. Name: aws.String("String"),
  553. PortMappings: []*ecs.PortMapping{
  554. { // Required
  555. ContainerPort: aws.Int64(1),
  556. HostPort: aws.Int64(1),
  557. Protocol: aws.String("TransportProtocol"),
  558. },
  559. // More values...
  560. },
  561. Privileged: aws.Bool(true),
  562. ReadonlyRootFilesystem: aws.Bool(true),
  563. Ulimits: []*ecs.Ulimit{
  564. { // Required
  565. HardLimit: aws.Int64(1), // Required
  566. Name: aws.String("UlimitName"), // Required
  567. SoftLimit: aws.Int64(1), // Required
  568. },
  569. // More values...
  570. },
  571. User: aws.String("String"),
  572. VolumesFrom: []*ecs.VolumeFrom{
  573. { // Required
  574. ReadOnly: aws.Bool(true),
  575. SourceContainer: aws.String("String"),
  576. },
  577. // More values...
  578. },
  579. WorkingDirectory: aws.String("String"),
  580. },
  581. // More values...
  582. },
  583. Family: aws.String("String"), // Required
  584. NetworkMode: aws.String("NetworkMode"),
  585. TaskRoleArn: aws.String("String"),
  586. Volumes: []*ecs.Volume{
  587. { // Required
  588. Host: &ecs.HostVolumeProperties{
  589. SourcePath: aws.String("String"),
  590. },
  591. Name: aws.String("String"),
  592. },
  593. // More values...
  594. },
  595. }
  596. resp, err := svc.RegisterTaskDefinition(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. }
  606. func ExampleECS_RunTask() {
  607. sess, err := session.NewSession()
  608. if err != nil {
  609. fmt.Println("failed to create session,", err)
  610. return
  611. }
  612. svc := ecs.New(sess)
  613. params := &ecs.RunTaskInput{
  614. TaskDefinition: aws.String("String"), // Required
  615. Cluster: aws.String("String"),
  616. Count: aws.Int64(1),
  617. Overrides: &ecs.TaskOverride{
  618. ContainerOverrides: []*ecs.ContainerOverride{
  619. { // Required
  620. Command: []*string{
  621. aws.String("String"), // Required
  622. // More values...
  623. },
  624. Environment: []*ecs.KeyValuePair{
  625. { // Required
  626. Name: aws.String("String"),
  627. Value: aws.String("String"),
  628. },
  629. // More values...
  630. },
  631. Name: aws.String("String"),
  632. },
  633. // More values...
  634. },
  635. TaskRoleArn: aws.String("String"),
  636. },
  637. StartedBy: aws.String("String"),
  638. }
  639. resp, err := svc.RunTask(params)
  640. if err != nil {
  641. // Print the error, cast err to awserr.Error to get the Code and
  642. // Message from an error.
  643. fmt.Println(err.Error())
  644. return
  645. }
  646. // Pretty-print the response data.
  647. fmt.Println(resp)
  648. }
  649. func ExampleECS_StartTask() {
  650. sess, err := session.NewSession()
  651. if err != nil {
  652. fmt.Println("failed to create session,", err)
  653. return
  654. }
  655. svc := ecs.New(sess)
  656. params := &ecs.StartTaskInput{
  657. ContainerInstances: []*string{ // Required
  658. aws.String("String"), // Required
  659. // More values...
  660. },
  661. TaskDefinition: aws.String("String"), // Required
  662. Cluster: aws.String("String"),
  663. Overrides: &ecs.TaskOverride{
  664. ContainerOverrides: []*ecs.ContainerOverride{
  665. { // Required
  666. Command: []*string{
  667. aws.String("String"), // Required
  668. // More values...
  669. },
  670. Environment: []*ecs.KeyValuePair{
  671. { // Required
  672. Name: aws.String("String"),
  673. Value: aws.String("String"),
  674. },
  675. // More values...
  676. },
  677. Name: aws.String("String"),
  678. },
  679. // More values...
  680. },
  681. TaskRoleArn: aws.String("String"),
  682. },
  683. StartedBy: aws.String("String"),
  684. }
  685. resp, err := svc.StartTask(params)
  686. if err != nil {
  687. // Print the error, cast err to awserr.Error to get the Code and
  688. // Message from an error.
  689. fmt.Println(err.Error())
  690. return
  691. }
  692. // Pretty-print the response data.
  693. fmt.Println(resp)
  694. }
  695. func ExampleECS_StopTask() {
  696. sess, err := session.NewSession()
  697. if err != nil {
  698. fmt.Println("failed to create session,", err)
  699. return
  700. }
  701. svc := ecs.New(sess)
  702. params := &ecs.StopTaskInput{
  703. Task: aws.String("String"), // Required
  704. Cluster: aws.String("String"),
  705. Reason: aws.String("String"),
  706. }
  707. resp, err := svc.StopTask(params)
  708. if err != nil {
  709. // Print the error, cast err to awserr.Error to get the Code and
  710. // Message from an error.
  711. fmt.Println(err.Error())
  712. return
  713. }
  714. // Pretty-print the response data.
  715. fmt.Println(resp)
  716. }
  717. func ExampleECS_SubmitContainerStateChange() {
  718. sess, err := session.NewSession()
  719. if err != nil {
  720. fmt.Println("failed to create session,", err)
  721. return
  722. }
  723. svc := ecs.New(sess)
  724. params := &ecs.SubmitContainerStateChangeInput{
  725. Cluster: aws.String("String"),
  726. ContainerName: aws.String("String"),
  727. ExitCode: aws.Int64(1),
  728. NetworkBindings: []*ecs.NetworkBinding{
  729. { // Required
  730. BindIP: aws.String("String"),
  731. ContainerPort: aws.Int64(1),
  732. HostPort: aws.Int64(1),
  733. Protocol: aws.String("TransportProtocol"),
  734. },
  735. // More values...
  736. },
  737. Reason: aws.String("String"),
  738. Status: aws.String("String"),
  739. Task: aws.String("String"),
  740. }
  741. resp, err := svc.SubmitContainerStateChange(params)
  742. if err != nil {
  743. // Print the error, cast err to awserr.Error to get the Code and
  744. // Message from an error.
  745. fmt.Println(err.Error())
  746. return
  747. }
  748. // Pretty-print the response data.
  749. fmt.Println(resp)
  750. }
  751. func ExampleECS_SubmitTaskStateChange() {
  752. sess, err := session.NewSession()
  753. if err != nil {
  754. fmt.Println("failed to create session,", err)
  755. return
  756. }
  757. svc := ecs.New(sess)
  758. params := &ecs.SubmitTaskStateChangeInput{
  759. Cluster: aws.String("String"),
  760. Reason: aws.String("String"),
  761. Status: aws.String("String"),
  762. Task: aws.String("String"),
  763. }
  764. resp, err := svc.SubmitTaskStateChange(params)
  765. if err != nil {
  766. // Print the error, cast err to awserr.Error to get the Code and
  767. // Message from an error.
  768. fmt.Println(err.Error())
  769. return
  770. }
  771. // Pretty-print the response data.
  772. fmt.Println(resp)
  773. }
  774. func ExampleECS_UpdateContainerAgent() {
  775. sess, err := session.NewSession()
  776. if err != nil {
  777. fmt.Println("failed to create session,", err)
  778. return
  779. }
  780. svc := ecs.New(sess)
  781. params := &ecs.UpdateContainerAgentInput{
  782. ContainerInstance: aws.String("String"), // Required
  783. Cluster: aws.String("String"),
  784. }
  785. resp, err := svc.UpdateContainerAgent(params)
  786. if err != nil {
  787. // Print the error, cast err to awserr.Error to get the Code and
  788. // Message from an error.
  789. fmt.Println(err.Error())
  790. return
  791. }
  792. // Pretty-print the response data.
  793. fmt.Println(resp)
  794. }
  795. func ExampleECS_UpdateService() {
  796. sess, err := session.NewSession()
  797. if err != nil {
  798. fmt.Println("failed to create session,", err)
  799. return
  800. }
  801. svc := ecs.New(sess)
  802. params := &ecs.UpdateServiceInput{
  803. Service: aws.String("String"), // Required
  804. Cluster: aws.String("String"),
  805. DeploymentConfiguration: &ecs.DeploymentConfiguration{
  806. MaximumPercent: aws.Int64(1),
  807. MinimumHealthyPercent: aws.Int64(1),
  808. },
  809. DesiredCount: aws.Int64(1),
  810. TaskDefinition: aws.String("String"),
  811. }
  812. resp, err := svc.UpdateService(params)
  813. if err != nil {
  814. // Print the error, cast err to awserr.Error to get the Code and
  815. // Message from an error.
  816. fmt.Println(err.Error())
  817. return
  818. }
  819. // Pretty-print the response data.
  820. fmt.Println(resp)
  821. }