|
| 1 | +import http from './http-request' |
| 2 | +import EndpointParameters from './parameters' |
| 3 | + |
| 4 | +const urlPath = '/luis/authoring/v3.0-preview/apps' |
| 5 | + |
| 6 | +export default { |
| 7 | + async assignAzureAccount( |
| 8 | + param: EndpointParameters, |
| 9 | + armToken: string, |
| 10 | + azureSubscriptionId: string, |
| 11 | + resourceGroup: string, |
| 12 | + accountName: string) { |
| 13 | + let url = buildUrl(param.endpoint) + `/${param.appId}/azureaccounts` |
| 14 | + |
| 15 | + const appJSON = { |
| 16 | + azureSubscriptionId, |
| 17 | + resourceGroup, |
| 18 | + accountName, |
| 19 | + } |
| 20 | + |
| 21 | + return http.post(url, param.subscriptionKey, appJSON, {Authorization: 'Bearer ' + armToken}) |
| 22 | + }, |
| 23 | + |
| 24 | + async create( |
| 25 | + param: EndpointParameters, |
| 26 | + applicationCreateObject: any) { |
| 27 | + let url = buildUrl(param.endpoint) |
| 28 | + |
| 29 | + return http.post(url, param.subscriptionKey, applicationCreateObject) |
| 30 | + }, |
| 31 | + |
| 32 | + async delete( |
| 33 | + param: EndpointParameters) { |
| 34 | + let url = buildUrl(param.endpoint) + `/${param.appId}` |
| 35 | + |
| 36 | + return http.delete(url, param.subscriptionKey) |
| 37 | + }, |
| 38 | + |
| 39 | + async getEndpoints( |
| 40 | + param: EndpointParameters) { |
| 41 | + let url = buildUrl(param.endpoint) + `/${param.appId}/endpoints` |
| 42 | + return http.get(url, param.subscriptionKey) |
| 43 | + }, |
| 44 | + |
| 45 | + async import( |
| 46 | + param: EndpointParameters, |
| 47 | + appJSON: any, |
| 48 | + name = '') { |
| 49 | + name = name ? `?appName=${name}` : '' |
| 50 | + let url = buildUrl(param.endpoint) + `/import${name}` |
| 51 | + return http.post(url, param.subscriptionKey, appJSON) |
| 52 | + }, |
| 53 | + |
| 54 | + async list( |
| 55 | + param: EndpointParameters, |
| 56 | + skip = '0', |
| 57 | + take = '100') { |
| 58 | + let url = buildUrl(param.endpoint) + `/?skip=${skip}&take=${take}` |
| 59 | + |
| 60 | + return http.get(url, param.subscriptionKey) |
| 61 | + }, |
| 62 | + |
| 63 | + async publish( |
| 64 | + param: EndpointParameters, |
| 65 | + applicationPublishObject: any) { |
| 66 | + let url = buildUrl(param.endpoint) + `/${ param.appId}/publish` |
| 67 | + |
| 68 | + return http.post(url, param.subscriptionKey, applicationPublishObject) |
| 69 | + }, |
| 70 | + |
| 71 | + async query( |
| 72 | + param: EndpointParameters, |
| 73 | + slotName = 'production', |
| 74 | + query: string, |
| 75 | + log: true, |
| 76 | + show_all = false, |
| 77 | + timezone = '') { |
| 78 | + let url = param.endpoint + |
| 79 | + `/luis/prediction/v3.0/apps/${param.appId}/slots/${slotName}/predict?verbose=false&log=${log}&show-all-intents=${show_all}` |
| 80 | + |
| 81 | + let body: any = {query} |
| 82 | + |
| 83 | + if (timezone) { |
| 84 | + body.options = { |
| 85 | + datetimeReference: timezone, |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + return http.post(url, param.subscriptionKey, body) |
| 90 | + }, |
| 91 | + |
| 92 | + async rename( |
| 93 | + param: EndpointParameters, |
| 94 | + name: string, |
| 95 | + description: string) { |
| 96 | + let url = buildUrl(param.endpoint) + `/${param.appId}` |
| 97 | + |
| 98 | + const body = { |
| 99 | + name, |
| 100 | + description |
| 101 | + } |
| 102 | + |
| 103 | + return http.put(url, param.subscriptionKey, body) |
| 104 | + }, |
| 105 | + |
| 106 | + async show( |
| 107 | + param: EndpointParameters) { |
| 108 | + let url = buildUrl(param.endpoint) + `/${param.appId}` |
| 109 | + return http.get(url, param.subscriptionKey) |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +const buildUrl = function (url: string) { |
| 114 | + return url + urlPath |
| 115 | +} |
0 commit comments