examples_test.go 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package codecommit_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/codecommit"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleCodeCommit_BatchGetRepositories() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := codecommit.New(sess)
  20. params := &codecommit.BatchGetRepositoriesInput{
  21. RepositoryNames: []*string{ // Required
  22. aws.String("RepositoryName"), // Required
  23. // More values...
  24. },
  25. }
  26. resp, err := svc.BatchGetRepositories(params)
  27. if err != nil {
  28. // Print the error, cast err to awserr.Error to get the Code and
  29. // Message from an error.
  30. fmt.Println(err.Error())
  31. return
  32. }
  33. // Pretty-print the response data.
  34. fmt.Println(resp)
  35. }
  36. func ExampleCodeCommit_CreateBranch() {
  37. sess, err := session.NewSession()
  38. if err != nil {
  39. fmt.Println("failed to create session,", err)
  40. return
  41. }
  42. svc := codecommit.New(sess)
  43. params := &codecommit.CreateBranchInput{
  44. BranchName: aws.String("BranchName"), // Required
  45. CommitId: aws.String("CommitId"), // Required
  46. RepositoryName: aws.String("RepositoryName"), // Required
  47. }
  48. resp, err := svc.CreateBranch(params)
  49. if err != nil {
  50. // Print the error, cast err to awserr.Error to get the Code and
  51. // Message from an error.
  52. fmt.Println(err.Error())
  53. return
  54. }
  55. // Pretty-print the response data.
  56. fmt.Println(resp)
  57. }
  58. func ExampleCodeCommit_CreateRepository() {
  59. sess, err := session.NewSession()
  60. if err != nil {
  61. fmt.Println("failed to create session,", err)
  62. return
  63. }
  64. svc := codecommit.New(sess)
  65. params := &codecommit.CreateRepositoryInput{
  66. RepositoryName: aws.String("RepositoryName"), // Required
  67. RepositoryDescription: aws.String("RepositoryDescription"),
  68. }
  69. resp, err := svc.CreateRepository(params)
  70. if err != nil {
  71. // Print the error, cast err to awserr.Error to get the Code and
  72. // Message from an error.
  73. fmt.Println(err.Error())
  74. return
  75. }
  76. // Pretty-print the response data.
  77. fmt.Println(resp)
  78. }
  79. func ExampleCodeCommit_DeleteRepository() {
  80. sess, err := session.NewSession()
  81. if err != nil {
  82. fmt.Println("failed to create session,", err)
  83. return
  84. }
  85. svc := codecommit.New(sess)
  86. params := &codecommit.DeleteRepositoryInput{
  87. RepositoryName: aws.String("RepositoryName"), // Required
  88. }
  89. resp, err := svc.DeleteRepository(params)
  90. if err != nil {
  91. // Print the error, cast err to awserr.Error to get the Code and
  92. // Message from an error.
  93. fmt.Println(err.Error())
  94. return
  95. }
  96. // Pretty-print the response data.
  97. fmt.Println(resp)
  98. }
  99. func ExampleCodeCommit_GetBranch() {
  100. sess, err := session.NewSession()
  101. if err != nil {
  102. fmt.Println("failed to create session,", err)
  103. return
  104. }
  105. svc := codecommit.New(sess)
  106. params := &codecommit.GetBranchInput{
  107. BranchName: aws.String("BranchName"),
  108. RepositoryName: aws.String("RepositoryName"),
  109. }
  110. resp, err := svc.GetBranch(params)
  111. if err != nil {
  112. // Print the error, cast err to awserr.Error to get the Code and
  113. // Message from an error.
  114. fmt.Println(err.Error())
  115. return
  116. }
  117. // Pretty-print the response data.
  118. fmt.Println(resp)
  119. }
  120. func ExampleCodeCommit_GetCommit() {
  121. sess, err := session.NewSession()
  122. if err != nil {
  123. fmt.Println("failed to create session,", err)
  124. return
  125. }
  126. svc := codecommit.New(sess)
  127. params := &codecommit.GetCommitInput{
  128. CommitId: aws.String("ObjectId"), // Required
  129. RepositoryName: aws.String("RepositoryName"), // Required
  130. }
  131. resp, err := svc.GetCommit(params)
  132. if err != nil {
  133. // Print the error, cast err to awserr.Error to get the Code and
  134. // Message from an error.
  135. fmt.Println(err.Error())
  136. return
  137. }
  138. // Pretty-print the response data.
  139. fmt.Println(resp)
  140. }
  141. func ExampleCodeCommit_GetRepository() {
  142. sess, err := session.NewSession()
  143. if err != nil {
  144. fmt.Println("failed to create session,", err)
  145. return
  146. }
  147. svc := codecommit.New(sess)
  148. params := &codecommit.GetRepositoryInput{
  149. RepositoryName: aws.String("RepositoryName"), // Required
  150. }
  151. resp, err := svc.GetRepository(params)
  152. if err != nil {
  153. // Print the error, cast err to awserr.Error to get the Code and
  154. // Message from an error.
  155. fmt.Println(err.Error())
  156. return
  157. }
  158. // Pretty-print the response data.
  159. fmt.Println(resp)
  160. }
  161. func ExampleCodeCommit_GetRepositoryTriggers() {
  162. sess, err := session.NewSession()
  163. if err != nil {
  164. fmt.Println("failed to create session,", err)
  165. return
  166. }
  167. svc := codecommit.New(sess)
  168. params := &codecommit.GetRepositoryTriggersInput{
  169. RepositoryName: aws.String("RepositoryName"),
  170. }
  171. resp, err := svc.GetRepositoryTriggers(params)
  172. if err != nil {
  173. // Print the error, cast err to awserr.Error to get the Code and
  174. // Message from an error.
  175. fmt.Println(err.Error())
  176. return
  177. }
  178. // Pretty-print the response data.
  179. fmt.Println(resp)
  180. }
  181. func ExampleCodeCommit_ListBranches() {
  182. sess, err := session.NewSession()
  183. if err != nil {
  184. fmt.Println("failed to create session,", err)
  185. return
  186. }
  187. svc := codecommit.New(sess)
  188. params := &codecommit.ListBranchesInput{
  189. RepositoryName: aws.String("RepositoryName"), // Required
  190. NextToken: aws.String("NextToken"),
  191. }
  192. resp, err := svc.ListBranches(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 ExampleCodeCommit_ListRepositories() {
  203. sess, err := session.NewSession()
  204. if err != nil {
  205. fmt.Println("failed to create session,", err)
  206. return
  207. }
  208. svc := codecommit.New(sess)
  209. params := &codecommit.ListRepositoriesInput{
  210. NextToken: aws.String("NextToken"),
  211. Order: aws.String("OrderEnum"),
  212. SortBy: aws.String("SortByEnum"),
  213. }
  214. resp, err := svc.ListRepositories(params)
  215. if err != nil {
  216. // Print the error, cast err to awserr.Error to get the Code and
  217. // Message from an error.
  218. fmt.Println(err.Error())
  219. return
  220. }
  221. // Pretty-print the response data.
  222. fmt.Println(resp)
  223. }
  224. func ExampleCodeCommit_PutRepositoryTriggers() {
  225. sess, err := session.NewSession()
  226. if err != nil {
  227. fmt.Println("failed to create session,", err)
  228. return
  229. }
  230. svc := codecommit.New(sess)
  231. params := &codecommit.PutRepositoryTriggersInput{
  232. RepositoryName: aws.String("RepositoryName"),
  233. Triggers: []*codecommit.RepositoryTrigger{
  234. { // Required
  235. Branches: []*string{
  236. aws.String("BranchName"), // Required
  237. // More values...
  238. },
  239. CustomData: aws.String("RepositoryTriggerCustomData"),
  240. DestinationArn: aws.String("Arn"),
  241. Events: []*string{
  242. aws.String("RepositoryTriggerEventEnum"), // Required
  243. // More values...
  244. },
  245. Name: aws.String("RepositoryTriggerName"),
  246. },
  247. // More values...
  248. },
  249. }
  250. resp, err := svc.PutRepositoryTriggers(params)
  251. if err != nil {
  252. // Print the error, cast err to awserr.Error to get the Code and
  253. // Message from an error.
  254. fmt.Println(err.Error())
  255. return
  256. }
  257. // Pretty-print the response data.
  258. fmt.Println(resp)
  259. }
  260. func ExampleCodeCommit_TestRepositoryTriggers() {
  261. sess, err := session.NewSession()
  262. if err != nil {
  263. fmt.Println("failed to create session,", err)
  264. return
  265. }
  266. svc := codecommit.New(sess)
  267. params := &codecommit.TestRepositoryTriggersInput{
  268. RepositoryName: aws.String("RepositoryName"),
  269. Triggers: []*codecommit.RepositoryTrigger{
  270. { // Required
  271. Branches: []*string{
  272. aws.String("BranchName"), // Required
  273. // More values...
  274. },
  275. CustomData: aws.String("RepositoryTriggerCustomData"),
  276. DestinationArn: aws.String("Arn"),
  277. Events: []*string{
  278. aws.String("RepositoryTriggerEventEnum"), // Required
  279. // More values...
  280. },
  281. Name: aws.String("RepositoryTriggerName"),
  282. },
  283. // More values...
  284. },
  285. }
  286. resp, err := svc.TestRepositoryTriggers(params)
  287. if err != nil {
  288. // Print the error, cast err to awserr.Error to get the Code and
  289. // Message from an error.
  290. fmt.Println(err.Error())
  291. return
  292. }
  293. // Pretty-print the response data.
  294. fmt.Println(resp)
  295. }
  296. func ExampleCodeCommit_UpdateDefaultBranch() {
  297. sess, err := session.NewSession()
  298. if err != nil {
  299. fmt.Println("failed to create session,", err)
  300. return
  301. }
  302. svc := codecommit.New(sess)
  303. params := &codecommit.UpdateDefaultBranchInput{
  304. DefaultBranchName: aws.String("BranchName"), // Required
  305. RepositoryName: aws.String("RepositoryName"), // Required
  306. }
  307. resp, err := svc.UpdateDefaultBranch(params)
  308. if err != nil {
  309. // Print the error, cast err to awserr.Error to get the Code and
  310. // Message from an error.
  311. fmt.Println(err.Error())
  312. return
  313. }
  314. // Pretty-print the response data.
  315. fmt.Println(resp)
  316. }
  317. func ExampleCodeCommit_UpdateRepositoryDescription() {
  318. sess, err := session.NewSession()
  319. if err != nil {
  320. fmt.Println("failed to create session,", err)
  321. return
  322. }
  323. svc := codecommit.New(sess)
  324. params := &codecommit.UpdateRepositoryDescriptionInput{
  325. RepositoryName: aws.String("RepositoryName"), // Required
  326. RepositoryDescription: aws.String("RepositoryDescription"),
  327. }
  328. resp, err := svc.UpdateRepositoryDescription(params)
  329. if err != nil {
  330. // Print the error, cast err to awserr.Error to get the Code and
  331. // Message from an error.
  332. fmt.Println(err.Error())
  333. return
  334. }
  335. // Pretty-print the response data.
  336. fmt.Println(resp)
  337. }
  338. func ExampleCodeCommit_UpdateRepositoryName() {
  339. sess, err := session.NewSession()
  340. if err != nil {
  341. fmt.Println("failed to create session,", err)
  342. return
  343. }
  344. svc := codecommit.New(sess)
  345. params := &codecommit.UpdateRepositoryNameInput{
  346. NewName: aws.String("RepositoryName"), // Required
  347. OldName: aws.String("RepositoryName"), // Required
  348. }
  349. resp, err := svc.UpdateRepositoryName(params)
  350. if err != nil {
  351. // Print the error, cast err to awserr.Error to get the Code and
  352. // Message from an error.
  353. fmt.Println(err.Error())
  354. return
  355. }
  356. // Pretty-print the response data.
  357. fmt.Println(resp)
  358. }