examples_test.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package budgets_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/budgets"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleBudgets_CreateBudget() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := budgets.New(sess)
  20. params := &budgets.CreateBudgetInput{
  21. AccountId: aws.String("AccountId"), // Required
  22. Budget: &budgets.Budget{ // Required
  23. BudgetLimit: &budgets.Spend{ // Required
  24. Amount: aws.String("NumericValue"), // Required
  25. Unit: aws.String("GenericString"), // Required
  26. },
  27. BudgetName: aws.String("BudgetName"), // Required
  28. BudgetType: aws.String("BudgetType"), // Required
  29. CostTypes: &budgets.CostTypes{ // Required
  30. IncludeSubscription: aws.Bool(true), // Required
  31. IncludeTax: aws.Bool(true), // Required
  32. UseBlended: aws.Bool(true), // Required
  33. },
  34. TimePeriod: &budgets.TimePeriod{ // Required
  35. End: aws.Time(time.Now()), // Required
  36. Start: aws.Time(time.Now()), // Required
  37. },
  38. TimeUnit: aws.String("TimeUnit"), // Required
  39. CalculatedSpend: &budgets.CalculatedSpend{
  40. ActualSpend: &budgets.Spend{ // Required
  41. Amount: aws.String("NumericValue"), // Required
  42. Unit: aws.String("GenericString"), // Required
  43. },
  44. ForecastedSpend: &budgets.Spend{
  45. Amount: aws.String("NumericValue"), // Required
  46. Unit: aws.String("GenericString"), // Required
  47. },
  48. },
  49. CostFilters: map[string][]*string{
  50. "Key": { // Required
  51. aws.String("GenericString"), // Required
  52. // More values...
  53. },
  54. // More values...
  55. },
  56. },
  57. NotificationsWithSubscribers: []*budgets.NotificationWithSubscribers{
  58. { // Required
  59. Notification: &budgets.Notification{ // Required
  60. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  61. NotificationType: aws.String("NotificationType"), // Required
  62. Threshold: aws.Float64(1.0), // Required
  63. },
  64. Subscribers: []*budgets.Subscriber{ // Required
  65. { // Required
  66. Address: aws.String("GenericString"), // Required
  67. SubscriptionType: aws.String("SubscriptionType"), // Required
  68. },
  69. // More values...
  70. },
  71. },
  72. // More values...
  73. },
  74. }
  75. resp, err := svc.CreateBudget(params)
  76. if err != nil {
  77. // Print the error, cast err to awserr.Error to get the Code and
  78. // Message from an error.
  79. fmt.Println(err.Error())
  80. return
  81. }
  82. // Pretty-print the response data.
  83. fmt.Println(resp)
  84. }
  85. func ExampleBudgets_CreateNotification() {
  86. sess, err := session.NewSession()
  87. if err != nil {
  88. fmt.Println("failed to create session,", err)
  89. return
  90. }
  91. svc := budgets.New(sess)
  92. params := &budgets.CreateNotificationInput{
  93. AccountId: aws.String("AccountId"), // Required
  94. BudgetName: aws.String("BudgetName"), // Required
  95. Notification: &budgets.Notification{ // Required
  96. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  97. NotificationType: aws.String("NotificationType"), // Required
  98. Threshold: aws.Float64(1.0), // Required
  99. },
  100. Subscribers: []*budgets.Subscriber{ // Required
  101. { // Required
  102. Address: aws.String("GenericString"), // Required
  103. SubscriptionType: aws.String("SubscriptionType"), // Required
  104. },
  105. // More values...
  106. },
  107. }
  108. resp, err := svc.CreateNotification(params)
  109. if err != nil {
  110. // Print the error, cast err to awserr.Error to get the Code and
  111. // Message from an error.
  112. fmt.Println(err.Error())
  113. return
  114. }
  115. // Pretty-print the response data.
  116. fmt.Println(resp)
  117. }
  118. func ExampleBudgets_CreateSubscriber() {
  119. sess, err := session.NewSession()
  120. if err != nil {
  121. fmt.Println("failed to create session,", err)
  122. return
  123. }
  124. svc := budgets.New(sess)
  125. params := &budgets.CreateSubscriberInput{
  126. AccountId: aws.String("AccountId"), // Required
  127. BudgetName: aws.String("BudgetName"), // Required
  128. Notification: &budgets.Notification{ // Required
  129. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  130. NotificationType: aws.String("NotificationType"), // Required
  131. Threshold: aws.Float64(1.0), // Required
  132. },
  133. Subscriber: &budgets.Subscriber{ // Required
  134. Address: aws.String("GenericString"), // Required
  135. SubscriptionType: aws.String("SubscriptionType"), // Required
  136. },
  137. }
  138. resp, err := svc.CreateSubscriber(params)
  139. if err != nil {
  140. // Print the error, cast err to awserr.Error to get the Code and
  141. // Message from an error.
  142. fmt.Println(err.Error())
  143. return
  144. }
  145. // Pretty-print the response data.
  146. fmt.Println(resp)
  147. }
  148. func ExampleBudgets_DeleteBudget() {
  149. sess, err := session.NewSession()
  150. if err != nil {
  151. fmt.Println("failed to create session,", err)
  152. return
  153. }
  154. svc := budgets.New(sess)
  155. params := &budgets.DeleteBudgetInput{
  156. AccountId: aws.String("AccountId"), // Required
  157. BudgetName: aws.String("BudgetName"), // Required
  158. }
  159. resp, err := svc.DeleteBudget(params)
  160. if err != nil {
  161. // Print the error, cast err to awserr.Error to get the Code and
  162. // Message from an error.
  163. fmt.Println(err.Error())
  164. return
  165. }
  166. // Pretty-print the response data.
  167. fmt.Println(resp)
  168. }
  169. func ExampleBudgets_DeleteNotification() {
  170. sess, err := session.NewSession()
  171. if err != nil {
  172. fmt.Println("failed to create session,", err)
  173. return
  174. }
  175. svc := budgets.New(sess)
  176. params := &budgets.DeleteNotificationInput{
  177. AccountId: aws.String("AccountId"), // Required
  178. BudgetName: aws.String("BudgetName"), // Required
  179. Notification: &budgets.Notification{ // Required
  180. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  181. NotificationType: aws.String("NotificationType"), // Required
  182. Threshold: aws.Float64(1.0), // Required
  183. },
  184. }
  185. resp, err := svc.DeleteNotification(params)
  186. if err != nil {
  187. // Print the error, cast err to awserr.Error to get the Code and
  188. // Message from an error.
  189. fmt.Println(err.Error())
  190. return
  191. }
  192. // Pretty-print the response data.
  193. fmt.Println(resp)
  194. }
  195. func ExampleBudgets_DeleteSubscriber() {
  196. sess, err := session.NewSession()
  197. if err != nil {
  198. fmt.Println("failed to create session,", err)
  199. return
  200. }
  201. svc := budgets.New(sess)
  202. params := &budgets.DeleteSubscriberInput{
  203. AccountId: aws.String("AccountId"), // Required
  204. BudgetName: aws.String("BudgetName"), // Required
  205. Notification: &budgets.Notification{ // Required
  206. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  207. NotificationType: aws.String("NotificationType"), // Required
  208. Threshold: aws.Float64(1.0), // Required
  209. },
  210. Subscriber: &budgets.Subscriber{ // Required
  211. Address: aws.String("GenericString"), // Required
  212. SubscriptionType: aws.String("SubscriptionType"), // Required
  213. },
  214. }
  215. resp, err := svc.DeleteSubscriber(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 ExampleBudgets_DescribeBudget() {
  226. sess, err := session.NewSession()
  227. if err != nil {
  228. fmt.Println("failed to create session,", err)
  229. return
  230. }
  231. svc := budgets.New(sess)
  232. params := &budgets.DescribeBudgetInput{
  233. AccountId: aws.String("AccountId"), // Required
  234. BudgetName: aws.String("BudgetName"), // Required
  235. }
  236. resp, err := svc.DescribeBudget(params)
  237. if err != nil {
  238. // Print the error, cast err to awserr.Error to get the Code and
  239. // Message from an error.
  240. fmt.Println(err.Error())
  241. return
  242. }
  243. // Pretty-print the response data.
  244. fmt.Println(resp)
  245. }
  246. func ExampleBudgets_DescribeBudgets() {
  247. sess, err := session.NewSession()
  248. if err != nil {
  249. fmt.Println("failed to create session,", err)
  250. return
  251. }
  252. svc := budgets.New(sess)
  253. params := &budgets.DescribeBudgetsInput{
  254. AccountId: aws.String("AccountId"), // Required
  255. MaxResults: aws.Int64(1),
  256. NextToken: aws.String("GenericString"),
  257. }
  258. resp, err := svc.DescribeBudgets(params)
  259. if err != nil {
  260. // Print the error, cast err to awserr.Error to get the Code and
  261. // Message from an error.
  262. fmt.Println(err.Error())
  263. return
  264. }
  265. // Pretty-print the response data.
  266. fmt.Println(resp)
  267. }
  268. func ExampleBudgets_DescribeNotificationsForBudget() {
  269. sess, err := session.NewSession()
  270. if err != nil {
  271. fmt.Println("failed to create session,", err)
  272. return
  273. }
  274. svc := budgets.New(sess)
  275. params := &budgets.DescribeNotificationsForBudgetInput{
  276. AccountId: aws.String("AccountId"), // Required
  277. BudgetName: aws.String("BudgetName"), // Required
  278. MaxResults: aws.Int64(1),
  279. NextToken: aws.String("GenericString"),
  280. }
  281. resp, err := svc.DescribeNotificationsForBudget(params)
  282. if err != nil {
  283. // Print the error, cast err to awserr.Error to get the Code and
  284. // Message from an error.
  285. fmt.Println(err.Error())
  286. return
  287. }
  288. // Pretty-print the response data.
  289. fmt.Println(resp)
  290. }
  291. func ExampleBudgets_DescribeSubscribersForNotification() {
  292. sess, err := session.NewSession()
  293. if err != nil {
  294. fmt.Println("failed to create session,", err)
  295. return
  296. }
  297. svc := budgets.New(sess)
  298. params := &budgets.DescribeSubscribersForNotificationInput{
  299. AccountId: aws.String("AccountId"), // Required
  300. BudgetName: aws.String("BudgetName"), // Required
  301. Notification: &budgets.Notification{ // Required
  302. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  303. NotificationType: aws.String("NotificationType"), // Required
  304. Threshold: aws.Float64(1.0), // Required
  305. },
  306. MaxResults: aws.Int64(1),
  307. NextToken: aws.String("GenericString"),
  308. }
  309. resp, err := svc.DescribeSubscribersForNotification(params)
  310. if err != nil {
  311. // Print the error, cast err to awserr.Error to get the Code and
  312. // Message from an error.
  313. fmt.Println(err.Error())
  314. return
  315. }
  316. // Pretty-print the response data.
  317. fmt.Println(resp)
  318. }
  319. func ExampleBudgets_UpdateBudget() {
  320. sess, err := session.NewSession()
  321. if err != nil {
  322. fmt.Println("failed to create session,", err)
  323. return
  324. }
  325. svc := budgets.New(sess)
  326. params := &budgets.UpdateBudgetInput{
  327. AccountId: aws.String("AccountId"), // Required
  328. NewBudget: &budgets.Budget{ // Required
  329. BudgetLimit: &budgets.Spend{ // Required
  330. Amount: aws.String("NumericValue"), // Required
  331. Unit: aws.String("GenericString"), // Required
  332. },
  333. BudgetName: aws.String("BudgetName"), // Required
  334. BudgetType: aws.String("BudgetType"), // Required
  335. CostTypes: &budgets.CostTypes{ // Required
  336. IncludeSubscription: aws.Bool(true), // Required
  337. IncludeTax: aws.Bool(true), // Required
  338. UseBlended: aws.Bool(true), // Required
  339. },
  340. TimePeriod: &budgets.TimePeriod{ // Required
  341. End: aws.Time(time.Now()), // Required
  342. Start: aws.Time(time.Now()), // Required
  343. },
  344. TimeUnit: aws.String("TimeUnit"), // Required
  345. CalculatedSpend: &budgets.CalculatedSpend{
  346. ActualSpend: &budgets.Spend{ // Required
  347. Amount: aws.String("NumericValue"), // Required
  348. Unit: aws.String("GenericString"), // Required
  349. },
  350. ForecastedSpend: &budgets.Spend{
  351. Amount: aws.String("NumericValue"), // Required
  352. Unit: aws.String("GenericString"), // Required
  353. },
  354. },
  355. CostFilters: map[string][]*string{
  356. "Key": { // Required
  357. aws.String("GenericString"), // Required
  358. // More values...
  359. },
  360. // More values...
  361. },
  362. },
  363. }
  364. resp, err := svc.UpdateBudget(params)
  365. if err != nil {
  366. // Print the error, cast err to awserr.Error to get the Code and
  367. // Message from an error.
  368. fmt.Println(err.Error())
  369. return
  370. }
  371. // Pretty-print the response data.
  372. fmt.Println(resp)
  373. }
  374. func ExampleBudgets_UpdateNotification() {
  375. sess, err := session.NewSession()
  376. if err != nil {
  377. fmt.Println("failed to create session,", err)
  378. return
  379. }
  380. svc := budgets.New(sess)
  381. params := &budgets.UpdateNotificationInput{
  382. AccountId: aws.String("AccountId"), // Required
  383. BudgetName: aws.String("BudgetName"), // Required
  384. NewNotification: &budgets.Notification{ // Required
  385. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  386. NotificationType: aws.String("NotificationType"), // Required
  387. Threshold: aws.Float64(1.0), // Required
  388. },
  389. OldNotification: &budgets.Notification{ // Required
  390. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  391. NotificationType: aws.String("NotificationType"), // Required
  392. Threshold: aws.Float64(1.0), // Required
  393. },
  394. }
  395. resp, err := svc.UpdateNotification(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 ExampleBudgets_UpdateSubscriber() {
  406. sess, err := session.NewSession()
  407. if err != nil {
  408. fmt.Println("failed to create session,", err)
  409. return
  410. }
  411. svc := budgets.New(sess)
  412. params := &budgets.UpdateSubscriberInput{
  413. AccountId: aws.String("AccountId"), // Required
  414. BudgetName: aws.String("BudgetName"), // Required
  415. NewSubscriber: &budgets.Subscriber{ // Required
  416. Address: aws.String("GenericString"), // Required
  417. SubscriptionType: aws.String("SubscriptionType"), // Required
  418. },
  419. Notification: &budgets.Notification{ // Required
  420. ComparisonOperator: aws.String("ComparisonOperator"), // Required
  421. NotificationType: aws.String("NotificationType"), // Required
  422. Threshold: aws.Float64(1.0), // Required
  423. },
  424. OldSubscriber: &budgets.Subscriber{ // Required
  425. Address: aws.String("GenericString"), // Required
  426. SubscriptionType: aws.String("SubscriptionType"), // Required
  427. },
  428. }
  429. resp, err := svc.UpdateSubscriber(params)
  430. if err != nil {
  431. // Print the error, cast err to awserr.Error to get the Code and
  432. // Message from an error.
  433. fmt.Println(err.Error())
  434. return
  435. }
  436. // Pretty-print the response data.
  437. fmt.Println(resp)
  438. }