Best JavaScript code snippet using storybook-root
schematics-2-0-api.v2.test.js
Source:schematics-2-0-api.v2.test.js
1/**2* @jest-environment node3*/4/**5 * (C) Copyright IBM Corp. 2022.6 *7 * Licensed under the Apache License, Version 2.0 (the "License");8 * you may not use this file except in compliance with the License.9 * You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing, software14 * distributed under the License is distributed on an "AS IS" BASIS,15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.16 * See the License for the specific language governing permissions and17 * limitations under the License.18 */19 'use strict';20 const Schematics20ApiV2 = require('../dist/schematics-2-0-api/v2');21 const { readExternalSources } = require('ibm-cloud-sdk-core');22 const authHelper = require('../test/resources/auth-helper.js');23 24 // Location of our config file.25 const configFile = 'schematics20_api_v2.env';26 27 const describe = authHelper.prepareTests(configFile);28 29 // Save original console.log and console.warn30 const originalLog = console.log;31 const originalWarn = console.warn;32 33 // Mocks for console.log and console.warn34 const consoleLogMock = jest.spyOn(console, 'log');35 const consoleWarnMock = jest.spyOn(console, 'warn');36 37 describe('Schematics20ApiV2', () => {38 39 // begin-common40 41 const schematics20ApiService = Schematics20ApiV2.newInstance({});42 43 // end-common44 45 const config = readExternalSources(Schematics20ApiV2.DEFAULT_SERVICE_NAME);46 47 test('getSchematicsInfo request example', done => {48 49 consoleLogMock.mockImplementation(output => {50 originalLog(output);51 done();52 });53 consoleWarnMock.mockImplementation(output => {54 done(output);55 });56 57 // begin-get_schematics_info58 59 schematics20ApiService.getSchematicsInfo({})60 .then(res => {61 console.log(JSON.stringify(res.result, null, 2));62 })63 .catch(err => {64 console.warn(err)65 });66 67 // end-get_schematics_info68 });69 test('listSchematicsAccessRules request example', done => {70 71 consoleLogMock.mockImplementation(output => {72 originalLog(output);73 done();74 });75 consoleWarnMock.mockImplementation(output => {76 done(output);77 });78 79 // begin-list_schematics_access_rules80 81 schematics20ApiService.listSchematicsAccessRules({})82 .then(res => {83 console.log(JSON.stringify(res.result, null, 2));84 })85 .catch(err => {86 console.warn(err)87 });88 89 // end-list_schematics_access_rules90 });91 test('getSchematicsAccessRulesForResource request example', done => {92 93 consoleLogMock.mockImplementation(output => {94 originalLog(output);95 done();96 });97 consoleWarnMock.mockImplementation(output => {98 done(output);99 });100 101 // begin-get_schematics_access_rules_for_resource102 103 const params = {104 resourceName: 'testString',105 };106 107 schematics20ApiService.getSchematicsAccessRulesForResource(params)108 .then(res => {109 console.log(JSON.stringify(res.result, null, 2));110 })111 .catch(err => {112 console.warn(err)113 });114 115 // end-get_schematics_access_rules_for_resource116 });117 test('getSchematicsCommandNames request example', done => {118 119 consoleLogMock.mockImplementation(output => {120 originalLog(output);121 done();122 });123 consoleWarnMock.mockImplementation(output => {124 done(output);125 });126 127 // begin-get_schematics_command_names128 129 const params = {130 resourceName: 'testString',131 };132 133 schematics20ApiService.getSchematicsCommandNames(params)134 .then(res => {135 console.log(JSON.stringify(res.result, null, 2));136 })137 .catch(err => {138 console.warn(err)139 });140 141 // end-get_schematics_command_names142 });143 test('listWorkspaces request example', done => {144 145 consoleLogMock.mockImplementation(output => {146 originalLog(output);147 done();148 });149 consoleWarnMock.mockImplementation(output => {150 done(output);151 });152 153 // begin-list_workspaces154 155 schematics20ApiService.listWorkspaces({})156 .then(res => {157 console.log(JSON.stringify(res.result, null, 2));158 })159 .catch(err => {160 console.warn(err)161 });162 163 // end-list_workspaces164 });165 test('createWorkspace request example', done => {166 167 consoleLogMock.mockImplementation(output => {168 originalLog(output);169 done();170 });171 consoleWarnMock.mockImplementation(output => {172 done(output);173 });174 175 // begin-create_workspace176 177 const params = {178 workspace: workspaceModel,179 };180 181 schematics20ApiService.createWorkspace(params)182 .then(res => {183 console.log(JSON.stringify(res.result, null, 2));184 })185 .catch(err => {186 console.warn(err)187 });188 189 // end-create_workspace190 });191 test('getWorkspace request example', done => {192 193 consoleLogMock.mockImplementation(output => {194 originalLog(output);195 done();196 });197 consoleWarnMock.mockImplementation(output => {198 done(output);199 });200 201 // begin-get_workspace202 203 const params = {204 wId: 'testString',205 };206 207 schematics20ApiService.getWorkspace(params)208 .then(res => {209 console.log(JSON.stringify(res.result, null, 2));210 })211 .catch(err => {212 console.warn(err)213 });214 215 // end-get_workspace216 });217 test('replaceWorkspace request example', done => {218 219 consoleLogMock.mockImplementation(output => {220 originalLog(output);221 done();222 });223 consoleWarnMock.mockImplementation(output => {224 done(output);225 });226 227 // begin-replace_workspace228 229 const params = {230 wId: 'testString',231 workspace: workspaceModel,232 };233 234 schematics20ApiService.replaceWorkspace(params)235 .then(res => {236 console.log(JSON.stringify(res.result, null, 2));237 })238 .catch(err => {239 console.warn(err)240 });241 242 // end-replace_workspace243 });244 test('updateWorkspace request example', done => {245 246 consoleLogMock.mockImplementation(output => {247 originalLog(output);248 done();249 });250 consoleWarnMock.mockImplementation(output => {251 done(output);252 });253 254 // begin-update_workspace255 256 const params = {257 wId: 'testString',258 workspace: workspaceModel,259 };260 261 schematics20ApiService.updateWorkspace(params)262 .then(res => {263 console.log(JSON.stringify(res.result, null, 2));264 })265 .catch(err => {266 console.warn(err)267 });268 269 // end-update_workspace270 });271 test('listWorkspaceInputs request example', done => {272 273 consoleLogMock.mockImplementation(output => {274 originalLog(output);275 done();276 });277 consoleWarnMock.mockImplementation(output => {278 done(output);279 });280 281 // begin-list_workspace_inputs282 283 const params = {284 wId: 'testString',285 };286 287 schematics20ApiService.listWorkspaceInputs(params)288 .then(res => {289 console.log(JSON.stringify(res.result, null, 2));290 })291 .catch(err => {292 console.warn(err)293 });294 295 // end-list_workspace_inputs296 });297 test('listWorkspaceOutputs request example', done => {298 299 consoleLogMock.mockImplementation(output => {300 originalLog(output);301 done();302 });303 consoleWarnMock.mockImplementation(output => {304 done(output);305 });306 307 // begin-list_workspace_outputs308 309 const params = {310 wId: 'testString',311 };312 313 schematics20ApiService.listWorkspaceOutputs(params)314 .then(res => {315 console.log(JSON.stringify(res.result, null, 2));316 })317 .catch(err => {318 console.warn(err)319 });320 321 // end-list_workspace_outputs322 });323 test('createWorkspaceTemplates request example', done => {324 325 consoleLogMock.mockImplementation(output => {326 originalLog(output);327 done();328 });329 consoleWarnMock.mockImplementation(output => {330 done(output);331 });332 333 // begin-create_workspace_templates334 335 const params = {336 templateListRequest: templateListRequestModel,337 };338 339 schematics20ApiService.createWorkspaceTemplates(params)340 .then(res => {341 console.log(JSON.stringify(res.result, null, 2));342 })343 .catch(err => {344 console.warn(err)345 });346 347 // end-create_workspace_templates348 });349 test('listTemplatesInWorkspace request example', done => {350 351 consoleLogMock.mockImplementation(output => {352 originalLog(output);353 done();354 });355 consoleWarnMock.mockImplementation(output => {356 done(output);357 });358 359 // begin-list_templates_in_workspace360 361 const params = {362 wId: 'testString',363 };364 365 schematics20ApiService.listTemplatesInWorkspace(params)366 .then(res => {367 console.log(JSON.stringify(res.result, null, 2));368 })369 .catch(err => {370 console.warn(err)371 });372 373 // end-list_templates_in_workspace374 });375 test('addTemplatesToWorkspace request example', done => {376 377 consoleLogMock.mockImplementation(output => {378 originalLog(output);379 done();380 });381 consoleWarnMock.mockImplementation(output => {382 done(output);383 });384 385 // begin-add_templates_to_workspace386 387 const params = {388 wId: 'testString',389 template: templateModel,390 };391 392 schematics20ApiService.addTemplatesToWorkspace(params)393 .then(res => {394 console.log(JSON.stringify(res.result, null, 2));395 })396 .catch(err => {397 console.warn(err)398 });399 400 // end-add_templates_to_workspace401 });402 test('getTemplateInWorkspace request example', done => {403 404 consoleLogMock.mockImplementation(output => {405 originalLog(output);406 done();407 });408 consoleWarnMock.mockImplementation(output => {409 done(output);410 });411 412 // begin-get_template_in_workspace413 414 const params = {415 wId: 'testString',416 tId: 'testString',417 };418 419 schematics20ApiService.getTemplateInWorkspace(params)420 .then(res => {421 console.log(JSON.stringify(res.result, null, 2));422 })423 .catch(err => {424 console.warn(err)425 });426 427 // end-get_template_in_workspace428 });429 test('replaceTemplateInWorkspace request example', done => {430 431 consoleLogMock.mockImplementation(output => {432 originalLog(output);433 done();434 });435 consoleWarnMock.mockImplementation(output => {436 done(output);437 });438 439 // begin-replace_template_in_workspace440 441 const params = {442 wId: 'testString',443 tId: 'testString',444 };445 446 schematics20ApiService.replaceTemplateInWorkspace(params)447 .then(res => {448 console.log(JSON.stringify(res.result, null, 2));449 })450 .catch(err => {451 console.warn(err)452 });453 454 // end-replace_template_in_workspace455 });456 test('updateTemplateInWorkspace request example', done => {457 458 consoleLogMock.mockImplementation(output => {459 originalLog(output);460 done();461 });462 consoleWarnMock.mockImplementation(output => {463 done(output);464 });465 466 // begin-update_template_in_workspace467 468 const params = {469 wId: 'testString',470 tId: 'testString',471 };472 473 schematics20ApiService.updateTemplateInWorkspace(params)474 .then(res => {475 console.log(JSON.stringify(res.result, null, 2));476 })477 .catch(err => {478 console.warn(err)479 });480 481 // end-update_template_in_workspace482 });483 test('uploadTemplateTarInWorkspace request example', done => {484 485 consoleLogMock.mockImplementation(output => {486 originalLog(output);487 done();488 });489 consoleWarnMock.mockImplementation(output => {490 done(output);491 });492 493 // begin-upload_template_tar_in_workspace494 495 const params = {496 wId: 'testString',497 tId: 'testString',498 };499 500 schematics20ApiService.uploadTemplateTarInWorkspace(params)501 .then(res => {502 console.log(JSON.stringify(res.result, null, 2));503 })504 .catch(err => {505 console.warn(err)506 });507 508 // end-upload_template_tar_in_workspace509 });510 test('getTemplateReadme request example', done => {511 512 consoleLogMock.mockImplementation(output => {513 originalLog(output);514 done();515 });516 consoleWarnMock.mockImplementation(output => {517 done(output);518 });519 520 // begin-get_template_readme521 522 const params = {523 wId: 'testString',524 tId: 'testString',525 };526 527 schematics20ApiService.getTemplateReadme(params)528 .then(res => {529 console.log(JSON.stringify(res.result, null, 2));530 })531 .catch(err => {532 console.warn(err)533 });534 535 // end-get_template_readme536 });537 test('getTemplateSource request example', done => {538 539 consoleLogMock.mockImplementation(output => {540 originalLog(output);541 done();542 });543 consoleWarnMock.mockImplementation(output => {544 done(output);545 });546 547 // begin-get_template_source548 549 const params = {550 wId: 'testString',551 tId: 'testString',552 };553 554 schematics20ApiService.getTemplateSource(params)555 .then(res => {556 console.log(JSON.stringify(res.result, null, 2));557 })558 .catch(err => {559 console.warn(err)560 });561 562 // end-get_template_source563 });564 test('listTemplateInputs request example', done => {565 566 consoleLogMock.mockImplementation(output => {567 originalLog(output);568 done();569 });570 consoleWarnMock.mockImplementation(output => {571 done(output);572 });573 574 // begin-list_template_inputs575 576 const params = {577 wId: 'testString',578 tId: 'testString',579 };580 581 schematics20ApiService.listTemplateInputs(params)582 .then(res => {583 console.log(JSON.stringify(res.result, null, 2));584 })585 .catch(err => {586 console.warn(err)587 });588 589 // end-list_template_inputs590 });591 test('listTemplateOutputs request example', done => {592 593 consoleLogMock.mockImplementation(output => {594 originalLog(output);595 done();596 });597 consoleWarnMock.mockImplementation(output => {598 done(output);599 });600 601 // begin-list_template_outputs602 603 const params = {604 wId: 'testString',605 tId: 'testString',606 };607 608 schematics20ApiService.listTemplateOutputs(params)609 .then(res => {610 console.log(JSON.stringify(res.result, null, 2));611 })612 .catch(err => {613 console.warn(err)614 });615 616 // end-list_template_outputs617 });618 test('listFlowsInWorkspace request example', done => {619 620 consoleLogMock.mockImplementation(output => {621 originalLog(output);622 done();623 });624 consoleWarnMock.mockImplementation(output => {625 done(output);626 });627 628 // begin-list_flows_in_workspace629 630 const params = {631 wId: 'testString',632 };633 634 schematics20ApiService.listFlowsInWorkspace(params)635 .then(res => {636 console.log(JSON.stringify(res.result, null, 2));637 })638 .catch(err => {639 console.warn(err)640 });641 642 // end-list_flows_in_workspace643 });644 test('addFlowToWorkspace request example', done => {645 646 consoleLogMock.mockImplementation(output => {647 originalLog(output);648 done();649 });650 consoleWarnMock.mockImplementation(output => {651 done(output);652 });653 654 // begin-add_flow_to_workspace655 656 const params = {657 wId: 'testString',658 templateFlow: templateFlowModel,659 };660 661 schematics20ApiService.addFlowToWorkspace(params)662 .then(res => {663 console.log(JSON.stringify(res.result, null, 2));664 })665 .catch(err => {666 console.warn(err)667 });668 669 // end-add_flow_to_workspace670 });671 test('getFlowInWorkspace request example', done => {672 673 consoleLogMock.mockImplementation(output => {674 originalLog(output);675 done();676 });677 consoleWarnMock.mockImplementation(output => {678 done(output);679 });680 681 // begin-get_flow_in_workspace682 683 const params = {684 wId: 'testString',685 flowId: 'testString',686 };687 688 schematics20ApiService.getFlowInWorkspace(params)689 .then(res => {690 console.log(JSON.stringify(res.result, null, 2));691 })692 .catch(err => {693 console.warn(err)694 });695 696 // end-get_flow_in_workspace697 });698 test('replaceFlowInWorkspace request example', done => {699 700 consoleLogMock.mockImplementation(output => {701 originalLog(output);702 done();703 });704 consoleWarnMock.mockImplementation(output => {705 done(output);706 });707 708 // begin-replace_flow_in_workspace709 710 const params = {711 wId: 'testString',712 flowId: 'testString',713 };714 715 schematics20ApiService.replaceFlowInWorkspace(params)716 .then(res => {717 console.log(JSON.stringify(res.result, null, 2));718 })719 .catch(err => {720 console.warn(err)721 });722 723 // end-replace_flow_in_workspace724 });725 test('updateFlowInWorkspace request example', done => {726 727 consoleLogMock.mockImplementation(output => {728 originalLog(output);729 done();730 });731 consoleWarnMock.mockImplementation(output => {732 done(output);733 });734 735 // begin-update_flow_in_workspace736 737 const params = {738 wId: 'testString',739 flowId: 'testString',740 };741 742 schematics20ApiService.updateFlowInWorkspace(params)743 .then(res => {744 console.log(JSON.stringify(res.result, null, 2));745 })746 .catch(err => {747 console.warn(err)748 });749 750 // end-update_flow_in_workspace751 });752 test('listActions request example', done => {753 754 consoleLogMock.mockImplementation(output => {755 originalLog(output);756 done();757 });758 consoleWarnMock.mockImplementation(output => {759 done(output);760 });761 762 // begin-list_actions763 764 schematics20ApiService.listActions({})765 .then(res => {766 console.log(JSON.stringify(res.result, null, 2));767 })768 .catch(err => {769 console.warn(err)770 });771 772 // end-list_actions773 });774 test('createAction request example', done => {775 776 consoleLogMock.mockImplementation(output => {777 originalLog(output);778 done();779 });780 consoleWarnMock.mockImplementation(output => {781 done(output);782 });783 784 // begin-create_action785 786 const params = {787 action: actionModel,788 };789 790 schematics20ApiService.createAction(params)791 .then(res => {792 console.log(JSON.stringify(res.result, null, 2));793 })794 .catch(err => {795 console.warn(err)796 });797 798 // end-create_action799 });800 test('getAction request example', done => {801 802 consoleLogMock.mockImplementation(output => {803 originalLog(output);804 done();805 });806 consoleWarnMock.mockImplementation(output => {807 done(output);808 });809 810 // begin-get_action811 812 const params = {813 actionId: 'testString',814 };815 816 schematics20ApiService.getAction(params)817 .then(res => {818 console.log(JSON.stringify(res.result, null, 2));819 })820 .catch(err => {821 console.warn(err)822 });823 824 // end-get_action825 });826 test('updateAction request example', done => {827 828 consoleLogMock.mockImplementation(output => {829 originalLog(output);830 done();831 });832 consoleWarnMock.mockImplementation(output => {833 done(output);834 });835 836 // begin-update_action837 838 const params = {839 actionId: 'testString',840 action: actionModel,841 };842 843 schematics20ApiService.updateAction(params)844 .then(res => {845 console.log(JSON.stringify(res.result, null, 2));846 })847 .catch(err => {848 console.warn(err)849 });850 851 // end-update_action852 });853 test('uploadTemplateTarAction request example', done => {854 855 consoleLogMock.mockImplementation(output => {856 originalLog(output);857 done();858 });859 consoleWarnMock.mockImplementation(output => {860 done(output);861 });862 863 // begin-upload_template_tar_action864 865 const params = {866 actionId: 'testString',867 };868 869 schematics20ApiService.uploadTemplateTarAction(params)870 .then(res => {871 console.log(JSON.stringify(res.result, null, 2));872 })873 .catch(err => {874 console.warn(err)875 });876 877 // end-upload_template_tar_action878 });879 test('listJobs request example', done => {880 881 consoleLogMock.mockImplementation(output => {882 originalLog(output);883 done();884 });885 consoleWarnMock.mockImplementation(output => {886 done(output);887 });888 889 // begin-list_jobs890 891 schematics20ApiService.listJobs({})892 .then(res => {893 console.log(JSON.stringify(res.result, null, 2));894 })895 .catch(err => {896 console.warn(err)897 });898 899 // end-list_jobs900 });901 test('createJob request example', done => {902 903 consoleLogMock.mockImplementation(output => {904 originalLog(output);905 done();906 });907 consoleWarnMock.mockImplementation(output => {908 done(output);909 });910 911 // begin-create_job912 913 const params = {914 refreshToken: 'testString',915 job: jobModel,916 };917 918 schematics20ApiService.createJob(params)919 .then(res => {920 console.log(JSON.stringify(res.result, null, 2));921 })922 .catch(err => {923 console.warn(err)924 });925 926 // end-create_job927 });928 test('getJob request example', done => {929 930 consoleLogMock.mockImplementation(output => {931 originalLog(output);932 done();933 });934 consoleWarnMock.mockImplementation(output => {935 done(output);936 });937 938 // begin-get_job939 940 const params = {941 jobId: 'testString',942 };943 944 schematics20ApiService.getJob(params)945 .then(res => {946 console.log(JSON.stringify(res.result, null, 2));947 })948 .catch(err => {949 console.warn(err)950 });951 952 // end-get_job953 });954 test('updateJob request example', done => {955 956 consoleLogMock.mockImplementation(output => {957 originalLog(output);958 done();959 });960 consoleWarnMock.mockImplementation(output => {961 done(output);962 });963 964 // begin-update_job965 966 const params = {967 jobId: 'testString',968 refreshToken: 'testString',969 job: jobModel,970 };971 972 schematics20ApiService.updateJob(params)973 .then(res => {974 console.log(JSON.stringify(res.result, null, 2));975 })976 .catch(err => {977 console.warn(err)978 });979 980 // end-update_job981 });982 test('listJobLogs request example', done => {983 984 consoleLogMock.mockImplementation(output => {985 originalLog(output);986 done();987 });988 consoleWarnMock.mockImplementation(output => {989 done(output);990 });991 992 // begin-list_job_logs993 994 const params = {995 jobId: 'testString',996 };997 998 schematics20ApiService.listJobLogs(params)999 .then(res => {1000 console.log(JSON.stringify(res.result, null, 2));1001 })1002 .catch(err => {1003 console.warn(err)1004 });1005 1006 // end-list_job_logs1007 });1008 test('getJobFiles request example', done => {1009 1010 consoleLogMock.mockImplementation(output => {1011 originalLog(output);1012 done();1013 });1014 consoleWarnMock.mockImplementation(output => {1015 done(output);1016 });1017 1018 // begin-get_job_files1019 1020 const params = {1021 jobId: 'testString',1022 fileType: 'template_repo',1023 };1024 1025 schematics20ApiService.getJobFiles(params)1026 .then(res => {1027 console.log(JSON.stringify(res.result, null, 2));1028 })1029 .catch(err => {1030 console.warn(err)1031 });1032 1033 // end-get_job_files1034 });1035 test('listControls request example', done => {1036 1037 consoleLogMock.mockImplementation(output => {1038 originalLog(output);1039 done();1040 });1041 consoleWarnMock.mockImplementation(output => {1042 done(output);1043 });1044 1045 // begin-list_controls1046 1047 schematics20ApiService.listControls({})1048 .then(res => {1049 console.log(JSON.stringify(res.result, null, 2));1050 })1051 .catch(err => {1052 console.warn(err)1053 });1054 1055 // end-list_controls1056 });1057 test('createControls request example', done => {1058 1059 consoleLogMock.mockImplementation(output => {1060 originalLog(output);1061 done();1062 });1063 consoleWarnMock.mockImplementation(output => {1064 done(output);1065 });1066 1067 // begin-create_controls1068 1069 const params = {1070 controls: controlsModel,1071 };1072 1073 schematics20ApiService.createControls(params)1074 .then(res => {1075 console.log(JSON.stringify(res.result, null, 2));1076 })1077 .catch(err => {1078 console.warn(err)1079 });1080 1081 // end-create_controls1082 });1083 test('getControls request example', done => {1084 1085 consoleLogMock.mockImplementation(output => {1086 originalLog(output);1087 done();1088 });1089 consoleWarnMock.mockImplementation(output => {1090 done(output);1091 });1092 1093 // begin-get_controls1094 1095 const params = {1096 controlsId: 'testString',1097 };1098 1099 schematics20ApiService.getControls(params)1100 .then(res => {1101 console.log(JSON.stringify(res.result, null, 2));1102 })1103 .catch(err => {1104 console.warn(err)1105 });1106 1107 // end-get_controls1108 });1109 test('updateControls request example', done => {1110 1111 consoleLogMock.mockImplementation(output => {1112 originalLog(output);1113 done();1114 });1115 consoleWarnMock.mockImplementation(output => {1116 done(output);1117 });1118 1119 // begin-update_controls1120 1121 const params = {1122 controlsId: 'testString',1123 controls: controlsModel,1124 };1125 1126 schematics20ApiService.updateControls(params)1127 .then(res => {1128 console.log(JSON.stringify(res.result, null, 2));1129 })1130 .catch(err => {1131 console.warn(err)1132 });1133 1134 // end-update_controls1135 });1136 test('listCapsules request example', done => {1137 1138 consoleLogMock.mockImplementation(output => {1139 originalLog(output);1140 done();1141 });1142 consoleWarnMock.mockImplementation(output => {1143 done(output);1144 });1145 1146 // begin-list_capsules1147 1148 const params = {1149 controlsId: 'testString',1150 };1151 1152 schematics20ApiService.listCapsules(params)1153 .then(res => {1154 console.log(JSON.stringify(res.result, null, 2));1155 })1156 .catch(err => {1157 console.warn(err)1158 });1159 1160 // end-list_capsules1161 });1162 test('createCapsule request example', done => {1163 1164 consoleLogMock.mockImplementation(output => {1165 originalLog(output);1166 done();1167 });1168 consoleWarnMock.mockImplementation(output => {1169 done(output);1170 });1171 1172 // begin-create_capsule1173 1174 const params = {1175 controlsId: 'testString',1176 capsule: capsuleModel,1177 };1178 1179 schematics20ApiService.createCapsule(params)1180 .then(res => {1181 console.log(JSON.stringify(res.result, null, 2));1182 })1183 .catch(err => {1184 console.warn(err)1185 });1186 1187 // end-create_capsule1188 });1189 test('getCapsule request example', done => {1190 1191 consoleLogMock.mockImplementation(output => {1192 originalLog(output);1193 done();1194 });1195 consoleWarnMock.mockImplementation(output => {1196 done(output);1197 });1198 1199 // begin-get_capsule1200 1201 const params = {1202 controlsId: 'testString',1203 capsuleId: 'testString',1204 };1205 1206 schematics20ApiService.getCapsule(params)1207 .then(res => {1208 console.log(JSON.stringify(res.result, null, 2));1209 })1210 .catch(err => {1211 console.warn(err)1212 });1213 1214 // end-get_capsule1215 });1216 test('updateCapsule request example', done => {1217 1218 consoleLogMock.mockImplementation(output => {1219 originalLog(output);1220 done();1221 });1222 consoleWarnMock.mockImplementation(output => {1223 done(output);1224 });1225 1226 // begin-update_capsule1227 1228 const params = {1229 controlsId: 'testString',1230 capsuleId: 'testString',1231 capsule: capsuleModel,1232 };1233 1234 schematics20ApiService.updateCapsule(params)1235 .then(res => {1236 console.log(JSON.stringify(res.result, null, 2));1237 })1238 .catch(err => {1239 console.warn(err)1240 });1241 1242 // end-update_capsule1243 });1244 test('listDatasets request example', done => {1245 1246 consoleLogMock.mockImplementation(output => {1247 originalLog(output);1248 done();1249 });1250 consoleWarnMock.mockImplementation(output => {1251 done(output);1252 });1253 1254 // begin-list_datasets1255 1256 schematics20ApiService.listDatasets({})1257 .then(res => {1258 console.log(JSON.stringify(res.result, null, 2));1259 })1260 .catch(err => {1261 console.warn(err)1262 });1263 1264 // end-list_datasets1265 });1266 test('createDataset request example', done => {1267 1268 consoleLogMock.mockImplementation(output => {1269 originalLog(output);1270 done();1271 });1272 consoleWarnMock.mockImplementation(output => {1273 done(output);1274 });1275 1276 // begin-create_dataset1277 1278 const params = {1279 dataset: datasetModel,1280 };1281 1282 schematics20ApiService.createDataset(params)1283 .then(res => {1284 console.log(JSON.stringify(res.result, null, 2));1285 })1286 .catch(err => {1287 console.warn(err)1288 });1289 1290 // end-create_dataset1291 });1292 test('getDataset request example', done => {1293 1294 consoleLogMock.mockImplementation(output => {1295 originalLog(output);1296 done();1297 });1298 consoleWarnMock.mockImplementation(output => {1299 done(output);1300 });1301 1302 // begin-get_dataset1303 1304 const params = {1305 datasetId: 'testString',1306 };1307 1308 schematics20ApiService.getDataset(params)1309 .then(res => {1310 console.log(JSON.stringify(res.result, null, 2));1311 })1312 .catch(err => {1313 console.warn(err)1314 });1315 1316 // end-get_dataset1317 });1318 test('replaceDataset request example', done => {1319 1320 consoleLogMock.mockImplementation(output => {1321 originalLog(output);1322 done();1323 });1324 consoleWarnMock.mockImplementation(output => {1325 done(output);1326 });1327 1328 // begin-replace_dataset1329 1330 const params = {1331 datasetId: 'testString',1332 dataset: datasetModel,1333 };1334 1335 schematics20ApiService.replaceDataset(params)1336 .then(res => {1337 console.log(JSON.stringify(res.result, null, 2));1338 })1339 .catch(err => {1340 console.warn(err)1341 });1342 1343 // end-replace_dataset1344 });1345 test('updateAtaset request example', done => {1346 1347 consoleLogMock.mockImplementation(output => {1348 originalLog(output);1349 done();1350 });1351 consoleWarnMock.mockImplementation(output => {1352 done(output);1353 });1354 1355 // begin-update_ataset1356 1357 const params = {1358 datasetId: 'testString',1359 dataset: datasetModel,1360 };1361 1362 schematics20ApiService.updateAtaset(params)1363 .then(res => {1364 console.log(JSON.stringify(res.result, null, 2));1365 })1366 .catch(err => {1367 console.warn(err)1368 });1369 1370 // end-update_ataset1371 });1372 test('listDatasetVariables request example', done => {1373 1374 consoleLogMock.mockImplementation(output => {1375 originalLog(output);1376 done();1377 });1378 consoleWarnMock.mockImplementation(output => {1379 done(output);1380 });1381 1382 // begin-list_dataset_variables1383 1384 const params = {1385 datasetId: 'testString',1386 };1387 1388 schematics20ApiService.listDatasetVariables(params)1389 .then(res => {1390 console.log(JSON.stringify(res.result, null, 2));1391 })1392 .catch(err => {1393 console.warn(err)1394 });1395 1396 // end-list_dataset_variables1397 });1398 test('getDatasetVariable request example', done => {1399 1400 consoleLogMock.mockImplementation(output => {1401 originalLog(output);1402 done();1403 });1404 consoleWarnMock.mockImplementation(output => {1405 done(output);1406 });1407 1408 // begin-get_dataset_variable1409 1410 const params = {1411 datasetId: 'testString',1412 varName: 'testString',1413 };1414 1415 schematics20ApiService.getDatasetVariable(params)1416 .then(res => {1417 console.log(JSON.stringify(res.result, null, 2));1418 })1419 .catch(err => {1420 console.warn(err)1421 });1422 1423 // end-get_dataset_variable1424 });1425 test('listInventories request example', done => {1426 1427 consoleLogMock.mockImplementation(output => {1428 originalLog(output);1429 done();1430 });1431 consoleWarnMock.mockImplementation(output => {1432 done(output);1433 });1434 1435 // begin-list_inventories1436 1437 schematics20ApiService.listInventories({})1438 .then(res => {1439 console.log(JSON.stringify(res.result, null, 2));1440 })1441 .catch(err => {1442 console.warn(err)1443 });1444 1445 // end-list_inventories1446 });1447 test('createInventory request example', done => {1448 1449 consoleLogMock.mockImplementation(output => {1450 originalLog(output);1451 done();1452 });1453 consoleWarnMock.mockImplementation(output => {1454 done(output);1455 });1456 1457 // begin-create_inventory1458 1459 const params = {1460 inventoryResourceDefinition: inventoryResourceDefinitionModel,1461 };1462 1463 schematics20ApiService.createInventory(params)1464 .then(res => {1465 console.log(JSON.stringify(res.result, null, 2));1466 })1467 .catch(err => {1468 console.warn(err)1469 });1470 1471 // end-create_inventory1472 });1473 test('getInventory request example', done => {1474 1475 consoleLogMock.mockImplementation(output => {1476 originalLog(output);1477 done();1478 });1479 consoleWarnMock.mockImplementation(output => {1480 done(output);1481 });1482 1483 // begin-get_inventory1484 1485 const params = {1486 inventoryId: 'testString',1487 };1488 1489 schematics20ApiService.getInventory(params)1490 .then(res => {1491 console.log(JSON.stringify(res.result, null, 2));1492 })1493 .catch(err => {1494 console.warn(err)1495 });1496 1497 // end-get_inventory1498 });1499 test('replaceInventory request example', done => {1500 1501 consoleLogMock.mockImplementation(output => {1502 originalLog(output);1503 done();1504 });1505 consoleWarnMock.mockImplementation(output => {1506 done(output);1507 });1508 1509 // begin-replace_inventory1510 1511 const params = {1512 inventoryId: 'testString',1513 inventoryResourceDefinition: inventoryResourceDefinitionModel,1514 };1515 1516 schematics20ApiService.replaceInventory(params)1517 .then(res => {1518 console.log(JSON.stringify(res.result, null, 2));1519 })1520 .catch(err => {1521 console.warn(err)1522 });1523 1524 // end-replace_inventory1525 });1526 test('listResourceQuery request example', done => {1527 1528 consoleLogMock.mockImplementation(output => {1529 originalLog(output);1530 done();1531 });1532 consoleWarnMock.mockImplementation(output => {1533 done(output);1534 });1535 1536 // begin-list_resource_query1537 1538 schematics20ApiService.listResourceQuery({})1539 .then(res => {1540 console.log(JSON.stringify(res.result, null, 2));1541 })1542 .catch(err => {1543 console.warn(err)1544 });1545 1546 // end-list_resource_query1547 });1548 test('createResourceQuery request example', done => {1549 1550 consoleLogMock.mockImplementation(output => {1551 originalLog(output);1552 done();1553 });1554 consoleWarnMock.mockImplementation(output => {1555 done(output);1556 });1557 1558 // begin-create_resource_query1559 1560 const params = {1561 resourceQueryDefinition: resourceQueryDefinitionModel,1562 };1563 1564 schematics20ApiService.createResourceQuery(params)1565 .then(res => {1566 console.log(JSON.stringify(res.result, null, 2));1567 })1568 .catch(err => {1569 console.warn(err)1570 });1571 1572 // end-create_resource_query1573 });1574 test('getResourcesQuery request example', done => {1575 1576 consoleLogMock.mockImplementation(output => {1577 originalLog(output);1578 done();1579 });1580 consoleWarnMock.mockImplementation(output => {1581 done(output);1582 });1583 1584 // begin-get_resources_query1585 1586 const params = {1587 queryId: 'testString',1588 };1589 1590 schematics20ApiService.getResourcesQuery(params)1591 .then(res => {1592 console.log(JSON.stringify(res.result, null, 2));1593 })1594 .catch(err => {1595 console.warn(err)1596 });1597 1598 // end-get_resources_query1599 });1600 test('replaceResourcesQuery request example', done => {1601 1602 consoleLogMock.mockImplementation(output => {1603 originalLog(output);1604 done();1605 });1606 consoleWarnMock.mockImplementation(output => {1607 done(output);1608 });1609 1610 // begin-replace_resources_query1611 1612 const params = {1613 queryId: 'testString',1614 resourceQueryDefinition: resourceQueryDefinitionModel,1615 };1616 1617 schematics20ApiService.replaceResourcesQuery(params)1618 .then(res => {1619 console.log(JSON.stringify(res.result, null, 2));1620 })1621 .catch(err => {1622 console.warn(err)1623 });1624 1625 // end-replace_resources_query1626 });1627 test('executeResourceQuery request example', done => {1628 1629 consoleLogMock.mockImplementation(output => {1630 originalLog(output);1631 done();1632 });1633 consoleWarnMock.mockImplementation(output => {1634 done(output);1635 });1636 1637 // begin-execute_resource_query1638 1639 const params = {1640 queryId: 'testString',1641 };1642 1643 schematics20ApiService.executeResourceQuery(params)1644 .then(res => {1645 console.log(JSON.stringify(res.result, null, 2));1646 })1647 .catch(err => {1648 console.warn(err)1649 });1650 1651 // end-execute_resource_query1652 });1653 test('listAgent request example', done => {1654 1655 consoleLogMock.mockImplementation(output => {1656 originalLog(output);1657 done();1658 });1659 consoleWarnMock.mockImplementation(output => {1660 done(output);1661 });1662 1663 // begin-list_agent1664 1665 schematics20ApiService.listAgent({})1666 .then(res => {1667 console.log(JSON.stringify(res.result, null, 2));1668 })1669 .catch(err => {1670 console.warn(err)1671 });1672 1673 // end-list_agent1674 });1675 test('registerAgent request example', done => {1676 1677 consoleLogMock.mockImplementation(output => {1678 originalLog(output);1679 done();1680 });1681 consoleWarnMock.mockImplementation(output => {1682 done(output);1683 });1684 1685 // begin-register_agent1686 1687 const params = {1688 agent: agentModel,1689 };1690 1691 schematics20ApiService.registerAgent(params)1692 .then(res => {1693 console.log(JSON.stringify(res.result, null, 2));1694 })1695 .catch(err => {1696 console.warn(err)1697 });1698 1699 // end-register_agent1700 });1701 test('getAgent request example', done => {1702 1703 consoleLogMock.mockImplementation(output => {1704 originalLog(output);1705 done();1706 });1707 consoleWarnMock.mockImplementation(output => {1708 done(output);1709 });1710 1711 // begin-get_agent1712 1713 const params = {1714 agentId: 'testString',1715 };1716 1717 schematics20ApiService.getAgent(params)1718 .then(res => {1719 console.log(JSON.stringify(res.result, null, 2));1720 })1721 .catch(err => {1722 console.warn(err)1723 });1724 1725 // end-get_agent1726 });1727 test('updateAgentRegistration request example', done => {1728 1729 consoleLogMock.mockImplementation(output => {1730 originalLog(output);1731 done();1732 });1733 consoleWarnMock.mockImplementation(output => {1734 done(output);1735 });1736 1737 // begin-update_agent_registration1738 1739 const params = {1740 agentId: 'testString',1741 agent: agentModel,1742 };1743 1744 schematics20ApiService.updateAgentRegistration(params)1745 .then(res => {1746 console.log(JSON.stringify(res.result, null, 2));1747 })1748 .catch(err => {1749 console.warn(err)1750 });1751 1752 // end-update_agent_registration1753 });1754 test('fetchJobs request example', done => {1755 1756 consoleLogMock.mockImplementation(output => {1757 originalLog(output);1758 done();1759 });1760 consoleWarnMock.mockImplementation(output => {1761 done(output);1762 });1763 1764 // begin-fetch_jobs1765 1766 const params = {1767 agentJob: agentJobModel,1768 };1769 1770 schematics20ApiService.fetchJobs(params)1771 .then(res => {1772 console.log(JSON.stringify(res.result, null, 2));1773 })1774 .catch(err => {1775 console.warn(err)1776 });1777 1778 // end-fetch_jobs1779 });1780 test('getAgentJobFiles request example', done => {1781 1782 consoleLogMock.mockImplementation(output => {1783 originalLog(output);1784 done();1785 });1786 consoleWarnMock.mockImplementation(output => {1787 done(output);1788 });1789 1790 // begin-get_agent_job_files1791 1792 const params = {1793 jobId: 'testString',1794 };1795 1796 schematics20ApiService.getAgentJobFiles(params)1797 .then(res => {1798 console.log(JSON.stringify(res.result, null, 2));1799 })1800 .catch(err => {1801 console.warn(err)1802 });1803 1804 // end-get_agent_job_files1805 });1806 test('postAgentJobFiles request example', done => {1807 1808 consoleLogMock.mockImplementation(output => {1809 originalLog(output);1810 done();1811 });1812 consoleWarnMock.mockImplementation(output => {1813 done(output);1814 });1815 1816 // begin-post_agent_job_files1817 1818 const params = {1819 jobId: 'testString',1820 fileType: 'template_repo',1821 };1822 1823 schematics20ApiService.postAgentJobFiles(params)1824 .then(res => {1825 console.log(JSON.stringify(res.result, null, 2));1826 })1827 .catch(err => {1828 console.warn(err)1829 });1830 1831 // end-post_agent_job_files1832 });1833 test('updateJobStatus request example', done => {1834 1835 consoleLogMock.mockImplementation(output => {1836 originalLog(output);1837 done();1838 });1839 consoleWarnMock.mockImplementation(output => {1840 done(output);1841 });1842 1843 // begin-update_job_status1844 1845 const params = {1846 jobId: 'testString',1847 agentJobStatus: agentJobStatusModel,1848 };1849 1850 schematics20ApiService.updateJobStatus(params)1851 .then(res => {1852 console.log(JSON.stringify(res.result, null, 2));1853 })1854 .catch(err => {1855 console.warn(err)1856 });1857 1858 // end-update_job_status1859 });1860 test('updateVariablesMetadata request example', done => {1861 1862 consoleLogMock.mockImplementation(output => {1863 originalLog(output);1864 done();1865 });1866 consoleWarnMock.mockImplementation(output => {1867 done(output);1868 });1869 1870 // begin-update_variables_metadata1871 1872 const params = {1873 jobId: 'testString',1874 wId: 'testString',1875 agentJobVariables: agentJobVariablesModel,1876 };1877 1878 schematics20ApiService.updateVariablesMetadata(params)1879 .then(res => {1880 console.log(JSON.stringify(res.result, null, 2));1881 })1882 .catch(err => {1883 console.warn(err)1884 });1885 1886 // end-update_variables_metadata1887 });1888 test('getDatasetVariableValue request example', done => {1889 1890 consoleLogMock.mockImplementation(output => {1891 originalLog(output);1892 done();1893 });1894 consoleWarnMock.mockImplementation(output => {1895 done(output);1896 });1897 1898 // begin-get_dataset_variable_value1899 1900 const params = {1901 datasetId: 'testString',1902 varName: 'testString',1903 };1904 1905 schematics20ApiService.getDatasetVariableValue(params)1906 .then(res => {1907 console.log(JSON.stringify(res.result, null, 2));1908 })1909 .catch(err => {1910 console.warn(err)1911 });1912 1913 // end-get_dataset_variable_value1914 });1915 test('getCredentialVariableValue request example', done => {1916 1917 consoleLogMock.mockImplementation(output => {1918 originalLog(output);1919 done();1920 });1921 consoleWarnMock.mockImplementation(output => {1922 done(output);1923 });1924 1925 // begin-get_credential_variable_value1926 1927 const params = {1928 credsId: 'testString',1929 varName: 'testString',1930 };1931 1932 schematics20ApiService.getCredentialVariableValue(params)1933 .then(res => {1934 console.log(JSON.stringify(res.result, null, 2));1935 })1936 .catch(err => {1937 console.warn(err)1938 });1939 1940 // end-get_credential_variable_value1941 });1942 test('getInventoryVariableValue request example', done => {1943 1944 consoleLogMock.mockImplementation(output => {1945 originalLog(output);1946 done();1947 });1948 consoleWarnMock.mockImplementation(output => {1949 done(output);1950 });1951 1952 // begin-get_inventory_variable_value1953 1954 const params = {1955 inventoryId: 'testString',1956 varName: 'testString',1957 };1958 1959 schematics20ApiService.getInventoryVariableValue(params)1960 .then(res => {1961 console.log(JSON.stringify(res.result, null, 2));1962 })1963 .catch(err => {1964 console.warn(err)1965 });1966 1967 // end-get_inventory_variable_value1968 });1969 test('getWorkspaceInputValue request example', done => {1970 1971 consoleLogMock.mockImplementation(output => {1972 originalLog(output);1973 done();1974 });1975 consoleWarnMock.mockImplementation(output => {1976 done(output);1977 });1978 1979 // begin-get_workspace_input_value1980 1981 const params = {1982 wId: 'testString',1983 varName: 'testString',1984 };1985 1986 schematics20ApiService.getWorkspaceInputValue(params)1987 .then(res => {1988 console.log(JSON.stringify(res.result, null, 2));1989 })1990 .catch(err => {1991 console.warn(err)1992 });1993 1994 // end-get_workspace_input_value1995 });1996 test('getWorkspaceOutputValue request example', done => {1997 1998 consoleLogMock.mockImplementation(output => {1999 originalLog(output);2000 done();2001 });2002 consoleWarnMock.mockImplementation(output => {2003 done(output);2004 });2005 2006 // begin-get_workspace_output_value2007 2008 const params = {2009 wId: 'testString',2010 varName: 'testString',2011 };2012 2013 schematics20ApiService.getWorkspaceOutputValue(params)2014 .then(res => {2015 console.log(JSON.stringify(res.result, null, 2));2016 })2017 .catch(err => {2018 console.warn(err)2019 });2020 2021 // end-get_workspace_output_value2022 });2023 test('getWorkspaceSettingsValue request example', done => {2024 2025 consoleLogMock.mockImplementation(output => {2026 originalLog(output);2027 done();2028 });2029 consoleWarnMock.mockImplementation(output => {2030 done(output);2031 });2032 2033 // begin-get_workspace_settings_value2034 2035 const params = {2036 wId: 'testString',2037 varName: 'testString',2038 };2039 2040 schematics20ApiService.getWorkspaceSettingsValue(params)2041 .then(res => {2042 console.log(JSON.stringify(res.result, null, 2));2043 })2044 .catch(err => {2045 console.warn(err)2046 });2047 2048 // end-get_workspace_settings_value2049 });2050 test('getWorkspaceTemplateInputValue request example', done => {2051 2052 consoleLogMock.mockImplementation(output => {2053 originalLog(output);2054 done();2055 });2056 consoleWarnMock.mockImplementation(output => {2057 done(output);2058 });2059 2060 // begin-get_workspace_template_input_value2061 2062 const params = {2063 wId: 'testString',2064 tId: 'testString',2065 varName: 'testString',2066 };2067 2068 schematics20ApiService.getWorkspaceTemplateInputValue(params)2069 .then(res => {2070 console.log(JSON.stringify(res.result, null, 2));2071 })2072 .catch(err => {2073 console.warn(err)2074 });2075 2076 // end-get_workspace_template_input_value2077 });2078 test('getWorkspaceTemplateOutputValue request example', done => {2079 2080 consoleLogMock.mockImplementation(output => {2081 originalLog(output);2082 done();2083 });2084 consoleWarnMock.mockImplementation(output => {2085 done(output);2086 });2087 2088 // begin-get_workspace_template_output_value2089 2090 const params = {2091 wId: 'testString',2092 tId: 'testString',2093 varName: 'testString',2094 };2095 2096 schematics20ApiService.getWorkspaceTemplateOutputValue(params)2097 .then(res => {2098 console.log(JSON.stringify(res.result, null, 2));2099 })2100 .catch(err => {2101 console.warn(err)2102 });2103 2104 // end-get_workspace_template_output_value2105 });2106 test('getWorkspaceTemplateSettingValue request example', done => {2107 2108 consoleLogMock.mockImplementation(output => {2109 originalLog(output);2110 done();2111 });2112 consoleWarnMock.mockImplementation(output => {2113 done(output);2114 });2115 2116 // begin-get_workspace_template_setting_value2117 2118 const params = {2119 wId: 'testString',2120 tId: 'testString',2121 varName: 'testString',2122 };2123 2124 schematics20ApiService.getWorkspaceTemplateSettingValue(params)2125 .then(res => {2126 console.log(JSON.stringify(res.result, null, 2));2127 })2128 .catch(err => {2129 console.warn(err)2130 });2131 2132 // end-get_workspace_template_setting_value2133 });2134 test('getJobWorkspaceInputValue request example', done => {2135 2136 consoleLogMock.mockImplementation(output => {2137 originalLog(output);2138 done();2139 });2140 consoleWarnMock.mockImplementation(output => {2141 done(output);2142 });2143 2144 // begin-get_job_workspace_input_value2145 2146 const params = {2147 jobId: 'testString',2148 wId: 'testString',2149 varName: 'testString',2150 };2151 2152 schematics20ApiService.getJobWorkspaceInputValue(params)2153 .then(res => {2154 console.log(JSON.stringify(res.result, null, 2));2155 })2156 .catch(err => {2157 console.warn(err)2158 });2159 2160 // end-get_job_workspace_input_value2161 });2162 test('getJobWorkspaceOutputValue request example', done => {2163 2164 consoleLogMock.mockImplementation(output => {2165 originalLog(output);2166 done();2167 });2168 consoleWarnMock.mockImplementation(output => {2169 done(output);2170 });2171 2172 // begin-get_job_workspace_output_value2173 2174 const params = {2175 jobId: 'testString',2176 wId: 'testString',2177 varName: 'testString',2178 };2179 2180 schematics20ApiService.getJobWorkspaceOutputValue(params)2181 .then(res => {2182 console.log(JSON.stringify(res.result, null, 2));2183 })2184 .catch(err => {2185 console.warn(err)2186 });2187 2188 // end-get_job_workspace_output_value2189 });2190 test('getJobWorkspaceSettingValue request example', done => {2191 2192 consoleLogMock.mockImplementation(output => {2193 originalLog(output);2194 done();2195 });2196 consoleWarnMock.mockImplementation(output => {2197 done(output);2198 });2199 2200 // begin-get_job_workspace_setting_value2201 2202 const params = {2203 jobId: 'testString',2204 wId: 'testString',2205 varName: 'testString',2206 };2207 2208 schematics20ApiService.getJobWorkspaceSettingValue(params)2209 .then(res => {2210 console.log(JSON.stringify(res.result, null, 2));2211 })2212 .catch(err => {2213 console.warn(err)2214 });2215 2216 // end-get_job_workspace_setting_value2217 });2218 test('getKmsSettings request example', done => {2219 2220 consoleLogMock.mockImplementation(output => {2221 originalLog(output);2222 done();2223 });2224 consoleWarnMock.mockImplementation(output => {2225 done(output);2226 });2227 2228 // begin-get_kms_settings2229 2230 const params = {2231 location: 'testString',2232 };2233 2234 schematics20ApiService.getKmsSettings(params)2235 .then(res => {2236 console.log(JSON.stringify(res.result, null, 2));2237 })2238 .catch(err => {2239 console.warn(err)2240 });2241 2242 // end-get_kms_settings2243 });2244 test('updateKmsSettings request example', done => {2245 2246 consoleLogMock.mockImplementation(output => {2247 originalLog(output);2248 done();2249 });2250 consoleWarnMock.mockImplementation(output => {2251 done(output);2252 });2253 2254 // begin-update_kms_settings2255 2256 const params = {2257 kmsSettings: kmsSettingsModel,2258 };2259 2260 schematics20ApiService.updateKmsSettings(params)2261 .then(res => {2262 console.log(JSON.stringify(res.result, null, 2));2263 })2264 .catch(err => {2265 console.warn(err)2266 });2267 2268 // end-update_kms_settings2269 });2270 test('listKms request example', done => {2271 2272 consoleLogMock.mockImplementation(output => {2273 originalLog(output);2274 done();2275 });2276 consoleWarnMock.mockImplementation(output => {2277 done(output);2278 });2279 2280 // begin-list_kms2281 2282 const params = {2283 encryptionScheme: 'testString',2284 location: 'testString',2285 };2286 2287 schematics20ApiService.listKms(params)2288 .then(res => {2289 console.log(JSON.stringify(res.result, null, 2));2290 })2291 .catch(err => {2292 console.warn(err)2293 });2294 2295 // end-list_kms2296 });2297 test('listTriggers request example', done => {2298 2299 consoleLogMock.mockImplementation(output => {2300 originalLog(output);2301 done();2302 });2303 consoleWarnMock.mockImplementation(output => {2304 done(output);2305 });2306 2307 // begin-list_triggers2308 2309 schematics20ApiService.listTriggers({})2310 .then(res => {2311 console.log(JSON.stringify(res.result, null, 2));2312 })2313 .catch(err => {2314 console.warn(err)2315 });2316 2317 // end-list_triggers2318 });2319 test('createTrigger request example', done => {2320 2321 consoleLogMock.mockImplementation(output => {2322 originalLog(output);2323 done();2324 });2325 consoleWarnMock.mockImplementation(output => {2326 done(output);2327 });2328 2329 // begin-create_trigger2330 2331 const params = {2332 trigger: triggerModel,2333 };2334 2335 schematics20ApiService.createTrigger(params)2336 .then(res => {2337 console.log(JSON.stringify(res.result, null, 2));2338 })2339 .catch(err => {2340 console.warn(err)2341 });2342 2343 // end-create_trigger2344 });2345 test('getTrigger request example', done => {2346 2347 consoleLogMock.mockImplementation(output => {2348 originalLog(output);2349 done();2350 });2351 consoleWarnMock.mockImplementation(output => {2352 done(output);2353 });2354 2355 // begin-get_trigger2356 2357 const params = {2358 triggerId: 'testString',2359 };2360 2361 schematics20ApiService.getTrigger(params)2362 .then(res => {2363 console.log(JSON.stringify(res.result, null, 2));2364 })2365 .catch(err => {2366 console.warn(err)2367 });2368 2369 // end-get_trigger2370 });2371 test('replaceTrigger request example', done => {2372 2373 consoleLogMock.mockImplementation(output => {2374 originalLog(output);2375 done();2376 });2377 consoleWarnMock.mockImplementation(output => {2378 done(output);2379 });2380 2381 // begin-replace_trigger2382 2383 const params = {2384 triggerId: 'testString',2385 trigger: triggerModel,2386 };2387 2388 schematics20ApiService.replaceTrigger(params)2389 .then(res => {2390 console.log(JSON.stringify(res.result, null, 2));2391 })2392 .catch(err => {2393 console.warn(err)2394 });2395 2396 // end-replace_trigger2397 });2398 test('listWebhook request example', done => {2399 2400 consoleLogMock.mockImplementation(output => {2401 originalLog(output);2402 done();2403 });2404 consoleWarnMock.mockImplementation(output => {2405 done(output);2406 });2407 2408 // begin-list_webhook2409 2410 schematics20ApiService.listWebhook({})2411 .then(res => {2412 console.log(JSON.stringify(res.result, null, 2));2413 })2414 .catch(err => {2415 console.warn(err)2416 });2417 2418 // end-list_webhook2419 });2420 test('createWebhook request example', done => {2421 2422 consoleLogMock.mockImplementation(output => {2423 originalLog(output);2424 done();2425 });2426 consoleWarnMock.mockImplementation(output => {2427 done(output);2428 });2429 2430 // begin-create_webhook2431 2432 const params = {2433 webHook: webHookModel,2434 };2435 2436 schematics20ApiService.createWebhook(params)2437 .then(res => {2438 console.log(JSON.stringify(res.result, null, 2));2439 })2440 .catch(err => {2441 console.warn(err)2442 });2443 2444 // end-create_webhook2445 });2446 test('getWebhook request example', done => {2447 2448 consoleLogMock.mockImplementation(output => {2449 originalLog(output);2450 done();2451 });2452 consoleWarnMock.mockImplementation(output => {2453 done(output);2454 });2455 2456 // begin-get_webhook2457 2458 const params = {2459 hookId: 'testString',2460 };2461 2462 schematics20ApiService.getWebhook(params)2463 .then(res => {2464 console.log(JSON.stringify(res.result, null, 2));2465 })2466 .catch(err => {2467 console.warn(err)2468 });2469 2470 // end-get_webhook2471 });2472 test('replaceWebhook request example', done => {2473 2474 consoleLogMock.mockImplementation(output => {2475 originalLog(output);2476 done();2477 });2478 consoleWarnMock.mockImplementation(output => {2479 done(output);2480 });2481 2482 // begin-replace_webhook2483 2484 const params = {2485 hookId: 'testString',2486 webHook: webHookModel,2487 };2488 2489 schematics20ApiService.replaceWebhook(params)2490 .then(res => {2491 console.log(JSON.stringify(res.result, null, 2));2492 })2493 .catch(err => {2494 console.warn(err)2495 });2496 2497 // end-replace_webhook2498 });2499 test('getPrivateCluster request example', done => {2500 2501 consoleLogMock.mockImplementation(output => {2502 originalLog(output);2503 done();2504 });2505 consoleWarnMock.mockImplementation(output => {2506 done(output);2507 });2508 2509 // begin-get_private_cluster2510 2511 schematics20ApiService.getPrivateCluster({})2512 .then(res => {2513 console.log(JSON.stringify(res.result, null, 2));2514 })2515 .catch(err => {2516 console.warn(err)2517 });2518 2519 // end-get_private_cluster2520 });2521 test('createPrivateCluster request example', done => {2522 2523 consoleLogMock.mockImplementation(output => {2524 originalLog(output);2525 done();2526 });2527 consoleWarnMock.mockImplementation(output => {2528 done(output);2529 });2530 2531 // begin-create_private_cluster2532 2533 const params = {2534 privateCluster: privateClusterModel,2535 };2536 2537 schematics20ApiService.createPrivateCluster(params)2538 .then(res => {2539 console.log(JSON.stringify(res.result, null, 2));2540 })2541 .catch(err => {2542 console.warn(err)2543 });2544 2545 // end-create_private_cluster2546 });2547 test('listAdapter request example', done => {2548 2549 consoleLogMock.mockImplementation(output => {2550 originalLog(output);2551 done();2552 });2553 consoleWarnMock.mockImplementation(output => {2554 done(output);2555 });2556 2557 // begin-list_adapter2558 2559 schematics20ApiService.listAdapter({})2560 .then(res => {2561 console.log(JSON.stringify(res.result, null, 2));2562 })2563 .catch(err => {2564 console.warn(err)2565 });2566 2567 // end-list_adapter2568 });2569 test('createAdapter request example', done => {2570 2571 consoleLogMock.mockImplementation(output => {2572 originalLog(output);2573 done();2574 });2575 consoleWarnMock.mockImplementation(output => {2576 done(output);2577 });2578 2579 // begin-create_adapter2580 2581 const params = {2582 adapter: adapterModel,2583 };2584 2585 schematics20ApiService.createAdapter(params)2586 .then(res => {2587 console.log(JSON.stringify(res.result, null, 2));2588 })2589 .catch(err => {2590 console.warn(err)2591 });2592 2593 // end-create_adapter2594 });2595 test('getAdapter request example', done => {2596 2597 consoleLogMock.mockImplementation(output => {2598 originalLog(output);2599 done();2600 });2601 consoleWarnMock.mockImplementation(output => {2602 done(output);2603 });2604 2605 // begin-get_adapter2606 2607 const params = {2608 adapterId: 'testString',2609 };2610 2611 schematics20ApiService.getAdapter(params)2612 .then(res => {2613 console.log(JSON.stringify(res.result, null, 2));2614 })2615 .catch(err => {2616 console.warn(err)2617 });2618 2619 // end-get_adapter2620 });2621 test('replaceAdapter request example', done => {2622 2623 consoleLogMock.mockImplementation(output => {2624 originalLog(output);2625 done();2626 });2627 consoleWarnMock.mockImplementation(output => {2628 done(output);2629 });2630 2631 // begin-replace_adapter2632 2633 const params = {2634 adapterId: 'testString',2635 adapter: adapterModel,2636 };2637 2638 schematics20ApiService.replaceAdapter(params)2639 .then(res => {2640 console.log(JSON.stringify(res.result, null, 2));2641 })2642 .catch(err => {2643 console.warn(err)2644 });2645 2646 // end-replace_adapter2647 });2648 test('listConnection request example', done => {2649 2650 consoleLogMock.mockImplementation(output => {2651 originalLog(output);2652 done();2653 });2654 consoleWarnMock.mockImplementation(output => {2655 done(output);2656 });2657 2658 // begin-list_connection2659 2660 schematics20ApiService.listConnection({})2661 .then(res => {2662 console.log(JSON.stringify(res.result, null, 2));2663 })2664 .catch(err => {2665 console.warn(err)2666 });2667 2668 // end-list_connection2669 });2670 test('createConnection request example', done => {2671 2672 consoleLogMock.mockImplementation(output => {2673 originalLog(output);2674 done();2675 });2676 consoleWarnMock.mockImplementation(output => {2677 done(output);2678 });2679 2680 // begin-create_connection2681 2682 const params = {2683 connection: connectionModel,2684 };2685 2686 schematics20ApiService.createConnection(params)2687 .then(res => {2688 console.log(JSON.stringify(res.result, null, 2));2689 })2690 .catch(err => {2691 console.warn(err)2692 });2693 2694 // end-create_connection2695 });2696 test('getConnection request example', done => {2697 2698 consoleLogMock.mockImplementation(output => {2699 originalLog(output);2700 done();2701 });2702 consoleWarnMock.mockImplementation(output => {2703 done(output);2704 });2705 2706 // begin-get_connection2707 2708 const params = {2709 connectionId: 'testString',2710 };2711 2712 schematics20ApiService.getConnection(params)2713 .then(res => {2714 console.log(JSON.stringify(res.result, null, 2));2715 })2716 .catch(err => {2717 console.warn(err)2718 });2719 2720 // end-get_connection2721 });2722 test('listDatasources request example', done => {2723 2724 consoleLogMock.mockImplementation(output => {2725 originalLog(output);2726 done();2727 });2728 consoleWarnMock.mockImplementation(output => {2729 done(output);2730 });2731 2732 // begin-list_datasources2733 2734 schematics20ApiService.listDatasources({})2735 .then(res => {2736 console.log(JSON.stringify(res.result, null, 2));2737 })2738 .catch(err => {2739 console.warn(err)2740 });2741 2742 // end-list_datasources2743 });2744 test('createDatasource request example', done => {2745 2746 consoleLogMock.mockImplementation(output => {2747 originalLog(output);2748 done();2749 });2750 consoleWarnMock.mockImplementation(output => {2751 done(output);2752 });2753 2754 // begin-create_datasource2755 2756 const params = {2757 datasource: datasourceModel,2758 };2759 2760 schematics20ApiService.createDatasource(params)2761 .then(res => {2762 console.log(JSON.stringify(res.result, null, 2));2763 })2764 .catch(err => {2765 console.warn(err)2766 });2767 2768 // end-create_datasource2769 });2770 test('getData request example', done => {2771 2772 consoleLogMock.mockImplementation(output => {2773 originalLog(output);2774 done();2775 });2776 consoleWarnMock.mockImplementation(output => {2777 done(output);2778 });2779 2780 // begin-get_data2781 2782 const params = {2783 datasourceId: 'testString',2784 };2785 2786 schematics20ApiService.getData(params)2787 .then(res => {2788 console.log(JSON.stringify(res.result, null, 2));2789 })2790 .catch(err => {2791 console.warn(err)2792 });2793 2794 // end-get_data2795 });2796 test('listCart request example', done => {2797 2798 consoleLogMock.mockImplementation(output => {2799 originalLog(output);2800 done();2801 });2802 consoleWarnMock.mockImplementation(output => {2803 done(output);2804 });2805 2806 // begin-list_cart2807 2808 schematics20ApiService.listCart({})2809 .then(res => {2810 console.log(JSON.stringify(res.result, null, 2));2811 })2812 .catch(err => {2813 console.warn(err)2814 });2815 2816 // end-list_cart2817 });2818 test('createCartOrder request example', done => {2819 2820 consoleLogMock.mockImplementation(output => {2821 originalLog(output);2822 done();2823 });2824 consoleWarnMock.mockImplementation(output => {2825 done(output);2826 });2827 2828 // begin-create_cart_order2829 2830 const params = {2831 cartOrder: cartOrderModel,2832 };2833 2834 schematics20ApiService.createCartOrder(params)2835 .then(res => {2836 console.log(JSON.stringify(res.result, null, 2));2837 })2838 .catch(err => {2839 console.warn(err)2840 });2841 2842 // end-create_cart_order2843 });2844 test('getCartOrder request example', done => {2845 2846 consoleLogMock.mockImplementation(output => {2847 originalLog(output);2848 done();2849 });2850 consoleWarnMock.mockImplementation(output => {2851 done(output);2852 });2853 2854 // begin-get_cart_order2855 2856 const params = {2857 orderId: 'testString',2858 };2859 2860 schematics20ApiService.getCartOrder(params)2861 .then(res => {2862 console.log(JSON.stringify(res.result, null, 2));2863 })2864 .catch(err => {2865 console.warn(err)2866 });2867 2868 // end-get_cart_order2869 });2870 test('replaceCartOrder request example', done => {2871 2872 consoleLogMock.mockImplementation(output => {2873 originalLog(output);2874 done();2875 });2876 consoleWarnMock.mockImplementation(output => {2877 done(output);2878 });2879 2880 // begin-replace_cart_order2881 2882 const params = {2883 orderId: 'testString',2884 operation: '0',2885 cartOrder: cartOrderModel,2886 };2887 2888 schematics20ApiService.replaceCartOrder(params)2889 .then(res => {2890 console.log(JSON.stringify(res.result, null, 2));2891 })2892 .catch(err => {2893 console.warn(err)2894 });2895 2896 // end-replace_cart_order2897 });2898 test('runFulfilmentOperation request example', done => {2899 2900 consoleLogMock.mockImplementation(output => {2901 originalLog(output);2902 done();2903 });2904 consoleWarnMock.mockImplementation(output => {2905 done(output);2906 });2907 2908 // begin-run_fulfilment_operation2909 2910 const params = {2911 orderId: 'testString',2912 operation: '0',2913 };2914 2915 schematics20ApiService.runFulfilmentOperation(params)2916 .then(res => {2917 console.log(JSON.stringify(res.result, null, 2));2918 })2919 .catch(err => {2920 console.warn(err)2921 });2922 2923 // end-run_fulfilment_operation2924 });2925 test('updateCartOrder request example', done => {2926 2927 consoleLogMock.mockImplementation(output => {2928 originalLog(output);2929 done();2930 });2931 consoleWarnMock.mockImplementation(output => {2932 done(output);2933 });2934 2935 // begin-update_cart_order2936 2937 const params = {2938 orderId: 'testString',2939 operation: '0',2940 updateCartOrder: updateCartOrderModel,2941 };2942 2943 schematics20ApiService.updateCartOrder(params)2944 .then(res => {2945 console.log(JSON.stringify(res.result, null, 2));2946 })2947 .catch(err => {2948 console.warn(err)2949 });2950 2951 // end-update_cart_order2952 });2953 test('getCartMetadata request example', done => {2954 2955 consoleLogMock.mockImplementation(output => {2956 originalLog(output);2957 done();2958 });2959 consoleWarnMock.mockImplementation(output => {2960 done(output);2961 });2962 2963 // begin-get_cart_metadata2964 2965 const params = {2966 orderId: 'testString',2967 };2968 2969 schematics20ApiService.getCartMetadata(params)2970 .then(res => {2971 console.log(JSON.stringify(res.result, null, 2));2972 })2973 .catch(err => {2974 console.warn(err)2975 });2976 2977 // end-get_cart_metadata2978 });2979 test('listCartResources request example', done => {2980 2981 consoleLogMock.mockImplementation(output => {2982 originalLog(output);2983 done();2984 });2985 consoleWarnMock.mockImplementation(output => {2986 done(output);2987 });2988 2989 // begin-list_cart_resources2990 2991 const params = {2992 orderId: 'testString',2993 };2994 2995 schematics20ApiService.listCartResources(params)2996 .then(res => {2997 console.log(JSON.stringify(res.result, null, 2));2998 })2999 .catch(err => {3000 console.warn(err)3001 });3002 3003 // end-list_cart_resources3004 });3005 test('listCartOrderJobs request example', done => {3006 3007 consoleLogMock.mockImplementation(output => {3008 originalLog(output);3009 done();3010 });3011 consoleWarnMock.mockImplementation(output => {3012 done(output);3013 });3014 3015 // begin-list_cart_order_jobs3016 3017 const params = {3018 orderId: 'testString',3019 };3020 3021 schematics20ApiService.listCartOrderJobs(params)3022 .then(res => {3023 console.log(JSON.stringify(res.result, null, 2));3024 })3025 .catch(err => {3026 console.warn(err)3027 });3028 3029 // end-list_cart_order_jobs3030 });3031 test('getCartOrderJob request example', done => {3032 3033 consoleLogMock.mockImplementation(output => {3034 originalLog(output);3035 done();3036 });3037 consoleWarnMock.mockImplementation(output => {3038 done(output);3039 });3040 3041 // begin-get_cart_order_job3042 3043 const params = {3044 orderId: 'testString',3045 jobId: 'testString',3046 };3047 3048 schematics20ApiService.getCartOrderJob(params)3049 .then(res => {3050 console.log(JSON.stringify(res.result, null, 2));3051 })3052 .catch(err => {3053 console.warn(err)3054 });3055 3056 // end-get_cart_order_job3057 });3058 test('getCartOrderJobLog request example', done => {3059 3060 consoleLogMock.mockImplementation(output => {3061 originalLog(output);3062 done();3063 });3064 consoleWarnMock.mockImplementation(output => {3065 done(output);3066 });3067 3068 // begin-get_cart_order_job_log3069 3070 const params = {3071 orderId: 'testString',3072 jobId: 'testString',3073 };3074 3075 schematics20ApiService.getCartOrderJobLog(params)3076 .then(res => {3077 console.log(JSON.stringify(res.result, null, 2));3078 })3079 .catch(err => {3080 console.warn(err)3081 });3082 3083 // end-get_cart_order_job_log3084 });3085 test('getCartOrderJobResources request example', done => {3086 3087 consoleLogMock.mockImplementation(output => {3088 originalLog(output);3089 done();3090 });3091 consoleWarnMock.mockImplementation(output => {3092 done(output);3093 });3094 3095 // begin-get_cart_order_job_resources3096 3097 const params = {3098 orderId: 'testString',3099 jobId: 'testString',3100 };3101 3102 schematics20ApiService.getCartOrderJobResources(params)3103 .then(res => {3104 console.log(JSON.stringify(res.result, null, 2));3105 })3106 .catch(err => {3107 console.warn(err)3108 });3109 3110 // end-get_cart_order_job_resources3111 });3112 test('listBlueprint request example', done => {3113 3114 consoleLogMock.mockImplementation(output => {3115 originalLog(output);3116 done();3117 });3118 consoleWarnMock.mockImplementation(output => {3119 done(output);3120 });3121 3122 // begin-list_blueprint3123 3124 schematics20ApiService.listBlueprint({})3125 .then(res => {3126 console.log(JSON.stringify(res.result, null, 2));3127 })3128 .catch(err => {3129 console.warn(err)3130 });3131 3132 // end-list_blueprint3133 });3134 test('createBlueprint request example', done => {3135 3136 consoleLogMock.mockImplementation(output => {3137 originalLog(output);3138 done();3139 });3140 consoleWarnMock.mockImplementation(output => {3141 done(output);3142 });3143 3144 // begin-create_blueprint3145 3146 const params = {3147 blueprint: blueprintModel,3148 };3149 3150 schematics20ApiService.createBlueprint(params)3151 .then(res => {3152 console.log(JSON.stringify(res.result, null, 2));3153 })3154 .catch(err => {3155 console.warn(err)3156 });3157 3158 // end-create_blueprint3159 });3160 test('getBlueprint request example', done => {3161 3162 consoleLogMock.mockImplementation(output => {3163 originalLog(output);3164 done();3165 });3166 consoleWarnMock.mockImplementation(output => {3167 done(output);3168 });3169 3170 // begin-get_blueprint3171 3172 const params = {3173 blueprintId: 'testString',3174 };3175 3176 schematics20ApiService.getBlueprint(params)3177 .then(res => {3178 console.log(JSON.stringify(res.result, null, 2));3179 })3180 .catch(err => {3181 console.warn(err)3182 });3183 3184 // end-get_blueprint3185 });3186 test('replaceBlueprint request example', done => {3187 3188 consoleLogMock.mockImplementation(output => {3189 originalLog(output);3190 done();3191 });3192 consoleWarnMock.mockImplementation(output => {3193 done(output);3194 });3195 3196 // begin-replace_blueprint3197 3198 const params = {3199 blueprintId: 'testString',3200 blueprint: blueprintModel,3201 };3202 3203 schematics20ApiService.replaceBlueprint(params)3204 .then(res => {3205 console.log(JSON.stringify(res.result, null, 2));3206 })3207 .catch(err => {3208 console.warn(err)3209 });3210 3211 // end-replace_blueprint3212 });3213 test('updateBlueprint request example', done => {3214 3215 consoleLogMock.mockImplementation(output => {3216 originalLog(output);3217 done();3218 });3219 consoleWarnMock.mockImplementation(output => {3220 done(output);3221 });3222 3223 // begin-update_blueprint3224 3225 const params = {3226 blueprintId: 'testString',3227 blueprint: blueprintModel,3228 };3229 3230 schematics20ApiService.updateBlueprint(params)3231 .then(res => {3232 console.log(JSON.stringify(res.result, null, 2));3233 })3234 .catch(err => {3235 console.warn(err)3236 });3237 3238 // end-update_blueprint3239 });3240 test('uploadTemplateTarBlueprint request example', done => {3241 3242 consoleLogMock.mockImplementation(output => {3243 originalLog(output);3244 done();3245 });3246 consoleWarnMock.mockImplementation(output => {3247 done(output);3248 });3249 3250 // begin-upload_template_tar_blueprint3251 3252 const params = {3253 blueprintId: 'testString',3254 };3255 3256 schematics20ApiService.uploadTemplateTarBlueprint(params)3257 .then(res => {3258 console.log(JSON.stringify(res.result, null, 2));3259 })3260 .catch(err => {3261 console.warn(err)3262 });3263 3264 // end-upload_template_tar_blueprint3265 });3266 test('listCatalogItems request example', done => {3267 3268 consoleLogMock.mockImplementation(output => {3269 originalLog(output);3270 done();3271 });3272 consoleWarnMock.mockImplementation(output => {3273 done(output);3274 });3275 3276 // begin-list_catalog_items3277 3278 schematics20ApiService.listCatalogItems({})3279 .then(res => {3280 console.log(JSON.stringify(res.result, null, 2));3281 })3282 .catch(err => {3283 console.warn(err)3284 });3285 3286 // end-list_catalog_items3287 });3288 test('getCatalogItem request example', done => {3289 3290 consoleLogMock.mockImplementation(output => {3291 originalLog(output);3292 done();3293 });3294 consoleWarnMock.mockImplementation(output => {3295 done(output);3296 });3297 3298 // begin-get_catalog_item3299 3300 const params = {3301 offeringId: 'testString',3302 };3303 3304 schematics20ApiService.getCatalogItem(params)3305 .then(res => {3306 console.log(JSON.stringify(res.result, null, 2));3307 })3308 .catch(err => {3309 console.warn(err)3310 });3311 3312 // end-get_catalog_item3313 });3314 test('listLocations request example', done => {3315 3316 consoleLogMock.mockImplementation(output => {3317 originalLog(output);3318 done();3319 });3320 consoleWarnMock.mockImplementation(output => {3321 done(output);3322 });3323 3324 // begin-list_locations3325 3326 schematics20ApiService.listLocations({})3327 .then(res => {3328 console.log(JSON.stringify(res.result, null, 2));3329 })3330 .catch(err => {3331 console.warn(err)3332 });3333 3334 // end-list_locations3335 });3336 test('deleteWorkspace request example', done => {3337 3338 consoleLogMock.mockImplementation(output => {3339 originalLog(output);3340 done();3341 });3342 consoleWarnMock.mockImplementation(output => {3343 done(output);3344 });3345 3346 // begin-delete_workspace3347 3348 const params = {3349 wId: 'testString',3350 };3351 3352 schematics20ApiService.deleteWorkspace(params)3353 .then(res => {3354 console.log(JSON.stringify(res.result, null, 2));3355 })3356 .catch(err => {3357 console.warn(err)3358 });3359 3360 // end-delete_workspace3361 });3362 test('deleteWebhook request example', done => {3363 3364 consoleLogMock.mockImplementation(output => {3365 originalLog(output);3366 done();3367 });3368 consoleWarnMock.mockImplementation(output => {3369 done(output);3370 });3371 3372 // begin-delete_webhook3373 3374 const params = {3375 hookId: 'testString',3376 };3377 3378 schematics20ApiService.deleteWebhook(params)3379 .then(res => {3380 console.log(JSON.stringify(res.result, null, 2));3381 })3382 .catch(err => {3383 console.warn(err)3384 });3385 3386 // end-delete_webhook3387 });3388 test('deleteTrigger request example', done => {3389 3390 consoleLogMock.mockImplementation(output => {3391 originalLog(output);3392 done();3393 });3394 consoleWarnMock.mockImplementation(output => {3395 done(output);3396 });3397 3398 // begin-delete_trigger3399 3400 const params = {3401 triggerId: 'testString',3402 };3403 3404 schematics20ApiService.deleteTrigger(params)3405 .then(res => {3406 console.log(JSON.stringify(res.result, null, 2));3407 })3408 .catch(err => {3409 console.warn(err)3410 });3411 3412 // end-delete_trigger3413 });3414 test('deleteTemplateFromWorkspace request example', done => {3415 3416 consoleLogMock.mockImplementation(output => {3417 originalLog(output);3418 done();3419 });3420 consoleWarnMock.mockImplementation(output => {3421 done(output);3422 });3423 3424 // begin-delete_template_from_workspace3425 3426 const params = {3427 wId: 'testString',3428 tId: 'testString',3429 };3430 3431 schematics20ApiService.deleteTemplateFromWorkspace(params)3432 .then(res => {3433 console.log(JSON.stringify(res.result, null, 2));3434 })3435 .catch(err => {3436 console.warn(err)3437 });3438 3439 // end-delete_template_from_workspace3440 });3441 test('deleteResourcesQuery request example', done => {3442 3443 consoleLogMock.mockImplementation(output => {3444 originalLog(output);3445 done();3446 });3447 consoleWarnMock.mockImplementation(output => {3448 done(output);3449 });3450 3451 // begin-delete_resources_query3452 3453 const params = {3454 queryId: 'testString',3455 };3456 3457 schematics20ApiService.deleteResourcesQuery(params)3458 .then(res => {3459 console.log(JSON.stringify(res.result, null, 2));3460 })3461 .catch(err => {3462 console.warn(err)3463 });3464 3465 // end-delete_resources_query3466 });3467 test('deletePrivateCluster request example', done => {3468 3469 consoleLogMock.mockImplementation(output => {3470 originalLog(output);3471 done();3472 });3473 consoleWarnMock.mockImplementation(output => {3474 done(output);3475 });3476 3477 // begin-delete_private_cluster3478 3479 schematics20ApiService.deletePrivateCluster({})3480 .then(res => {3481 console.log(JSON.stringify(res.result, null, 2));3482 })3483 .catch(err => {3484 console.warn(err)3485 });3486 3487 // end-delete_private_cluster3488 });3489 test('deleteJob request example', done => {3490 3491 consoleLogMock.mockImplementation(output => {3492 originalLog(output);3493 done();3494 });3495 consoleWarnMock.mockImplementation(output => {3496 done(output);3497 });3498 3499 // begin-delete_job3500 3501 const params = {3502 jobId: 'testString',3503 refreshToken: 'testString',3504 };3505 3506 schematics20ApiService.deleteJob(params)3507 .then(res => {3508 console.log(JSON.stringify(res.result, null, 2));3509 })3510 .catch(err => {3511 console.warn(err)3512 });3513 3514 // end-delete_job3515 });3516 test('deleteInventory request example', done => {3517 3518 consoleLogMock.mockImplementation(output => {3519 originalLog(output);3520 done();3521 });3522 consoleWarnMock.mockImplementation(output => {3523 done(output);3524 });3525 3526 // begin-delete_inventory3527 3528 const params = {3529 inventoryId: 'testString',3530 };3531 3532 schematics20ApiService.deleteInventory(params)3533 .then(res => {3534 console.log(JSON.stringify(res.result, null, 2));3535 })3536 .catch(err => {3537 console.warn(err)3538 });3539 3540 // end-delete_inventory3541 });3542 test('deleteFlowFromWorkspace request example', done => {3543 3544 consoleLogMock.mockImplementation(output => {3545 originalLog(output);3546 done();3547 });3548 consoleWarnMock.mockImplementation(output => {3549 done(output);3550 });3551 3552 // begin-delete_flow_from_workspace3553 3554 const params = {3555 wId: 'testString',3556 flowId: 'testString',3557 };3558 3559 schematics20ApiService.deleteFlowFromWorkspace(params)3560 .then(res => {3561 console.log(JSON.stringify(res.result, null, 2));3562 })3563 .catch(err => {3564 console.warn(err)3565 });3566 3567 // end-delete_flow_from_workspace3568 });3569 test('deleteDataset request example', done => {3570 3571 consoleLogMock.mockImplementation(output => {3572 originalLog(output);3573 done();3574 });3575 consoleWarnMock.mockImplementation(output => {3576 done(output);3577 });3578 3579 // begin-delete_dataset3580 3581 const params = {3582 datasetId: 'testString',3583 };3584 3585 schematics20ApiService.deleteDataset(params)3586 .then(res => {3587 console.log(JSON.stringify(res.result, null, 2));3588 })3589 .catch(err => {3590 console.warn(err)3591 });3592 3593 // end-delete_dataset3594 });3595 test('deleteControls request example', done => {3596 3597 consoleLogMock.mockImplementation(output => {3598 originalLog(output);3599 done();3600 });3601 consoleWarnMock.mockImplementation(output => {3602 done(output);3603 });3604 3605 // begin-delete_controls3606 3607 const params = {3608 controlsId: 'testString',3609 };3610 3611 schematics20ApiService.deleteControls(params)3612 .then(res => {3613 console.log(JSON.stringify(res.result, null, 2));3614 })3615 .catch(err => {3616 console.warn(err)3617 });3618 3619 // end-delete_controls3620 });3621 test('deleteConnection request example', done => {3622 3623 consoleLogMock.mockImplementation(output => {3624 originalLog(output);3625 done();3626 });3627 consoleWarnMock.mockImplementation(output => {3628 done(output);3629 });3630 3631 // begin-delete_connection3632 3633 const params = {3634 connectionId: 'testString',3635 };3636 3637 schematics20ApiService.deleteConnection(params)3638 .then(res => {3639 console.log(JSON.stringify(res.result, null, 2));3640 })3641 .catch(err => {3642 console.warn(err)3643 });3644 3645 // end-delete_connection3646 });3647 test('deleteCartOrder request example', done => {3648 3649 consoleLogMock.mockImplementation(output => {3650 originalLog(output);3651 done();3652 });3653 consoleWarnMock.mockImplementation(output => {3654 done(output);3655 });3656 3657 // begin-delete_cart_order3658 3659 const params = {3660 orderId: 'testString',3661 };3662 3663 schematics20ApiService.deleteCartOrder(params)3664 .then(res => {3665 console.log(JSON.stringify(res.result, null, 2));3666 })3667 .catch(err => {3668 console.warn(err)3669 });3670 3671 // end-delete_cart_order3672 });3673 test('deleteCapsule request example', done => {3674 3675 consoleLogMock.mockImplementation(output => {3676 originalLog(output);3677 done();3678 });3679 consoleWarnMock.mockImplementation(output => {3680 done(output);3681 });3682 3683 // begin-delete_capsule3684 3685 const params = {3686 controlsId: 'testString',3687 capsuleId: 'testString',3688 };3689 3690 schematics20ApiService.deleteCapsule(params)3691 .then(res => {3692 console.log(JSON.stringify(res.result, null, 2));3693 })3694 .catch(err => {3695 console.warn(err)3696 });3697 3698 // end-delete_capsule3699 });3700 test('deleteBlueprint request example', done => {3701 3702 consoleLogMock.mockImplementation(output => {3703 originalLog(output);3704 done();3705 });3706 consoleWarnMock.mockImplementation(output => {3707 done(output);3708 });3709 3710 // begin-delete_blueprint3711 3712 const params = {3713 blueprintId: 'testString',3714 };3715 3716 schematics20ApiService.deleteBlueprint(params)3717 .then(res => {3718 console.log(JSON.stringify(res.result, null, 2));3719 })3720 .catch(err => {3721 console.warn(err)3722 });3723 3724 // end-delete_blueprint3725 });3726 test('deleteAgent request example', done => {3727 3728 consoleLogMock.mockImplementation(output => {3729 originalLog(output);3730 done();3731 });3732 consoleWarnMock.mockImplementation(output => {3733 done(output);3734 });3735 3736 // begin-delete_agent3737 3738 const params = {3739 agentId: 'testString',3740 };3741 3742 schematics20ApiService.deleteAgent(params)3743 .then(res => {3744 console.log(JSON.stringify(res.result, null, 2));3745 })3746 .catch(err => {3747 console.warn(err)3748 });3749 3750 // end-delete_agent3751 });3752 test('deleteAdapter request example', done => {3753 3754 consoleLogMock.mockImplementation(output => {3755 originalLog(output);3756 done();3757 });3758 consoleWarnMock.mockImplementation(output => {3759 done(output);3760 });3761 3762 // begin-delete_adapter3763 3764 const params = {3765 adapterId: 'testString',3766 };3767 3768 schematics20ApiService.deleteAdapter(params)3769 .then(res => {3770 console.log(JSON.stringify(res.result, null, 2));3771 })3772 .catch(err => {3773 console.warn(err)3774 });3775 3776 // end-delete_adapter3777 });3778 test('deleteAction request example', done => {3779 3780 consoleLogMock.mockImplementation(output => {3781 originalLog(output);3782 done();3783 });3784 consoleWarnMock.mockImplementation(output => {3785 done(output);3786 });3787 3788 // begin-delete_action3789 3790 const params = {3791 actionId: 'testString',3792 };3793 3794 schematics20ApiService.deleteAction(params)3795 .then(res => {3796 console.log(JSON.stringify(res.result, null, 2));3797 })3798 .catch(err => {3799 console.warn(err)3800 });3801 3802 // end-delete_action3803 });3804 });...
cloud-databases.v5.test.js
Source:cloud-databases.v5.test.js
1/**2* @jest-environment node3*/4/**5 * (C) Copyright IBM Corp. 2021.6 *7 * Licensed under the Apache License, Version 2.0 (the "License");8 * you may not use this file except in compliance with the License.9 * You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing, software14 * distributed under the License is distributed on an "AS IS" BASIS,15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.16 * See the License for the specific language governing permissions and17 * limitations under the License.18 */19'use strict';20const CloudDatabasesV5 = require('../dist/cloud-databases/v5');21const { readExternalSources } = require('ibm-cloud-sdk-core');22const authHelper = require('../test/resources/auth-helper.js');23//24// This file provides an example of how to use the Cloud Databases service.25//26// The following configuration properties are assumed to be defined:27// CLOUD_DATABASES_URL=<service base url>28// CLOUD_DATABASES_AUTH_TYPE=iam29// CLOUD_DATABASES_APIKEY=<IAM apikey>30// CLOUD_DATABASES_AUTH_URL=<IAM token service base URL - omit this if using the production environment>31// CLOUD_DATABASES_DEPLOYMENT_ID=<ID of an example deployment>32// CLOUD_DATABASES_REPLICA_ID=<ID of an example replica>33//34// These configuration properties can be exported as environment variables, or stored35// in a configuration file and then:36// export IBM_CREDENTIALS_FILE=<name of configuration file>37//38const configFile = 'cloud_databases.env';39const describe = authHelper.prepareTests(configFile);40// Save original console.log and console.warn41const originalLog = console.log;42const originalWarn = console.warn;43// Mocks for console.log and console.warn44const consoleLogMock = jest.spyOn(console, 'log');45const consoleWarnMock = jest.spyOn(console, 'warn');46// testcase timeout value (200s).47const timeout = 200000;48const autoScalingGroupId = 'member';49const ipAddress1 = '195.212.0.0/16';50const ipAddress3 = '172.16.0.0/16';51const username = 'exampleUsername';52const password = 'examplePassword';53const newPassowrd = 'exampleNewPassword';54const userType = 'database';55let cloudDatabasesServiceRef;56let deploymentId;57let replicaId;58// Global variables to hold link values59let taskIdLink;60let backupIdLink;61let scalingGroupIdLink;62async function waitForTask(taskId) {63 let complete = false;64 for (let attempts = 0; !complete && attempts < 30; attempts++) {65 const res = await cloudDatabasesServiceRef.getTask({66 id: taskId,67 });68 expect(res.status).toEqual(200);69 expect(res.result).not.toBeNull();70 if (res.result.task == null) {71 complete = true;72 } else {73 switch (res.result.task.status) {74 case 'completed':75 case 'failed':76 complete = true;77 expect(res.result.task.status).toEqual('completed');78 break;79 case 'queued':80 case 'running':81 break;82 default:83 console.log('status is', res.result.task.status);84 break;85 }86 }87 await new Promise(r => setTimeout(r, 2000));88 }89}90describe('CloudDatabasesV5', () => {91 // begin-common92 const cloudDatabasesService = CloudDatabasesV5.newInstance({});93 // end-common94 cloudDatabasesServiceRef = cloudDatabasesService;95 const config = readExternalSources(CloudDatabasesV5.DEFAULT_SERVICE_NAME);96 deploymentId = config.deploymentId;97 expect(deploymentId).not.toBeNull();98 replicaId = config.replicaId;99 expect(replicaId).not.toBeNull();100 jest.setTimeout(timeout);101 test('addAllowlistEntry request example', done => {102 consoleLogMock.mockImplementation(output => {103 originalLog(output);104 let responseBody = JSON.parse(output);105 taskIdLink = responseBody.task.id;106 waitForTask(taskIdLink)107 .finally(() => done());108 });109 consoleWarnMock.mockImplementation(output => {110 done(output);111 });112 originalLog('addAllowlistEntry() result:');113 // begin-addAllowlistEntry114 const allowlistEntryModel = {115 address: ipAddress3,116 description: 'Dev IP space 3',117 };118 const params = {119 id: deploymentId,120 ipAddress: allowlistEntryModel,121 };122 cloudDatabasesService.addAllowlistEntry(params)123 .then(res => {124 console.log(JSON.stringify(res.result, null, 2));125 })126 .catch(err => {127 console.warn(err)128 });129 // end-addAllowlistEntry130 });131 test('deleteAllowlistEntry request example', done => {132 consoleLogMock.mockImplementation(output => {133 originalLog(output);134 let responseBody = JSON.parse(output);135 taskIdLink = responseBody.task.id;136 waitForTask(taskIdLink)137 .finally(() => done());138 });139 consoleWarnMock.mockImplementation(output => {140 done(output);141 });142 originalLog('deleteAllowlistEntry() result:');143 // begin-deleteAllowlistEntry144 const params = {145 id: deploymentId,146 ipaddress: ipAddress3,147 };148 cloudDatabasesService.deleteAllowlistEntry(params)149 .then(res => {150 console.log(JSON.stringify(res.result, null, 2));151 })152 .catch(err => {153 console.warn(err)154 });155 // end-deleteAllowlistEntry156 });157 test('createDatabaseUser request example', done => {158 consoleLogMock.mockImplementation(output => {159 originalLog(output);160 let responseBody = JSON.parse(output);161 taskIdLink = responseBody.task.id;162 waitForTask(taskIdLink)163 .finally(() => done());164 });165 consoleWarnMock.mockImplementation(output => {166 done(output);167 });168 originalLog('createDatabaseUser() result:');169 // begin-createDatabaseUser170 const createDatabaseUserRequestUserModel = {171 username: username,172 password: password,173 };174 const params = {175 id: deploymentId,176 userType: userType,177 user: createDatabaseUserRequestUserModel,178 };179 cloudDatabasesService.createDatabaseUser(params)180 .then(res => {181 console.log(JSON.stringify(res.result, null, 2));182 })183 .catch(err => {184 console.warn(err)185 });186 // end-createDatabaseUser187 });188 test('changeUserPassword request example', done => {189 consoleLogMock.mockImplementation(output => {190 originalLog(output);191 let responseBody = JSON.parse(output);192 taskIdLink = responseBody.task.id;193 waitForTask(taskIdLink)194 .finally(() => done());195 });196 consoleWarnMock.mockImplementation(output => {197 done(output);198 });199 originalLog('changeUserPassword() result:');200 // begin-changeUserPassword201 const aPasswordSettingUserModel = {202 password: newPassowrd,203 };204 const params = {205 id: deploymentId,206 userType: userType,207 username: username,208 user: aPasswordSettingUserModel,209 };210 cloudDatabasesService.changeUserPassword(params)211 .then(res => {212 console.log(JSON.stringify(res.result, null, 2));213 })214 .catch(err => {215 console.warn(err)216 });217 // end-changeUserPassword218 });219 test('deleteDatabaseUser request example', done => {220 consoleLogMock.mockImplementation(output => {221 originalLog(output);222 let responseBody = JSON.parse(output);223 taskIdLink = responseBody.task.id;224 waitForTask(taskIdLink)225 .finally(() => done());226 });227 consoleWarnMock.mockImplementation(output => {228 done(output);229 });230 originalLog('deleteDatabaseUser() result:');231 // begin-deleteDatabaseUser232 const params = {233 id: deploymentId,234 userType: userType,235 username: username,236 };237 cloudDatabasesService.deleteDatabaseUser(params)238 .then(res => {239 console.log(JSON.stringify(res.result, null, 2));240 })241 .catch(err => {242 console.warn(err)243 });244 // end-deleteDatabaseUser245 });246 test('killConnections request example', done => {247 consoleLogMock.mockImplementation(output => {248 originalLog(output);249 let responseBody = JSON.parse(output);250 taskIdLink = responseBody.task.id;251 waitForTask(taskIdLink)252 .finally(() => done());253 });254 consoleWarnMock.mockImplementation(output => {255 done(output);256 });257 originalLog('killConnections() result:');258 // begin-killConnections259 const params = {260 id: deploymentId,261 };262 cloudDatabasesService.killConnections(params)263 .then(res => {264 console.log(JSON.stringify(res.result, null, 2));265 })266 .catch(err => {267 console.warn(err)268 });269 // end-killConnections270 });271 test('setAllowlist request example', done => {272 consoleLogMock.mockImplementation(output => {273 originalLog(output);274 let responseBody = JSON.parse(output);275 taskIdLink = responseBody.task.id;276 waitForTask(taskIdLink)277 .finally(() => done());278 });279 consoleWarnMock.mockImplementation(output => {280 done(output);281 });282 originalLog('setAllowlist() result:');283 // begin-setAllowlist284 const allowlistEntryModel = {285 address: ipAddress1,286 description: 'Dev IP space 1'287 };288 const params = {289 id: deploymentId,290 ipAddresses: [allowlistEntryModel],291 ifMatch: 'exampleETag',292 };293 cloudDatabasesService.setAllowlist(params)294 .then(res => {295 console.log(JSON.stringify(res.result, null, 2));296 })297 .catch(err => {298 console.warn(err)299 });300 // end-setAllowlist301 });302 test('setAutoscalingConditions request example', done => {303 consoleLogMock.mockImplementation(output => {304 originalLog(output);305 let responseBody = JSON.parse(output);306 taskIdLink = responseBody.task.id;307 waitForTask(taskIdLink)308 .finally(() => done());309 });310 consoleWarnMock.mockImplementation(output => {311 done(output);312 });313 originalLog('setAutoscalingConditions() result:');314 // begin-setAutoscalingConditions315 const autoscalingMemoryGroupMemoryScalersIoUtilizationModel = {316 enabled: true,317 over_period: '5m',318 above_percent: 90,319 };320 const autoscalingMemoryGroupMemoryScalersModel = {321 io_utilization: autoscalingMemoryGroupMemoryScalersIoUtilizationModel,322 };323 const autoscalingMemoryGroupMemoryRateModel = {324 increase_percent: 10.0,325 period_seconds: 300,326 limit_mb_per_member: 114432,327 units: 'mb',328 };329 const autoscalingMemoryGroupMemoryModel = {330 scalers: autoscalingMemoryGroupMemoryScalersModel,331 rate: autoscalingMemoryGroupMemoryRateModel,332 };333 const autoscalingSetGroupAutoscalingModel = {334 memory: autoscalingMemoryGroupMemoryModel,335 };336 const params = {337 id: deploymentId,338 groupId: autoScalingGroupId,339 autoscaling: autoscalingSetGroupAutoscalingModel,340 };341 cloudDatabasesService.setAutoscalingConditions(params)342 .then(res => {343 console.log(JSON.stringify(res.result, null, 2));344 })345 .catch(err => {346 console.warn(err)347 });348 // end-setAutoscalingConditions349 });350 test('updateDatabaseConfiguration request example', done => {351 consoleLogMock.mockImplementation(output => {352 originalLog(output);353 let responseBody = JSON.parse(output);354 taskIdLink = responseBody.task.id;355 waitForTask(taskIdLink)356 .finally(() => done());357 });358 consoleWarnMock.mockImplementation(output => {359 done(output);360 });361 originalLog('updateDatabaseConfiguration() result:');362 // begin-updateDatabaseConfiguration363 const setConfigurationConfigurationModel = {364 max_connections: 200,365 max_prepared_transactions: 0,366 deadlock_timeout: 100,367 effective_io_concurrency: 1,368 max_replication_slots: 10,369 max_wal_senders: 12,370 shared_buffers: 16,371 synchronous_commit: 'local',372 wal_level: 'hot_standby',373 archive_timeout: 300,374 log_min_duration_statement: 100,375 };376 const params = {377 id: deploymentId,378 configuration: setConfigurationConfigurationModel,379 };380 cloudDatabasesService.updateDatabaseConfiguration(params)381 .then(res => {382 console.log(JSON.stringify(res.result, null, 2));383 })384 .catch(err => {385 console.warn(err)386 });387 // end-updateDatabaseConfiguration388 });389 test('listDeployables request example', done => {390 consoleLogMock.mockImplementation(output => {391 originalLog(output);392 done();393 });394 consoleWarnMock.mockImplementation(output => {395 done(output);396 });397 originalLog('listDeployables() result:');398 // begin-listDeployables399 cloudDatabasesService.listDeployables({})400 .then(res => {401 console.log(JSON.stringify(res.result, null, 2));402 })403 .catch(err => {404 console.warn(err)405 });406 // end-listDeployables407 });408 test('listRegions request example', done => {409 consoleLogMock.mockImplementation(output => {410 originalLog(output);411 done();412 });413 consoleWarnMock.mockImplementation(output => {414 done(output);415 });416 originalLog('listRegions() result:');417 // begin-listRegions418 cloudDatabasesService.listRegions({})419 .then(res => {420 console.log(JSON.stringify(res.result, null, 2));421 })422 .catch(err => {423 console.warn(err)424 });425 // end-listRegions426 });427 test('getDeploymentInfo request example', done => {428 consoleLogMock.mockImplementation(output => {429 originalLog(output);430 done();431 });432 consoleWarnMock.mockImplementation(output => {433 done(output);434 });435 originalLog('getDeploymentInfo() result:');436 // begin-getDeploymentInfo437 const params = {438 id: deploymentId,439 };440 cloudDatabasesService.getDeploymentInfo(params)441 .then(res => {442 console.log(JSON.stringify(res.result, null, 2));443 })444 .catch(err => {445 console.warn(err)446 });447 // end-getDeploymentInfo448 });449 test('listRemotes request example', done => {450 consoleLogMock.mockImplementation(output => {451 originalLog(output);452 done();453 });454 consoleWarnMock.mockImplementation(output => {455 done(output);456 });457 originalLog('listRemotes() result:');458 // begin-listRemotes459 const params = {460 id: deploymentId,461 };462 cloudDatabasesService.listRemotes(params)463 .then(res => {464 console.log(JSON.stringify(res.result, null, 2));465 })466 .catch(err => {467 console.warn(err)468 });469 // end-listRemotes470 });471 test('resyncReplica request example', done => {472 consoleLogMock.mockImplementation(output => {473 originalLog(output);474 let responseBody = JSON.parse(output);475 taskIdLink = responseBody.task.id;476 waitForTask(taskIdLink)477 .finally(() => done());478 });479 consoleWarnMock.mockImplementation(output => {480 done(output);481 });482 // begin-resyncReplica483 const params = {484 id: replicaId,485 };486 cloudDatabasesService.resyncReplica(params)487 .then(res => {488 console.log(JSON.stringify(res.result, null, 2));489 })490 .catch(err => {491 console.warn(err)492 });493 // end-resyncReplica494 });495 // Skip the setPromotion test by default to preserve test environment496 test.skip('setPromotion request example', done => {497 consoleLogMock.mockImplementation(output => {498 originalLog(output);499 let responseBody = JSON.parse(output);500 taskIdLink = responseBody.task.id;501 waitForTask(taskIdLink)502 .finally(() => done());503 });504 consoleWarnMock.mockImplementation(output => {505 done(output);506 });507 originalLog('setPromotion() result:');508 // begin-setPromotion509 const promotion = {510 skip_initial_backup: true,511 };512 const setPromotionPromotionModel = {513 promotion: promotion,514 };515 const params = {516 id: replicaId,517 promotion: setPromotionPromotionModel,518 };519 cloudDatabasesService.setPromotion(params)520 .then(res => {521 console.log(JSON.stringify(res.result, null, 2));522 })523 .catch(err => {524 console.warn(err)525 });526 // end-setPromotion527 });528 test('listDeploymentTasks request example', done => {529 consoleLogMock.mockImplementation(output => {530 originalLog(output);531 done();532 });533 consoleWarnMock.mockImplementation(output => {534 done(output);535 });536 originalLog('listDeploymentTasks() result:');537 // begin-listDeploymentTasks538 const params = {539 id: deploymentId,540 };541 cloudDatabasesService.listDeploymentTasks(params)542 .then(res => {543 console.log(JSON.stringify(res.result, null, 2));544 })545 .catch(err => {546 console.warn(err)547 });548 // end-listDeploymentTasks549 });550 test('getTask request example', done => {551 consoleLogMock.mockImplementation(output => {552 originalLog(output);553 done();554 });555 consoleWarnMock.mockImplementation(output => {556 done(output);557 });558 originalLog('getTask() result:');559 // begin-getTask560 const params = {561 id: taskIdLink,562 };563 cloudDatabasesService.getTask(params)564 .then(res => {565 console.log(JSON.stringify(res.result, null, 2));566 })567 .catch(err => {568 console.warn(err)569 });570 // end-getTask571 });572 test('listDeploymentBackups request example', done => {573 consoleLogMock.mockImplementation(output => {574 originalLog(output);575 let responseBody = JSON.parse(output);576 backupIdLink = responseBody.backups[0].id;577 done();578 });579 consoleWarnMock.mockImplementation(output => {580 done(output);581 });582 originalLog('listDeploymentBackups() result:');583 // begin-listDeploymentBackups584 const params = {585 id: deploymentId,586 };587 cloudDatabasesService.listDeploymentBackups(params)588 .then(res => {589 console.log(JSON.stringify(res.result, null, 2));590 })591 .catch(err => {592 console.warn(err)593 });594 // end-listDeploymentBackups595 });596 test('getBackupInfo request example', done => {597 consoleLogMock.mockImplementation(output => {598 originalLog(output);599 done();600 });601 consoleWarnMock.mockImplementation(output => {602 done(output);603 });604 originalLog('getBackupInfo() result:');605 // begin-getBackupInfo606 const params = {607 backupId: backupIdLink,608 };609 cloudDatabasesService.getBackupInfo(params)610 .then(res => {611 console.log(JSON.stringify(res.result, null, 2));612 })613 .catch(err => {614 console.warn(err)615 });616 // end-getBackupInfo617 });618 test('startOndemandBackup request example', done => {619 consoleLogMock.mockImplementation(output => {620 originalLog(output);621 done();622 });623 consoleWarnMock.mockImplementation(output => {624 done(output);625 });626 originalLog('startOndemandBackup() result:');627 // begin-startOndemandBackup628 const params = {629 id: deploymentId,630 };631 cloudDatabasesService.startOndemandBackup(params)632 .then(res => {633 console.log(JSON.stringify(res.result, null, 2));634 })635 .catch(err => {636 console.warn(err)637 });638 // end-startOndemandBackup639 });640 test('getPitRdata request example', done => {641 consoleLogMock.mockImplementation(output => {642 originalLog(output);643 done();644 });645 consoleWarnMock.mockImplementation(output => {646 done(output);647 });648 originalLog('getPitRdata() result:');649 // begin-getPITRdata650 const params = {651 id: deploymentId,652 };653 cloudDatabasesService.getPitRdata(params)654 .then(res => {655 console.log(JSON.stringify(res.result, null, 2));656 })657 .catch(err => {658 console.warn(err)659 });660 // end-getPITRdata661 });662 test('getConnection request example', done => {663 consoleLogMock.mockImplementation(output => {664 originalLog(output);665 done();666 });667 consoleWarnMock.mockImplementation(output => {668 done(output);669 });670 originalLog('getConnection() result:');671 // begin-getConnection672 const params = {673 id: deploymentId,674 userType: userType,675 userId: 'exampleUserID',676 endpointType: 'public',677 certificateRoot: 'exampleCertRoot'678 };679 cloudDatabasesService.getConnection(params)680 .then(res => {681 console.log(JSON.stringify(res.result, null, 2));682 })683 .catch(err => {684 console.warn(err)685 });686 // end-getConnection687 });688 test('completeConnection request example', done => {689 consoleLogMock.mockImplementation(output => {690 originalLog(output);691 done();692 });693 consoleWarnMock.mockImplementation(output => {694 done(output);695 });696 originalLog('completeConnection() result:');697 // begin-completeConnection698 const params = {699 id: deploymentId,700 userType: userType,701 userId: 'exampleUserID',702 endpointType: 'public',703 password: 'examplePassword',704 certificateRoot: 'exampleCertRoot',705 };706 cloudDatabasesService.completeConnection(params)707 .then(res => {708 console.log(JSON.stringify(res.result, null, 2));709 })710 .catch(err => {711 console.warn(err)712 });713 // end-completeConnection714 });715 test('listDeploymentScalingGroups request example', done => {716 consoleLogMock.mockImplementation(output => {717 originalLog(output);718 let responseBody = JSON.parse(output);719 scalingGroupIdLink = responseBody.groups[0].id;720 done();721 });722 consoleWarnMock.mockImplementation(output => {723 done(output);724 });725 originalLog('listDeploymentScalingGroups() result:');726 // begin-listDeploymentScalingGroups727 const params = {728 id: deploymentId,729 };730 cloudDatabasesService.listDeploymentScalingGroups(params)731 .then(res => {732 console.log(JSON.stringify(res.result, null, 2));733 })734 .catch(err => {735 console.warn(err)736 });737 // end-listDeploymentScalingGroups738 });739 test('setDeploymentScalingGroup request example', done => {740 consoleLogMock.mockImplementation(output => {741 originalLog(output);742 let responseBody = JSON.parse(output);743 taskIdLink = responseBody.task.id;744 waitForTask(taskIdLink)745 .finally(() => {746 const setMemoryGroupMemoryModel = {747 allocation_mb: 114432,748 };749 const setDeploymentScalingGroupRequestModel = {750 memory: setMemoryGroupMemoryModel,751 };752 const params = {753 id: deploymentId,754 groupId: scalingGroupIdLink,755 setDeploymentScalingGroupRequest: setDeploymentScalingGroupRequestModel,756 };757 cloudDatabasesService.setDeploymentScalingGroup(params)758 .finally(() => {759 waitForTask(taskIdLink)760 .finally(() => done());761 });762 })763 });764 consoleWarnMock.mockImplementation(output => {765 const setMemoryGroupMemoryModel = {766 allocation_mb: 114432,767 };768 const setDeploymentScalingGroupRequestModel = {769 memory: setMemoryGroupMemoryModel,770 };771 const params = {772 id: deploymentId,773 groupId: scalingGroupIdLink,774 setDeploymentScalingGroupRequest: setDeploymentScalingGroupRequestModel,775 };776 cloudDatabasesService.setDeploymentScalingGroup(params)777 .finally(() => {778 waitForTask(taskIdLink)779 .finally(() => done());780 });781 });782 originalLog('setDeploymentScalingGroup() result:');783 // begin-setDeploymentScalingGroup784 const setMemoryGroupMemoryModel = {785 allocation_mb: 114688,786 };787 const setDeploymentScalingGroupRequestModel = {788 memory: setMemoryGroupMemoryModel,789 };790 const params = {791 id: deploymentId,792 groupId: scalingGroupIdLink,793 setDeploymentScalingGroupRequest: setDeploymentScalingGroupRequestModel,794 };795 cloudDatabasesService.setDeploymentScalingGroup(params)796 .then(res => {797 console.log(JSON.stringify(res.result, null, 2));798 })799 .catch(err => {800 console.warn(err)801 });802 // end-setDeploymentScalingGroup803 });804 test('getDefaultScalingGroups request example', done => {805 consoleLogMock.mockImplementation(output => {806 originalLog(output);807 done();808 });809 consoleWarnMock.mockImplementation(output => {810 done(output);811 });812 originalLog('getDefaultScalingGroups() result:');813 // begin-getDefaultScalingGroups814 const params = {815 type: 'postgresql',816 };817 cloudDatabasesService.getDefaultScalingGroups(params)818 .then(res => {819 console.log(JSON.stringify(res.result, null, 2));820 })821 .catch(err => {822 console.warn(err)823 });824 // end-getDefaultScalingGroups825 });826 test('getAutoscalingConditions request example', done => {827 consoleLogMock.mockImplementation(output => {828 originalLog(output);829 done();830 });831 consoleWarnMock.mockImplementation(output => {832 done(output);833 });834 originalLog('getAutoscalingConditions() result:');835 // begin-getAutoscalingConditions836 const params = {837 id: deploymentId,838 groupId: autoScalingGroupId,839 };840 cloudDatabasesService.getAutoscalingConditions(params)841 .then(res => {842 console.log(JSON.stringify(res.result, null, 2));843 })844 .catch(err => {845 console.warn(err)846 });847 // end-getAutoscalingConditions848 });849 test('getAllowlist request example', done => {850 consoleLogMock.mockImplementation(output => {851 originalLog(output);852 done();853 });854 consoleWarnMock.mockImplementation(output => {855 done(output);856 });857 originalLog('getAllowlist() result:');858 // begin-getAllowlist859 const params = {860 id: deploymentId,861 };862 cloudDatabasesService.getAllowlist(params)863 .then(res => {864 console.log(JSON.stringify(res.result, null, 2));865 })866 .catch(err => {867 console.warn(err)868 });869 // end-getAllowlist870 });...
getSelectableFiles.test.ts
Source:getSelectableFiles.test.ts
1import getSelectableFiles, { emptyDirWarning, wrongArgsWarning, badInputWarning } from './getSelectableFiles';2describe('Return Value:', () => {3 test('should return array of all .srt and .mkv files!', () => {4 expect(getSelectableFiles('./src/assets/mixed_files')).toEqual(['movie1.mkv', 'movie2.MKV', 'subtitle1.srt', 'subtitle2.SRT']);5 });6});7describe('Warnings:', () => {8 const consoleWarnMock = jest.spyOn(console, 'warn').mockImplementation();9 test('should display emptyDirWarning if no .srt or .mkv files were found!', () => {10 getSelectableFiles('./src/assets/wrong_files');11 expect(consoleWarnMock).toHaveBeenLastCalledWith(emptyDirWarning);12 });13 test('should display wrongArgsWarning if wrong arguments were passed in!', () => {14 // @ts-ignore15 getSelectableFiles(1);16 expect(consoleWarnMock).toHaveBeenLastCalledWith(wrongArgsWarning);17 });18 test('should display badInputWarning if fs.readdirSync() failed!', () => {19 getSelectableFiles('/wrong/directory');20 expect(consoleWarnMock).toHaveBeenLastCalledWith(badInputWarning);21 });22 afterAll(() => consoleWarnMock.mockRestore());...
Using AI Code Generation
1import { consoleWarnMock } from 'storybook-root-decorator';2import { consoleErrorMock } from 'storybook-root-decorator';3import { consoleInfoMock } from 'storybook-root-decorator';4import { consoleLogMock } from 'storybook-root-decorator';5import { consoleDebugMock } from 'storybook-root-decorator';6import { consoleMock } from 'storybook-root-decorator';7import { consoleMockAll } from 'storybook-root-decorator';8import { consoleMockRestore } from 'storybook-root-decorator';9import { consoleMockRestoreAll } from 'storybook-root-decorator';10import { consoleMockReset } from 'storybook-root-decorator';11import { consoleMockResetAll } from 'storybook-root-decorator';12import { consoleMockClear } from 'storybook-root-decorator';13import { consoleMockClearAll } from 'storybook-root-decorator';14import { consoleMockClearAll } from 'storybook-root-decorator';15import { consoleMockClearAll } from 'storybook-root-decorator';16import { consoleSpy } from 'storybook-root-decorator';17import { consoleSpyAll } from 'storybook-root
Using AI Code Generation
1import consoleWarnMock from 'storybook-root'2import { render } from 'react-dom'3import App from './App'4const root = document.createElement('div')5document.body.appendChild(root)6render(<App />, root)7import React from 'react'8import './App.css'9function App() {10 return (11}12.App {13 text-align: center;14}15.App-header {16 background-color: #282c34;17 min-height: 100vh;18 display: flex;19 flex-direction: column;20 align-items: center;21 justify-content: center;22 font-size: calc(10px + 2vmin);23 color: white;24}25import React from 'react'26import ReactDOM from 'react-dom'27import App from './App'28it('renders without crashing', () => {29 const div = document.createElement('div')30 ReactDOM.render(<App />, div)31 ReactDOM.unmountComponentAtNode(div)32})33module.exports = {34 stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],35}36import { addDecorator } from '@storybook/react'37import { withConsole } from '@storybook/addon-console'38import { withTests } from '@storybook/addon-jest'39import results from '../.jest-test-results.json'40addDecorator(41 (storyFn, context) =>42 withConsole({
Using AI Code Generation
1import { consoleWarnMock } from 'storybook-root';2describe('test', () => {3 it('test', () => {4 consoleWarnMock();5 });6});7I would recommend using jest.spyOn() to mock the console.warn method. It's a lot more flexible and you can restore the original method after the test is done. Here's an example:8describe('test', () => {9 it('test', () => {10 const spy = jest.spyOn(console, 'warn').mockImplementation(() => {});11 expect(spy).toHaveBeenCalled();12 spy.mockRestore();13 });14});15describe('test', () => {16 it('test', () => {17 const spy = jest.spyOn(console, 'warn').mockImplementation(() => {});18 const spy2 = jest.spyOn(console, 'error').mockImplementation(() => {});19 expect(spy).toHaveBeenCalled();20 expect(spy2).toHaveBeenCalled();21 spy.mockRestore();22 spy2.mockRestore();23 });24});
Using AI Code Generation
1import { consoleWarnMock } from 'storybook-root';2consoleWarnMock();3console.warn('test');4import { cleanup } from '@testing-library/react';5afterEach(() => {6 cleanup();7 jest.clearAllMocks();8});9console.warn('test');10import { cleanup } from '@testing-library/react';11afterEach(() => {12 cleanup();13 jest.clearAllMocks();14});15console.warn('test');16import { cleanup } from '@testing-library/react';17afterEach(() => {18 cleanup();19 jest.clearAllMocks();20});21console.warn('test');22import { cleanup } from '@testing-library/react';23afterEach(() => {24 cleanup();25 jest.clearAllMocks();26});27console.warn('test');28import { cleanup } from '@testing-library/react';29afterEach(() => {30 cleanup();31 jest.clearAllMocks();32});33console.warn('test');34import { cleanup } from '@testing-library/react';35afterEach(() => {36 cleanup();37 jest.clearAllMocks();38});39console.warn('test');40import { cleanup } from '@testing-library/react';41afterEach(() => {42 cleanup();43 jest.clearAllMocks();44});45console.warn('test');46import { cleanup } from '@testing-library/react';47afterEach(() => {48 cleanup();49 jest.clearAllMocks();50});51console.warn('test');52import { cleanup } from '@testing-library/react';53afterEach(() => {54 cleanup();55 jest.clearAllMocks();56});57console.warn('test');58import { cleanup } from '@testing-library/react
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!