examples_test.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package workspaces_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/workspaces"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleWorkSpaces_CreateTags() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := workspaces.New(sess)
  20. params := &workspaces.CreateTagsInput{
  21. ResourceId: aws.String("NonEmptyString"), // Required
  22. Tags: []*workspaces.Tag{ // Required
  23. { // Required
  24. Key: aws.String("TagKey"), // Required
  25. Value: aws.String("TagValue"),
  26. },
  27. // More values...
  28. },
  29. }
  30. resp, err := svc.CreateTags(params)
  31. if err != nil {
  32. // Print the error, cast err to awserr.Error to get the Code and
  33. // Message from an error.
  34. fmt.Println(err.Error())
  35. return
  36. }
  37. // Pretty-print the response data.
  38. fmt.Println(resp)
  39. }
  40. func ExampleWorkSpaces_CreateWorkspaces() {
  41. sess, err := session.NewSession()
  42. if err != nil {
  43. fmt.Println("failed to create session,", err)
  44. return
  45. }
  46. svc := workspaces.New(sess)
  47. params := &workspaces.CreateWorkspacesInput{
  48. Workspaces: []*workspaces.WorkspaceRequest{ // Required
  49. { // Required
  50. BundleId: aws.String("BundleId"), // Required
  51. DirectoryId: aws.String("DirectoryId"), // Required
  52. UserName: aws.String("UserName"), // Required
  53. RootVolumeEncryptionEnabled: aws.Bool(true),
  54. Tags: []*workspaces.Tag{
  55. { // Required
  56. Key: aws.String("TagKey"), // Required
  57. Value: aws.String("TagValue"),
  58. },
  59. // More values...
  60. },
  61. UserVolumeEncryptionEnabled: aws.Bool(true),
  62. VolumeEncryptionKey: aws.String("VolumeEncryptionKey"),
  63. WorkspaceProperties: &workspaces.WorkspaceProperties{
  64. RunningMode: aws.String("RunningMode"),
  65. RunningModeAutoStopTimeoutInMinutes: aws.Int64(1),
  66. },
  67. },
  68. // More values...
  69. },
  70. }
  71. resp, err := svc.CreateWorkspaces(params)
  72. if err != nil {
  73. // Print the error, cast err to awserr.Error to get the Code and
  74. // Message from an error.
  75. fmt.Println(err.Error())
  76. return
  77. }
  78. // Pretty-print the response data.
  79. fmt.Println(resp)
  80. }
  81. func ExampleWorkSpaces_DeleteTags() {
  82. sess, err := session.NewSession()
  83. if err != nil {
  84. fmt.Println("failed to create session,", err)
  85. return
  86. }
  87. svc := workspaces.New(sess)
  88. params := &workspaces.DeleteTagsInput{
  89. ResourceId: aws.String("NonEmptyString"), // Required
  90. TagKeys: []*string{ // Required
  91. aws.String("NonEmptyString"), // Required
  92. // More values...
  93. },
  94. }
  95. resp, err := svc.DeleteTags(params)
  96. if err != nil {
  97. // Print the error, cast err to awserr.Error to get the Code and
  98. // Message from an error.
  99. fmt.Println(err.Error())
  100. return
  101. }
  102. // Pretty-print the response data.
  103. fmt.Println(resp)
  104. }
  105. func ExampleWorkSpaces_DescribeTags() {
  106. sess, err := session.NewSession()
  107. if err != nil {
  108. fmt.Println("failed to create session,", err)
  109. return
  110. }
  111. svc := workspaces.New(sess)
  112. params := &workspaces.DescribeTagsInput{
  113. ResourceId: aws.String("NonEmptyString"), // Required
  114. }
  115. resp, err := svc.DescribeTags(params)
  116. if err != nil {
  117. // Print the error, cast err to awserr.Error to get the Code and
  118. // Message from an error.
  119. fmt.Println(err.Error())
  120. return
  121. }
  122. // Pretty-print the response data.
  123. fmt.Println(resp)
  124. }
  125. func ExampleWorkSpaces_DescribeWorkspaceBundles() {
  126. sess, err := session.NewSession()
  127. if err != nil {
  128. fmt.Println("failed to create session,", err)
  129. return
  130. }
  131. svc := workspaces.New(sess)
  132. params := &workspaces.DescribeWorkspaceBundlesInput{
  133. BundleIds: []*string{
  134. aws.String("BundleId"), // Required
  135. // More values...
  136. },
  137. NextToken: aws.String("PaginationToken"),
  138. Owner: aws.String("BundleOwner"),
  139. }
  140. resp, err := svc.DescribeWorkspaceBundles(params)
  141. if err != nil {
  142. // Print the error, cast err to awserr.Error to get the Code and
  143. // Message from an error.
  144. fmt.Println(err.Error())
  145. return
  146. }
  147. // Pretty-print the response data.
  148. fmt.Println(resp)
  149. }
  150. func ExampleWorkSpaces_DescribeWorkspaceDirectories() {
  151. sess, err := session.NewSession()
  152. if err != nil {
  153. fmt.Println("failed to create session,", err)
  154. return
  155. }
  156. svc := workspaces.New(sess)
  157. params := &workspaces.DescribeWorkspaceDirectoriesInput{
  158. DirectoryIds: []*string{
  159. aws.String("DirectoryId"), // Required
  160. // More values...
  161. },
  162. NextToken: aws.String("PaginationToken"),
  163. }
  164. resp, err := svc.DescribeWorkspaceDirectories(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 ExampleWorkSpaces_DescribeWorkspaces() {
  175. sess, err := session.NewSession()
  176. if err != nil {
  177. fmt.Println("failed to create session,", err)
  178. return
  179. }
  180. svc := workspaces.New(sess)
  181. params := &workspaces.DescribeWorkspacesInput{
  182. BundleId: aws.String("BundleId"),
  183. DirectoryId: aws.String("DirectoryId"),
  184. Limit: aws.Int64(1),
  185. NextToken: aws.String("PaginationToken"),
  186. UserName: aws.String("UserName"),
  187. WorkspaceIds: []*string{
  188. aws.String("WorkspaceId"), // Required
  189. // More values...
  190. },
  191. }
  192. resp, err := svc.DescribeWorkspaces(params)
  193. if err != nil {
  194. // Print the error, cast err to awserr.Error to get the Code and
  195. // Message from an error.
  196. fmt.Println(err.Error())
  197. return
  198. }
  199. // Pretty-print the response data.
  200. fmt.Println(resp)
  201. }
  202. func ExampleWorkSpaces_DescribeWorkspacesConnectionStatus() {
  203. sess, err := session.NewSession()
  204. if err != nil {
  205. fmt.Println("failed to create session,", err)
  206. return
  207. }
  208. svc := workspaces.New(sess)
  209. params := &workspaces.DescribeWorkspacesConnectionStatusInput{
  210. NextToken: aws.String("PaginationToken"),
  211. WorkspaceIds: []*string{
  212. aws.String("WorkspaceId"), // Required
  213. // More values...
  214. },
  215. }
  216. resp, err := svc.DescribeWorkspacesConnectionStatus(params)
  217. if err != nil {
  218. // Print the error, cast err to awserr.Error to get the Code and
  219. // Message from an error.
  220. fmt.Println(err.Error())
  221. return
  222. }
  223. // Pretty-print the response data.
  224. fmt.Println(resp)
  225. }
  226. func ExampleWorkSpaces_ModifyWorkspaceProperties() {
  227. sess, err := session.NewSession()
  228. if err != nil {
  229. fmt.Println("failed to create session,", err)
  230. return
  231. }
  232. svc := workspaces.New(sess)
  233. params := &workspaces.ModifyWorkspacePropertiesInput{
  234. WorkspaceId: aws.String("WorkspaceId"), // Required
  235. WorkspaceProperties: &workspaces.WorkspaceProperties{ // Required
  236. RunningMode: aws.String("RunningMode"),
  237. RunningModeAutoStopTimeoutInMinutes: aws.Int64(1),
  238. },
  239. }
  240. resp, err := svc.ModifyWorkspaceProperties(params)
  241. if err != nil {
  242. // Print the error, cast err to awserr.Error to get the Code and
  243. // Message from an error.
  244. fmt.Println(err.Error())
  245. return
  246. }
  247. // Pretty-print the response data.
  248. fmt.Println(resp)
  249. }
  250. func ExampleWorkSpaces_RebootWorkspaces() {
  251. sess, err := session.NewSession()
  252. if err != nil {
  253. fmt.Println("failed to create session,", err)
  254. return
  255. }
  256. svc := workspaces.New(sess)
  257. params := &workspaces.RebootWorkspacesInput{
  258. RebootWorkspaceRequests: []*workspaces.RebootRequest{ // Required
  259. { // Required
  260. WorkspaceId: aws.String("WorkspaceId"), // Required
  261. },
  262. // More values...
  263. },
  264. }
  265. resp, err := svc.RebootWorkspaces(params)
  266. if err != nil {
  267. // Print the error, cast err to awserr.Error to get the Code and
  268. // Message from an error.
  269. fmt.Println(err.Error())
  270. return
  271. }
  272. // Pretty-print the response data.
  273. fmt.Println(resp)
  274. }
  275. func ExampleWorkSpaces_RebuildWorkspaces() {
  276. sess, err := session.NewSession()
  277. if err != nil {
  278. fmt.Println("failed to create session,", err)
  279. return
  280. }
  281. svc := workspaces.New(sess)
  282. params := &workspaces.RebuildWorkspacesInput{
  283. RebuildWorkspaceRequests: []*workspaces.RebuildRequest{ // Required
  284. { // Required
  285. WorkspaceId: aws.String("WorkspaceId"), // Required
  286. },
  287. // More values...
  288. },
  289. }
  290. resp, err := svc.RebuildWorkspaces(params)
  291. if err != nil {
  292. // Print the error, cast err to awserr.Error to get the Code and
  293. // Message from an error.
  294. fmt.Println(err.Error())
  295. return
  296. }
  297. // Pretty-print the response data.
  298. fmt.Println(resp)
  299. }
  300. func ExampleWorkSpaces_StartWorkspaces() {
  301. sess, err := session.NewSession()
  302. if err != nil {
  303. fmt.Println("failed to create session,", err)
  304. return
  305. }
  306. svc := workspaces.New(sess)
  307. params := &workspaces.StartWorkspacesInput{
  308. StartWorkspaceRequests: []*workspaces.StartRequest{ // Required
  309. { // Required
  310. WorkspaceId: aws.String("WorkspaceId"),
  311. },
  312. // More values...
  313. },
  314. }
  315. resp, err := svc.StartWorkspaces(params)
  316. if err != nil {
  317. // Print the error, cast err to awserr.Error to get the Code and
  318. // Message from an error.
  319. fmt.Println(err.Error())
  320. return
  321. }
  322. // Pretty-print the response data.
  323. fmt.Println(resp)
  324. }
  325. func ExampleWorkSpaces_StopWorkspaces() {
  326. sess, err := session.NewSession()
  327. if err != nil {
  328. fmt.Println("failed to create session,", err)
  329. return
  330. }
  331. svc := workspaces.New(sess)
  332. params := &workspaces.StopWorkspacesInput{
  333. StopWorkspaceRequests: []*workspaces.StopRequest{ // Required
  334. { // Required
  335. WorkspaceId: aws.String("WorkspaceId"),
  336. },
  337. // More values...
  338. },
  339. }
  340. resp, err := svc.StopWorkspaces(params)
  341. if err != nil {
  342. // Print the error, cast err to awserr.Error to get the Code and
  343. // Message from an error.
  344. fmt.Println(err.Error())
  345. return
  346. }
  347. // Pretty-print the response data.
  348. fmt.Println(resp)
  349. }
  350. func ExampleWorkSpaces_TerminateWorkspaces() {
  351. sess, err := session.NewSession()
  352. if err != nil {
  353. fmt.Println("failed to create session,", err)
  354. return
  355. }
  356. svc := workspaces.New(sess)
  357. params := &workspaces.TerminateWorkspacesInput{
  358. TerminateWorkspaceRequests: []*workspaces.TerminateRequest{ // Required
  359. { // Required
  360. WorkspaceId: aws.String("WorkspaceId"), // Required
  361. },
  362. // More values...
  363. },
  364. }
  365. resp, err := svc.TerminateWorkspaces(params)
  366. if err != nil {
  367. // Print the error, cast err to awserr.Error to get the Code and
  368. // Message from an error.
  369. fmt.Println(err.Error())
  370. return
  371. }
  372. // Pretty-print the response data.
  373. fmt.Println(resp)
  374. }