This repository was archived by the owner on Jan 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Removing SDK from LUIS endpoint calls #877
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
889b86a
Removing SDK from LUIS endpoint calls
munozemilio 8cdab19
Adding test to http hanlder
munozemilio a8c389b
Fixing test details
munozemilio 6e7a574
Fixing linting issues
munozemilio a231da0
Adding function to convert from LU to Luis if needed
munozemilio 37e8fcf
Fixing linting errors
munozemilio e9e8ac9
Merge branch 'master' into emimunoz/remove-luis-sdk
munozemilio 066c464
Removing unintended file
munozemilio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| import http from './http-request' | ||
| import EndpointParameters from './parameters' | ||
|
|
||
| const urlPath = '/luis/authoring/v3.0-preview/apps' | ||
|
|
||
| export default { | ||
| async assignAzureAccount( | ||
| param: EndpointParameters, | ||
| armToken: string, | ||
| azureSubscriptionId: string, | ||
| resourceGroup: string, | ||
| accountName: string) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}/azureaccounts` | ||
|
|
||
| const appJSON = { | ||
| azureSubscriptionId, | ||
| resourceGroup, | ||
| accountName, | ||
| } | ||
|
|
||
| return http.post(url, param.subscriptionKey, appJSON, {Authorization: 'Bearer ' + armToken}) | ||
| }, | ||
|
|
||
| async create( | ||
| param: EndpointParameters, | ||
| applicationCreateObject: any) { | ||
| let url = buildUrl(param.endpoint) | ||
|
|
||
| return http.post(url, param.subscriptionKey, applicationCreateObject) | ||
| }, | ||
|
|
||
| async delete( | ||
| param: EndpointParameters) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}` | ||
|
|
||
| return http.delete(url, param.subscriptionKey) | ||
| }, | ||
|
|
||
| async getEndpoints( | ||
| param: EndpointParameters) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}/endpoints` | ||
| return http.get(url, param.subscriptionKey) | ||
| }, | ||
|
|
||
| async import( | ||
| param: EndpointParameters, | ||
| appJSON: any, | ||
| name = '') { | ||
| name = name ? `?appName=${name}` : '' | ||
| let url = buildUrl(param.endpoint) + `/import${name}` | ||
| return http.post(url, param.subscriptionKey, appJSON) | ||
| }, | ||
|
|
||
| async list( | ||
| param: EndpointParameters, | ||
| skip = '0', | ||
| take = '100') { | ||
| let url = buildUrl(param.endpoint) + `/?skip=${skip}&take=${take}` | ||
|
|
||
| return http.get(url, param.subscriptionKey) | ||
| }, | ||
|
|
||
| async publish( | ||
| param: EndpointParameters, | ||
| applicationPublishObject: any) { | ||
| let url = buildUrl(param.endpoint) + `/${ param.appId}/publish` | ||
|
|
||
| return http.post(url, param.subscriptionKey, applicationPublishObject) | ||
| }, | ||
|
|
||
| async query( | ||
| param: EndpointParameters, | ||
| slotName = 'production', | ||
| query: string, | ||
| log: true, | ||
| show_all = false, | ||
| timezone = '') { | ||
| let url = param.endpoint + | ||
| `/luis/prediction/v3.0/apps/${param.appId}/slots/${slotName}/predict?verbose=false&log=${log}&show-all-intents=${show_all}` | ||
|
|
||
| let body: any = {query} | ||
|
|
||
| if (timezone) { | ||
| body.options = { | ||
| datetimeReference: timezone, | ||
| } | ||
| } | ||
|
|
||
| return http.post(url, param.subscriptionKey, body) | ||
| }, | ||
|
|
||
| async rename( | ||
| param: EndpointParameters, | ||
| name: string, | ||
| description: string) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}` | ||
|
|
||
| const body = { | ||
| name, | ||
| description | ||
| } | ||
|
|
||
| return http.put(url, param.subscriptionKey, body) | ||
| }, | ||
|
|
||
| async show( | ||
| param: EndpointParameters) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}` | ||
| return http.get(url, param.subscriptionKey) | ||
| } | ||
| } | ||
|
|
||
| const buildUrl = function (url: string) { | ||
| return url + urlPath | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import fetch from 'node-fetch' | ||
|
|
||
| let headers = { | ||
| 'Content-Type': 'application/json', | ||
| 'Ocp-Apim-Subscription-Key': '' | ||
| } | ||
|
|
||
| export default { | ||
| async get( | ||
| url: string, | ||
| subscriptionKey: string) { | ||
| setSubscriptionKey(subscriptionKey) | ||
| const response = await fetch(url, {method: 'GET', headers}) | ||
| return response.json() | ||
| }, | ||
|
|
||
| async post( | ||
| url: string, | ||
| subscriptionKey: string, | ||
| body: any, | ||
| extraHeaders = {}) { | ||
| setSubscriptionKey(subscriptionKey) | ||
| headers = {...headers, ...extraHeaders} | ||
| const response = await fetch(url, {method: 'POST', headers, body: JSON.stringify(body)}) | ||
| return response.json() | ||
| }, | ||
|
|
||
| async put( | ||
| url: string, | ||
| subscriptionKey: string, | ||
| body: any) { | ||
| setSubscriptionKey(subscriptionKey) | ||
| const response = await fetch(url, {method: 'PUT', headers, body: JSON.stringify(body)}) | ||
|
|
||
| return isJSON(response) ? response.json() : {code: 'Success'} | ||
| }, | ||
|
|
||
| async delete( | ||
| url: string, | ||
| subscriptionKey: string) { | ||
| setSubscriptionKey(subscriptionKey) | ||
| const response = await fetch(url, {method: 'DELETE', headers}) | ||
| return isJSON(response) ? response.json() : {code: 'Success'} | ||
| } | ||
| } | ||
|
|
||
| const setSubscriptionKey = function (subscriptionKey: string) { | ||
| headers['Ocp-Apim-Subscription-Key'] = subscriptionKey | ||
| } | ||
|
|
||
| /* tslint:disable:no-unused */ | ||
| const isJSON = function (jsonObject: any) { | ||
| try { | ||
| JSON.parse(jsonObject + '') | ||
| } catch (error) { | ||
| return false | ||
| } | ||
| return true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export default interface EndpointParameters { | ||
| appId?: string, | ||
|
|
||
| endpoint: string, | ||
|
|
||
| subscriptionKey: string, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import http from './http-request' | ||
| import EndpointParameters from './parameters' | ||
|
|
||
| const urlPath = '/luis/authoring/v3.0-preview/apps' | ||
|
|
||
| export default { | ||
| async train( | ||
| param: EndpointParameters, | ||
| versionId: string) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}/versions/${versionId}/train` | ||
|
|
||
| return http.post(url, param.subscriptionKey, {}) | ||
| }, | ||
|
|
||
| async getStatus( | ||
| param: EndpointParameters, | ||
| versionId: string) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}/versions/${versionId}/train` | ||
|
|
||
| return http.get(url, param.subscriptionKey) | ||
| } | ||
| } | ||
|
|
||
| const buildUrl = function (url: string) { | ||
| return url + urlPath | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import http from './http-request' | ||
| import EndpointParameters from './parameters' | ||
|
|
||
| const urlPath = '/luis/authoring/v3.0-preview/apps' | ||
|
|
||
| export default { | ||
| async clone( | ||
| param: EndpointParameters, | ||
| oldVersionId: string, | ||
| version: string) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}/versions/${oldVersionId}/clone` | ||
|
|
||
| return http.post(url, param.subscriptionKey, {version}) | ||
| }, | ||
|
|
||
| async delete( | ||
| param: EndpointParameters, | ||
| versionId: string) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}/versions/${versionId}/` | ||
|
|
||
| return http.delete(url, param.subscriptionKey) | ||
| }, | ||
|
|
||
| async export( | ||
| param: EndpointParameters, | ||
| versionId: string) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}/versions/${versionId}/export?format=json"` | ||
| return http.get(url, param.subscriptionKey) | ||
| }, | ||
|
|
||
| async import( | ||
| param: EndpointParameters, | ||
| appJSON: any, | ||
| versionId: string) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}/versions/import?versionId=${versionId}` | ||
|
|
||
| return http.post(url, param.subscriptionKey, appJSON) | ||
| }, | ||
|
|
||
| async list( | ||
| param: EndpointParameters, | ||
| skip = '0', | ||
| take = '100') { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}/versions/?skip=${skip}&take=${take}]` | ||
|
|
||
| return http.get(url, param.subscriptionKey) | ||
| }, | ||
|
|
||
| async rename( | ||
| param: EndpointParameters, | ||
| versionId: string, | ||
| newVersion: string) { | ||
| let url = buildUrl(param.endpoint) + `/${param.appId}/versions/${versionId}/` | ||
|
|
||
| return http.put(url, param.subscriptionKey, {version: newVersion}) | ||
| } | ||
| } | ||
|
|
||
| const buildUrl = function (url: string) { | ||
| return url + urlPath | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.