@itentialopensource/adapter-azure_devops 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTH.md +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +169 -0
- package/CHANGELOG.md +17 -2
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +221 -571
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +11999 -57
- package/adapterBase.js +1007 -253
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/README.md +59 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/specificCallScript.js +97 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/update.js +532 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/adapter.js +11651 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/AnnotatedTags/action.json +43 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/AnnotatedTags/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/AnnotatedTags/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Blobs/action.json +43 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Blobs/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Blobs/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/CherryPicks/action.json +64 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/CherryPicks/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/CherryPicks/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Commits/action.json +85 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Commits/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Commits/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Diffs/action.json +23 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Diffs/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Diffs/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Forks/action.json +85 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Forks/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Forks/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/ImportRequests/action.json +84 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/ImportRequests/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/ImportRequests/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Items/action.json +43 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Items/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Items/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/MergeBases/action.json +23 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/MergeBases/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/MergeBases/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Merges/action.json +43 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Merges/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Merges/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PolicyConfigurations/action.json +23 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PolicyConfigurations/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PolicyConfigurations/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestAttachments/action.json +84 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestAttachments/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestAttachments/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommentLikes/action.json +63 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommentLikes/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommentLikes/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommits/action.json +44 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommits/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommits/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationChanges/action.json +23 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationChanges/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationChanges/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationStatuses/action.json +104 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationStatuses/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationStatuses/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterations/action.json +44 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterations/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterations/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestLabels/action.json +84 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestLabels/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestLabels/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestProperties/action.json +43 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestProperties/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestProperties/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestQuery/action.json +22 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestQuery/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestQuery/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestReviewers/action.json +164 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestReviewers/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestReviewers/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestShare/action.json +22 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestShare/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestShare/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestStatuses/action.json +104 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestStatuses/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestStatuses/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreadComments/action.json +104 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreadComments/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreadComments/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreads/action.json +84 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreads/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreads/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestWorkItems/action.json +23 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestWorkItems/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestWorkItems/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequests/action.json +126 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequests/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequests/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Pushes/action.json +64 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Pushes/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Pushes/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Refs/action.json +63 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Refs/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Refs/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/RefsFavorites/action.json +84 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/RefsFavorites/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/RefsFavorites/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Repositories/action.json +186 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Repositories/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Repositories/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Reverts/action.json +64 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Reverts/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Reverts/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Stats/action.json +23 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Stats/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Stats/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Statuses/action.json +43 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Statuses/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Statuses/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Suggestions/action.json +23 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Suggestions/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Suggestions/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Trees/action.json +23 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Trees/mockdatafiles/mockdata.json +20817 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Trees/schema.json +125 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/methods.json +74975 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/pronghorn.json +11730 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/test/integration/adapterTestIntegration.js +5493 -0
- package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/test/unit/adapterTestUnit.js +10889 -0
- package/entities/.generic/action.json +105 -0
- package/entities/.generic/schema.json +6 -1
- package/entities/AnnotatedTags/action.json +45 -0
- package/entities/AnnotatedTags/schema.json +20 -0
- package/entities/Blobs/action.json +45 -0
- package/entities/Blobs/schema.json +20 -0
- package/entities/CherryPicks/action.json +66 -0
- package/entities/CherryPicks/schema.json +21 -0
- package/entities/Commits/action.json +87 -0
- package/entities/Commits/mockdatafiles/commitsGetCommitsBatch-default.json +707 -0
- package/entities/Commits/mockdatafiles/commitsGetPushCommits-default.json +336 -0
- package/entities/Commits/schema.json +22 -0
- package/entities/Diffs/action.json +25 -0
- package/entities/Diffs/schema.json +19 -0
- package/entities/Forks/action.json +87 -0
- package/entities/Forks/mockdatafiles/forksGetForkSyncRequests-default.json +200 -0
- package/entities/Forks/mockdatafiles/forksList-default.json +102 -0
- package/entities/Forks/schema.json +22 -0
- package/entities/ImportRequests/action.json +86 -0
- package/entities/ImportRequests/mockdatafiles/importRequestsQuery-default.json +91 -0
- package/entities/ImportRequests/schema.json +22 -0
- package/entities/Items/action.json +45 -0
- package/entities/Items/mockdatafiles/itemsGetItemsBatch-default.json +5 -0
- package/entities/Items/mockdatafiles/itemsList-default.json +40 -0
- package/entities/Items/schema.json +20 -0
- package/entities/MergeBases/action.json +25 -0
- package/entities/MergeBases/mockdatafiles/mergeBasesList-default.json +580 -0
- package/entities/MergeBases/schema.json +19 -0
- package/entities/Merges/action.json +45 -0
- package/entities/Merges/schema.json +20 -0
- package/entities/PolicyConfigurations/action.json +25 -0
- package/entities/PolicyConfigurations/mockdatafiles/policyConfigurationsGet-default.json +20 -0
- package/entities/PolicyConfigurations/schema.json +19 -0
- package/entities/PullRequestAttachments/action.json +86 -0
- package/entities/PullRequestAttachments/mockdatafiles/pullRequestAttachmentsList-default.json +159 -0
- package/entities/PullRequestAttachments/schema.json +22 -0
- package/entities/PullRequestCommentLikes/action.json +65 -0
- package/entities/PullRequestCommentLikes/mockdatafiles/pullRequestCommentLikesList-default.json +10 -0
- package/entities/PullRequestCommentLikes/schema.json +21 -0
- package/entities/PullRequestCommits/action.json +46 -0
- package/entities/PullRequestCommits/mockdatafiles/pullRequestCommitsGetPullRequestCommits-default.json +818 -0
- package/entities/PullRequestCommits/mockdatafiles/pullRequestCommitsGetPullRequestIterationCommits-default.json +813 -0
- package/entities/PullRequestCommits/schema.json +20 -0
- package/entities/PullRequestIterationChanges/action.json +25 -0
- package/entities/PullRequestIterationChanges/schema.json +19 -0
- package/entities/PullRequestIterationStatuses/action.json +106 -0
- package/entities/PullRequestIterationStatuses/mockdatafiles/pullRequestIterationStatusesList-default.json +71 -0
- package/entities/PullRequestIterationStatuses/schema.json +23 -0
- package/entities/PullRequestIterations/action.json +46 -0
- package/entities/PullRequestIterations/mockdatafiles/pullRequestIterationsList-default.json +2403 -0
- package/entities/PullRequestIterations/schema.json +20 -0
- package/entities/PullRequestLabels/action.json +86 -0
- package/entities/PullRequestLabels/mockdatafiles/pullRequestLabelsList-default.json +20 -0
- package/entities/PullRequestLabels/schema.json +22 -0
- package/entities/PullRequestProperties/action.json +45 -0
- package/entities/PullRequestProperties/schema.json +20 -0
- package/entities/PullRequestQuery/action.json +24 -0
- package/entities/PullRequestQuery/schema.json +19 -0
- package/entities/PullRequestReviewers/action.json +166 -0
- package/entities/PullRequestReviewers/mockdatafiles/pullRequestReviewersCreatePullRequestReviewers-default.json +10 -0
- package/entities/PullRequestReviewers/mockdatafiles/pullRequestReviewersList-default.json +10 -0
- package/entities/PullRequestReviewers/schema.json +26 -0
- package/entities/PullRequestShare/action.json +24 -0
- package/entities/PullRequestShare/schema.json +19 -0
- package/entities/PullRequestStatuses/action.json +106 -0
- package/entities/PullRequestStatuses/mockdatafiles/pullRequestStatusesList-default.json +48 -0
- package/entities/PullRequestStatuses/schema.json +23 -0
- package/entities/PullRequestThreadComments/action.json +106 -0
- package/entities/PullRequestThreadComments/mockdatafiles/pullRequestThreadCommentsList-default.json +215 -0
- package/entities/PullRequestThreadComments/schema.json +23 -0
- package/entities/PullRequestThreads/action.json +86 -0
- package/entities/PullRequestThreads/mockdatafiles/pullRequestThreadsList-default.json +395 -0
- package/entities/PullRequestThreads/schema.json +22 -0
- package/entities/PullRequestWorkItems/action.json +25 -0
- package/entities/PullRequestWorkItems/mockdatafiles/pullRequestWorkItemsList-default.json +18 -0
- package/entities/PullRequestWorkItems/schema.json +19 -0
- package/entities/PullRequests/action.json +128 -0
- package/entities/PullRequests/mockdatafiles/pullRequestsGetPullRequests-default.json +6555 -0
- package/entities/PullRequests/mockdatafiles/pullRequestsGetPullRequestsByProject-default.json +5929 -0
- package/entities/PullRequests/schema.json +24 -0
- package/entities/Pushes/action.json +66 -0
- package/entities/Pushes/mockdatafiles/pushesList-default.json +34 -0
- package/entities/Pushes/schema.json +21 -0
- package/entities/Refs/action.json +65 -0
- package/entities/Refs/mockdatafiles/refsList-default.json +500 -0
- package/entities/Refs/mockdatafiles/refsUpdateRefs-default.json +13 -0
- package/entities/Refs/schema.json +21 -0
- package/entities/RefsFavorites/action.json +86 -0
- package/entities/RefsFavorites/mockdatafiles/refsFavoritesList-default.json +35 -0
- package/entities/RefsFavorites/schema.json +22 -0
- package/entities/Repositories/action.json +188 -0
- package/entities/Repositories/mockdatafiles/repositoriesGetDeletedRepositories-default.json +54 -0
- package/entities/Repositories/mockdatafiles/repositoriesGetRecycleBinRepositories-default.json +28 -0
- package/entities/Repositories/mockdatafiles/repositoriesList-default.json +123 -0
- package/entities/Repositories/schema.json +27 -0
- package/entities/Reverts/action.json +66 -0
- package/entities/Reverts/schema.json +21 -0
- package/entities/Stats/action.json +25 -0
- package/entities/Stats/mockdatafiles/statsList-default.json +195 -0
- package/entities/Stats/schema.json +19 -0
- package/entities/Statuses/action.json +45 -0
- package/entities/Statuses/mockdatafiles/statusesList-default.json +94 -0
- package/entities/Statuses/schema.json +20 -0
- package/entities/Suggestions/action.json +25 -0
- package/entities/Suggestions/mockdatafiles/suggestionsList-default.json +14 -0
- package/entities/Suggestions/schema.json +19 -0
- package/entities/Trees/action.json +25 -0
- package/entities/Trees/schema.json +19 -0
- package/error.json +6 -0
- package/package.json +5 -3
- package/previousVersion.zip +0 -0
- package/pronghorn.json +49635 -378
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +421 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1653439219306.json +120 -0
- package/sampleProperties.json +90 -1
- package/test/integration/adapterTestBasicGet.js +1 -1
- package/test/integration/adapterTestIntegration.js +4869 -105
- package/test/unit/adapterBaseTestUnit.js +30 -25
- package/test/unit/adapterTestUnit.js +11057 -159
- package/utils/adapterInfo.js +206 -0
- package/utils/entitiesToDB.js +12 -57
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +3 -0
- package/utils/tbScript.js +35 -20
- package/utils/tbUtils.js +59 -35
- package/utils/testRunner.js +16 -16
- package/versions.json +135 -0
package/adapterBase.js
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
/* eslint no-cond-assign: warn */
|
|
9
9
|
/* eslint global-require: warn */
|
|
10
10
|
/* eslint no-unused-vars: warn */
|
|
11
|
+
/* eslint prefer-destructuring: warn */
|
|
11
12
|
|
|
12
13
|
/* Required libraries. */
|
|
13
14
|
const fs = require('fs-extra');
|
|
14
15
|
const path = require('path');
|
|
16
|
+
const jsonQuery = require('json-query');
|
|
15
17
|
const EventEmitterCl = require('events').EventEmitter;
|
|
16
18
|
const { execSync } = require('child_process');
|
|
17
19
|
|
|
@@ -143,6 +145,27 @@ function updatePackage(changes) {
|
|
|
143
145
|
return null;
|
|
144
146
|
}
|
|
145
147
|
|
|
148
|
+
/*
|
|
149
|
+
* INTERNAL FUNCTION: get data from source(s) - nested
|
|
150
|
+
*/
|
|
151
|
+
function getDataFromSources(loopField, sources) {
|
|
152
|
+
let fieldValue = loopField;
|
|
153
|
+
|
|
154
|
+
// go through the sources to find the field
|
|
155
|
+
for (let s = 0; s < sources.length; s += 1) {
|
|
156
|
+
// find the field value using jsonquery
|
|
157
|
+
const nestedValue = jsonQuery(loopField, { data: sources[s] }).value;
|
|
158
|
+
|
|
159
|
+
// if we found in source - set and no need to check other sources
|
|
160
|
+
if (nestedValue) {
|
|
161
|
+
fieldValue = nestedValue;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return fieldValue;
|
|
167
|
+
}
|
|
168
|
+
|
|
146
169
|
/* GENERAL ADAPTER FUNCTIONS THESE SHOULD NOT BE DIRECTLY MODIFIED */
|
|
147
170
|
/* IF YOU NEED MODIFICATIONS, REDEFINE THEM IN adapter.js!!! */
|
|
148
171
|
class AdapterBase extends EventEmitterCl {
|
|
@@ -154,6 +177,9 @@ class AdapterBase extends EventEmitterCl {
|
|
|
154
177
|
// Instantiate the EventEmitter super class
|
|
155
178
|
super();
|
|
156
179
|
|
|
180
|
+
// IAP home directory injected by core when running the adapter within IAP
|
|
181
|
+
[, , , process.env.iap_home] = process.argv;
|
|
182
|
+
|
|
157
183
|
try {
|
|
158
184
|
// Capture the adapter id
|
|
159
185
|
this.id = prongid;
|
|
@@ -277,129 +303,6 @@ class AdapterBase extends EventEmitterCl {
|
|
|
277
303
|
}
|
|
278
304
|
}
|
|
279
305
|
|
|
280
|
-
/**
|
|
281
|
-
* updateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
282
|
-
* allows customers to make changes to adapter configuration without having to be on the
|
|
283
|
-
* file system.
|
|
284
|
-
*
|
|
285
|
-
* @function updateAdapterConfiguration
|
|
286
|
-
* @param {string} configFile - the name of the file being updated (required)
|
|
287
|
-
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
288
|
-
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
289
|
-
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
290
|
-
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
291
|
-
* @param {Callback} callback - The results of the call
|
|
292
|
-
*/
|
|
293
|
-
updateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
294
|
-
const meth = 'adapterBase-updateAdapterConfiguration';
|
|
295
|
-
const origin = `${this.id}-${meth}`;
|
|
296
|
-
log.trace(origin);
|
|
297
|
-
|
|
298
|
-
// verify the parameters are valid
|
|
299
|
-
if (changes === undefined || changes === null || typeof changes !== 'object'
|
|
300
|
-
|| Object.keys(changes).length === 0) {
|
|
301
|
-
const result = {
|
|
302
|
-
response: 'No configuration updates to make'
|
|
303
|
-
};
|
|
304
|
-
log.info(result.response);
|
|
305
|
-
return callback(result, null);
|
|
306
|
-
}
|
|
307
|
-
if (configFile === undefined || configFile === null || configFile === '') {
|
|
308
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['configFile'], null, null, null);
|
|
309
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
310
|
-
return callback(null, errorObj);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// take action based on configFile being changed
|
|
314
|
-
if (configFile === 'package.json') {
|
|
315
|
-
const pres = updatePackage(changes);
|
|
316
|
-
if (pres) {
|
|
317
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: ${pres}`, [], null, null, null);
|
|
318
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
319
|
-
return callback(null, errorObj);
|
|
320
|
-
}
|
|
321
|
-
const result = {
|
|
322
|
-
response: 'Package updates completed - restarting adapter'
|
|
323
|
-
};
|
|
324
|
-
log.info(result.response);
|
|
325
|
-
forceFail(true);
|
|
326
|
-
return callback(result, null);
|
|
327
|
-
}
|
|
328
|
-
if (entity === undefined || entity === null || entity === '') {
|
|
329
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Unsupported Configuration Change or Missing Entity', [], null, null, null);
|
|
330
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
331
|
-
return callback(null, errorObj);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// this means we are changing an entity file so type is required
|
|
335
|
-
if (type === undefined || type === null || type === '') {
|
|
336
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['type'], null, null, null);
|
|
337
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
338
|
-
return callback(null, errorObj);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// if the entity does not exist - error
|
|
342
|
-
const epath = `${__dirname}/entities/${entity}`;
|
|
343
|
-
if (!fs.existsSync(epath)) {
|
|
344
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: Invalid Entity - ${entity}`, [], null, null, null);
|
|
345
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
346
|
-
return callback(null, errorObj);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// take action based on type of file being changed
|
|
350
|
-
if (type === 'action') {
|
|
351
|
-
// BACKUP???
|
|
352
|
-
const ares = updateAction(epath, action, changes);
|
|
353
|
-
if (ares) {
|
|
354
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: ${ares}`, [], null, null, null);
|
|
355
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
356
|
-
return callback(null, errorObj);
|
|
357
|
-
}
|
|
358
|
-
// AJV CHECK???
|
|
359
|
-
// RESTORE IF NEEDED???
|
|
360
|
-
const result = {
|
|
361
|
-
response: `Action updates completed to entity: ${entity} - ${action}`
|
|
362
|
-
};
|
|
363
|
-
log.info(result.response);
|
|
364
|
-
return callback(result, null);
|
|
365
|
-
}
|
|
366
|
-
if (type === 'schema') {
|
|
367
|
-
const sres = updateSchema(epath, configFile, changes);
|
|
368
|
-
if (sres) {
|
|
369
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: ${sres}`, [], null, null, null);
|
|
370
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
371
|
-
return callback(null, errorObj);
|
|
372
|
-
}
|
|
373
|
-
const result = {
|
|
374
|
-
response: `Schema updates completed to entity: ${entity} - ${configFile}`
|
|
375
|
-
};
|
|
376
|
-
log.info(result.response);
|
|
377
|
-
return callback(result, null);
|
|
378
|
-
}
|
|
379
|
-
if (type === 'mock') {
|
|
380
|
-
// if the mock directory does not exist - error
|
|
381
|
-
const mpath = `${__dirname}/entities/${entity}/mockdatafiles`;
|
|
382
|
-
if (!fs.existsSync(mpath)) {
|
|
383
|
-
fs.mkdirSync(mpath);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
const mres = updateMock(mpath, configFile, changes);
|
|
387
|
-
if (mres) {
|
|
388
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: ${mres}`, [], null, null, null);
|
|
389
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
390
|
-
return callback(null, errorObj);
|
|
391
|
-
}
|
|
392
|
-
const result = {
|
|
393
|
-
response: `Mock data updates completed to entity: ${entity} - ${configFile}`
|
|
394
|
-
};
|
|
395
|
-
log.info(result.response);
|
|
396
|
-
return callback(result, null);
|
|
397
|
-
}
|
|
398
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: Unsupported Type - ${type}`, [], null, null, null);
|
|
399
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
400
|
-
return callback(null, errorObj);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
306
|
/**
|
|
404
307
|
* @summary Connect function is used during Pronghorn startup to provide instantiation feedback.
|
|
405
308
|
*
|
|
@@ -468,7 +371,7 @@ class AdapterBase extends EventEmitterCl {
|
|
|
468
371
|
}
|
|
469
372
|
|
|
470
373
|
// call to the healthcheck in connector
|
|
471
|
-
return this.requestHandlerInst.identifyHealthcheck(
|
|
374
|
+
return this.requestHandlerInst.identifyHealthcheck(myRequest, (res, error) => {
|
|
472
375
|
// unhealthy
|
|
473
376
|
if (error) {
|
|
474
377
|
// if we were healthy, toggle health
|
|
@@ -500,68 +403,6 @@ class AdapterBase extends EventEmitterCl {
|
|
|
500
403
|
});
|
|
501
404
|
}
|
|
502
405
|
|
|
503
|
-
/**
|
|
504
|
-
* @summary Suspends the adapter
|
|
505
|
-
* @param {Callback} callback - The adapater suspension status
|
|
506
|
-
* @function suspend
|
|
507
|
-
*/
|
|
508
|
-
suspend(mode, callback) {
|
|
509
|
-
const origin = `${this.id}-adapterBase-suspend`;
|
|
510
|
-
if (this.suspended) {
|
|
511
|
-
throw new Error(`${origin}: Adapter is already suspended`);
|
|
512
|
-
}
|
|
513
|
-
try {
|
|
514
|
-
this.suspended = true;
|
|
515
|
-
this.suspendMode = mode;
|
|
516
|
-
if (this.suspendMode === 'pause') {
|
|
517
|
-
const props = JSON.parse(JSON.stringify(this.initProps));
|
|
518
|
-
// To suspend adapter, enable throttling and set concurrent max to 0
|
|
519
|
-
props.throttle.throttle_enabled = true;
|
|
520
|
-
props.throttle.concurrent_max = 0;
|
|
521
|
-
this.refreshProperties(props);
|
|
522
|
-
}
|
|
523
|
-
return callback({ suspended: true });
|
|
524
|
-
} catch (error) {
|
|
525
|
-
return callback(null, error);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* @summary Unsuspends the adapter
|
|
531
|
-
* @param {Callback} callback - The adapater suspension status
|
|
532
|
-
*
|
|
533
|
-
* @function unsuspend
|
|
534
|
-
*/
|
|
535
|
-
unsuspend(callback) {
|
|
536
|
-
const origin = `${this.id}-adapterBase-unsuspend`;
|
|
537
|
-
if (!this.suspended) {
|
|
538
|
-
throw new Error(`${origin}: Adapter is not suspended`);
|
|
539
|
-
}
|
|
540
|
-
if (this.suspendMode === 'pause') {
|
|
541
|
-
const props = JSON.parse(JSON.stringify(this.initProps));
|
|
542
|
-
// To unsuspend adapter, keep throttling enabled and begin processing queued requests in order
|
|
543
|
-
props.throttle.throttle_enabled = true;
|
|
544
|
-
props.throttle.concurrent_max = 1;
|
|
545
|
-
this.refreshProperties(props);
|
|
546
|
-
setTimeout(() => {
|
|
547
|
-
this.getQueue((q, error) => {
|
|
548
|
-
// console.log("Items in queue: " + String(q.length))
|
|
549
|
-
if (q.length === 0) {
|
|
550
|
-
// if queue is empty, return to initial properties state
|
|
551
|
-
this.refreshProperties(this.initProps);
|
|
552
|
-
this.suspended = false;
|
|
553
|
-
return callback({ suspended: false });
|
|
554
|
-
}
|
|
555
|
-
// recursive call to check queue again every second
|
|
556
|
-
return this.unsuspend(callback);
|
|
557
|
-
});
|
|
558
|
-
}, 1000);
|
|
559
|
-
} else {
|
|
560
|
-
this.suspended = false;
|
|
561
|
-
callback({ suspend: false });
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
406
|
/**
|
|
566
407
|
* getAllFunctions is used to get all of the exposed function in the adapter
|
|
567
408
|
*
|
|
@@ -587,12 +428,67 @@ class AdapterBase extends EventEmitterCl {
|
|
|
587
428
|
}
|
|
588
429
|
|
|
589
430
|
/**
|
|
590
|
-
*
|
|
431
|
+
* checkActionFiles is used to update the validation of the action files.
|
|
432
|
+
*
|
|
433
|
+
* @function checkActionFiles
|
|
434
|
+
*/
|
|
435
|
+
checkActionFiles() {
|
|
436
|
+
const origin = `${this.id}-adapterBase-checkActionFiles`;
|
|
437
|
+
log.trace(origin);
|
|
438
|
+
|
|
439
|
+
// validate the action files for the adapter
|
|
440
|
+
try {
|
|
441
|
+
return this.requestHandlerInst.checkActionFiles();
|
|
442
|
+
} catch (e) {
|
|
443
|
+
return ['Exception increase log level'];
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* checkProperties is used to validate the adapter properties.
|
|
449
|
+
*
|
|
450
|
+
* @function checkProperties
|
|
451
|
+
* @param {Object} properties - an object containing all of the properties
|
|
452
|
+
*/
|
|
453
|
+
checkProperties(properties) {
|
|
454
|
+
const origin = `${this.myid}-adapterBase-checkProperties`;
|
|
455
|
+
log.trace(origin);
|
|
456
|
+
|
|
457
|
+
// validate the properties for the adapter
|
|
458
|
+
try {
|
|
459
|
+
return this.requestHandlerInst.checkProperties(properties);
|
|
460
|
+
} catch (e) {
|
|
461
|
+
return { exception: 'Exception increase log level' };
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* @summary Takes in property text and an encoding/encryption and returns the resulting
|
|
467
|
+
* encoded/encrypted string
|
|
468
|
+
*
|
|
469
|
+
* @function encryptProperty
|
|
470
|
+
* @param {String} property - the property to encrypt
|
|
471
|
+
* @param {String} technique - the technique to use to encrypt
|
|
472
|
+
*
|
|
473
|
+
* @param {Callback} callback - a callback function to return the result
|
|
474
|
+
* Encrypted String or the Error
|
|
475
|
+
*/
|
|
476
|
+
encryptProperty(property, technique, callback) {
|
|
477
|
+
const origin = `${this.id}-adapterBase-encryptProperty`;
|
|
478
|
+
log.trace(origin);
|
|
479
|
+
|
|
480
|
+
// Make the call -
|
|
481
|
+
// encryptProperty(property, technique, callback)
|
|
482
|
+
return this.requestHandlerInst.encryptProperty(property, technique, callback);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* iapGetAdapterWorkflowFunctions is used to get all of the workflow function in the adapter
|
|
591
487
|
* @param {array} ignoreThese - additional methods to ignore (optional)
|
|
592
488
|
*
|
|
593
|
-
* @function
|
|
489
|
+
* @function iapGetAdapterWorkflowFunctions
|
|
594
490
|
*/
|
|
595
|
-
|
|
491
|
+
iapGetAdapterWorkflowFunctions(ignoreThese) {
|
|
596
492
|
const myfunctions = this.getAllFunctions();
|
|
597
493
|
const wffunctions = [];
|
|
598
494
|
|
|
@@ -602,9 +498,7 @@ class AdapterBase extends EventEmitterCl {
|
|
|
602
498
|
// got to the second tier (adapterBase)
|
|
603
499
|
break;
|
|
604
500
|
}
|
|
605
|
-
if (myfunctions[m]
|
|
606
|
-
&& myfunctions[m] !== 'healthCheck' && myfunctions[m] !== 'getWorkflowFunctions'
|
|
607
|
-
&& !(myfunctions[m].endsWith('Emit') || myfunctions[m].match(/Emit__v[0-9]+/))) {
|
|
501
|
+
if (!(myfunctions[m].endsWith('Emit') || myfunctions[m].match(/Emit__v[0-9]+/))) {
|
|
608
502
|
let found = false;
|
|
609
503
|
if (ignoreThese && Array.isArray(ignoreThese)) {
|
|
610
504
|
for (let i = 0; i < ignoreThese.length; i += 1) {
|
|
@@ -623,30 +517,136 @@ class AdapterBase extends EventEmitterCl {
|
|
|
623
517
|
}
|
|
624
518
|
|
|
625
519
|
/**
|
|
626
|
-
*
|
|
520
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
521
|
+
* allows customers to make changes to adapter configuration without having to be on the
|
|
522
|
+
* file system.
|
|
627
523
|
*
|
|
628
|
-
* @function
|
|
524
|
+
* @function iapUpdateAdapterConfiguration
|
|
525
|
+
* @param {string} configFile - the name of the file being updated (required)
|
|
526
|
+
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
527
|
+
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
528
|
+
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
529
|
+
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
530
|
+
* @param {Callback} callback - The results of the call
|
|
629
531
|
*/
|
|
630
|
-
|
|
631
|
-
const
|
|
532
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
533
|
+
const meth = 'adapterBase-iapUpdateAdapterConfiguration';
|
|
534
|
+
const origin = `${this.id}-${meth}`;
|
|
632
535
|
log.trace(origin);
|
|
633
536
|
|
|
634
|
-
//
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
537
|
+
// verify the parameters are valid
|
|
538
|
+
if (changes === undefined || changes === null || typeof changes !== 'object'
|
|
539
|
+
|| Object.keys(changes).length === 0) {
|
|
540
|
+
const result = {
|
|
541
|
+
response: 'No configuration updates to make'
|
|
542
|
+
};
|
|
543
|
+
log.info(result.response);
|
|
544
|
+
return callback(result, null);
|
|
545
|
+
}
|
|
546
|
+
if (configFile === undefined || configFile === null || configFile === '') {
|
|
547
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['configFile'], null, null, null);
|
|
548
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
549
|
+
return callback(null, errorObj);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// take action based on configFile being changed
|
|
553
|
+
if (configFile === 'package.json') {
|
|
554
|
+
const pres = updatePackage(changes);
|
|
555
|
+
if (pres) {
|
|
556
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: ${pres}`, [], null, null, null);
|
|
557
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
558
|
+
return callback(null, errorObj);
|
|
559
|
+
}
|
|
560
|
+
const result = {
|
|
561
|
+
response: 'Package updates completed - restarting adapter'
|
|
562
|
+
};
|
|
563
|
+
log.info(result.response);
|
|
564
|
+
forceFail(true);
|
|
565
|
+
return callback(result, null);
|
|
566
|
+
}
|
|
567
|
+
if (entity === undefined || entity === null || entity === '') {
|
|
568
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Unsupported Configuration Change or Missing Entity', [], null, null, null);
|
|
569
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
570
|
+
return callback(null, errorObj);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// this means we are changing an entity file so type is required
|
|
574
|
+
if (type === undefined || type === null || type === '') {
|
|
575
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['type'], null, null, null);
|
|
576
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
577
|
+
return callback(null, errorObj);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// if the entity does not exist - error
|
|
581
|
+
const epath = `${__dirname}/entities/${entity}`;
|
|
582
|
+
if (!fs.existsSync(epath)) {
|
|
583
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: Invalid Entity - ${entity}`, [], null, null, null);
|
|
584
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
585
|
+
return callback(null, errorObj);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// take action based on type of file being changed
|
|
589
|
+
if (type === 'action') {
|
|
590
|
+
// BACKUP???
|
|
591
|
+
const ares = updateAction(epath, action, changes);
|
|
592
|
+
if (ares) {
|
|
593
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: ${ares}`, [], null, null, null);
|
|
594
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
595
|
+
return callback(null, errorObj);
|
|
596
|
+
}
|
|
597
|
+
// AJV CHECK???
|
|
598
|
+
// RESTORE IF NEEDED???
|
|
599
|
+
const result = {
|
|
600
|
+
response: `Action updates completed to entity: ${entity} - ${action}`
|
|
601
|
+
};
|
|
602
|
+
log.info(result.response);
|
|
603
|
+
return callback(result, null);
|
|
639
604
|
}
|
|
605
|
+
if (type === 'schema') {
|
|
606
|
+
const sres = updateSchema(epath, configFile, changes);
|
|
607
|
+
if (sres) {
|
|
608
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: ${sres}`, [], null, null, null);
|
|
609
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
610
|
+
return callback(null, errorObj);
|
|
611
|
+
}
|
|
612
|
+
const result = {
|
|
613
|
+
response: `Schema updates completed to entity: ${entity} - ${configFile}`
|
|
614
|
+
};
|
|
615
|
+
log.info(result.response);
|
|
616
|
+
return callback(result, null);
|
|
617
|
+
}
|
|
618
|
+
if (type === 'mock') {
|
|
619
|
+
// if the mock directory does not exist - error
|
|
620
|
+
const mpath = `${__dirname}/entities/${entity}/mockdatafiles`;
|
|
621
|
+
if (!fs.existsSync(mpath)) {
|
|
622
|
+
fs.mkdirSync(mpath);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
const mres = updateMock(mpath, configFile, changes);
|
|
626
|
+
if (mres) {
|
|
627
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: ${mres}`, [], null, null, null);
|
|
628
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
629
|
+
return callback(null, errorObj);
|
|
630
|
+
}
|
|
631
|
+
const result = {
|
|
632
|
+
response: `Mock data updates completed to entity: ${entity} - ${configFile}`
|
|
633
|
+
};
|
|
634
|
+
log.info(result.response);
|
|
635
|
+
return callback(result, null);
|
|
636
|
+
}
|
|
637
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Incomplete Configuration Change: Unsupported Type - ${type}`, [], null, null, null);
|
|
638
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
639
|
+
return callback(null, errorObj);
|
|
640
640
|
}
|
|
641
641
|
|
|
642
642
|
/**
|
|
643
643
|
* See if the API path provided is found in this adapter
|
|
644
644
|
*
|
|
645
|
-
* @function
|
|
645
|
+
* @function iapFindAdapterPath
|
|
646
646
|
* @param {string} apiPath - the api path to check on
|
|
647
647
|
* @param {Callback} callback - The results of the call
|
|
648
648
|
*/
|
|
649
|
-
|
|
649
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
650
650
|
const result = {
|
|
651
651
|
apiPath
|
|
652
652
|
};
|
|
@@ -723,66 +723,90 @@ class AdapterBase extends EventEmitterCl {
|
|
|
723
723
|
}
|
|
724
724
|
|
|
725
725
|
/**
|
|
726
|
-
*
|
|
727
|
-
*
|
|
728
|
-
* @function
|
|
729
|
-
* @param {Object} properties - an object containing all of the properties
|
|
726
|
+
* @summary Suspends the adapter
|
|
727
|
+
* @param {Callback} callback - The adapater suspension status
|
|
728
|
+
* @function iapSuspendAdapter
|
|
730
729
|
*/
|
|
731
|
-
|
|
732
|
-
const origin = `${this.
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
730
|
+
iapSuspendAdapter(mode, callback) {
|
|
731
|
+
const origin = `${this.id}-adapterBase-iapSuspendAdapter`;
|
|
732
|
+
if (this.suspended) {
|
|
733
|
+
throw new Error(`${origin}: Adapter is already suspended`);
|
|
734
|
+
}
|
|
736
735
|
try {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
736
|
+
this.suspended = true;
|
|
737
|
+
this.suspendMode = mode;
|
|
738
|
+
if (this.suspendMode === 'pause') {
|
|
739
|
+
const props = JSON.parse(JSON.stringify(this.initProps));
|
|
740
|
+
// To suspend adapter, enable throttling and set concurrent max to 0
|
|
741
|
+
props.throttle.throttle_enabled = true;
|
|
742
|
+
props.throttle.concurrent_max = 0;
|
|
743
|
+
this.refreshProperties(props);
|
|
744
|
+
}
|
|
745
|
+
return callback({ suspended: true });
|
|
746
|
+
} catch (error) {
|
|
747
|
+
return callback(null, error);
|
|
740
748
|
}
|
|
741
749
|
}
|
|
742
750
|
|
|
743
751
|
/**
|
|
744
|
-
*
|
|
752
|
+
* @summary Unsuspends the adapter
|
|
753
|
+
* @param {Callback} callback - The adapater suspension status
|
|
745
754
|
*
|
|
746
|
-
* @function
|
|
747
|
-
* @param {Callback} callback - a callback function to return the result (Queue) or the error
|
|
755
|
+
* @function iapUnsuspendAdapter
|
|
748
756
|
*/
|
|
749
|
-
|
|
750
|
-
const origin = `${this.id}-adapterBase-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
757
|
+
iapUnsuspendAdapter(callback) {
|
|
758
|
+
const origin = `${this.id}-adapterBase-iapUnsuspendAdapter`;
|
|
759
|
+
if (!this.suspended) {
|
|
760
|
+
throw new Error(`${origin}: Adapter is not suspended`);
|
|
761
|
+
}
|
|
762
|
+
if (this.suspendMode === 'pause') {
|
|
763
|
+
const props = JSON.parse(JSON.stringify(this.initProps));
|
|
764
|
+
// To unsuspend adapter, keep throttling enabled and begin processing queued requests in order
|
|
765
|
+
props.throttle.throttle_enabled = true;
|
|
766
|
+
props.throttle.concurrent_max = 1;
|
|
767
|
+
this.refreshProperties(props);
|
|
768
|
+
setTimeout(() => {
|
|
769
|
+
this.getQueue((q, error) => {
|
|
770
|
+
// console.log("Items in queue: " + String(q.length))
|
|
771
|
+
if (q.length === 0) {
|
|
772
|
+
// if queue is empty, return to initial properties state
|
|
773
|
+
this.refreshProperties(this.initProps);
|
|
774
|
+
this.suspended = false;
|
|
775
|
+
return callback({ suspended: false });
|
|
776
|
+
}
|
|
777
|
+
// recursive call to check queue again every second
|
|
778
|
+
return this.iapUnsuspendAdapter(callback);
|
|
779
|
+
});
|
|
780
|
+
}, 1000);
|
|
781
|
+
} else {
|
|
782
|
+
this.suspended = false;
|
|
783
|
+
callback({ suspend: false });
|
|
784
|
+
}
|
|
754
785
|
}
|
|
755
786
|
|
|
756
787
|
/**
|
|
757
|
-
*
|
|
758
|
-
* encoded/encrypted string
|
|
788
|
+
* iapGetAdapterQueue is used to get information for all of the requests currently in the queue.
|
|
759
789
|
*
|
|
760
|
-
* @function
|
|
761
|
-
* @param {
|
|
762
|
-
* @param {String} technique - the technique to use to encrypt
|
|
763
|
-
*
|
|
764
|
-
* @param {Callback} callback - a callback function to return the result
|
|
765
|
-
* Encrypted String or the Error
|
|
790
|
+
* @function iapGetAdapterQueue
|
|
791
|
+
* @param {Callback} callback - a callback function to return the result (Queue) or the error
|
|
766
792
|
*/
|
|
767
|
-
|
|
768
|
-
const origin = `${this.id}-adapterBase-
|
|
793
|
+
iapGetAdapterQueue(callback) {
|
|
794
|
+
const origin = `${this.id}-adapterBase-iapGetAdapterQueue`;
|
|
769
795
|
log.trace(origin);
|
|
770
796
|
|
|
771
|
-
|
|
772
|
-
// encryptProperty(property, technique, callback)
|
|
773
|
-
return this.requestHandlerInst.encryptProperty(property, technique, callback);
|
|
797
|
+
return this.requestHandlerInst.getQueue(callback);
|
|
774
798
|
}
|
|
775
799
|
|
|
776
800
|
/**
|
|
777
801
|
* @summary runs troubleshoot scripts for adapter
|
|
778
802
|
*
|
|
779
|
-
* @function
|
|
803
|
+
* @function iapTroubleshootAdapter
|
|
780
804
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
781
805
|
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
782
806
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
783
807
|
* @param {Callback} callback - callback function to return troubleshoot results
|
|
784
808
|
*/
|
|
785
|
-
async
|
|
809
|
+
async iapTroubleshootAdapter(props, persistFlag, adapter, callback) {
|
|
786
810
|
try {
|
|
787
811
|
const result = await troubleshootingAdapter.troubleshoot(props, false, persistFlag, adapter);
|
|
788
812
|
if (result.healthCheck && result.connectivity.failCount === 0 && result.basicGet.failCount === 0) {
|
|
@@ -797,11 +821,11 @@ class AdapterBase extends EventEmitterCl {
|
|
|
797
821
|
/**
|
|
798
822
|
* @summary runs healthcheck script for adapter
|
|
799
823
|
*
|
|
800
|
-
* @function
|
|
824
|
+
* @function iapRunAdapterHealthcheck
|
|
801
825
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
802
826
|
* @param {Callback} callback - callback function to return healthcheck status
|
|
803
827
|
*/
|
|
804
|
-
async
|
|
828
|
+
async iapRunAdapterHealthcheck(adapter, callback) {
|
|
805
829
|
try {
|
|
806
830
|
const result = await tbUtils.healthCheck(adapter);
|
|
807
831
|
if (result) {
|
|
@@ -816,13 +840,13 @@ class AdapterBase extends EventEmitterCl {
|
|
|
816
840
|
/**
|
|
817
841
|
* @summary runs connectivity check script for adapter
|
|
818
842
|
*
|
|
819
|
-
* @function
|
|
843
|
+
* @function iapRunAdapterConnectivity
|
|
820
844
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
821
845
|
* @param {Callback} callback - callback function to return connectivity status
|
|
822
846
|
*/
|
|
823
|
-
async
|
|
847
|
+
async iapRunAdapterConnectivity(callback) {
|
|
824
848
|
try {
|
|
825
|
-
const { serviceItem } = await
|
|
849
|
+
const { serviceItem } = await tbUtils.getAdapterConfig();
|
|
826
850
|
const { host } = serviceItem.properties.properties;
|
|
827
851
|
const result = tbUtils.runConnectivity(host, false);
|
|
828
852
|
if (result.failCount > 0) {
|
|
@@ -837,10 +861,10 @@ class AdapterBase extends EventEmitterCl {
|
|
|
837
861
|
/**
|
|
838
862
|
* @summary runs basicGet script for adapter
|
|
839
863
|
*
|
|
840
|
-
* @function
|
|
864
|
+
* @function iapRunAdapterBasicGet
|
|
841
865
|
* @param {Callback} callback - callback function to return basicGet result
|
|
842
866
|
*/
|
|
843
|
-
|
|
867
|
+
iapRunAdapterBasicGet(callback) {
|
|
844
868
|
try {
|
|
845
869
|
const result = tbUtils.runBasicGet(false);
|
|
846
870
|
if (result.failCount > 0) {
|
|
@@ -852,6 +876,28 @@ class AdapterBase extends EventEmitterCl {
|
|
|
852
876
|
}
|
|
853
877
|
}
|
|
854
878
|
|
|
879
|
+
/**
|
|
880
|
+
* @summary moves entities to mongo database
|
|
881
|
+
*
|
|
882
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
883
|
+
*
|
|
884
|
+
* @return {Callback} - containing the response from the mongo transaction
|
|
885
|
+
*/
|
|
886
|
+
async iapMoveAdapterEntitiesToDB(callback) {
|
|
887
|
+
const meth = 'adapterBase-iapMoveAdapterEntitiesToDB';
|
|
888
|
+
const origin = `${this.id}-${meth}`;
|
|
889
|
+
log.trace(origin);
|
|
890
|
+
|
|
891
|
+
try {
|
|
892
|
+
const result = await entitiesToDB.moveEntitiesToDB(__dirname, { pronghornProps: this.allProps, id: this.id });
|
|
893
|
+
return callback(result, null);
|
|
894
|
+
} catch (err) {
|
|
895
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, err);
|
|
896
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
897
|
+
return callback(null, err.message);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
855
901
|
/**
|
|
856
902
|
* @summary take the entities and add them to the cache
|
|
857
903
|
*
|
|
@@ -1004,21 +1050,729 @@ class AdapterBase extends EventEmitterCl {
|
|
|
1004
1050
|
}
|
|
1005
1051
|
|
|
1006
1052
|
/**
|
|
1007
|
-
* @summary
|
|
1053
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
1008
1054
|
*
|
|
1009
|
-
* @function
|
|
1055
|
+
* @function hasEntities
|
|
1056
|
+
* @param {String} entityType - the entity type to check for
|
|
1057
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
1010
1058
|
*
|
|
1011
|
-
* @
|
|
1059
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
1060
|
+
* value is true or false
|
|
1061
|
+
*/
|
|
1062
|
+
hasEntities(entityType, entityList, callback) {
|
|
1063
|
+
const origin = `${this.id}-adapter-hasEntities`;
|
|
1064
|
+
log.trace(origin);
|
|
1065
|
+
|
|
1066
|
+
switch (entityType) {
|
|
1067
|
+
case 'Device':
|
|
1068
|
+
return this.hasDevices(entityList, callback);
|
|
1069
|
+
default:
|
|
1070
|
+
return callback(null, `${this.id} does not support entity ${entityType}`);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* @summary Helper method for hasEntities for the specific device case
|
|
1076
|
+
*
|
|
1077
|
+
* @param {Array} deviceList - array of unique device identifiers
|
|
1078
|
+
* @param {Callback} callback - A map where the device is the key and the
|
|
1079
|
+
* value is true or false
|
|
1080
|
+
*/
|
|
1081
|
+
hasDevices(deviceList, callback) {
|
|
1082
|
+
const origin = `${this.id}-adapter-hasDevices`;
|
|
1083
|
+
log.trace(origin);
|
|
1084
|
+
|
|
1085
|
+
const findings = deviceList.reduce((map, device) => {
|
|
1086
|
+
// eslint-disable-next-line no-param-reassign
|
|
1087
|
+
map[device] = false;
|
|
1088
|
+
log.debug(`In reduce: ${JSON.stringify(map)}`);
|
|
1089
|
+
return map;
|
|
1090
|
+
}, {});
|
|
1091
|
+
const apiCalls = deviceList.map((device) => new Promise((resolve) => {
|
|
1092
|
+
this.getDevice(device, (result, error) => {
|
|
1093
|
+
if (error) {
|
|
1094
|
+
log.debug(`In map error: ${JSON.stringify(device)}`);
|
|
1095
|
+
return resolve({ name: device, found: false });
|
|
1096
|
+
}
|
|
1097
|
+
log.debug(`In map: ${JSON.stringify(device)}`);
|
|
1098
|
+
return resolve({ name: device, found: true });
|
|
1099
|
+
});
|
|
1100
|
+
}));
|
|
1101
|
+
Promise.all(apiCalls).then((results) => {
|
|
1102
|
+
results.forEach((device) => {
|
|
1103
|
+
findings[device.name] = device.found;
|
|
1104
|
+
});
|
|
1105
|
+
log.debug(`FINDINGS: ${JSON.stringify(findings)}`);
|
|
1106
|
+
return callback(findings);
|
|
1107
|
+
}).catch((errors) => {
|
|
1108
|
+
log.error('Unable to do device lookup.');
|
|
1109
|
+
return callback(null, { code: 503, message: 'Unable to do device lookup.', error: errors });
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* @summary Make one of the needed Broker calls - could be one of many
|
|
1115
|
+
*
|
|
1116
|
+
* @function iapMakeBrokerCall
|
|
1117
|
+
* @param {string} brokCall - the name of the broker call (required)
|
|
1118
|
+
* @param {object} callProps - the proeprties for the broker call (required)
|
|
1119
|
+
* @param {object} devResp - the device details to extract needed inputs (required)
|
|
1120
|
+
* @param {string} filterName - any filter to search on (required)
|
|
1121
|
+
*
|
|
1122
|
+
* @param {getCallback} callback - a callback function to return the result of the call
|
|
1012
1123
|
*/
|
|
1013
|
-
|
|
1014
|
-
const meth = 'adapterBase-
|
|
1124
|
+
iapMakeBrokerCall(brokCall, callProps, devResp, filterName, callback) {
|
|
1125
|
+
const meth = 'adapterBase-iapMakeBrokerCall';
|
|
1015
1126
|
const origin = `${this.id}-${meth}`;
|
|
1016
1127
|
log.trace(origin);
|
|
1017
1128
|
|
|
1018
1129
|
try {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1130
|
+
let uriPath = '';
|
|
1131
|
+
let uriMethod = 'GET';
|
|
1132
|
+
let callQuery = {};
|
|
1133
|
+
let callBody = {};
|
|
1134
|
+
let callHeaders = {};
|
|
1135
|
+
let handleFail = 'fail';
|
|
1136
|
+
let ostypePrefix = '';
|
|
1137
|
+
let statusValue = 'true';
|
|
1138
|
+
if (callProps.path) {
|
|
1139
|
+
uriPath = `${callProps.path}`;
|
|
1140
|
+
|
|
1141
|
+
// make any necessary changes to the path
|
|
1142
|
+
if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
|
|
1143
|
+
const rqKeys = Object.keys(callProps.requestFields);
|
|
1144
|
+
|
|
1145
|
+
// get the field from the provided device
|
|
1146
|
+
for (let rq = 0; rq < rqKeys.length; rq += 1) {
|
|
1147
|
+
const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
|
|
1148
|
+
|
|
1149
|
+
// put the value into the path - if it has been specified in the path
|
|
1150
|
+
uriPath = uriPath.replace(`{${rqKeys[rq]}}`, fieldValue);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
if (callProps.method) {
|
|
1155
|
+
uriMethod = callProps.method;
|
|
1156
|
+
}
|
|
1157
|
+
if (callProps.query) {
|
|
1158
|
+
callQuery = callProps.query;
|
|
1159
|
+
|
|
1160
|
+
// go through the query params to check for variable values
|
|
1161
|
+
const cpKeys = Object.keys(callQuery);
|
|
1162
|
+
for (let cp = 0; cp < cpKeys.length; cp += 1) {
|
|
1163
|
+
if (callQuery[cpKeys[cp]].startsWith('{') && callQuery[cpKeys[cp]].endsWith('}')) {
|
|
1164
|
+
// make any necessary changes to the query params
|
|
1165
|
+
if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
|
|
1166
|
+
const rqKeys = Object.keys(callProps.requestFields);
|
|
1167
|
+
|
|
1168
|
+
// get the field from the provided device
|
|
1169
|
+
for (let rq = 0; rq < rqKeys.length; rq += 1) {
|
|
1170
|
+
if (cpKeys[cp] === rqKeys[rq]) {
|
|
1171
|
+
const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
|
|
1172
|
+
|
|
1173
|
+
// put the value into the query - if it has been specified in the query
|
|
1174
|
+
callQuery[cpKeys[cp]] = fieldValue;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
if (callProps.body) {
|
|
1182
|
+
callBody = callProps.body;
|
|
1183
|
+
|
|
1184
|
+
// go through the body fields to check for variable values
|
|
1185
|
+
const cbKeys = Object.keys(callBody);
|
|
1186
|
+
for (let cb = 0; cb < cbKeys.length; cb += 1) {
|
|
1187
|
+
if (callBody[cbKeys[cb]].startsWith('{') && callBody[cbKeys[cb]].endsWith('}')) {
|
|
1188
|
+
// make any necessary changes to the query params
|
|
1189
|
+
if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
|
|
1190
|
+
const rqKeys = Object.keys(callProps.requestFields);
|
|
1191
|
+
|
|
1192
|
+
// get the field from the provided device
|
|
1193
|
+
for (let rq = 0; rq < rqKeys.length; rq += 1) {
|
|
1194
|
+
if (cbKeys[cb] === rqKeys[rq]) {
|
|
1195
|
+
const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
|
|
1196
|
+
|
|
1197
|
+
// put the value into the query - if it has been specified in the query
|
|
1198
|
+
callBody[cbKeys[cb]] = fieldValue;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
if (callProps.headers) {
|
|
1206
|
+
callHeaders = callProps.headers;
|
|
1207
|
+
|
|
1208
|
+
// go through the body fields to check for variable values
|
|
1209
|
+
const chKeys = Object.keys(callHeaders);
|
|
1210
|
+
for (let ch = 0; ch < chKeys.length; ch += 1) {
|
|
1211
|
+
if (callHeaders[chKeys[ch]].startsWith('{') && callHeaders[chKeys[ch]].endsWith('}')) {
|
|
1212
|
+
// make any necessary changes to the query params
|
|
1213
|
+
if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
|
|
1214
|
+
const rqKeys = Object.keys(callProps.requestFields);
|
|
1215
|
+
|
|
1216
|
+
// get the field from the provided device
|
|
1217
|
+
for (let rq = 0; rq < rqKeys.length; rq += 1) {
|
|
1218
|
+
if (chKeys[ch] === rqKeys[rq]) {
|
|
1219
|
+
const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
|
|
1220
|
+
|
|
1221
|
+
// put the value into the query - if it has been specified in the query
|
|
1222
|
+
callHeaders[chKeys[ch]] = fieldValue;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
if (callProps.handleFailure) {
|
|
1230
|
+
handleFail = callProps.handleFailure;
|
|
1231
|
+
}
|
|
1232
|
+
if (callProps.responseFields && callProps.responseFields.ostypePrefix) {
|
|
1233
|
+
ostypePrefix = callProps.responseFields.ostypePrefix;
|
|
1234
|
+
}
|
|
1235
|
+
if (callProps.responseFields && callProps.responseFields.statusValue) {
|
|
1236
|
+
statusValue = callProps.responseFields.statusValue;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
|
1240
|
+
// !! you can also replace with a specific call if that is easier
|
|
1241
|
+
return this.genericAdapterRequest(uriPath, uriMethod, callQuery, callBody, callHeaders, (result, error) => {
|
|
1242
|
+
// if we received an error or their is no response on the results return an error
|
|
1243
|
+
if (error) {
|
|
1244
|
+
if (handleFail === 'fail') {
|
|
1245
|
+
return callback(null, error);
|
|
1246
|
+
}
|
|
1247
|
+
return callback({}, null);
|
|
1248
|
+
}
|
|
1249
|
+
if (!result.response) {
|
|
1250
|
+
if (handleFail === 'fail') {
|
|
1251
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', [brokCall], null, null, null);
|
|
1252
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1253
|
+
return callback(null, errorObj);
|
|
1254
|
+
}
|
|
1255
|
+
return callback({}, null);
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
// get the response piece we care about from the response
|
|
1259
|
+
const myResult = result;
|
|
1260
|
+
if (callProps.responseDatakey) {
|
|
1261
|
+
myResult.response = jsonQuery(callProps.responseDatakey, { data: myResult.response }).value;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
// get the keys for the response fields
|
|
1265
|
+
let rfKeys = [];
|
|
1266
|
+
if (callProps.responseFields && Object.keys(callProps.responseFields).length > 0) {
|
|
1267
|
+
rfKeys = Object.keys(callProps.responseFields);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// if we got an array returned (e.g. getDevicesFitered)
|
|
1271
|
+
if (Array.isArray(myResult.response)) {
|
|
1272
|
+
const listDevices = [];
|
|
1273
|
+
for (let a = 0; a < myResult.response.length; a += 1) {
|
|
1274
|
+
const thisDevice = myResult.response[a];
|
|
1275
|
+
for (let rf = 0; rf < rfKeys.length; rf += 1) {
|
|
1276
|
+
if (rfKeys[rf] !== 'ostypePrefix') {
|
|
1277
|
+
let fieldValue = getDataFromSources(callProps.responseFields[rfKeys[rf]], [thisDevice, devResp, callProps.requestFields]);
|
|
1278
|
+
|
|
1279
|
+
// if the field is ostype - need to add prefix
|
|
1280
|
+
if (rfKeys[rf] === 'ostype' && typeof fieldValue === 'string') {
|
|
1281
|
+
fieldValue = ostypePrefix + fieldValue;
|
|
1282
|
+
}
|
|
1283
|
+
// if there is a status to set, set it
|
|
1284
|
+
if (rfKeys[rf] === 'status') {
|
|
1285
|
+
// if really looking for just a good response
|
|
1286
|
+
if (callProps.responseFields[rfKeys[rf]] === 'return2xx' && myResult.icode === statusValue.toString()) {
|
|
1287
|
+
thisDevice.isAlive = true;
|
|
1288
|
+
} else if (fieldValue.toString() === statusValue.toString()) {
|
|
1289
|
+
thisDevice.isAlive = true;
|
|
1290
|
+
} else {
|
|
1291
|
+
thisDevice.isAlive = false;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
// if we found a good value
|
|
1295
|
+
thisDevice[rfKeys[rf]] = fieldValue;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
// if there is no filter - add the device to the list
|
|
1300
|
+
if (!filterName || filterName.length === 0) {
|
|
1301
|
+
listDevices.push(thisDevice);
|
|
1302
|
+
} else {
|
|
1303
|
+
// if we have to match a filter
|
|
1304
|
+
let found = false;
|
|
1305
|
+
for (let f = 0; f < filterName.length; f += 1) {
|
|
1306
|
+
if (thisDevice.name.indexOf(filterName[f]) >= 0) {
|
|
1307
|
+
found = true;
|
|
1308
|
+
break;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
// matching device
|
|
1312
|
+
if (found) {
|
|
1313
|
+
listDevices.push(thisDevice);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
// return the array of devices
|
|
1319
|
+
return callback(listDevices, null);
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
// if this is not an array - just about everything else, just handle as a single object
|
|
1323
|
+
let thisDevice = myResult.response;
|
|
1324
|
+
for (let rf = 0; rf < rfKeys.length; rf += 1) {
|
|
1325
|
+
// skip ostypePrefix since it is not a field
|
|
1326
|
+
if (rfKeys[rf] !== 'ostypePrefix') {
|
|
1327
|
+
let fieldValue = getDataFromSources(callProps.responseFields[rfKeys[rf]], [thisDevice, devResp, callProps.requestFields]);
|
|
1328
|
+
|
|
1329
|
+
// if the field is ostype - need to add prefix
|
|
1330
|
+
if (rfKeys[rf] === 'ostype' && typeof fieldValue === 'string') {
|
|
1331
|
+
fieldValue = ostypePrefix + fieldValue;
|
|
1332
|
+
}
|
|
1333
|
+
// if there is a status to set, set it
|
|
1334
|
+
if (rfKeys[rf] === 'status') {
|
|
1335
|
+
// if really looking for just a good response
|
|
1336
|
+
if (callProps.responseFields[rfKeys[rf]] === 'return2xx' && myResult.icode === statusValue.toString()) {
|
|
1337
|
+
thisDevice.isAlive = true;
|
|
1338
|
+
} else if (fieldValue.toString() === statusValue.toString()) {
|
|
1339
|
+
thisDevice.isAlive = true;
|
|
1340
|
+
} else {
|
|
1341
|
+
thisDevice.isAlive = false;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
// if we found a good value
|
|
1345
|
+
thisDevice[rfKeys[rf]] = fieldValue;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
// if there is a filter - check the device is in the list
|
|
1350
|
+
if (filterName && filterName.length > 0) {
|
|
1351
|
+
let found = false;
|
|
1352
|
+
for (let f = 0; f < filterName.length; f += 1) {
|
|
1353
|
+
if (thisDevice.name.indexOf(filterName[f]) >= 0) {
|
|
1354
|
+
found = true;
|
|
1355
|
+
break;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
// no matching device - clear the device
|
|
1359
|
+
if (!found) {
|
|
1360
|
+
thisDevice = {};
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
return callback(thisDevice, null);
|
|
1365
|
+
});
|
|
1366
|
+
} catch (e) {
|
|
1367
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, e);
|
|
1368
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1369
|
+
return callback(null, errorObj);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
/**
|
|
1374
|
+
* @summary Get Appliance that match the deviceName
|
|
1375
|
+
*
|
|
1376
|
+
* @function getDevice
|
|
1377
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
1378
|
+
*
|
|
1379
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1380
|
+
* (appliance) or the error
|
|
1381
|
+
*/
|
|
1382
|
+
getDevice(deviceName, callback) {
|
|
1383
|
+
const meth = 'adapterBase-getDevice';
|
|
1384
|
+
const origin = `${this.id}-${meth}`;
|
|
1385
|
+
log.trace(origin);
|
|
1386
|
+
|
|
1387
|
+
// make sure we are set up for device broker getDevice
|
|
1388
|
+
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getDevice || this.allProps.devicebroker.getDevice.length === 0 || !this.allProps.devicebroker.getDevice[0].path) {
|
|
1389
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getDevice.path'], null, null, null);
|
|
1390
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1391
|
+
return callback(null, errorObj);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1395
|
+
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
1396
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
1397
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1398
|
+
return callback(null, errorObj);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
try {
|
|
1402
|
+
// need to get the device so we can convert the deviceName to an id
|
|
1403
|
+
// !! if we can do a lookup by name the getDevicesFiltered may not be necessary
|
|
1404
|
+
const opts = {
|
|
1405
|
+
filter: {
|
|
1406
|
+
name: deviceName
|
|
1407
|
+
}
|
|
1408
|
+
};
|
|
1409
|
+
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
1410
|
+
// if we received an error or their is no response on the results return an error
|
|
1411
|
+
if (ferr) {
|
|
1412
|
+
return callback(null, ferr);
|
|
1413
|
+
}
|
|
1414
|
+
if (devs.list.length < 1) {
|
|
1415
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
1416
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1417
|
+
return callback(null, errorObj);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
const callPromises = [];
|
|
1421
|
+
for (let i = 0; i < this.allProps.devicebroker.getDevice.length; i += 1) {
|
|
1422
|
+
// Perform component calls here.
|
|
1423
|
+
callPromises.push(
|
|
1424
|
+
new Promise((resolve, reject) => {
|
|
1425
|
+
this.iapMakeBrokerCall('getDevice', this.allProps.devicebroker.getDevice[i], [devs.list[0]], null, (callRet, callErr) => {
|
|
1426
|
+
// return an error
|
|
1427
|
+
if (callErr) {
|
|
1428
|
+
reject(callErr);
|
|
1429
|
+
} else {
|
|
1430
|
+
// return the data
|
|
1431
|
+
resolve(callRet);
|
|
1432
|
+
}
|
|
1433
|
+
});
|
|
1434
|
+
})
|
|
1435
|
+
);
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
// return an array of repsonses
|
|
1439
|
+
return Promise.all(callPromises).then((results) => {
|
|
1440
|
+
let myResult = {};
|
|
1441
|
+
results.forEach((result) => {
|
|
1442
|
+
myResult = { ...myResult, ...result };
|
|
1443
|
+
});
|
|
1444
|
+
|
|
1445
|
+
return callback(myResult, null);
|
|
1446
|
+
});
|
|
1447
|
+
});
|
|
1448
|
+
} catch (ex) {
|
|
1449
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1450
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1451
|
+
return callback(null, errorObj);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* @summary Get Appliances that match the filter
|
|
1457
|
+
*
|
|
1458
|
+
* @function getDevicesFiltered
|
|
1459
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
1460
|
+
*
|
|
1461
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1462
|
+
* (appliances) or the error
|
|
1463
|
+
*/
|
|
1464
|
+
getDevicesFiltered(options, callback) {
|
|
1465
|
+
const meth = 'adapterBase-getDevicesFiltered';
|
|
1466
|
+
const origin = `${this.id}-${meth}`;
|
|
1467
|
+
log.trace(origin);
|
|
1468
|
+
|
|
1469
|
+
// make sure we are set up for device broker getDevicesFiltered
|
|
1470
|
+
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getDevicesFiltered || this.allProps.devicebroker.getDevicesFiltered.length === 0 || !this.allProps.devicebroker.getDevicesFiltered[0].path) {
|
|
1471
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getDevicesFiltered.path'], null, null, null);
|
|
1472
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1473
|
+
return callback(null, errorObj);
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
// verify the required fields have been provided
|
|
1477
|
+
if (options === undefined || options === null || options === '' || options.length === 0) {
|
|
1478
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['options'], null, null, null);
|
|
1479
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1480
|
+
return callback(null, errorObj);
|
|
1481
|
+
}
|
|
1482
|
+
log.debug(`Device Filter Options: ${JSON.stringify(options)}`);
|
|
1483
|
+
|
|
1484
|
+
try {
|
|
1485
|
+
// TODO - get pagination working
|
|
1486
|
+
// const nextToken = options.start;
|
|
1487
|
+
// const maxResults = options.limit;
|
|
1488
|
+
|
|
1489
|
+
// set up the filter of Device Names
|
|
1490
|
+
let filterName = [];
|
|
1491
|
+
if (options && options.filter && options.filter.name) {
|
|
1492
|
+
// when this hack is removed, remove the lint ignore above
|
|
1493
|
+
if (Array.isArray(options.filter.name)) {
|
|
1494
|
+
// eslint-disable-next-line prefer-destructuring
|
|
1495
|
+
filterName = options.filter.name;
|
|
1496
|
+
} else {
|
|
1497
|
+
filterName = [options.filter.name];
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
// TODO - get sort and order working
|
|
1502
|
+
/*
|
|
1503
|
+
if (options && options.sort) {
|
|
1504
|
+
reqObj.uriOptions.sort = JSON.stringify(options.sort);
|
|
1505
|
+
}
|
|
1506
|
+
if (options && options.order) {
|
|
1507
|
+
reqObj.uriOptions.order = options.order;
|
|
1508
|
+
}
|
|
1509
|
+
*/
|
|
1510
|
+
const callPromises = [];
|
|
1511
|
+
for (let i = 0; i < this.allProps.devicebroker.getDevicesFiltered.length; i += 1) {
|
|
1512
|
+
// Perform component calls here.
|
|
1513
|
+
callPromises.push(
|
|
1514
|
+
new Promise((resolve, reject) => {
|
|
1515
|
+
this.iapMakeBrokerCall('getDevicesFiltered', this.allProps.devicebroker.getDevicesFiltered[i], [{ fake: 'fakedata' }], filterName, (callRet, callErr) => {
|
|
1516
|
+
// return an error
|
|
1517
|
+
if (callErr) {
|
|
1518
|
+
reject(callErr);
|
|
1519
|
+
} else {
|
|
1520
|
+
// return the data
|
|
1521
|
+
resolve(callRet);
|
|
1522
|
+
}
|
|
1523
|
+
});
|
|
1524
|
+
})
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
// return an array of repsonses
|
|
1529
|
+
return Promise.all(callPromises).then((results) => {
|
|
1530
|
+
let myResult = [];
|
|
1531
|
+
results.forEach((result) => {
|
|
1532
|
+
if (Array.isArray(result)) {
|
|
1533
|
+
myResult = [...myResult, ...result];
|
|
1534
|
+
} else if (Object.keys(result).length > 0) {
|
|
1535
|
+
myResult.push(result);
|
|
1536
|
+
}
|
|
1537
|
+
});
|
|
1538
|
+
|
|
1539
|
+
log.debug(`${origin}: Found #${myResult.length} devices.`);
|
|
1540
|
+
log.debug(`Devices: ${JSON.stringify(myResult)}`);
|
|
1541
|
+
return callback({ total: myResult.length, list: myResult });
|
|
1542
|
+
});
|
|
1543
|
+
} catch (ex) {
|
|
1544
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1545
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1546
|
+
return callback(null, errorObj);
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* @summary Gets the status for the provided appliance
|
|
1552
|
+
*
|
|
1553
|
+
* @function isAlive
|
|
1554
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
1555
|
+
*
|
|
1556
|
+
* @param {configCallback} callback - callback function to return the result
|
|
1557
|
+
* (appliance isAlive) or the error
|
|
1558
|
+
*/
|
|
1559
|
+
isAlive(deviceName, callback) {
|
|
1560
|
+
const meth = 'adapterBase-isAlive';
|
|
1561
|
+
const origin = `${this.id}-${meth}`;
|
|
1562
|
+
log.trace(origin);
|
|
1563
|
+
|
|
1564
|
+
// make sure we are set up for device broker isAlive
|
|
1565
|
+
if (!this.allProps.devicebroker || !this.allProps.devicebroker.isAlive || this.allProps.devicebroker.isAlive.length === 0 || !this.allProps.devicebroker.isAlive[0].path) {
|
|
1566
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.isAlive.path'], null, null, null);
|
|
1567
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1568
|
+
return callback(null, errorObj);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
// verify the required fields have been provided
|
|
1572
|
+
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
1573
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
1574
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1575
|
+
return callback(null, errorObj);
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
try {
|
|
1579
|
+
// need to get the device so we can convert the deviceName to an id
|
|
1580
|
+
// !! if we can do a lookup by name the getDevicesFiltered may not be necessary
|
|
1581
|
+
const opts = {
|
|
1582
|
+
filter: {
|
|
1583
|
+
name: deviceName
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
1587
|
+
// if we received an error or their is no response on the results return an error
|
|
1588
|
+
if (ferr) {
|
|
1589
|
+
return callback(null, ferr);
|
|
1590
|
+
}
|
|
1591
|
+
if (devs.list.length < 1) {
|
|
1592
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
1593
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1594
|
+
return callback(null, errorObj);
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
const callPromises = [];
|
|
1598
|
+
for (let i = 0; i < this.allProps.devicebroker.isAlive.length; i += 1) {
|
|
1599
|
+
// Perform component calls here.
|
|
1600
|
+
callPromises.push(
|
|
1601
|
+
new Promise((resolve, reject) => {
|
|
1602
|
+
this.iapMakeBrokerCall('isAlive', this.allProps.devicebroker.isAlive[i], [devs.list[0]], null, (callRet, callErr) => {
|
|
1603
|
+
// return an error
|
|
1604
|
+
if (callErr) {
|
|
1605
|
+
reject(callErr);
|
|
1606
|
+
} else {
|
|
1607
|
+
// return the data
|
|
1608
|
+
resolve(callRet);
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
})
|
|
1612
|
+
);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
// return an array of repsonses
|
|
1616
|
+
return Promise.all(callPromises).then((results) => {
|
|
1617
|
+
let myResult = {};
|
|
1618
|
+
results.forEach((result) => {
|
|
1619
|
+
myResult = { ...myResult, ...result };
|
|
1620
|
+
});
|
|
1621
|
+
|
|
1622
|
+
let response = true;
|
|
1623
|
+
if (myResult.isAlive !== null && myResult.isAlive !== undefined && myResult.isAlive === false) {
|
|
1624
|
+
response = false;
|
|
1625
|
+
}
|
|
1626
|
+
return callback(response);
|
|
1627
|
+
});
|
|
1628
|
+
});
|
|
1629
|
+
} catch (ex) {
|
|
1630
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1631
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1632
|
+
return callback(null, errorObj);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
/**
|
|
1637
|
+
* @summary Gets a config for the provided Appliance
|
|
1638
|
+
*
|
|
1639
|
+
* @function getConfig
|
|
1640
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
1641
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
1642
|
+
*
|
|
1643
|
+
* @param {configCallback} callback - callback function to return the result
|
|
1644
|
+
* (appliance config) or the error
|
|
1645
|
+
*/
|
|
1646
|
+
getConfig(deviceName, format, callback) {
|
|
1647
|
+
const meth = 'adapterBase-getConfig';
|
|
1648
|
+
const origin = `${this.id}-${meth}`;
|
|
1649
|
+
log.trace(origin);
|
|
1650
|
+
|
|
1651
|
+
// make sure we are set up for device broker getConfig
|
|
1652
|
+
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getConfig || this.allProps.devicebroker.getConfig.length === 0 || !this.allProps.devicebroker.getConfig[0].path) {
|
|
1653
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getConfig.path'], null, null, null);
|
|
1654
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1655
|
+
return callback(null, errorObj);
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
// verify the required fields have been provided
|
|
1659
|
+
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
1660
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
1661
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1662
|
+
return callback(null, errorObj);
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
try {
|
|
1666
|
+
// need to get the device so we can convert the deviceName to an id
|
|
1667
|
+
// !! if we can do a lookup by name the getDevicesFiltered may not be necessary
|
|
1668
|
+
const opts = {
|
|
1669
|
+
filter: {
|
|
1670
|
+
name: deviceName
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
1674
|
+
// if we received an error or their is no response on the results return an error
|
|
1675
|
+
if (ferr) {
|
|
1676
|
+
return callback(null, ferr);
|
|
1677
|
+
}
|
|
1678
|
+
if (devs.list.length < 1) {
|
|
1679
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
1680
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1681
|
+
return callback(null, errorObj);
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
const callPromises = [];
|
|
1685
|
+
for (let i = 0; i < this.allProps.devicebroker.getConfig.length; i += 1) {
|
|
1686
|
+
// Perform component calls here.
|
|
1687
|
+
callPromises.push(
|
|
1688
|
+
new Promise((resolve, reject) => {
|
|
1689
|
+
this.iapMakeBrokerCall('getConfig', this.allProps.devicebroker.getConfig[i], [devs.list[0]], null, (callRet, callErr) => {
|
|
1690
|
+
// return an error
|
|
1691
|
+
if (callErr) {
|
|
1692
|
+
reject(callErr);
|
|
1693
|
+
} else {
|
|
1694
|
+
// return the data
|
|
1695
|
+
resolve(callRet);
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1698
|
+
})
|
|
1699
|
+
);
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
// return an array of repsonses
|
|
1703
|
+
return Promise.all(callPromises).then((results) => {
|
|
1704
|
+
let myResult = {};
|
|
1705
|
+
results.forEach((result) => {
|
|
1706
|
+
myResult = { ...myResult, ...result };
|
|
1707
|
+
});
|
|
1708
|
+
|
|
1709
|
+
// return the result
|
|
1710
|
+
const newResponse = {
|
|
1711
|
+
response: JSON.stringify(myResult, null, 2)
|
|
1712
|
+
};
|
|
1713
|
+
return callback(newResponse, null);
|
|
1714
|
+
});
|
|
1715
|
+
});
|
|
1716
|
+
} catch (ex) {
|
|
1717
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1718
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1719
|
+
return callback(null, errorObj);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/**
|
|
1724
|
+
* @summary Gets the device count from the system
|
|
1725
|
+
*
|
|
1726
|
+
* @function iapGetDeviceCount
|
|
1727
|
+
*
|
|
1728
|
+
* @param {getCallback} callback - callback function to return the result
|
|
1729
|
+
* (count) or the error
|
|
1730
|
+
*/
|
|
1731
|
+
iapGetDeviceCount(callback) {
|
|
1732
|
+
const meth = 'adapterBase-iapGetDeviceCount';
|
|
1733
|
+
const origin = `${this.id}-${meth}`;
|
|
1734
|
+
log.trace(origin);
|
|
1735
|
+
|
|
1736
|
+
// make sure we are set up for device broker getCount
|
|
1737
|
+
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getCount || this.allProps.devicebroker.getCount.length === 0 || !this.allProps.devicebroker.getCount[0].path) {
|
|
1738
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getCount.path'], null, null, null);
|
|
1739
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1740
|
+
return callback(null, errorObj);
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
// verify the required fields have been provided
|
|
1744
|
+
|
|
1745
|
+
try {
|
|
1746
|
+
const callPromises = [];
|
|
1747
|
+
for (let i = 0; i < this.allProps.devicebroker.getCount.length; i += 1) {
|
|
1748
|
+
// Perform component calls here.
|
|
1749
|
+
callPromises.push(
|
|
1750
|
+
new Promise((resolve, reject) => {
|
|
1751
|
+
this.iapMakeBrokerCall('getCount', this.allProps.devicebroker.getCount[i], null, null, (callRet, callErr) => {
|
|
1752
|
+
// return an error
|
|
1753
|
+
if (callErr) {
|
|
1754
|
+
reject(callErr);
|
|
1755
|
+
} else {
|
|
1756
|
+
// return the data
|
|
1757
|
+
resolve(callRet);
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
})
|
|
1761
|
+
);
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
// return an array of repsonses
|
|
1765
|
+
return Promise.all(callPromises).then((results) => {
|
|
1766
|
+
let myResult = {};
|
|
1767
|
+
results.forEach((result) => {
|
|
1768
|
+
myResult = { ...myResult, ...result };
|
|
1769
|
+
});
|
|
1770
|
+
|
|
1771
|
+
// return the result
|
|
1772
|
+
return callback({ count: myResult.length });
|
|
1773
|
+
});
|
|
1774
|
+
} catch (ex) {
|
|
1775
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1022
1776
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1023
1777
|
return callback(null, errorObj);
|
|
1024
1778
|
}
|