examples_test.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package emr_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/emr"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleEMR_AddInstanceGroups() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := emr.New(sess)
  20. params := &emr.AddInstanceGroupsInput{
  21. InstanceGroups: []*emr.InstanceGroupConfig{ // Required
  22. { // Required
  23. InstanceCount: aws.Int64(1), // Required
  24. InstanceRole: aws.String("InstanceRoleType"), // Required
  25. InstanceType: aws.String("InstanceType"), // Required
  26. BidPrice: aws.String("XmlStringMaxLen256"),
  27. Configurations: []*emr.Configuration{
  28. { // Required
  29. Classification: aws.String("String"),
  30. Configurations: []*emr.Configuration{
  31. // Recursive values...
  32. },
  33. Properties: map[string]*string{
  34. "Key": aws.String("String"), // Required
  35. // More values...
  36. },
  37. },
  38. // More values...
  39. },
  40. EbsConfiguration: &emr.EbsConfiguration{
  41. EbsBlockDeviceConfigs: []*emr.EbsBlockDeviceConfig{
  42. { // Required
  43. VolumeSpecification: &emr.VolumeSpecification{ // Required
  44. SizeInGB: aws.Int64(1), // Required
  45. VolumeType: aws.String("String"), // Required
  46. Iops: aws.Int64(1),
  47. },
  48. VolumesPerInstance: aws.Int64(1),
  49. },
  50. // More values...
  51. },
  52. EbsOptimized: aws.Bool(true),
  53. },
  54. Market: aws.String("MarketType"),
  55. Name: aws.String("XmlStringMaxLen256"),
  56. },
  57. // More values...
  58. },
  59. JobFlowId: aws.String("XmlStringMaxLen256"), // Required
  60. }
  61. resp, err := svc.AddInstanceGroups(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 ExampleEMR_AddJobFlowSteps() {
  72. sess, err := session.NewSession()
  73. if err != nil {
  74. fmt.Println("failed to create session,", err)
  75. return
  76. }
  77. svc := emr.New(sess)
  78. params := &emr.AddJobFlowStepsInput{
  79. JobFlowId: aws.String("XmlStringMaxLen256"), // Required
  80. Steps: []*emr.StepConfig{ // Required
  81. { // Required
  82. HadoopJarStep: &emr.HadoopJarStepConfig{ // Required
  83. Jar: aws.String("XmlString"), // Required
  84. Args: []*string{
  85. aws.String("XmlString"), // Required
  86. // More values...
  87. },
  88. MainClass: aws.String("XmlString"),
  89. Properties: []*emr.KeyValue{
  90. { // Required
  91. Key: aws.String("XmlString"),
  92. Value: aws.String("XmlString"),
  93. },
  94. // More values...
  95. },
  96. },
  97. Name: aws.String("XmlStringMaxLen256"), // Required
  98. ActionOnFailure: aws.String("ActionOnFailure"),
  99. },
  100. // More values...
  101. },
  102. }
  103. resp, err := svc.AddJobFlowSteps(params)
  104. if err != nil {
  105. // Print the error, cast err to awserr.Error to get the Code and
  106. // Message from an error.
  107. fmt.Println(err.Error())
  108. return
  109. }
  110. // Pretty-print the response data.
  111. fmt.Println(resp)
  112. }
  113. func ExampleEMR_AddTags() {
  114. sess, err := session.NewSession()
  115. if err != nil {
  116. fmt.Println("failed to create session,", err)
  117. return
  118. }
  119. svc := emr.New(sess)
  120. params := &emr.AddTagsInput{
  121. ResourceId: aws.String("ResourceId"), // Required
  122. Tags: []*emr.Tag{ // Required
  123. { // Required
  124. Key: aws.String("String"),
  125. Value: aws.String("String"),
  126. },
  127. // More values...
  128. },
  129. }
  130. resp, err := svc.AddTags(params)
  131. if err != nil {
  132. // Print the error, cast err to awserr.Error to get the Code and
  133. // Message from an error.
  134. fmt.Println(err.Error())
  135. return
  136. }
  137. // Pretty-print the response data.
  138. fmt.Println(resp)
  139. }
  140. func ExampleEMR_DescribeCluster() {
  141. sess, err := session.NewSession()
  142. if err != nil {
  143. fmt.Println("failed to create session,", err)
  144. return
  145. }
  146. svc := emr.New(sess)
  147. params := &emr.DescribeClusterInput{
  148. ClusterId: aws.String("ClusterId"), // Required
  149. }
  150. resp, err := svc.DescribeCluster(params)
  151. if err != nil {
  152. // Print the error, cast err to awserr.Error to get the Code and
  153. // Message from an error.
  154. fmt.Println(err.Error())
  155. return
  156. }
  157. // Pretty-print the response data.
  158. fmt.Println(resp)
  159. }
  160. func ExampleEMR_DescribeJobFlows() {
  161. sess, err := session.NewSession()
  162. if err != nil {
  163. fmt.Println("failed to create session,", err)
  164. return
  165. }
  166. svc := emr.New(sess)
  167. params := &emr.DescribeJobFlowsInput{
  168. CreatedAfter: aws.Time(time.Now()),
  169. CreatedBefore: aws.Time(time.Now()),
  170. JobFlowIds: []*string{
  171. aws.String("XmlString"), // Required
  172. // More values...
  173. },
  174. JobFlowStates: []*string{
  175. aws.String("JobFlowExecutionState"), // Required
  176. // More values...
  177. },
  178. }
  179. resp, err := svc.DescribeJobFlows(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 ExampleEMR_DescribeStep() {
  190. sess, err := session.NewSession()
  191. if err != nil {
  192. fmt.Println("failed to create session,", err)
  193. return
  194. }
  195. svc := emr.New(sess)
  196. params := &emr.DescribeStepInput{
  197. ClusterId: aws.String("ClusterId"), // Required
  198. StepId: aws.String("StepId"), // Required
  199. }
  200. resp, err := svc.DescribeStep(params)
  201. if err != nil {
  202. // Print the error, cast err to awserr.Error to get the Code and
  203. // Message from an error.
  204. fmt.Println(err.Error())
  205. return
  206. }
  207. // Pretty-print the response data.
  208. fmt.Println(resp)
  209. }
  210. func ExampleEMR_ListBootstrapActions() {
  211. sess, err := session.NewSession()
  212. if err != nil {
  213. fmt.Println("failed to create session,", err)
  214. return
  215. }
  216. svc := emr.New(sess)
  217. params := &emr.ListBootstrapActionsInput{
  218. ClusterId: aws.String("ClusterId"), // Required
  219. Marker: aws.String("Marker"),
  220. }
  221. resp, err := svc.ListBootstrapActions(params)
  222. if err != nil {
  223. // Print the error, cast err to awserr.Error to get the Code and
  224. // Message from an error.
  225. fmt.Println(err.Error())
  226. return
  227. }
  228. // Pretty-print the response data.
  229. fmt.Println(resp)
  230. }
  231. func ExampleEMR_ListClusters() {
  232. sess, err := session.NewSession()
  233. if err != nil {
  234. fmt.Println("failed to create session,", err)
  235. return
  236. }
  237. svc := emr.New(sess)
  238. params := &emr.ListClustersInput{
  239. ClusterStates: []*string{
  240. aws.String("ClusterState"), // Required
  241. // More values...
  242. },
  243. CreatedAfter: aws.Time(time.Now()),
  244. CreatedBefore: aws.Time(time.Now()),
  245. Marker: aws.String("Marker"),
  246. }
  247. resp, err := svc.ListClusters(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 ExampleEMR_ListInstanceGroups() {
  258. sess, err := session.NewSession()
  259. if err != nil {
  260. fmt.Println("failed to create session,", err)
  261. return
  262. }
  263. svc := emr.New(sess)
  264. params := &emr.ListInstanceGroupsInput{
  265. ClusterId: aws.String("ClusterId"), // Required
  266. Marker: aws.String("Marker"),
  267. }
  268. resp, err := svc.ListInstanceGroups(params)
  269. if err != nil {
  270. // Print the error, cast err to awserr.Error to get the Code and
  271. // Message from an error.
  272. fmt.Println(err.Error())
  273. return
  274. }
  275. // Pretty-print the response data.
  276. fmt.Println(resp)
  277. }
  278. func ExampleEMR_ListInstances() {
  279. sess, err := session.NewSession()
  280. if err != nil {
  281. fmt.Println("failed to create session,", err)
  282. return
  283. }
  284. svc := emr.New(sess)
  285. params := &emr.ListInstancesInput{
  286. ClusterId: aws.String("ClusterId"), // Required
  287. InstanceGroupId: aws.String("InstanceGroupId"),
  288. InstanceGroupTypes: []*string{
  289. aws.String("InstanceGroupType"), // Required
  290. // More values...
  291. },
  292. InstanceStates: []*string{
  293. aws.String("InstanceState"), // Required
  294. // More values...
  295. },
  296. Marker: aws.String("Marker"),
  297. }
  298. resp, err := svc.ListInstances(params)
  299. if err != nil {
  300. // Print the error, cast err to awserr.Error to get the Code and
  301. // Message from an error.
  302. fmt.Println(err.Error())
  303. return
  304. }
  305. // Pretty-print the response data.
  306. fmt.Println(resp)
  307. }
  308. func ExampleEMR_ListSteps() {
  309. sess, err := session.NewSession()
  310. if err != nil {
  311. fmt.Println("failed to create session,", err)
  312. return
  313. }
  314. svc := emr.New(sess)
  315. params := &emr.ListStepsInput{
  316. ClusterId: aws.String("ClusterId"), // Required
  317. Marker: aws.String("Marker"),
  318. StepIds: []*string{
  319. aws.String("XmlString"), // Required
  320. // More values...
  321. },
  322. StepStates: []*string{
  323. aws.String("StepState"), // Required
  324. // More values...
  325. },
  326. }
  327. resp, err := svc.ListSteps(params)
  328. if err != nil {
  329. // Print the error, cast err to awserr.Error to get the Code and
  330. // Message from an error.
  331. fmt.Println(err.Error())
  332. return
  333. }
  334. // Pretty-print the response data.
  335. fmt.Println(resp)
  336. }
  337. func ExampleEMR_ModifyInstanceGroups() {
  338. sess, err := session.NewSession()
  339. if err != nil {
  340. fmt.Println("failed to create session,", err)
  341. return
  342. }
  343. svc := emr.New(sess)
  344. params := &emr.ModifyInstanceGroupsInput{
  345. InstanceGroups: []*emr.InstanceGroupModifyConfig{
  346. { // Required
  347. InstanceGroupId: aws.String("XmlStringMaxLen256"), // Required
  348. EC2InstanceIdsToTerminate: []*string{
  349. aws.String("InstanceId"), // Required
  350. // More values...
  351. },
  352. InstanceCount: aws.Int64(1),
  353. ShrinkPolicy: &emr.ShrinkPolicy{
  354. DecommissionTimeout: aws.Int64(1),
  355. InstanceResizePolicy: &emr.InstanceResizePolicy{
  356. InstanceTerminationTimeout: aws.Int64(1),
  357. InstancesToProtect: []*string{
  358. aws.String("InstanceId"), // Required
  359. // More values...
  360. },
  361. InstancesToTerminate: []*string{
  362. aws.String("InstanceId"), // Required
  363. // More values...
  364. },
  365. },
  366. },
  367. },
  368. // More values...
  369. },
  370. }
  371. resp, err := svc.ModifyInstanceGroups(params)
  372. if err != nil {
  373. // Print the error, cast err to awserr.Error to get the Code and
  374. // Message from an error.
  375. fmt.Println(err.Error())
  376. return
  377. }
  378. // Pretty-print the response data.
  379. fmt.Println(resp)
  380. }
  381. func ExampleEMR_RemoveTags() {
  382. sess, err := session.NewSession()
  383. if err != nil {
  384. fmt.Println("failed to create session,", err)
  385. return
  386. }
  387. svc := emr.New(sess)
  388. params := &emr.RemoveTagsInput{
  389. ResourceId: aws.String("ResourceId"), // Required
  390. TagKeys: []*string{ // Required
  391. aws.String("String"), // Required
  392. // More values...
  393. },
  394. }
  395. resp, err := svc.RemoveTags(params)
  396. if err != nil {
  397. // Print the error, cast err to awserr.Error to get the Code and
  398. // Message from an error.
  399. fmt.Println(err.Error())
  400. return
  401. }
  402. // Pretty-print the response data.
  403. fmt.Println(resp)
  404. }
  405. func ExampleEMR_RunJobFlow() {
  406. sess, err := session.NewSession()
  407. if err != nil {
  408. fmt.Println("failed to create session,", err)
  409. return
  410. }
  411. svc := emr.New(sess)
  412. params := &emr.RunJobFlowInput{
  413. Instances: &emr.JobFlowInstancesConfig{ // Required
  414. AdditionalMasterSecurityGroups: []*string{
  415. aws.String("XmlStringMaxLen256"), // Required
  416. // More values...
  417. },
  418. AdditionalSlaveSecurityGroups: []*string{
  419. aws.String("XmlStringMaxLen256"), // Required
  420. // More values...
  421. },
  422. Ec2KeyName: aws.String("XmlStringMaxLen256"),
  423. Ec2SubnetId: aws.String("XmlStringMaxLen256"),
  424. EmrManagedMasterSecurityGroup: aws.String("XmlStringMaxLen256"),
  425. EmrManagedSlaveSecurityGroup: aws.String("XmlStringMaxLen256"),
  426. HadoopVersion: aws.String("XmlStringMaxLen256"),
  427. InstanceCount: aws.Int64(1),
  428. InstanceGroups: []*emr.InstanceGroupConfig{
  429. { // Required
  430. InstanceCount: aws.Int64(1), // Required
  431. InstanceRole: aws.String("InstanceRoleType"), // Required
  432. InstanceType: aws.String("InstanceType"), // Required
  433. BidPrice: aws.String("XmlStringMaxLen256"),
  434. Configurations: []*emr.Configuration{
  435. { // Required
  436. Classification: aws.String("String"),
  437. Configurations: []*emr.Configuration{
  438. // Recursive values...
  439. },
  440. Properties: map[string]*string{
  441. "Key": aws.String("String"), // Required
  442. // More values...
  443. },
  444. },
  445. // More values...
  446. },
  447. EbsConfiguration: &emr.EbsConfiguration{
  448. EbsBlockDeviceConfigs: []*emr.EbsBlockDeviceConfig{
  449. { // Required
  450. VolumeSpecification: &emr.VolumeSpecification{ // Required
  451. SizeInGB: aws.Int64(1), // Required
  452. VolumeType: aws.String("String"), // Required
  453. Iops: aws.Int64(1),
  454. },
  455. VolumesPerInstance: aws.Int64(1),
  456. },
  457. // More values...
  458. },
  459. EbsOptimized: aws.Bool(true),
  460. },
  461. Market: aws.String("MarketType"),
  462. Name: aws.String("XmlStringMaxLen256"),
  463. },
  464. // More values...
  465. },
  466. KeepJobFlowAliveWhenNoSteps: aws.Bool(true),
  467. MasterInstanceType: aws.String("InstanceType"),
  468. Placement: &emr.PlacementType{
  469. AvailabilityZone: aws.String("XmlString"), // Required
  470. },
  471. ServiceAccessSecurityGroup: aws.String("XmlStringMaxLen256"),
  472. SlaveInstanceType: aws.String("InstanceType"),
  473. TerminationProtected: aws.Bool(true),
  474. },
  475. Name: aws.String("XmlStringMaxLen256"), // Required
  476. AdditionalInfo: aws.String("XmlString"),
  477. AmiVersion: aws.String("XmlStringMaxLen256"),
  478. Applications: []*emr.Application{
  479. { // Required
  480. AdditionalInfo: map[string]*string{
  481. "Key": aws.String("String"), // Required
  482. // More values...
  483. },
  484. Args: []*string{
  485. aws.String("String"), // Required
  486. // More values...
  487. },
  488. Name: aws.String("String"),
  489. Version: aws.String("String"),
  490. },
  491. // More values...
  492. },
  493. BootstrapActions: []*emr.BootstrapActionConfig{
  494. { // Required
  495. Name: aws.String("XmlStringMaxLen256"), // Required
  496. ScriptBootstrapAction: &emr.ScriptBootstrapActionConfig{ // Required
  497. Path: aws.String("XmlString"), // Required
  498. Args: []*string{
  499. aws.String("XmlString"), // Required
  500. // More values...
  501. },
  502. },
  503. },
  504. // More values...
  505. },
  506. Configurations: []*emr.Configuration{
  507. { // Required
  508. Classification: aws.String("String"),
  509. Configurations: []*emr.Configuration{
  510. // Recursive values...
  511. },
  512. Properties: map[string]*string{
  513. "Key": aws.String("String"), // Required
  514. // More values...
  515. },
  516. },
  517. // More values...
  518. },
  519. JobFlowRole: aws.String("XmlString"),
  520. LogUri: aws.String("XmlString"),
  521. NewSupportedProducts: []*emr.SupportedProductConfig{
  522. { // Required
  523. Args: []*string{
  524. aws.String("XmlString"), // Required
  525. // More values...
  526. },
  527. Name: aws.String("XmlStringMaxLen256"),
  528. },
  529. // More values...
  530. },
  531. ReleaseLabel: aws.String("XmlStringMaxLen256"),
  532. ServiceRole: aws.String("XmlString"),
  533. Steps: []*emr.StepConfig{
  534. { // Required
  535. HadoopJarStep: &emr.HadoopJarStepConfig{ // Required
  536. Jar: aws.String("XmlString"), // Required
  537. Args: []*string{
  538. aws.String("XmlString"), // Required
  539. // More values...
  540. },
  541. MainClass: aws.String("XmlString"),
  542. Properties: []*emr.KeyValue{
  543. { // Required
  544. Key: aws.String("XmlString"),
  545. Value: aws.String("XmlString"),
  546. },
  547. // More values...
  548. },
  549. },
  550. Name: aws.String("XmlStringMaxLen256"), // Required
  551. ActionOnFailure: aws.String("ActionOnFailure"),
  552. },
  553. // More values...
  554. },
  555. SupportedProducts: []*string{
  556. aws.String("XmlStringMaxLen256"), // Required
  557. // More values...
  558. },
  559. Tags: []*emr.Tag{
  560. { // Required
  561. Key: aws.String("String"),
  562. Value: aws.String("String"),
  563. },
  564. // More values...
  565. },
  566. VisibleToAllUsers: aws.Bool(true),
  567. }
  568. resp, err := svc.RunJobFlow(params)
  569. if err != nil {
  570. // Print the error, cast err to awserr.Error to get the Code and
  571. // Message from an error.
  572. fmt.Println(err.Error())
  573. return
  574. }
  575. // Pretty-print the response data.
  576. fmt.Println(resp)
  577. }
  578. func ExampleEMR_SetTerminationProtection() {
  579. sess, err := session.NewSession()
  580. if err != nil {
  581. fmt.Println("failed to create session,", err)
  582. return
  583. }
  584. svc := emr.New(sess)
  585. params := &emr.SetTerminationProtectionInput{
  586. JobFlowIds: []*string{ // Required
  587. aws.String("XmlString"), // Required
  588. // More values...
  589. },
  590. TerminationProtected: aws.Bool(true), // Required
  591. }
  592. resp, err := svc.SetTerminationProtection(params)
  593. if err != nil {
  594. // Print the error, cast err to awserr.Error to get the Code and
  595. // Message from an error.
  596. fmt.Println(err.Error())
  597. return
  598. }
  599. // Pretty-print the response data.
  600. fmt.Println(resp)
  601. }
  602. func ExampleEMR_SetVisibleToAllUsers() {
  603. sess, err := session.NewSession()
  604. if err != nil {
  605. fmt.Println("failed to create session,", err)
  606. return
  607. }
  608. svc := emr.New(sess)
  609. params := &emr.SetVisibleToAllUsersInput{
  610. JobFlowIds: []*string{ // Required
  611. aws.String("XmlString"), // Required
  612. // More values...
  613. },
  614. VisibleToAllUsers: aws.Bool(true), // Required
  615. }
  616. resp, err := svc.SetVisibleToAllUsers(params)
  617. if err != nil {
  618. // Print the error, cast err to awserr.Error to get the Code and
  619. // Message from an error.
  620. fmt.Println(err.Error())
  621. return
  622. }
  623. // Pretty-print the response data.
  624. fmt.Println(resp)
  625. }
  626. func ExampleEMR_TerminateJobFlows() {
  627. sess, err := session.NewSession()
  628. if err != nil {
  629. fmt.Println("failed to create session,", err)
  630. return
  631. }
  632. svc := emr.New(sess)
  633. params := &emr.TerminateJobFlowsInput{
  634. JobFlowIds: []*string{ // Required
  635. aws.String("XmlString"), // Required
  636. // More values...
  637. },
  638. }
  639. resp, err := svc.TerminateJobFlows(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. }