diff --git a/sdk/appconfiguration/app-configuration/LICENSE.txt b/sdk/appconfiguration/app-configuration/LICENSE.txt new file mode 100644 index 000000000000..b73b4a1293c3 --- /dev/null +++ b/sdk/appconfiguration/app-configuration/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/appconfiguration/app-configuration/README.md b/sdk/appconfiguration/app-configuration/README.md new file mode 100644 index 000000000000..a87164e854ba --- /dev/null +++ b/sdk/appconfiguration/app-configuration/README.md @@ -0,0 +1,106 @@ +## Azure ConfigurationClient SDK for JavaScript + +This package contains an isomorphic SDK for ConfigurationClient. + +### Currently supported environments + +- Node.js version 6.x.x or higher +- Browser JavaScript + +### How to Install + +```bash +npm install @azure/app-config +``` + +### How to use + +#### nodejs - Authentication, client creation and listConfigurationSettings as an example written in TypeScript. + +##### Install @azure/ms-rest-nodeauth + +```bash +npm install @azure/ms-rest-nodeauth +``` + +##### Sample code + +```typescript +import * as coreHttp from "@azure/core-http"; +import * as coreArm from "@azure/core-arm"; +import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; +import { ConfigurationClient, ConfigurationModels, ConfigurationMappers } from "@azure/app-config"; +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new ConfigurationClient(creds, subscriptionId); + const label = ["testlabel"]; + const key = ["testkey"]; + const acceptDateTime = new Date().toISOString(); + const fields = ["etag"]; + client.listConfigurationSettings(label, key, acceptDateTime, fields).then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.error(err); +}); +``` + +#### browser - Authentication, client creation and listConfigurationSettings as an example written in JavaScript. + +##### Install @azure/ms-rest-browserauth + +```bash +npm install @azure/ms-rest-browserauth +``` + +##### Sample code + +See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. + +- index.html +```html + + + + @azure/app-configuration sample + + + + + + + + +``` + +## Related projects + +- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/appconfiguration/app-config/README.png) diff --git a/sdk/appconfiguration/app-configuration/package.json b/sdk/appconfiguration/app-configuration/package.json new file mode 100644 index 000000000000..8ab6c2ec8bbf --- /dev/null +++ b/sdk/appconfiguration/app-configuration/package.json @@ -0,0 +1,59 @@ +{ + "name": "@azure/app-configuration", + "author": "Microsoft Corporation", + "description": "An isomorphic client library for the Azure App Configuration service.", + "version": "1.0.0-preview.1", + "dependencies": { + "@azure/core-arm": "1.0.0-preview.1", + "@azure/core-http": "1.0.0-preview.1", + "tslib": "^1.9.3" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/app-configuration.js", + "module": "./esm/index.js", + "types": "./esm/index.d.ts", + "devDependencies": { + "rollup": "^0.66.2", + "rollup-plugin-node-resolve": "^3.4.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "ts-node": "^8.3.0", + "typescript": "^3.1.1", + "uglify-js": "^3.4.9" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/appconfiguration/app-configuration", + "repository": { + "type": "git", + "url": "https://github.com/Azure/azure-sdk-for-js.git" + }, + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map", + "esm/**/*.js", + "esm/**/*.js.map", + "esm/**/*.d.ts", + "esm/**/*.d.ts.map", + "src/**/*.ts", + "README.md", + "rollup.config.js", + "tsconfig.json" + ], + "scripts": { + "build": "tsc && rollup -c rollup.config.js && npm run minify", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/app-configuration.js.map'\" -o ./dist/app-configuration.min.js ./dist/app-configuration.js", + "prepack": "npm install && npm run build" + }, + "sideEffects": false, + "autoPublish": false +} diff --git a/sdk/appconfiguration/app-configuration/rollup.config.js b/sdk/appconfiguration/app-configuration/rollup.config.js new file mode 100644 index 000000000000..79908471c2b6 --- /dev/null +++ b/sdk/appconfiguration/app-configuration/rollup.config.js @@ -0,0 +1,30 @@ +import rollup from "rollup"; +import nodeResolve from "rollup-plugin-node-resolve"; +import sourcemaps from "rollup-plugin-sourcemaps"; + +/** + * @type {rollup.RollupFileOptions} + */ +const config = { + input: "./esm/index.js", + external: [ + "@azure/core-http", + "@azure/core-arm" + ], + output: { + file: "./dist/app-configuration.js", + format: "umd", + name: "Azure.AppConfig", + sourcemap: true, + globals: { + "@azure/core-http": "coreHttp", + "@azure/core-arm": "coreArm" + } + }, + plugins: [ + nodeResolve({ module: true }), + sourcemaps() + ] +}; + +export default config; diff --git a/sdk/appconfiguration/app-configuration/src/appConfigCredential.ts b/sdk/appconfiguration/app-configuration/src/appConfigCredential.ts new file mode 100644 index 000000000000..2133154b5ed1 --- /dev/null +++ b/sdk/appconfiguration/app-configuration/src/appConfigCredential.ts @@ -0,0 +1,41 @@ +import * as crypto from "crypto"; +import { ServiceClientCredentials, WebResource, URLBuilder } from "@azure/core-http"; + +export class AppConfigCredential implements ServiceClientCredentials { + private credential: string; + private secret: string; + + constructor(credential: string, secret: string) { + this.credential = credential; + this.secret = secret; + } + + signRequest(webResource: WebResource): Promise { + const verb = webResource.method.toUpperCase() + const utcNow = new Date().toUTCString(); + const contentHash = + crypto.createHash("sha256") + .update(webResource.body || "") + .digest("base64"); + + const signedHeaders = "x-ms-date;host;x-ms-content-sha256"; + + const url = URLBuilder.parse(webResource.url); + const query = url.getQuery(); + const urlPathAndQuery = `${url.getPath()}${ query ? "?" + query : "" }` + + const stringToSign = `${verb}\n${urlPathAndQuery}\n${utcNow};${url.getHost()};${contentHash}`; + + const decodedSecret = Buffer.from(this.secret, "base64"); + var signature = + crypto.createHmac("sha256", decodedSecret) + .update(stringToSign) + .digest("base64"); + + webResource.headers.set("x-ms-date", utcNow); + webResource.headers.set("x-ms-content-sha256", contentHash); + webResource.headers.set("Authorization", `HMAC-SHA256 Credential=${this.credential}, SignedHeaders=${signedHeaders}, Signature=${signature}`); + + return Promise.resolve(webResource); + } +} diff --git a/sdk/appconfiguration/app-configuration/src/generated/configurationClient.ts b/sdk/appconfiguration/app-configuration/src/generated/configurationClient.ts new file mode 100644 index 000000000000..d8cefa150f2a --- /dev/null +++ b/sdk/appconfiguration/app-configuration/src/generated/configurationClient.ts @@ -0,0 +1,592 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as coreHttp from "@azure/core-http"; +import * as Models from "./models"; +import * as Mappers from "./models/mappers"; +import * as Parameters from "./models/parameters"; +import { ConfigurationClientContext } from "./configurationClientContext"; + + +class ConfigurationClient extends ConfigurationClientContext { + /** + * Initializes a new instance of the ConfigurationClient class. + * @param credentials Credentials needed for the client to connect to Azure. + * @param [options] The parameter options + */ + constructor(credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials, options?: Models.ConfigurationClientOptions) { + super(credentials, options); + } + + /** + * List the configuration settings in the configuration store, optionally filtered by label + * @summary List configuration settings + * @param [options] The optional parameters + * @returns Promise + */ + listConfigurationSettings(options?: Models.ConfigurationClientListConfigurationSettingsOptionalParams): Promise; + /** + * @param callback The callback + */ + listConfigurationSettings(callback: coreHttp.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + listConfigurationSettings(options: Models.ConfigurationClientListConfigurationSettingsOptionalParams, callback: coreHttp.ServiceCallback): void; + listConfigurationSettings(options?: Models.ConfigurationClientListConfigurationSettingsOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + options + }, + listConfigurationSettingsOperationSpec, + callback) as Promise; + } + + /** + * Get the ConfigurationSetting for the given key and label + * @summary Get a ConfigurationSetting + * @param key string + * @param [options] The optional parameters + * @returns Promise + */ + getConfigurationSetting(key: string, options?: Models.ConfigurationClientGetConfigurationSettingOptionalParams): Promise; + /** + * @param key string + * @param callback The callback + */ + getConfigurationSetting(key: string, callback: coreHttp.ServiceCallback): void; + /** + * @param key string + * @param options The optional parameters + * @param callback The callback + */ + getConfigurationSetting(key: string, options: Models.ConfigurationClientGetConfigurationSettingOptionalParams, callback: coreHttp.ServiceCallback): void; + getConfigurationSetting(key: string, options?: Models.ConfigurationClientGetConfigurationSettingOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + key, + options + }, + getConfigurationSettingOperationSpec, + callback) as Promise; + } + + /** + * Create (or update) a ConfigurationSetting + * @summary Create (or update) a ConfigurationSetting + * @param configurationSetting + * @param key string + * @param [options] The optional parameters + * @returns Promise + */ + createOrUpdateConfigurationSetting(configurationSetting: Models.ConfigurationSetting, key: string, options?: Models.ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams): Promise; + /** + * @param configurationSetting + * @param key string + * @param callback The callback + */ + createOrUpdateConfigurationSetting(configurationSetting: Models.ConfigurationSetting, key: string, callback: coreHttp.ServiceCallback): void; + /** + * @param configurationSetting + * @param key string + * @param options The optional parameters + * @param callback The callback + */ + createOrUpdateConfigurationSetting(configurationSetting: Models.ConfigurationSetting, key: string, options: Models.ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams, callback: coreHttp.ServiceCallback): void; + createOrUpdateConfigurationSetting(configurationSetting: Models.ConfigurationSetting, key: string, options?: Models.ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + configurationSetting, + key, + options + }, + createOrUpdateConfigurationSettingOperationSpec, + callback) as Promise; + } + + /** + * Delete a ConfigurationSetting + * @param key string + * @param [options] The optional parameters + * @returns Promise + */ + deleteConfigurationSetting(key: string, options?: Models.ConfigurationClientDeleteConfigurationSettingOptionalParams): Promise; + /** + * @param key string + * @param callback The callback + */ + deleteConfigurationSetting(key: string, callback: coreHttp.ServiceCallback): void; + /** + * @param key string + * @param options The optional parameters + * @param callback The callback + */ + deleteConfigurationSetting(key: string, options: Models.ConfigurationClientDeleteConfigurationSettingOptionalParams, callback: coreHttp.ServiceCallback): void; + deleteConfigurationSetting(key: string, options?: Models.ConfigurationClientDeleteConfigurationSettingOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + key, + options + }, + deleteConfigurationSettingOperationSpec, + callback) as Promise; + } + + /** + * @param [options] The optional parameters + * @returns Promise + */ + listKeys(options?: Models.ConfigurationClientListKeysOptionalParams): Promise; + /** + * @param callback The callback + */ + listKeys(callback: coreHttp.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + listKeys(options: Models.ConfigurationClientListKeysOptionalParams, callback: coreHttp.ServiceCallback): void; + listKeys(options?: Models.ConfigurationClientListKeysOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + options + }, + listKeysOperationSpec, + callback) as Promise; + } + + /** + * List labels + * @param [options] The optional parameters + * @returns Promise + */ + listLabels(options?: Models.ConfigurationClientListLabelsOptionalParams): Promise; + /** + * @param callback The callback + */ + listLabels(callback: coreHttp.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + listLabels(options: Models.ConfigurationClientListLabelsOptionalParams, callback: coreHttp.ServiceCallback): void; + listLabels(options?: Models.ConfigurationClientListLabelsOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + options + }, + listLabelsOperationSpec, + callback) as Promise; + } + + /** + * @param key + * @param [options] The optional parameters + * @returns Promise + */ + lockConfigurationSetting(key: string, options?: Models.ConfigurationClientLockConfigurationSettingOptionalParams): Promise; + /** + * @param key + * @param callback The callback + */ + lockConfigurationSetting(key: string, callback: coreHttp.ServiceCallback): void; + /** + * @param key + * @param options The optional parameters + * @param callback The callback + */ + lockConfigurationSetting(key: string, options: Models.ConfigurationClientLockConfigurationSettingOptionalParams, callback: coreHttp.ServiceCallback): void; + lockConfigurationSetting(key: string, options?: Models.ConfigurationClientLockConfigurationSettingOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + key, + options + }, + lockConfigurationSettingOperationSpec, + callback) as Promise; + } + + /** + * @param key + * @param [options] The optional parameters + * @returns Promise + */ + unlockConfigurationSetting(key: string, options?: Models.ConfigurationClientUnlockConfigurationSettingOptionalParams): Promise; + /** + * @param key + * @param callback The callback + */ + unlockConfigurationSetting(key: string, callback: coreHttp.ServiceCallback): void; + /** + * @param key + * @param options The optional parameters + * @param callback The callback + */ + unlockConfigurationSetting(key: string, options: Models.ConfigurationClientUnlockConfigurationSettingOptionalParams, callback: coreHttp.ServiceCallback): void; + unlockConfigurationSetting(key: string, options?: Models.ConfigurationClientUnlockConfigurationSettingOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + key, + options + }, + unlockConfigurationSettingOperationSpec, + callback) as Promise; + } + + /** + * @param [options] The optional parameters + * @returns Promise + */ + listRevisions(options?: Models.ConfigurationClientListRevisionsOptionalParams): Promise; + /** + * @param callback The callback + */ + listRevisions(callback: coreHttp.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + listRevisions(options: Models.ConfigurationClientListRevisionsOptionalParams, callback: coreHttp.ServiceCallback): void; + listRevisions(options?: Models.ConfigurationClientListRevisionsOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + options + }, + listRevisionsOperationSpec, + callback) as Promise; + } + + /** + * List the configuration settings in the configuration store, optionally filtered by label + * @summary List configuration settings + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listConfigurationSettingsNext(nextPageLink: string, options?: Models.ConfigurationClientListConfigurationSettingsNextOptionalParams): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listConfigurationSettingsNext(nextPageLink: string, callback: coreHttp.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listConfigurationSettingsNext(nextPageLink: string, options: Models.ConfigurationClientListConfigurationSettingsNextOptionalParams, callback: coreHttp.ServiceCallback): void; + listConfigurationSettingsNext(nextPageLink: string, options?: Models.ConfigurationClientListConfigurationSettingsNextOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + nextPageLink, + options + }, + listConfigurationSettingsNextOperationSpec, + callback) as Promise; + } + + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param [options] The optional parameters + * @returns Promise + */ + listRevisionsNext(nextPageLink: string, options?: Models.ConfigurationClientListRevisionsNextOptionalParams): Promise; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param callback The callback + */ + listRevisionsNext(nextPageLink: string, callback: coreHttp.ServiceCallback): void; + /** + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param options The optional parameters + * @param callback The callback + */ + listRevisionsNext(nextPageLink: string, options: Models.ConfigurationClientListRevisionsNextOptionalParams, callback: coreHttp.ServiceCallback): void; + listRevisionsNext(nextPageLink: string, options?: Models.ConfigurationClientListRevisionsNextOptionalParams | coreHttp.ServiceCallback, callback?: coreHttp.ServiceCallback): Promise { + return this.sendOperationRequest( + { + nextPageLink, + options + }, + listRevisionsNextOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new coreHttp.Serializer(Mappers); +const listConfigurationSettingsOperationSpec: coreHttp.OperationSpec = { + httpMethod: "GET", + path: "kv", + queryParameters: [ + Parameters.label0, + Parameters.key0, + Parameters.fields + ], + headerParameters: [ + Parameters.acceptDateTime, + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.ConfigurationSettingList + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const getConfigurationSettingOperationSpec: coreHttp.OperationSpec = { + httpMethod: "GET", + path: "kv/{key}", + urlParameters: [ + Parameters.key1 + ], + queryParameters: [ + Parameters.label1 + ], + headerParameters: [ + Parameters.acceptDateTime, + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.ConfigurationSetting, + headersMapper: Mappers.GetConfigurationSettingHeaders + }, + 304: { + headersMapper: Mappers.GetConfigurationSettingHeaders + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const createOrUpdateConfigurationSettingOperationSpec: coreHttp.OperationSpec = { + httpMethod: "PUT", + path: "kv/{key}", + urlParameters: [ + Parameters.key1 + ], + queryParameters: [ + Parameters.label1 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + requestBody: { + parameterPath: "configurationSetting", + mapper: { + ...Mappers.ConfigurationSetting, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.ConfigurationSetting + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const deleteConfigurationSettingOperationSpec: coreHttp.OperationSpec = { + httpMethod: "DELETE", + path: "kv/{key}", + urlParameters: [ + Parameters.key1 + ], + queryParameters: [ + Parameters.label2 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.ConfigurationSetting + }, + 204: {}, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const listKeysOperationSpec: coreHttp.OperationSpec = { + httpMethod: "GET", + path: "keys", + queryParameters: [ + Parameters.name + ], + headerParameters: [ + Parameters.acceptDateTime, + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.KeyList + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const listLabelsOperationSpec: coreHttp.OperationSpec = { + httpMethod: "GET", + path: "labels", + queryParameters: [ + Parameters.fields, + Parameters.name + ], + headerParameters: [ + Parameters.acceptDateTime, + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.LabelList + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const lockConfigurationSettingOperationSpec: coreHttp.OperationSpec = { + httpMethod: "PUT", + path: "locks/{key}", + urlParameters: [ + Parameters.key1 + ], + queryParameters: [ + Parameters.label2 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.ConfigurationSetting + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const unlockConfigurationSettingOperationSpec: coreHttp.OperationSpec = { + httpMethod: "DELETE", + path: "locks/{key}", + urlParameters: [ + Parameters.key1 + ], + queryParameters: [ + Parameters.label2 + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.ConfigurationSetting + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const listRevisionsOperationSpec: coreHttp.OperationSpec = { + httpMethod: "GET", + path: "revisions", + queryParameters: [ + Parameters.label0, + Parameters.key0, + Parameters.fields + ], + headerParameters: [ + Parameters.acceptDateTime, + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.ConfigurationSettingList + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const listConfigurationSettingsNextOperationSpec: coreHttp.OperationSpec = { + httpMethod: "GET", + baseUrl: "http://localhost", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptDateTime, + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.ConfigurationSettingList + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const listRevisionsNextOperationSpec: coreHttp.OperationSpec = { + httpMethod: "GET", + baseUrl: "http://localhost", + path: "{nextLink}", + urlParameters: [ + Parameters.nextPageLink + ], + headerParameters: [ + Parameters.acceptDateTime, + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.ConfigurationSettingList + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +export { + ConfigurationClient, + ConfigurationClientContext, + Models as ConfigurationModels, + Mappers as ConfigurationMappers +}; diff --git a/sdk/appconfiguration/app-configuration/src/generated/configurationClientContext.ts b/sdk/appconfiguration/app-configuration/src/generated/configurationClientContext.ts new file mode 100644 index 000000000000..8a3eed9b73d2 --- /dev/null +++ b/sdk/appconfiguration/app-configuration/src/generated/configurationClientContext.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as Models from "./models"; +import * as coreHttp from "@azure/core-http"; +import * as coreArm from "@azure/core-arm"; + +const packageName = "@azure/app-config"; +const packageVersion = "1.0.0"; + +export class ConfigurationClientContext extends coreArm.AzureServiceClient { + credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials; + apiVersion: string; + + /** + * Initializes a new instance of the ConfigurationClient class. + * @param credentials Credentials needed for the client to connect to Azure. + * @param [options] The parameter options + */ + constructor(credentials: coreHttp.TokenCredential | coreHttp.ServiceClientCredentials, options?: Models.ConfigurationClientOptions) { + if (credentials == undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + + if (!options) { + options = {}; + } + if(!options.userAgent) { + const defaultUserAgent = coreArm.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.apiVersion = '2019-01-01'; + this.acceptLanguage = 'en-US'; + this.longRunningOperationRetryTimeout = 30; + this.baseUri = options.baseUri || this.baseUri || "http://localhost"; + this.requestContentType = "application/json; charset=utf-8"; + this.credentials = credentials; + + if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + this.acceptLanguage = options.acceptLanguage; + } + if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; + } + } +} diff --git a/sdk/appconfiguration/app-configuration/src/generated/models/index.ts b/sdk/appconfiguration/app-configuration/src/generated/models/index.ts new file mode 100644 index 000000000000..ab5c83290254 --- /dev/null +++ b/sdk/appconfiguration/app-configuration/src/generated/models/index.ts @@ -0,0 +1,458 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { BaseResource, CloudError, AzureServiceClientOptions } from "@azure/core-arm"; +import * as coreHttp from "@azure/core-http"; + +export { BaseResource, CloudError }; + +/** + * A configuration value + */ +export interface ConfigurationSetting { + /** + * Entity tag (etag) of the object + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly etag?: string; + key?: string; + label?: string; + contentType?: string; + value?: string; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly lastModified?: Date; + /** + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly locked?: boolean; + tags?: { [propertyName: string]: string }; +} + +/** + * An interface representing Key. + */ +export interface Key { + name: string; +} + +/** + * An interface representing Label. + */ +export interface Label { + name: string; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientListConfigurationSettingsOptionalParams extends coreHttp.RequestOptionsBase { + /** + * Filter returned values based on their label. '*' can be used as wildcard in the beginning or + * end of the filter + */ + label?: string[]; + /** + * Filter returned values based on their keys. '*' can be used as wildcard in the beginning or + * end of the filter + */ + key?: string[]; + /** + * Obtain representation of the result related to past time. + */ + acceptDateTime?: Date; + /** + * Specify which fields to return + */ + fields?: string[]; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientGetConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase { + /** + * Label of key to retreive. Default value: '%00'. + */ + label?: string; + /** + * Obtain representation of the result related to past time. + */ + acceptDateTime?: Date; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase { + /** + * Default value: '%00'. + */ + label?: string; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientDeleteConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase { + label?: string; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientListKeysOptionalParams extends coreHttp.RequestOptionsBase { + name?: string; + /** + * Obtain representation of the result related to past time. + */ + acceptDateTime?: Date; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientListLabelsOptionalParams extends coreHttp.RequestOptionsBase { + /** + * Obtain representation of the result related to past time. + */ + acceptDateTime?: Date; + /** + * Specify which fields to return + */ + fields?: string[]; + name?: string; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientLockConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase { + label?: string; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientUnlockConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase { + label?: string; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientListRevisionsOptionalParams extends coreHttp.RequestOptionsBase { + /** + * Filter returned values based on their label. '*' can be used as wildcard in the beginning or + * end of the filter + */ + label?: string[]; + /** + * Filter returned values based on their keys. '*' can be used as wildcard in the beginning or + * end of the filter + */ + key?: string[]; + /** + * Specify which fields to return + */ + fields?: string[]; + /** + * Obtain representation of the result related to past time. + */ + acceptDateTime?: Date; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientListConfigurationSettingsNextOptionalParams extends coreHttp.RequestOptionsBase { + /** + * Obtain representation of the result related to past time. + */ + acceptDateTime?: Date; +} + +/** + * Optional Parameters. + */ +export interface ConfigurationClientListRevisionsNextOptionalParams extends coreHttp.RequestOptionsBase { + /** + * Obtain representation of the result related to past time. + */ + acceptDateTime?: Date; +} + +/** + * An interface representing ConfigurationClientOptions. + */ +export interface ConfigurationClientOptions extends AzureServiceClientOptions { + baseUri?: string; +} + +/** + * Defines headers for GetConfigurationSetting operation. + */ +export interface GetConfigurationSettingHeaders { + /** + * A UTC date/time value generated by the service the last time the resource was modified + */ + lastModifiedHeader: string; +} + +/** + * @interface + * An interface representing the ConfigurationSettingList. + * @extends Array + */ +export interface ConfigurationSettingList extends Array { + items?: ConfigurationSetting[]; +} + +/** + * @interface + * An interface representing the KeyList. + * @extends Array + */ +export interface KeyList extends Array { + items?: Key[]; +} + +/** + * @interface + * An interface representing the LabelList. + * @extends Array