examples_test.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package machinelearning_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/service/machinelearning"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleMachineLearning_CreateBatchPrediction() {
  13. svc := machinelearning.New(nil)
  14. params := &machinelearning.CreateBatchPredictionInput{
  15. BatchPredictionDataSourceId: aws.String("EntityId"), // Required
  16. BatchPredictionId: aws.String("EntityId"), // Required
  17. MLModelId: aws.String("EntityId"), // Required
  18. OutputUri: aws.String("S3Url"), // Required
  19. BatchPredictionName: aws.String("EntityName"),
  20. }
  21. resp, err := svc.CreateBatchPrediction(params)
  22. if err != nil {
  23. // Print the error, cast err to awserr.Error to get the Code and
  24. // Message from an error.
  25. fmt.Println(err.Error())
  26. return
  27. }
  28. // Pretty-print the response data.
  29. fmt.Println(resp)
  30. }
  31. func ExampleMachineLearning_CreateDataSourceFromRDS() {
  32. svc := machinelearning.New(nil)
  33. params := &machinelearning.CreateDataSourceFromRDSInput{
  34. DataSourceId: aws.String("EntityId"), // Required
  35. RDSData: &machinelearning.RDSDataSpec{ // Required
  36. DatabaseCredentials: &machinelearning.RDSDatabaseCredentials{ // Required
  37. Password: aws.String("RDSDatabasePassword"), // Required
  38. Username: aws.String("RDSDatabaseUsername"), // Required
  39. },
  40. DatabaseInformation: &machinelearning.RDSDatabase{ // Required
  41. DatabaseName: aws.String("RDSDatabaseName"), // Required
  42. InstanceIdentifier: aws.String("RDSInstanceIdentifier"), // Required
  43. },
  44. ResourceRole: aws.String("EDPResourceRole"), // Required
  45. S3StagingLocation: aws.String("S3Url"), // Required
  46. SecurityGroupIds: []*string{ // Required
  47. aws.String("EDPSecurityGroupId"), // Required
  48. // More values...
  49. },
  50. SelectSqlQuery: aws.String("RDSSelectSqlQuery"), // Required
  51. ServiceRole: aws.String("EDPServiceRole"), // Required
  52. SubnetId: aws.String("EDPSubnetId"), // Required
  53. DataRearrangement: aws.String("DataRearrangement"),
  54. DataSchema: aws.String("DataSchema"),
  55. DataSchemaUri: aws.String("S3Url"),
  56. },
  57. RoleARN: aws.String("RoleARN"), // Required
  58. ComputeStatistics: aws.Bool(true),
  59. DataSourceName: aws.String("EntityName"),
  60. }
  61. resp, err := svc.CreateDataSourceFromRDS(params)
  62. if err != nil {
  63. // Print the error, cast err to awserr.Error to get the Code and
  64. // Message from an error.
  65. fmt.Println(err.Error())
  66. return
  67. }
  68. // Pretty-print the response data.
  69. fmt.Println(resp)
  70. }
  71. func ExampleMachineLearning_CreateDataSourceFromRedshift() {
  72. svc := machinelearning.New(nil)
  73. params := &machinelearning.CreateDataSourceFromRedshiftInput{
  74. DataSourceId: aws.String("EntityId"), // Required
  75. DataSpec: &machinelearning.RedshiftDataSpec{ // Required
  76. DatabaseCredentials: &machinelearning.RedshiftDatabaseCredentials{ // Required
  77. Password: aws.String("RedshiftDatabasePassword"), // Required
  78. Username: aws.String("RedshiftDatabaseUsername"), // Required
  79. },
  80. DatabaseInformation: &machinelearning.RedshiftDatabase{ // Required
  81. ClusterIdentifier: aws.String("RedshiftClusterIdentifier"), // Required
  82. DatabaseName: aws.String("RedshiftDatabaseName"), // Required
  83. },
  84. S3StagingLocation: aws.String("S3Url"), // Required
  85. SelectSqlQuery: aws.String("RedshiftSelectSqlQuery"), // Required
  86. DataRearrangement: aws.String("DataRearrangement"),
  87. DataSchema: aws.String("DataSchema"),
  88. DataSchemaUri: aws.String("S3Url"),
  89. },
  90. RoleARN: aws.String("RoleARN"), // Required
  91. ComputeStatistics: aws.Bool(true),
  92. DataSourceName: aws.String("EntityName"),
  93. }
  94. resp, err := svc.CreateDataSourceFromRedshift(params)
  95. if err != nil {
  96. // Print the error, cast err to awserr.Error to get the Code and
  97. // Message from an error.
  98. fmt.Println(err.Error())
  99. return
  100. }
  101. // Pretty-print the response data.
  102. fmt.Println(resp)
  103. }
  104. func ExampleMachineLearning_CreateDataSourceFromS3() {
  105. svc := machinelearning.New(nil)
  106. params := &machinelearning.CreateDataSourceFromS3Input{
  107. DataSourceId: aws.String("EntityId"), // Required
  108. DataSpec: &machinelearning.S3DataSpec{ // Required
  109. DataLocationS3: aws.String("S3Url"), // Required
  110. DataRearrangement: aws.String("DataRearrangement"),
  111. DataSchema: aws.String("DataSchema"),
  112. DataSchemaLocationS3: aws.String("S3Url"),
  113. },
  114. ComputeStatistics: aws.Bool(true),
  115. DataSourceName: aws.String("EntityName"),
  116. }
  117. resp, err := svc.CreateDataSourceFromS3(params)
  118. if err != nil {
  119. // Print the error, cast err to awserr.Error to get the Code and
  120. // Message from an error.
  121. fmt.Println(err.Error())
  122. return
  123. }
  124. // Pretty-print the response data.
  125. fmt.Println(resp)
  126. }
  127. func ExampleMachineLearning_CreateEvaluation() {
  128. svc := machinelearning.New(nil)
  129. params := &machinelearning.CreateEvaluationInput{
  130. EvaluationDataSourceId: aws.String("EntityId"), // Required
  131. EvaluationId: aws.String("EntityId"), // Required
  132. MLModelId: aws.String("EntityId"), // Required
  133. EvaluationName: aws.String("EntityName"),
  134. }
  135. resp, err := svc.CreateEvaluation(params)
  136. if err != nil {
  137. // Print the error, cast err to awserr.Error to get the Code and
  138. // Message from an error.
  139. fmt.Println(err.Error())
  140. return
  141. }
  142. // Pretty-print the response data.
  143. fmt.Println(resp)
  144. }
  145. func ExampleMachineLearning_CreateMLModel() {
  146. svc := machinelearning.New(nil)
  147. params := &machinelearning.CreateMLModelInput{
  148. MLModelId: aws.String("EntityId"), // Required
  149. MLModelType: aws.String("MLModelType"), // Required
  150. TrainingDataSourceId: aws.String("EntityId"), // Required
  151. MLModelName: aws.String("EntityName"),
  152. Parameters: map[string]*string{
  153. "Key": aws.String("StringType"), // Required
  154. // More values...
  155. },
  156. Recipe: aws.String("Recipe"),
  157. RecipeUri: aws.String("S3Url"),
  158. }
  159. resp, err := svc.CreateMLModel(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 ExampleMachineLearning_CreateRealtimeEndpoint() {
  170. svc := machinelearning.New(nil)
  171. params := &machinelearning.CreateRealtimeEndpointInput{
  172. MLModelId: aws.String("EntityId"), // Required
  173. }
  174. resp, err := svc.CreateRealtimeEndpoint(params)
  175. if err != nil {
  176. // Print the error, cast err to awserr.Error to get the Code and
  177. // Message from an error.
  178. fmt.Println(err.Error())
  179. return
  180. }
  181. // Pretty-print the response data.
  182. fmt.Println(resp)
  183. }
  184. func ExampleMachineLearning_DeleteBatchPrediction() {
  185. svc := machinelearning.New(nil)
  186. params := &machinelearning.DeleteBatchPredictionInput{
  187. BatchPredictionId: aws.String("EntityId"), // Required
  188. }
  189. resp, err := svc.DeleteBatchPrediction(params)
  190. if err != nil {
  191. // Print the error, cast err to awserr.Error to get the Code and
  192. // Message from an error.
  193. fmt.Println(err.Error())
  194. return
  195. }
  196. // Pretty-print the response data.
  197. fmt.Println(resp)
  198. }
  199. func ExampleMachineLearning_DeleteDataSource() {
  200. svc := machinelearning.New(nil)
  201. params := &machinelearning.DeleteDataSourceInput{
  202. DataSourceId: aws.String("EntityId"), // Required
  203. }
  204. resp, err := svc.DeleteDataSource(params)
  205. if err != nil {
  206. // Print the error, cast err to awserr.Error to get the Code and
  207. // Message from an error.
  208. fmt.Println(err.Error())
  209. return
  210. }
  211. // Pretty-print the response data.
  212. fmt.Println(resp)
  213. }
  214. func ExampleMachineLearning_DeleteEvaluation() {
  215. svc := machinelearning.New(nil)
  216. params := &machinelearning.DeleteEvaluationInput{
  217. EvaluationId: aws.String("EntityId"), // Required
  218. }
  219. resp, err := svc.DeleteEvaluation(params)
  220. if err != nil {
  221. // Print the error, cast err to awserr.Error to get the Code and
  222. // Message from an error.
  223. fmt.Println(err.Error())
  224. return
  225. }
  226. // Pretty-print the response data.
  227. fmt.Println(resp)
  228. }
  229. func ExampleMachineLearning_DeleteMLModel() {
  230. svc := machinelearning.New(nil)
  231. params := &machinelearning.DeleteMLModelInput{
  232. MLModelId: aws.String("EntityId"), // Required
  233. }
  234. resp, err := svc.DeleteMLModel(params)
  235. if err != nil {
  236. // Print the error, cast err to awserr.Error to get the Code and
  237. // Message from an error.
  238. fmt.Println(err.Error())
  239. return
  240. }
  241. // Pretty-print the response data.
  242. fmt.Println(resp)
  243. }
  244. func ExampleMachineLearning_DeleteRealtimeEndpoint() {
  245. svc := machinelearning.New(nil)
  246. params := &machinelearning.DeleteRealtimeEndpointInput{
  247. MLModelId: aws.String("EntityId"), // Required
  248. }
  249. resp, err := svc.DeleteRealtimeEndpoint(params)
  250. if err != nil {
  251. // Print the error, cast err to awserr.Error to get the Code and
  252. // Message from an error.
  253. fmt.Println(err.Error())
  254. return
  255. }
  256. // Pretty-print the response data.
  257. fmt.Println(resp)
  258. }
  259. func ExampleMachineLearning_DescribeBatchPredictions() {
  260. svc := machinelearning.New(nil)
  261. params := &machinelearning.DescribeBatchPredictionsInput{
  262. EQ: aws.String("ComparatorValue"),
  263. FilterVariable: aws.String("BatchPredictionFilterVariable"),
  264. GE: aws.String("ComparatorValue"),
  265. GT: aws.String("ComparatorValue"),
  266. LE: aws.String("ComparatorValue"),
  267. LT: aws.String("ComparatorValue"),
  268. Limit: aws.Int64(1),
  269. NE: aws.String("ComparatorValue"),
  270. NextToken: aws.String("StringType"),
  271. Prefix: aws.String("ComparatorValue"),
  272. SortOrder: aws.String("SortOrder"),
  273. }
  274. resp, err := svc.DescribeBatchPredictions(params)
  275. if err != nil {
  276. // Print the error, cast err to awserr.Error to get the Code and
  277. // Message from an error.
  278. fmt.Println(err.Error())
  279. return
  280. }
  281. // Pretty-print the response data.
  282. fmt.Println(resp)
  283. }
  284. func ExampleMachineLearning_DescribeDataSources() {
  285. svc := machinelearning.New(nil)
  286. params := &machinelearning.DescribeDataSourcesInput{
  287. EQ: aws.String("ComparatorValue"),
  288. FilterVariable: aws.String("DataSourceFilterVariable"),
  289. GE: aws.String("ComparatorValue"),
  290. GT: aws.String("ComparatorValue"),
  291. LE: aws.String("ComparatorValue"),
  292. LT: aws.String("ComparatorValue"),
  293. Limit: aws.Int64(1),
  294. NE: aws.String("ComparatorValue"),
  295. NextToken: aws.String("StringType"),
  296. Prefix: aws.String("ComparatorValue"),
  297. SortOrder: aws.String("SortOrder"),
  298. }
  299. resp, err := svc.DescribeDataSources(params)
  300. if err != nil {
  301. // Print the error, cast err to awserr.Error to get the Code and
  302. // Message from an error.
  303. fmt.Println(err.Error())
  304. return
  305. }
  306. // Pretty-print the response data.
  307. fmt.Println(resp)
  308. }
  309. func ExampleMachineLearning_DescribeEvaluations() {
  310. svc := machinelearning.New(nil)
  311. params := &machinelearning.DescribeEvaluationsInput{
  312. EQ: aws.String("ComparatorValue"),
  313. FilterVariable: aws.String("EvaluationFilterVariable"),
  314. GE: aws.String("ComparatorValue"),
  315. GT: aws.String("ComparatorValue"),
  316. LE: aws.String("ComparatorValue"),
  317. LT: aws.String("ComparatorValue"),
  318. Limit: aws.Int64(1),
  319. NE: aws.String("ComparatorValue"),
  320. NextToken: aws.String("StringType"),
  321. Prefix: aws.String("ComparatorValue"),
  322. SortOrder: aws.String("SortOrder"),
  323. }
  324. resp, err := svc.DescribeEvaluations(params)
  325. if err != nil {
  326. // Print the error, cast err to awserr.Error to get the Code and
  327. // Message from an error.
  328. fmt.Println(err.Error())
  329. return
  330. }
  331. // Pretty-print the response data.
  332. fmt.Println(resp)
  333. }
  334. func ExampleMachineLearning_DescribeMLModels() {
  335. svc := machinelearning.New(nil)
  336. params := &machinelearning.DescribeMLModelsInput{
  337. EQ: aws.String("ComparatorValue"),
  338. FilterVariable: aws.String("MLModelFilterVariable"),
  339. GE: aws.String("ComparatorValue"),
  340. GT: aws.String("ComparatorValue"),
  341. LE: aws.String("ComparatorValue"),
  342. LT: aws.String("ComparatorValue"),
  343. Limit: aws.Int64(1),
  344. NE: aws.String("ComparatorValue"),
  345. NextToken: aws.String("StringType"),
  346. Prefix: aws.String("ComparatorValue"),
  347. SortOrder: aws.String("SortOrder"),
  348. }
  349. resp, err := svc.DescribeMLModels(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. }
  359. func ExampleMachineLearning_GetBatchPrediction() {
  360. svc := machinelearning.New(nil)
  361. params := &machinelearning.GetBatchPredictionInput{
  362. BatchPredictionId: aws.String("EntityId"), // Required
  363. }
  364. resp, err := svc.GetBatchPrediction(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 ExampleMachineLearning_GetDataSource() {
  375. svc := machinelearning.New(nil)
  376. params := &machinelearning.GetDataSourceInput{
  377. DataSourceId: aws.String("EntityId"), // Required
  378. Verbose: aws.Bool(true),
  379. }
  380. resp, err := svc.GetDataSource(params)
  381. if err != nil {
  382. // Print the error, cast err to awserr.Error to get the Code and
  383. // Message from an error.
  384. fmt.Println(err.Error())
  385. return
  386. }
  387. // Pretty-print the response data.
  388. fmt.Println(resp)
  389. }
  390. func ExampleMachineLearning_GetEvaluation() {
  391. svc := machinelearning.New(nil)
  392. params := &machinelearning.GetEvaluationInput{
  393. EvaluationId: aws.String("EntityId"), // Required
  394. }
  395. resp, err := svc.GetEvaluation(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 ExampleMachineLearning_GetMLModel() {
  406. svc := machinelearning.New(nil)
  407. params := &machinelearning.GetMLModelInput{
  408. MLModelId: aws.String("EntityId"), // Required
  409. Verbose: aws.Bool(true),
  410. }
  411. resp, err := svc.GetMLModel(params)
  412. if err != nil {
  413. // Print the error, cast err to awserr.Error to get the Code and
  414. // Message from an error.
  415. fmt.Println(err.Error())
  416. return
  417. }
  418. // Pretty-print the response data.
  419. fmt.Println(resp)
  420. }
  421. func ExampleMachineLearning_Predict() {
  422. svc := machinelearning.New(nil)
  423. params := &machinelearning.PredictInput{
  424. MLModelId: aws.String("EntityId"), // Required
  425. PredictEndpoint: aws.String("VipURL"), // Required
  426. Record: map[string]*string{ // Required
  427. "Key": aws.String("VariableValue"), // Required
  428. // More values...
  429. },
  430. }
  431. resp, err := svc.Predict(params)
  432. if err != nil {
  433. // Print the error, cast err to awserr.Error to get the Code and
  434. // Message from an error.
  435. fmt.Println(err.Error())
  436. return
  437. }
  438. // Pretty-print the response data.
  439. fmt.Println(resp)
  440. }
  441. func ExampleMachineLearning_UpdateBatchPrediction() {
  442. svc := machinelearning.New(nil)
  443. params := &machinelearning.UpdateBatchPredictionInput{
  444. BatchPredictionId: aws.String("EntityId"), // Required
  445. BatchPredictionName: aws.String("EntityName"), // Required
  446. }
  447. resp, err := svc.UpdateBatchPrediction(params)
  448. if err != nil {
  449. // Print the error, cast err to awserr.Error to get the Code and
  450. // Message from an error.
  451. fmt.Println(err.Error())
  452. return
  453. }
  454. // Pretty-print the response data.
  455. fmt.Println(resp)
  456. }
  457. func ExampleMachineLearning_UpdateDataSource() {
  458. svc := machinelearning.New(nil)
  459. params := &machinelearning.UpdateDataSourceInput{
  460. DataSourceId: aws.String("EntityId"), // Required
  461. DataSourceName: aws.String("EntityName"), // Required
  462. }
  463. resp, err := svc.UpdateDataSource(params)
  464. if err != nil {
  465. // Print the error, cast err to awserr.Error to get the Code and
  466. // Message from an error.
  467. fmt.Println(err.Error())
  468. return
  469. }
  470. // Pretty-print the response data.
  471. fmt.Println(resp)
  472. }
  473. func ExampleMachineLearning_UpdateEvaluation() {
  474. svc := machinelearning.New(nil)
  475. params := &machinelearning.UpdateEvaluationInput{
  476. EvaluationId: aws.String("EntityId"), // Required
  477. EvaluationName: aws.String("EntityName"), // Required
  478. }
  479. resp, err := svc.UpdateEvaluation(params)
  480. if err != nil {
  481. // Print the error, cast err to awserr.Error to get the Code and
  482. // Message from an error.
  483. fmt.Println(err.Error())
  484. return
  485. }
  486. // Pretty-print the response data.
  487. fmt.Println(resp)
  488. }
  489. func ExampleMachineLearning_UpdateMLModel() {
  490. svc := machinelearning.New(nil)
  491. params := &machinelearning.UpdateMLModelInput{
  492. MLModelId: aws.String("EntityId"), // Required
  493. MLModelName: aws.String("EntityName"),
  494. ScoreThreshold: aws.Float64(1.0),
  495. }
  496. resp, err := svc.UpdateMLModel(params)
  497. if err != nil {
  498. // Print the error, cast err to awserr.Error to get the Code and
  499. // Message from an error.
  500. fmt.Println(err.Error())
  501. return
  502. }
  503. // Pretty-print the response data.
  504. fmt.Println(resp)
  505. }