examples_test.go 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package iot_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/iot"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleIoT_AcceptCertificateTransfer() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := iot.New(sess)
  20. params := &iot.AcceptCertificateTransferInput{
  21. CertificateId: aws.String("CertificateId"), // Required
  22. SetAsActive: aws.Bool(true),
  23. }
  24. resp, err := svc.AcceptCertificateTransfer(params)
  25. if err != nil {
  26. // Print the error, cast err to awserr.Error to get the Code and
  27. // Message from an error.
  28. fmt.Println(err.Error())
  29. return
  30. }
  31. // Pretty-print the response data.
  32. fmt.Println(resp)
  33. }
  34. func ExampleIoT_AttachPrincipalPolicy() {
  35. sess, err := session.NewSession()
  36. if err != nil {
  37. fmt.Println("failed to create session,", err)
  38. return
  39. }
  40. svc := iot.New(sess)
  41. params := &iot.AttachPrincipalPolicyInput{
  42. PolicyName: aws.String("PolicyName"), // Required
  43. Principal: aws.String("Principal"), // Required
  44. }
  45. resp, err := svc.AttachPrincipalPolicy(params)
  46. if err != nil {
  47. // Print the error, cast err to awserr.Error to get the Code and
  48. // Message from an error.
  49. fmt.Println(err.Error())
  50. return
  51. }
  52. // Pretty-print the response data.
  53. fmt.Println(resp)
  54. }
  55. func ExampleIoT_AttachThingPrincipal() {
  56. sess, err := session.NewSession()
  57. if err != nil {
  58. fmt.Println("failed to create session,", err)
  59. return
  60. }
  61. svc := iot.New(sess)
  62. params := &iot.AttachThingPrincipalInput{
  63. Principal: aws.String("Principal"), // Required
  64. ThingName: aws.String("ThingName"), // Required
  65. }
  66. resp, err := svc.AttachThingPrincipal(params)
  67. if err != nil {
  68. // Print the error, cast err to awserr.Error to get the Code and
  69. // Message from an error.
  70. fmt.Println(err.Error())
  71. return
  72. }
  73. // Pretty-print the response data.
  74. fmt.Println(resp)
  75. }
  76. func ExampleIoT_CancelCertificateTransfer() {
  77. sess, err := session.NewSession()
  78. if err != nil {
  79. fmt.Println("failed to create session,", err)
  80. return
  81. }
  82. svc := iot.New(sess)
  83. params := &iot.CancelCertificateTransferInput{
  84. CertificateId: aws.String("CertificateId"), // Required
  85. }
  86. resp, err := svc.CancelCertificateTransfer(params)
  87. if err != nil {
  88. // Print the error, cast err to awserr.Error to get the Code and
  89. // Message from an error.
  90. fmt.Println(err.Error())
  91. return
  92. }
  93. // Pretty-print the response data.
  94. fmt.Println(resp)
  95. }
  96. func ExampleIoT_CreateCertificateFromCsr() {
  97. sess, err := session.NewSession()
  98. if err != nil {
  99. fmt.Println("failed to create session,", err)
  100. return
  101. }
  102. svc := iot.New(sess)
  103. params := &iot.CreateCertificateFromCsrInput{
  104. CertificateSigningRequest: aws.String("CertificateSigningRequest"), // Required
  105. SetAsActive: aws.Bool(true),
  106. }
  107. resp, err := svc.CreateCertificateFromCsr(params)
  108. if err != nil {
  109. // Print the error, cast err to awserr.Error to get the Code and
  110. // Message from an error.
  111. fmt.Println(err.Error())
  112. return
  113. }
  114. // Pretty-print the response data.
  115. fmt.Println(resp)
  116. }
  117. func ExampleIoT_CreateKeysAndCertificate() {
  118. sess, err := session.NewSession()
  119. if err != nil {
  120. fmt.Println("failed to create session,", err)
  121. return
  122. }
  123. svc := iot.New(sess)
  124. params := &iot.CreateKeysAndCertificateInput{
  125. SetAsActive: aws.Bool(true),
  126. }
  127. resp, err := svc.CreateKeysAndCertificate(params)
  128. if err != nil {
  129. // Print the error, cast err to awserr.Error to get the Code and
  130. // Message from an error.
  131. fmt.Println(err.Error())
  132. return
  133. }
  134. // Pretty-print the response data.
  135. fmt.Println(resp)
  136. }
  137. func ExampleIoT_CreatePolicy() {
  138. sess, err := session.NewSession()
  139. if err != nil {
  140. fmt.Println("failed to create session,", err)
  141. return
  142. }
  143. svc := iot.New(sess)
  144. params := &iot.CreatePolicyInput{
  145. PolicyDocument: aws.String("PolicyDocument"), // Required
  146. PolicyName: aws.String("PolicyName"), // Required
  147. }
  148. resp, err := svc.CreatePolicy(params)
  149. if err != nil {
  150. // Print the error, cast err to awserr.Error to get the Code and
  151. // Message from an error.
  152. fmt.Println(err.Error())
  153. return
  154. }
  155. // Pretty-print the response data.
  156. fmt.Println(resp)
  157. }
  158. func ExampleIoT_CreatePolicyVersion() {
  159. sess, err := session.NewSession()
  160. if err != nil {
  161. fmt.Println("failed to create session,", err)
  162. return
  163. }
  164. svc := iot.New(sess)
  165. params := &iot.CreatePolicyVersionInput{
  166. PolicyDocument: aws.String("PolicyDocument"), // Required
  167. PolicyName: aws.String("PolicyName"), // Required
  168. SetAsDefault: aws.Bool(true),
  169. }
  170. resp, err := svc.CreatePolicyVersion(params)
  171. if err != nil {
  172. // Print the error, cast err to awserr.Error to get the Code and
  173. // Message from an error.
  174. fmt.Println(err.Error())
  175. return
  176. }
  177. // Pretty-print the response data.
  178. fmt.Println(resp)
  179. }
  180. func ExampleIoT_CreateThing() {
  181. sess, err := session.NewSession()
  182. if err != nil {
  183. fmt.Println("failed to create session,", err)
  184. return
  185. }
  186. svc := iot.New(sess)
  187. params := &iot.CreateThingInput{
  188. ThingName: aws.String("ThingName"), // Required
  189. AttributePayload: &iot.AttributePayload{
  190. Attributes: map[string]*string{
  191. "Key": aws.String("AttributeValue"), // Required
  192. // More values...
  193. },
  194. Merge: aws.Bool(true),
  195. },
  196. ThingTypeName: aws.String("ThingTypeName"),
  197. }
  198. resp, err := svc.CreateThing(params)
  199. if err != nil {
  200. // Print the error, cast err to awserr.Error to get the Code and
  201. // Message from an error.
  202. fmt.Println(err.Error())
  203. return
  204. }
  205. // Pretty-print the response data.
  206. fmt.Println(resp)
  207. }
  208. func ExampleIoT_CreateThingType() {
  209. sess, err := session.NewSession()
  210. if err != nil {
  211. fmt.Println("failed to create session,", err)
  212. return
  213. }
  214. svc := iot.New(sess)
  215. params := &iot.CreateThingTypeInput{
  216. ThingTypeName: aws.String("ThingTypeName"), // Required
  217. ThingTypeProperties: &iot.ThingTypeProperties{
  218. SearchableAttributes: []*string{
  219. aws.String("AttributeName"), // Required
  220. // More values...
  221. },
  222. ThingTypeDescription: aws.String("ThingTypeDescription"),
  223. },
  224. }
  225. resp, err := svc.CreateThingType(params)
  226. if err != nil {
  227. // Print the error, cast err to awserr.Error to get the Code and
  228. // Message from an error.
  229. fmt.Println(err.Error())
  230. return
  231. }
  232. // Pretty-print the response data.
  233. fmt.Println(resp)
  234. }
  235. func ExampleIoT_CreateTopicRule() {
  236. sess, err := session.NewSession()
  237. if err != nil {
  238. fmt.Println("failed to create session,", err)
  239. return
  240. }
  241. svc := iot.New(sess)
  242. params := &iot.CreateTopicRuleInput{
  243. RuleName: aws.String("RuleName"), // Required
  244. TopicRulePayload: &iot.TopicRulePayload{ // Required
  245. Actions: []*iot.Action{ // Required
  246. { // Required
  247. CloudwatchAlarm: &iot.CloudwatchAlarmAction{
  248. AlarmName: aws.String("AlarmName"), // Required
  249. RoleArn: aws.String("AwsArn"), // Required
  250. StateReason: aws.String("StateReason"), // Required
  251. StateValue: aws.String("StateValue"), // Required
  252. },
  253. CloudwatchMetric: &iot.CloudwatchMetricAction{
  254. MetricName: aws.String("MetricName"), // Required
  255. MetricNamespace: aws.String("MetricNamespace"), // Required
  256. MetricUnit: aws.String("MetricUnit"), // Required
  257. MetricValue: aws.String("MetricValue"), // Required
  258. RoleArn: aws.String("AwsArn"), // Required
  259. MetricTimestamp: aws.String("MetricTimestamp"),
  260. },
  261. DynamoDB: &iot.DynamoDBAction{
  262. HashKeyField: aws.String("HashKeyField"), // Required
  263. HashKeyValue: aws.String("HashKeyValue"), // Required
  264. RoleArn: aws.String("AwsArn"), // Required
  265. TableName: aws.String("TableName"), // Required
  266. HashKeyType: aws.String("DynamoKeyType"),
  267. Operation: aws.String("DynamoOperation"),
  268. PayloadField: aws.String("PayloadField"),
  269. RangeKeyField: aws.String("RangeKeyField"),
  270. RangeKeyType: aws.String("DynamoKeyType"),
  271. RangeKeyValue: aws.String("RangeKeyValue"),
  272. },
  273. Elasticsearch: &iot.ElasticsearchAction{
  274. Endpoint: aws.String("ElasticsearchEndpoint"), // Required
  275. Id: aws.String("ElasticsearchId"), // Required
  276. Index: aws.String("ElasticsearchIndex"), // Required
  277. RoleArn: aws.String("AwsArn"), // Required
  278. Type: aws.String("ElasticsearchType"), // Required
  279. },
  280. Firehose: &iot.FirehoseAction{
  281. DeliveryStreamName: aws.String("DeliveryStreamName"), // Required
  282. RoleArn: aws.String("AwsArn"), // Required
  283. Separator: aws.String("FirehoseSeparator"),
  284. },
  285. Kinesis: &iot.KinesisAction{
  286. RoleArn: aws.String("AwsArn"), // Required
  287. StreamName: aws.String("StreamName"), // Required
  288. PartitionKey: aws.String("PartitionKey"),
  289. },
  290. Lambda: &iot.LambdaAction{
  291. FunctionArn: aws.String("FunctionArn"), // Required
  292. },
  293. Republish: &iot.RepublishAction{
  294. RoleArn: aws.String("AwsArn"), // Required
  295. Topic: aws.String("TopicPattern"), // Required
  296. },
  297. S3: &iot.S3Action{
  298. BucketName: aws.String("BucketName"), // Required
  299. Key: aws.String("Key"), // Required
  300. RoleArn: aws.String("AwsArn"), // Required
  301. },
  302. Sns: &iot.SnsAction{
  303. RoleArn: aws.String("AwsArn"), // Required
  304. TargetArn: aws.String("AwsArn"), // Required
  305. MessageFormat: aws.String("MessageFormat"),
  306. },
  307. Sqs: &iot.SqsAction{
  308. QueueUrl: aws.String("QueueUrl"), // Required
  309. RoleArn: aws.String("AwsArn"), // Required
  310. UseBase64: aws.Bool(true),
  311. },
  312. },
  313. // More values...
  314. },
  315. Sql: aws.String("SQL"), // Required
  316. AwsIotSqlVersion: aws.String("AwsIotSqlVersion"),
  317. Description: aws.String("Description"),
  318. RuleDisabled: aws.Bool(true),
  319. },
  320. }
  321. resp, err := svc.CreateTopicRule(params)
  322. if err != nil {
  323. // Print the error, cast err to awserr.Error to get the Code and
  324. // Message from an error.
  325. fmt.Println(err.Error())
  326. return
  327. }
  328. // Pretty-print the response data.
  329. fmt.Println(resp)
  330. }
  331. func ExampleIoT_DeleteCACertificate() {
  332. sess, err := session.NewSession()
  333. if err != nil {
  334. fmt.Println("failed to create session,", err)
  335. return
  336. }
  337. svc := iot.New(sess)
  338. params := &iot.DeleteCACertificateInput{
  339. CertificateId: aws.String("CertificateId"), // Required
  340. }
  341. resp, err := svc.DeleteCACertificate(params)
  342. if err != nil {
  343. // Print the error, cast err to awserr.Error to get the Code and
  344. // Message from an error.
  345. fmt.Println(err.Error())
  346. return
  347. }
  348. // Pretty-print the response data.
  349. fmt.Println(resp)
  350. }
  351. func ExampleIoT_DeleteCertificate() {
  352. sess, err := session.NewSession()
  353. if err != nil {
  354. fmt.Println("failed to create session,", err)
  355. return
  356. }
  357. svc := iot.New(sess)
  358. params := &iot.DeleteCertificateInput{
  359. CertificateId: aws.String("CertificateId"), // Required
  360. }
  361. resp, err := svc.DeleteCertificate(params)
  362. if err != nil {
  363. // Print the error, cast err to awserr.Error to get the Code and
  364. // Message from an error.
  365. fmt.Println(err.Error())
  366. return
  367. }
  368. // Pretty-print the response data.
  369. fmt.Println(resp)
  370. }
  371. func ExampleIoT_DeletePolicy() {
  372. sess, err := session.NewSession()
  373. if err != nil {
  374. fmt.Println("failed to create session,", err)
  375. return
  376. }
  377. svc := iot.New(sess)
  378. params := &iot.DeletePolicyInput{
  379. PolicyName: aws.String("PolicyName"), // Required
  380. }
  381. resp, err := svc.DeletePolicy(params)
  382. if err != nil {
  383. // Print the error, cast err to awserr.Error to get the Code and
  384. // Message from an error.
  385. fmt.Println(err.Error())
  386. return
  387. }
  388. // Pretty-print the response data.
  389. fmt.Println(resp)
  390. }
  391. func ExampleIoT_DeletePolicyVersion() {
  392. sess, err := session.NewSession()
  393. if err != nil {
  394. fmt.Println("failed to create session,", err)
  395. return
  396. }
  397. svc := iot.New(sess)
  398. params := &iot.DeletePolicyVersionInput{
  399. PolicyName: aws.String("PolicyName"), // Required
  400. PolicyVersionId: aws.String("PolicyVersionId"), // Required
  401. }
  402. resp, err := svc.DeletePolicyVersion(params)
  403. if err != nil {
  404. // Print the error, cast err to awserr.Error to get the Code and
  405. // Message from an error.
  406. fmt.Println(err.Error())
  407. return
  408. }
  409. // Pretty-print the response data.
  410. fmt.Println(resp)
  411. }
  412. func ExampleIoT_DeleteRegistrationCode() {
  413. sess, err := session.NewSession()
  414. if err != nil {
  415. fmt.Println("failed to create session,", err)
  416. return
  417. }
  418. svc := iot.New(sess)
  419. var params *iot.DeleteRegistrationCodeInput
  420. resp, err := svc.DeleteRegistrationCode(params)
  421. if err != nil {
  422. // Print the error, cast err to awserr.Error to get the Code and
  423. // Message from an error.
  424. fmt.Println(err.Error())
  425. return
  426. }
  427. // Pretty-print the response data.
  428. fmt.Println(resp)
  429. }
  430. func ExampleIoT_DeleteThing() {
  431. sess, err := session.NewSession()
  432. if err != nil {
  433. fmt.Println("failed to create session,", err)
  434. return
  435. }
  436. svc := iot.New(sess)
  437. params := &iot.DeleteThingInput{
  438. ThingName: aws.String("ThingName"), // Required
  439. ExpectedVersion: aws.Int64(1),
  440. }
  441. resp, err := svc.DeleteThing(params)
  442. if err != nil {
  443. // Print the error, cast err to awserr.Error to get the Code and
  444. // Message from an error.
  445. fmt.Println(err.Error())
  446. return
  447. }
  448. // Pretty-print the response data.
  449. fmt.Println(resp)
  450. }
  451. func ExampleIoT_DeleteThingType() {
  452. sess, err := session.NewSession()
  453. if err != nil {
  454. fmt.Println("failed to create session,", err)
  455. return
  456. }
  457. svc := iot.New(sess)
  458. params := &iot.DeleteThingTypeInput{
  459. ThingTypeName: aws.String("ThingTypeName"), // Required
  460. }
  461. resp, err := svc.DeleteThingType(params)
  462. if err != nil {
  463. // Print the error, cast err to awserr.Error to get the Code and
  464. // Message from an error.
  465. fmt.Println(err.Error())
  466. return
  467. }
  468. // Pretty-print the response data.
  469. fmt.Println(resp)
  470. }
  471. func ExampleIoT_DeleteTopicRule() {
  472. sess, err := session.NewSession()
  473. if err != nil {
  474. fmt.Println("failed to create session,", err)
  475. return
  476. }
  477. svc := iot.New(sess)
  478. params := &iot.DeleteTopicRuleInput{
  479. RuleName: aws.String("RuleName"), // Required
  480. }
  481. resp, err := svc.DeleteTopicRule(params)
  482. if err != nil {
  483. // Print the error, cast err to awserr.Error to get the Code and
  484. // Message from an error.
  485. fmt.Println(err.Error())
  486. return
  487. }
  488. // Pretty-print the response data.
  489. fmt.Println(resp)
  490. }
  491. func ExampleIoT_DeprecateThingType() {
  492. sess, err := session.NewSession()
  493. if err != nil {
  494. fmt.Println("failed to create session,", err)
  495. return
  496. }
  497. svc := iot.New(sess)
  498. params := &iot.DeprecateThingTypeInput{
  499. ThingTypeName: aws.String("ThingTypeName"), // Required
  500. UndoDeprecate: aws.Bool(true),
  501. }
  502. resp, err := svc.DeprecateThingType(params)
  503. if err != nil {
  504. // Print the error, cast err to awserr.Error to get the Code and
  505. // Message from an error.
  506. fmt.Println(err.Error())
  507. return
  508. }
  509. // Pretty-print the response data.
  510. fmt.Println(resp)
  511. }
  512. func ExampleIoT_DescribeCACertificate() {
  513. sess, err := session.NewSession()
  514. if err != nil {
  515. fmt.Println("failed to create session,", err)
  516. return
  517. }
  518. svc := iot.New(sess)
  519. params := &iot.DescribeCACertificateInput{
  520. CertificateId: aws.String("CertificateId"), // Required
  521. }
  522. resp, err := svc.DescribeCACertificate(params)
  523. if err != nil {
  524. // Print the error, cast err to awserr.Error to get the Code and
  525. // Message from an error.
  526. fmt.Println(err.Error())
  527. return
  528. }
  529. // Pretty-print the response data.
  530. fmt.Println(resp)
  531. }
  532. func ExampleIoT_DescribeCertificate() {
  533. sess, err := session.NewSession()
  534. if err != nil {
  535. fmt.Println("failed to create session,", err)
  536. return
  537. }
  538. svc := iot.New(sess)
  539. params := &iot.DescribeCertificateInput{
  540. CertificateId: aws.String("CertificateId"), // Required
  541. }
  542. resp, err := svc.DescribeCertificate(params)
  543. if err != nil {
  544. // Print the error, cast err to awserr.Error to get the Code and
  545. // Message from an error.
  546. fmt.Println(err.Error())
  547. return
  548. }
  549. // Pretty-print the response data.
  550. fmt.Println(resp)
  551. }
  552. func ExampleIoT_DescribeEndpoint() {
  553. sess, err := session.NewSession()
  554. if err != nil {
  555. fmt.Println("failed to create session,", err)
  556. return
  557. }
  558. svc := iot.New(sess)
  559. var params *iot.DescribeEndpointInput
  560. resp, err := svc.DescribeEndpoint(params)
  561. if err != nil {
  562. // Print the error, cast err to awserr.Error to get the Code and
  563. // Message from an error.
  564. fmt.Println(err.Error())
  565. return
  566. }
  567. // Pretty-print the response data.
  568. fmt.Println(resp)
  569. }
  570. func ExampleIoT_DescribeThing() {
  571. sess, err := session.NewSession()
  572. if err != nil {
  573. fmt.Println("failed to create session,", err)
  574. return
  575. }
  576. svc := iot.New(sess)
  577. params := &iot.DescribeThingInput{
  578. ThingName: aws.String("ThingName"), // Required
  579. }
  580. resp, err := svc.DescribeThing(params)
  581. if err != nil {
  582. // Print the error, cast err to awserr.Error to get the Code and
  583. // Message from an error.
  584. fmt.Println(err.Error())
  585. return
  586. }
  587. // Pretty-print the response data.
  588. fmt.Println(resp)
  589. }
  590. func ExampleIoT_DescribeThingType() {
  591. sess, err := session.NewSession()
  592. if err != nil {
  593. fmt.Println("failed to create session,", err)
  594. return
  595. }
  596. svc := iot.New(sess)
  597. params := &iot.DescribeThingTypeInput{
  598. ThingTypeName: aws.String("ThingTypeName"), // Required
  599. }
  600. resp, err := svc.DescribeThingType(params)
  601. if err != nil {
  602. // Print the error, cast err to awserr.Error to get the Code and
  603. // Message from an error.
  604. fmt.Println(err.Error())
  605. return
  606. }
  607. // Pretty-print the response data.
  608. fmt.Println(resp)
  609. }
  610. func ExampleIoT_DetachPrincipalPolicy() {
  611. sess, err := session.NewSession()
  612. if err != nil {
  613. fmt.Println("failed to create session,", err)
  614. return
  615. }
  616. svc := iot.New(sess)
  617. params := &iot.DetachPrincipalPolicyInput{
  618. PolicyName: aws.String("PolicyName"), // Required
  619. Principal: aws.String("Principal"), // Required
  620. }
  621. resp, err := svc.DetachPrincipalPolicy(params)
  622. if err != nil {
  623. // Print the error, cast err to awserr.Error to get the Code and
  624. // Message from an error.
  625. fmt.Println(err.Error())
  626. return
  627. }
  628. // Pretty-print the response data.
  629. fmt.Println(resp)
  630. }
  631. func ExampleIoT_DetachThingPrincipal() {
  632. sess, err := session.NewSession()
  633. if err != nil {
  634. fmt.Println("failed to create session,", err)
  635. return
  636. }
  637. svc := iot.New(sess)
  638. params := &iot.DetachThingPrincipalInput{
  639. Principal: aws.String("Principal"), // Required
  640. ThingName: aws.String("ThingName"), // Required
  641. }
  642. resp, err := svc.DetachThingPrincipal(params)
  643. if err != nil {
  644. // Print the error, cast err to awserr.Error to get the Code and
  645. // Message from an error.
  646. fmt.Println(err.Error())
  647. return
  648. }
  649. // Pretty-print the response data.
  650. fmt.Println(resp)
  651. }
  652. func ExampleIoT_DisableTopicRule() {
  653. sess, err := session.NewSession()
  654. if err != nil {
  655. fmt.Println("failed to create session,", err)
  656. return
  657. }
  658. svc := iot.New(sess)
  659. params := &iot.DisableTopicRuleInput{
  660. RuleName: aws.String("RuleName"), // Required
  661. }
  662. resp, err := svc.DisableTopicRule(params)
  663. if err != nil {
  664. // Print the error, cast err to awserr.Error to get the Code and
  665. // Message from an error.
  666. fmt.Println(err.Error())
  667. return
  668. }
  669. // Pretty-print the response data.
  670. fmt.Println(resp)
  671. }
  672. func ExampleIoT_EnableTopicRule() {
  673. sess, err := session.NewSession()
  674. if err != nil {
  675. fmt.Println("failed to create session,", err)
  676. return
  677. }
  678. svc := iot.New(sess)
  679. params := &iot.EnableTopicRuleInput{
  680. RuleName: aws.String("RuleName"), // Required
  681. }
  682. resp, err := svc.EnableTopicRule(params)
  683. if err != nil {
  684. // Print the error, cast err to awserr.Error to get the Code and
  685. // Message from an error.
  686. fmt.Println(err.Error())
  687. return
  688. }
  689. // Pretty-print the response data.
  690. fmt.Println(resp)
  691. }
  692. func ExampleIoT_GetLoggingOptions() {
  693. sess, err := session.NewSession()
  694. if err != nil {
  695. fmt.Println("failed to create session,", err)
  696. return
  697. }
  698. svc := iot.New(sess)
  699. var params *iot.GetLoggingOptionsInput
  700. resp, err := svc.GetLoggingOptions(params)
  701. if err != nil {
  702. // Print the error, cast err to awserr.Error to get the Code and
  703. // Message from an error.
  704. fmt.Println(err.Error())
  705. return
  706. }
  707. // Pretty-print the response data.
  708. fmt.Println(resp)
  709. }
  710. func ExampleIoT_GetPolicy() {
  711. sess, err := session.NewSession()
  712. if err != nil {
  713. fmt.Println("failed to create session,", err)
  714. return
  715. }
  716. svc := iot.New(sess)
  717. params := &iot.GetPolicyInput{
  718. PolicyName: aws.String("PolicyName"), // Required
  719. }
  720. resp, err := svc.GetPolicy(params)
  721. if err != nil {
  722. // Print the error, cast err to awserr.Error to get the Code and
  723. // Message from an error.
  724. fmt.Println(err.Error())
  725. return
  726. }
  727. // Pretty-print the response data.
  728. fmt.Println(resp)
  729. }
  730. func ExampleIoT_GetPolicyVersion() {
  731. sess, err := session.NewSession()
  732. if err != nil {
  733. fmt.Println("failed to create session,", err)
  734. return
  735. }
  736. svc := iot.New(sess)
  737. params := &iot.GetPolicyVersionInput{
  738. PolicyName: aws.String("PolicyName"), // Required
  739. PolicyVersionId: aws.String("PolicyVersionId"), // Required
  740. }
  741. resp, err := svc.GetPolicyVersion(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 ExampleIoT_GetRegistrationCode() {
  752. sess, err := session.NewSession()
  753. if err != nil {
  754. fmt.Println("failed to create session,", err)
  755. return
  756. }
  757. svc := iot.New(sess)
  758. var params *iot.GetRegistrationCodeInput
  759. resp, err := svc.GetRegistrationCode(params)
  760. if err != nil {
  761. // Print the error, cast err to awserr.Error to get the Code and
  762. // Message from an error.
  763. fmt.Println(err.Error())
  764. return
  765. }
  766. // Pretty-print the response data.
  767. fmt.Println(resp)
  768. }
  769. func ExampleIoT_GetTopicRule() {
  770. sess, err := session.NewSession()
  771. if err != nil {
  772. fmt.Println("failed to create session,", err)
  773. return
  774. }
  775. svc := iot.New(sess)
  776. params := &iot.GetTopicRuleInput{
  777. RuleName: aws.String("RuleName"), // Required
  778. }
  779. resp, err := svc.GetTopicRule(params)
  780. if err != nil {
  781. // Print the error, cast err to awserr.Error to get the Code and
  782. // Message from an error.
  783. fmt.Println(err.Error())
  784. return
  785. }
  786. // Pretty-print the response data.
  787. fmt.Println(resp)
  788. }
  789. func ExampleIoT_ListCACertificates() {
  790. sess, err := session.NewSession()
  791. if err != nil {
  792. fmt.Println("failed to create session,", err)
  793. return
  794. }
  795. svc := iot.New(sess)
  796. params := &iot.ListCACertificatesInput{
  797. AscendingOrder: aws.Bool(true),
  798. Marker: aws.String("Marker"),
  799. PageSize: aws.Int64(1),
  800. }
  801. resp, err := svc.ListCACertificates(params)
  802. if err != nil {
  803. // Print the error, cast err to awserr.Error to get the Code and
  804. // Message from an error.
  805. fmt.Println(err.Error())
  806. return
  807. }
  808. // Pretty-print the response data.
  809. fmt.Println(resp)
  810. }
  811. func ExampleIoT_ListCertificates() {
  812. sess, err := session.NewSession()
  813. if err != nil {
  814. fmt.Println("failed to create session,", err)
  815. return
  816. }
  817. svc := iot.New(sess)
  818. params := &iot.ListCertificatesInput{
  819. AscendingOrder: aws.Bool(true),
  820. Marker: aws.String("Marker"),
  821. PageSize: aws.Int64(1),
  822. }
  823. resp, err := svc.ListCertificates(params)
  824. if err != nil {
  825. // Print the error, cast err to awserr.Error to get the Code and
  826. // Message from an error.
  827. fmt.Println(err.Error())
  828. return
  829. }
  830. // Pretty-print the response data.
  831. fmt.Println(resp)
  832. }
  833. func ExampleIoT_ListCertificatesByCA() {
  834. sess, err := session.NewSession()
  835. if err != nil {
  836. fmt.Println("failed to create session,", err)
  837. return
  838. }
  839. svc := iot.New(sess)
  840. params := &iot.ListCertificatesByCAInput{
  841. CaCertificateId: aws.String("CertificateId"), // Required
  842. AscendingOrder: aws.Bool(true),
  843. Marker: aws.String("Marker"),
  844. PageSize: aws.Int64(1),
  845. }
  846. resp, err := svc.ListCertificatesByCA(params)
  847. if err != nil {
  848. // Print the error, cast err to awserr.Error to get the Code and
  849. // Message from an error.
  850. fmt.Println(err.Error())
  851. return
  852. }
  853. // Pretty-print the response data.
  854. fmt.Println(resp)
  855. }
  856. func ExampleIoT_ListOutgoingCertificates() {
  857. sess, err := session.NewSession()
  858. if err != nil {
  859. fmt.Println("failed to create session,", err)
  860. return
  861. }
  862. svc := iot.New(sess)
  863. params := &iot.ListOutgoingCertificatesInput{
  864. AscendingOrder: aws.Bool(true),
  865. Marker: aws.String("Marker"),
  866. PageSize: aws.Int64(1),
  867. }
  868. resp, err := svc.ListOutgoingCertificates(params)
  869. if err != nil {
  870. // Print the error, cast err to awserr.Error to get the Code and
  871. // Message from an error.
  872. fmt.Println(err.Error())
  873. return
  874. }
  875. // Pretty-print the response data.
  876. fmt.Println(resp)
  877. }
  878. func ExampleIoT_ListPolicies() {
  879. sess, err := session.NewSession()
  880. if err != nil {
  881. fmt.Println("failed to create session,", err)
  882. return
  883. }
  884. svc := iot.New(sess)
  885. params := &iot.ListPoliciesInput{
  886. AscendingOrder: aws.Bool(true),
  887. Marker: aws.String("Marker"),
  888. PageSize: aws.Int64(1),
  889. }
  890. resp, err := svc.ListPolicies(params)
  891. if err != nil {
  892. // Print the error, cast err to awserr.Error to get the Code and
  893. // Message from an error.
  894. fmt.Println(err.Error())
  895. return
  896. }
  897. // Pretty-print the response data.
  898. fmt.Println(resp)
  899. }
  900. func ExampleIoT_ListPolicyPrincipals() {
  901. sess, err := session.NewSession()
  902. if err != nil {
  903. fmt.Println("failed to create session,", err)
  904. return
  905. }
  906. svc := iot.New(sess)
  907. params := &iot.ListPolicyPrincipalsInput{
  908. PolicyName: aws.String("PolicyName"), // Required
  909. AscendingOrder: aws.Bool(true),
  910. Marker: aws.String("Marker"),
  911. PageSize: aws.Int64(1),
  912. }
  913. resp, err := svc.ListPolicyPrincipals(params)
  914. if err != nil {
  915. // Print the error, cast err to awserr.Error to get the Code and
  916. // Message from an error.
  917. fmt.Println(err.Error())
  918. return
  919. }
  920. // Pretty-print the response data.
  921. fmt.Println(resp)
  922. }
  923. func ExampleIoT_ListPolicyVersions() {
  924. sess, err := session.NewSession()
  925. if err != nil {
  926. fmt.Println("failed to create session,", err)
  927. return
  928. }
  929. svc := iot.New(sess)
  930. params := &iot.ListPolicyVersionsInput{
  931. PolicyName: aws.String("PolicyName"), // Required
  932. }
  933. resp, err := svc.ListPolicyVersions(params)
  934. if err != nil {
  935. // Print the error, cast err to awserr.Error to get the Code and
  936. // Message from an error.
  937. fmt.Println(err.Error())
  938. return
  939. }
  940. // Pretty-print the response data.
  941. fmt.Println(resp)
  942. }
  943. func ExampleIoT_ListPrincipalPolicies() {
  944. sess, err := session.NewSession()
  945. if err != nil {
  946. fmt.Println("failed to create session,", err)
  947. return
  948. }
  949. svc := iot.New(sess)
  950. params := &iot.ListPrincipalPoliciesInput{
  951. Principal: aws.String("Principal"), // Required
  952. AscendingOrder: aws.Bool(true),
  953. Marker: aws.String("Marker"),
  954. PageSize: aws.Int64(1),
  955. }
  956. resp, err := svc.ListPrincipalPolicies(params)
  957. if err != nil {
  958. // Print the error, cast err to awserr.Error to get the Code and
  959. // Message from an error.
  960. fmt.Println(err.Error())
  961. return
  962. }
  963. // Pretty-print the response data.
  964. fmt.Println(resp)
  965. }
  966. func ExampleIoT_ListPrincipalThings() {
  967. sess, err := session.NewSession()
  968. if err != nil {
  969. fmt.Println("failed to create session,", err)
  970. return
  971. }
  972. svc := iot.New(sess)
  973. params := &iot.ListPrincipalThingsInput{
  974. Principal: aws.String("Principal"), // Required
  975. MaxResults: aws.Int64(1),
  976. NextToken: aws.String("NextToken"),
  977. }
  978. resp, err := svc.ListPrincipalThings(params)
  979. if err != nil {
  980. // Print the error, cast err to awserr.Error to get the Code and
  981. // Message from an error.
  982. fmt.Println(err.Error())
  983. return
  984. }
  985. // Pretty-print the response data.
  986. fmt.Println(resp)
  987. }
  988. func ExampleIoT_ListThingPrincipals() {
  989. sess, err := session.NewSession()
  990. if err != nil {
  991. fmt.Println("failed to create session,", err)
  992. return
  993. }
  994. svc := iot.New(sess)
  995. params := &iot.ListThingPrincipalsInput{
  996. ThingName: aws.String("ThingName"), // Required
  997. }
  998. resp, err := svc.ListThingPrincipals(params)
  999. if err != nil {
  1000. // Print the error, cast err to awserr.Error to get the Code and
  1001. // Message from an error.
  1002. fmt.Println(err.Error())
  1003. return
  1004. }
  1005. // Pretty-print the response data.
  1006. fmt.Println(resp)
  1007. }
  1008. func ExampleIoT_ListThingTypes() {
  1009. sess, err := session.NewSession()
  1010. if err != nil {
  1011. fmt.Println("failed to create session,", err)
  1012. return
  1013. }
  1014. svc := iot.New(sess)
  1015. params := &iot.ListThingTypesInput{
  1016. MaxResults: aws.Int64(1),
  1017. NextToken: aws.String("NextToken"),
  1018. ThingTypeName: aws.String("ThingTypeName"),
  1019. }
  1020. resp, err := svc.ListThingTypes(params)
  1021. if err != nil {
  1022. // Print the error, cast err to awserr.Error to get the Code and
  1023. // Message from an error.
  1024. fmt.Println(err.Error())
  1025. return
  1026. }
  1027. // Pretty-print the response data.
  1028. fmt.Println(resp)
  1029. }
  1030. func ExampleIoT_ListThings() {
  1031. sess, err := session.NewSession()
  1032. if err != nil {
  1033. fmt.Println("failed to create session,", err)
  1034. return
  1035. }
  1036. svc := iot.New(sess)
  1037. params := &iot.ListThingsInput{
  1038. AttributeName: aws.String("AttributeName"),
  1039. AttributeValue: aws.String("AttributeValue"),
  1040. MaxResults: aws.Int64(1),
  1041. NextToken: aws.String("NextToken"),
  1042. ThingTypeName: aws.String("ThingTypeName"),
  1043. }
  1044. resp, err := svc.ListThings(params)
  1045. if err != nil {
  1046. // Print the error, cast err to awserr.Error to get the Code and
  1047. // Message from an error.
  1048. fmt.Println(err.Error())
  1049. return
  1050. }
  1051. // Pretty-print the response data.
  1052. fmt.Println(resp)
  1053. }
  1054. func ExampleIoT_ListTopicRules() {
  1055. sess, err := session.NewSession()
  1056. if err != nil {
  1057. fmt.Println("failed to create session,", err)
  1058. return
  1059. }
  1060. svc := iot.New(sess)
  1061. params := &iot.ListTopicRulesInput{
  1062. MaxResults: aws.Int64(1),
  1063. NextToken: aws.String("NextToken"),
  1064. RuleDisabled: aws.Bool(true),
  1065. Topic: aws.String("Topic"),
  1066. }
  1067. resp, err := svc.ListTopicRules(params)
  1068. if err != nil {
  1069. // Print the error, cast err to awserr.Error to get the Code and
  1070. // Message from an error.
  1071. fmt.Println(err.Error())
  1072. return
  1073. }
  1074. // Pretty-print the response data.
  1075. fmt.Println(resp)
  1076. }
  1077. func ExampleIoT_RegisterCACertificate() {
  1078. sess, err := session.NewSession()
  1079. if err != nil {
  1080. fmt.Println("failed to create session,", err)
  1081. return
  1082. }
  1083. svc := iot.New(sess)
  1084. params := &iot.RegisterCACertificateInput{
  1085. CaCertificate: aws.String("CertificatePem"), // Required
  1086. VerificationCertificate: aws.String("CertificatePem"), // Required
  1087. AllowAutoRegistration: aws.Bool(true),
  1088. SetAsActive: aws.Bool(true),
  1089. }
  1090. resp, err := svc.RegisterCACertificate(params)
  1091. if err != nil {
  1092. // Print the error, cast err to awserr.Error to get the Code and
  1093. // Message from an error.
  1094. fmt.Println(err.Error())
  1095. return
  1096. }
  1097. // Pretty-print the response data.
  1098. fmt.Println(resp)
  1099. }
  1100. func ExampleIoT_RegisterCertificate() {
  1101. sess, err := session.NewSession()
  1102. if err != nil {
  1103. fmt.Println("failed to create session,", err)
  1104. return
  1105. }
  1106. svc := iot.New(sess)
  1107. params := &iot.RegisterCertificateInput{
  1108. CertificatePem: aws.String("CertificatePem"), // Required
  1109. CaCertificatePem: aws.String("CertificatePem"),
  1110. SetAsActive: aws.Bool(true),
  1111. }
  1112. resp, err := svc.RegisterCertificate(params)
  1113. if err != nil {
  1114. // Print the error, cast err to awserr.Error to get the Code and
  1115. // Message from an error.
  1116. fmt.Println(err.Error())
  1117. return
  1118. }
  1119. // Pretty-print the response data.
  1120. fmt.Println(resp)
  1121. }
  1122. func ExampleIoT_RejectCertificateTransfer() {
  1123. sess, err := session.NewSession()
  1124. if err != nil {
  1125. fmt.Println("failed to create session,", err)
  1126. return
  1127. }
  1128. svc := iot.New(sess)
  1129. params := &iot.RejectCertificateTransferInput{
  1130. CertificateId: aws.String("CertificateId"), // Required
  1131. RejectReason: aws.String("Message"),
  1132. }
  1133. resp, err := svc.RejectCertificateTransfer(params)
  1134. if err != nil {
  1135. // Print the error, cast err to awserr.Error to get the Code and
  1136. // Message from an error.
  1137. fmt.Println(err.Error())
  1138. return
  1139. }
  1140. // Pretty-print the response data.
  1141. fmt.Println(resp)
  1142. }
  1143. func ExampleIoT_ReplaceTopicRule() {
  1144. sess, err := session.NewSession()
  1145. if err != nil {
  1146. fmt.Println("failed to create session,", err)
  1147. return
  1148. }
  1149. svc := iot.New(sess)
  1150. params := &iot.ReplaceTopicRuleInput{
  1151. RuleName: aws.String("RuleName"), // Required
  1152. TopicRulePayload: &iot.TopicRulePayload{ // Required
  1153. Actions: []*iot.Action{ // Required
  1154. { // Required
  1155. CloudwatchAlarm: &iot.CloudwatchAlarmAction{
  1156. AlarmName: aws.String("AlarmName"), // Required
  1157. RoleArn: aws.String("AwsArn"), // Required
  1158. StateReason: aws.String("StateReason"), // Required
  1159. StateValue: aws.String("StateValue"), // Required
  1160. },
  1161. CloudwatchMetric: &iot.CloudwatchMetricAction{
  1162. MetricName: aws.String("MetricName"), // Required
  1163. MetricNamespace: aws.String("MetricNamespace"), // Required
  1164. MetricUnit: aws.String("MetricUnit"), // Required
  1165. MetricValue: aws.String("MetricValue"), // Required
  1166. RoleArn: aws.String("AwsArn"), // Required
  1167. MetricTimestamp: aws.String("MetricTimestamp"),
  1168. },
  1169. DynamoDB: &iot.DynamoDBAction{
  1170. HashKeyField: aws.String("HashKeyField"), // Required
  1171. HashKeyValue: aws.String("HashKeyValue"), // Required
  1172. RoleArn: aws.String("AwsArn"), // Required
  1173. TableName: aws.String("TableName"), // Required
  1174. HashKeyType: aws.String("DynamoKeyType"),
  1175. Operation: aws.String("DynamoOperation"),
  1176. PayloadField: aws.String("PayloadField"),
  1177. RangeKeyField: aws.String("RangeKeyField"),
  1178. RangeKeyType: aws.String("DynamoKeyType"),
  1179. RangeKeyValue: aws.String("RangeKeyValue"),
  1180. },
  1181. Elasticsearch: &iot.ElasticsearchAction{
  1182. Endpoint: aws.String("ElasticsearchEndpoint"), // Required
  1183. Id: aws.String("ElasticsearchId"), // Required
  1184. Index: aws.String("ElasticsearchIndex"), // Required
  1185. RoleArn: aws.String("AwsArn"), // Required
  1186. Type: aws.String("ElasticsearchType"), // Required
  1187. },
  1188. Firehose: &iot.FirehoseAction{
  1189. DeliveryStreamName: aws.String("DeliveryStreamName"), // Required
  1190. RoleArn: aws.String("AwsArn"), // Required
  1191. Separator: aws.String("FirehoseSeparator"),
  1192. },
  1193. Kinesis: &iot.KinesisAction{
  1194. RoleArn: aws.String("AwsArn"), // Required
  1195. StreamName: aws.String("StreamName"), // Required
  1196. PartitionKey: aws.String("PartitionKey"),
  1197. },
  1198. Lambda: &iot.LambdaAction{
  1199. FunctionArn: aws.String("FunctionArn"), // Required
  1200. },
  1201. Republish: &iot.RepublishAction{
  1202. RoleArn: aws.String("AwsArn"), // Required
  1203. Topic: aws.String("TopicPattern"), // Required
  1204. },
  1205. S3: &iot.S3Action{
  1206. BucketName: aws.String("BucketName"), // Required
  1207. Key: aws.String("Key"), // Required
  1208. RoleArn: aws.String("AwsArn"), // Required
  1209. },
  1210. Sns: &iot.SnsAction{
  1211. RoleArn: aws.String("AwsArn"), // Required
  1212. TargetArn: aws.String("AwsArn"), // Required
  1213. MessageFormat: aws.String("MessageFormat"),
  1214. },
  1215. Sqs: &iot.SqsAction{
  1216. QueueUrl: aws.String("QueueUrl"), // Required
  1217. RoleArn: aws.String("AwsArn"), // Required
  1218. UseBase64: aws.Bool(true),
  1219. },
  1220. },
  1221. // More values...
  1222. },
  1223. Sql: aws.String("SQL"), // Required
  1224. AwsIotSqlVersion: aws.String("AwsIotSqlVersion"),
  1225. Description: aws.String("Description"),
  1226. RuleDisabled: aws.Bool(true),
  1227. },
  1228. }
  1229. resp, err := svc.ReplaceTopicRule(params)
  1230. if err != nil {
  1231. // Print the error, cast err to awserr.Error to get the Code and
  1232. // Message from an error.
  1233. fmt.Println(err.Error())
  1234. return
  1235. }
  1236. // Pretty-print the response data.
  1237. fmt.Println(resp)
  1238. }
  1239. func ExampleIoT_SetDefaultPolicyVersion() {
  1240. sess, err := session.NewSession()
  1241. if err != nil {
  1242. fmt.Println("failed to create session,", err)
  1243. return
  1244. }
  1245. svc := iot.New(sess)
  1246. params := &iot.SetDefaultPolicyVersionInput{
  1247. PolicyName: aws.String("PolicyName"), // Required
  1248. PolicyVersionId: aws.String("PolicyVersionId"), // Required
  1249. }
  1250. resp, err := svc.SetDefaultPolicyVersion(params)
  1251. if err != nil {
  1252. // Print the error, cast err to awserr.Error to get the Code and
  1253. // Message from an error.
  1254. fmt.Println(err.Error())
  1255. return
  1256. }
  1257. // Pretty-print the response data.
  1258. fmt.Println(resp)
  1259. }
  1260. func ExampleIoT_SetLoggingOptions() {
  1261. sess, err := session.NewSession()
  1262. if err != nil {
  1263. fmt.Println("failed to create session,", err)
  1264. return
  1265. }
  1266. svc := iot.New(sess)
  1267. params := &iot.SetLoggingOptionsInput{
  1268. LoggingOptionsPayload: &iot.LoggingOptionsPayload{ // Required
  1269. RoleArn: aws.String("AwsArn"), // Required
  1270. LogLevel: aws.String("LogLevel"),
  1271. },
  1272. }
  1273. resp, err := svc.SetLoggingOptions(params)
  1274. if err != nil {
  1275. // Print the error, cast err to awserr.Error to get the Code and
  1276. // Message from an error.
  1277. fmt.Println(err.Error())
  1278. return
  1279. }
  1280. // Pretty-print the response data.
  1281. fmt.Println(resp)
  1282. }
  1283. func ExampleIoT_TransferCertificate() {
  1284. sess, err := session.NewSession()
  1285. if err != nil {
  1286. fmt.Println("failed to create session,", err)
  1287. return
  1288. }
  1289. svc := iot.New(sess)
  1290. params := &iot.TransferCertificateInput{
  1291. CertificateId: aws.String("CertificateId"), // Required
  1292. TargetAwsAccount: aws.String("AwsAccountId"), // Required
  1293. TransferMessage: aws.String("Message"),
  1294. }
  1295. resp, err := svc.TransferCertificate(params)
  1296. if err != nil {
  1297. // Print the error, cast err to awserr.Error to get the Code and
  1298. // Message from an error.
  1299. fmt.Println(err.Error())
  1300. return
  1301. }
  1302. // Pretty-print the response data.
  1303. fmt.Println(resp)
  1304. }
  1305. func ExampleIoT_UpdateCACertificate() {
  1306. sess, err := session.NewSession()
  1307. if err != nil {
  1308. fmt.Println("failed to create session,", err)
  1309. return
  1310. }
  1311. svc := iot.New(sess)
  1312. params := &iot.UpdateCACertificateInput{
  1313. CertificateId: aws.String("CertificateId"), // Required
  1314. NewAutoRegistrationStatus: aws.String("AutoRegistrationStatus"),
  1315. NewStatus: aws.String("CACertificateStatus"),
  1316. }
  1317. resp, err := svc.UpdateCACertificate(params)
  1318. if err != nil {
  1319. // Print the error, cast err to awserr.Error to get the Code and
  1320. // Message from an error.
  1321. fmt.Println(err.Error())
  1322. return
  1323. }
  1324. // Pretty-print the response data.
  1325. fmt.Println(resp)
  1326. }
  1327. func ExampleIoT_UpdateCertificate() {
  1328. sess, err := session.NewSession()
  1329. if err != nil {
  1330. fmt.Println("failed to create session,", err)
  1331. return
  1332. }
  1333. svc := iot.New(sess)
  1334. params := &iot.UpdateCertificateInput{
  1335. CertificateId: aws.String("CertificateId"), // Required
  1336. NewStatus: aws.String("CertificateStatus"), // Required
  1337. }
  1338. resp, err := svc.UpdateCertificate(params)
  1339. if err != nil {
  1340. // Print the error, cast err to awserr.Error to get the Code and
  1341. // Message from an error.
  1342. fmt.Println(err.Error())
  1343. return
  1344. }
  1345. // Pretty-print the response data.
  1346. fmt.Println(resp)
  1347. }
  1348. func ExampleIoT_UpdateThing() {
  1349. sess, err := session.NewSession()
  1350. if err != nil {
  1351. fmt.Println("failed to create session,", err)
  1352. return
  1353. }
  1354. svc := iot.New(sess)
  1355. params := &iot.UpdateThingInput{
  1356. ThingName: aws.String("ThingName"), // Required
  1357. AttributePayload: &iot.AttributePayload{
  1358. Attributes: map[string]*string{
  1359. "Key": aws.String("AttributeValue"), // Required
  1360. // More values...
  1361. },
  1362. Merge: aws.Bool(true),
  1363. },
  1364. ExpectedVersion: aws.Int64(1),
  1365. RemoveThingType: aws.Bool(true),
  1366. ThingTypeName: aws.String("ThingTypeName"),
  1367. }
  1368. resp, err := svc.UpdateThing(params)
  1369. if err != nil {
  1370. // Print the error, cast err to awserr.Error to get the Code and
  1371. // Message from an error.
  1372. fmt.Println(err.Error())
  1373. return
  1374. }
  1375. // Pretty-print the response data.
  1376. fmt.Println(resp)
  1377. }