Skip to content

Commit

Permalink
[app-configuration] Regenerated models, fixing AppConfigurationClient (
Browse files Browse the repository at this point in the history
…#5176)

* Regenerated models based on latest swagger file from the appconfig team

Also, normalizing our API to look a bit more like the other SDKs.
Namely:
* Removing the separation of key if we also required the user to fill out
value
* Removing fields that aren't used when ConfigurationSetting is passed
as a parameter
  • Loading branch information
richardpark-msft authored Sep 19, 2019
1 parent a2c59b8 commit 60f4d2d
Show file tree
Hide file tree
Showing 22 changed files with 2,844 additions and 1,863 deletions.
2 changes: 2 additions & 0 deletions sdk/appconfiguration/app-configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dependencies": {
"@azure/core-arm": "1.0.0-preview.3",
"@azure/core-http": "1.0.0-preview.3",
"@azure/core-paging": "1.0.0-preview.2",
"tslib": "^1.9.3"
},
"keywords": [
Expand Down Expand Up @@ -80,6 +81,7 @@
"lint": "eslint -c ../../.eslintrc.json src test --ext .ts -f html -o template-lintReport.html || exit 0",
"prebuild": "npm run clean",
"pack": "npm pack 2>&1",
"swagger": "autorest --typescript swagger/swagger.md",
"test": "npm run build:test && mocha -t 1200000 test-dist/index.node.js --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-",
"unit-test:browser": "echo skipped",
"unit-test:node": "echo skipped",
Expand Down
183 changes: 84 additions & 99 deletions sdk/appconfiguration/app-configuration/review/app-configuration.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,111 +7,75 @@
import * as coreHttp from '@azure/core-http';
import { TokenCredential } from '@azure/core-http';

// @public (undocumented)
export type AddConfigurationSettingConfig = Pick<ModelConfigurationSetting, Exclude<keyof ModelConfigurationSetting, "key">>;

// @public (undocumented)
export type AddConfigurationSettingOptions = ModelConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams;

// @public (undocumented)
export type AddConfigurationSettingsResponse = ModelCreateOrUpdateConfigurationSettingResponse;

// @public
export class AppConfigurationClient {
constructor(connectionString: string);
constructor(uri: string, credential: TokenCredential);
addConfigurationSetting(key: string, configSettings: AddConfigurationSettingConfig, options?: AddConfigurationSettingOptions): Promise<AddConfigurationSettingsResponse>;
deleteConfigurationSetting(key: string, options: DeleteConfigurationSettingOptions): Promise<DeleteConfigurationSettingResponse>;
getConfigurationSetting(key: string, options?: GetConfigurationSettingOptions): Promise<GetConfigurationSettingResponse>;
constructor(connectionString: string);
addConfigurationSetting(configurationSetting: ConfigurationSettingParam, options?: ConfigurationSettingOptions): Promise<PutKeyValueResponse>;
deleteConfigurationSetting(key: string, options: AppConfigurationDeleteKeyValueOptionalParams & ETagOption): Promise<DeleteKeyValueResponse>;
getConfigurationSetting(key: string, options?: AppConfigurationGetKeyValueOptionalParams): Promise<GetKeyValueResponse>;
listConfigurationSettings(options?: ListConfigurationSettingsOptions): Promise<ListConfigurationSettingsResponse>;
listRevisions(options?: ListRevisionsOptions): Promise<ListRevisionsResponse>;
setConfigurationSetting(key: string, configSettings: SetConfigurationSettingConfig, options?: SetConfigurationSettingOptions): Promise<SetConfigurationSettingResponse>;
}

// @public
export interface ConfigurationSettingList extends Array<ModelConfigurationSetting> {
// (undocumented)
items?: ModelConfigurationSetting[];
}

// @public (undocumented)
export type DeleteConfigurationSettingOptions = ModelConfigurationClientDeleteConfigurationSettingOptionalParams & ETagOption;

// @public (undocumented)
export type DeleteConfigurationSettingResponse = ModelDeleteConfigurationSettingResponse;

// @public (undocumented)
export interface ETagOption {
etag?: string;
}

// @public
export interface GetConfigurationSettingHeaders {
lastModifiedHeader: string;
listConfigurationSettingsNext(nextLink: string, options?: ListConfigurationSettingsOptions): Promise<ListConfigurationSettingsResponse>;
listRevisions(options?: AppConfigurationGetRevisionsOptionalParams): Promise<GetRevisionsResponse>;
setConfigurationSetting(configurationSetting: ConfigurationSettingParam & ETagOption, options?: ConfigurationSettingOptions): Promise<PutKeyValueResponse>;
}

// @public (undocumented)
export type GetConfigurationSettingOptions = ModelConfigurationClientGetConfigurationSettingOptionalParams;

// @public (undocumented)
export type GetConfigurationSettingResponse = ModelGetConfigurationSettingResponse;

// @public (undocumented)
export type ListConfigurationSettingsOptions = ModelConfigurationClientListConfigurationSettingsOptionalParams;

// @public (undocumented)
export type ListConfigurationSettingsResponse = ModelListConfigurationSettingsResponse;

// @public (undocumented)
export type ListRevisionsOptions = ModelConfigurationClientListRevisionsOptionalParams;

// @public (undocumented)
export type ListRevisionsResponse = ModelListRevisionsResponse;

// @public
export interface ModelConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase {
export interface AppConfigurationDeleteKeyValueOptionalParams extends coreHttp.RequestOptionsBase {
ifMatch?: string;
label?: string;
}

// @public
export interface ModelConfigurationClientDeleteConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase {
// (undocumented)
export interface AppConfigurationGetKeyValueOptionalParams extends coreHttp.RequestOptionsBase {
acceptDatetime?: string;
ifMatch?: string;
ifNoneMatch?: string;
label?: string;
select?: string[];
}

// @public
export interface ModelConfigurationClientGetConfigurationSettingOptionalParams extends coreHttp.RequestOptionsBase {
acceptDateTime?: Date;
export interface AppConfigurationGetKeyValuesOptionalParams extends coreHttp.RequestOptionsBase {
acceptDatetime?: string;
after?: string;
key?: string;
label?: string;
select?: string[];
}

// @public
export interface ModelConfigurationClientListConfigurationSettingsOptionalParams extends coreHttp.RequestOptionsBase {
acceptDateTime?: Date;
fields?: string[];
key?: string[];
label?: string[];
export interface AppConfigurationGetRevisionsOptionalParams extends coreHttp.RequestOptionsBase {
acceptDatetime?: string;
after?: string;
key?: string;
label?: string;
select?: string[];
}

// @public
export interface ModelConfigurationClientListRevisionsOptionalParams extends coreHttp.RequestOptionsBase {
acceptDateTime?: Date;
fields?: string[];
key?: string[];
label?: string[];
export interface AppConfigurationPutKeyValueOptionalParams extends coreHttp.RequestOptionsBase {
entity?: ConfigurationSetting;
ifMatch?: string;
ifNoneMatch?: string;
label?: string;
}

// @public
export interface ModelConfigurationSetting {
export interface ConfigurationSetting {
// (undocumented)
contentType?: string;
readonly etag?: string;
// (undocumented)
key?: string;
etag?: string;
// (undocumented)
key: string;
// (undocumented)
label?: string;
readonly lastModified?: Date;
readonly locked?: boolean;
// (undocumented)
lastModified?: Date;
// (undocumented)
locked?: boolean;
// (undocumented)
tags?: {
[propertyName: string]: string;
Expand All @@ -120,55 +84,76 @@ export interface ModelConfigurationSetting {
value?: string;
}

// @public
export type ModelCreateOrUpdateConfigurationSettingResponse = ModelConfigurationSetting & {
_response: coreHttp.HttpResponse & {
bodyAsText: string;
parsedBody: ModelConfigurationSetting;
};
};
// @public (undocumented)
export interface ConfigurationSettingOptions extends Pick<AppConfigurationPutKeyValueOptionalParams, Exclude<keyof AppConfigurationPutKeyValueOptionalParams, 'label' | 'entity'>> {
}

// @public
export type ModelDeleteConfigurationSettingResponse = ModelConfigurationSetting & {
_response: coreHttp.HttpResponse & {
bodyAsText: string;
parsedBody: ModelConfigurationSetting;
};
};
// @public (undocumented)
export interface ConfigurationSettingParam extends Pick<ConfigurationSetting, Exclude<keyof ConfigurationSetting, 'locked' | 'etag' | 'lastModified'>> {
}

// Warning: (ae-forgotten-export) The symbol "DeleteKeyValueHeaders" needs to be exported by the entry point index.d.ts
//
// @public
export type ModelGetConfigurationSettingResponse = ModelConfigurationSetting & GetConfigurationSettingHeaders & {
export type DeleteKeyValueResponse = ConfigurationSetting & DeleteKeyValueHeaders & {
_response: coreHttp.HttpResponse & {
parsedHeaders: GetConfigurationSettingHeaders;
parsedHeaders: DeleteKeyValueHeaders;
bodyAsText: string;
parsedBody: ModelConfigurationSetting;
parsedBody: ConfigurationSetting;
};
};

// @public (undocumented)
export interface ETagOption {
etag?: string;
}

// Warning: (ae-forgotten-export) The symbol "GetKeyValueHeaders" needs to be exported by the entry point index.d.ts
//
// @public
export type ModelListConfigurationSettingsResponse = ConfigurationSettingList & {
export type GetKeyValueResponse = ConfigurationSetting & GetKeyValueHeaders & {
_response: coreHttp.HttpResponse & {
parsedHeaders: GetKeyValueHeaders;
bodyAsText: string;
parsedBody: ConfigurationSettingList;
parsedBody: ConfigurationSetting;
};
};

// Warning: (ae-forgotten-export) The symbol "KeyValueListResult" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "GetRevisionsHeaders" needs to be exported by the entry point index.d.ts
//
// @public
export type ModelListRevisionsResponse = ConfigurationSettingList & {
export type GetRevisionsResponse = KeyValueListResult & GetRevisionsHeaders & {
_response: coreHttp.HttpResponse & {
parsedHeaders: GetRevisionsHeaders;
bodyAsText: string;
parsedBody: ConfigurationSettingList;
parsedBody: KeyValueListResult;
};
};

// @public (undocumented)
export type SetConfigurationSettingConfig = Pick<ModelConfigurationSetting, Exclude<keyof ModelConfigurationSetting, "key">>;
export interface ListConfigurationSettingsOptions extends Pick<AppConfigurationGetKeyValuesOptionalParams, Exclude<keyof AppConfigurationGetKeyValuesOptionalParams, 'key' | 'label' | 'select' | 'after'>> {
fields?: (keyof ConfigurationSetting)[];
keys?: string[];
labels?: string[];
}

// Warning: (ae-forgotten-export) The symbol "GetKeyValuesResponse" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type SetConfigurationSettingOptions = ModelConfigurationClientCreateOrUpdateConfigurationSettingOptionalParams;
export interface ListConfigurationSettingsResponse extends GetKeyValuesResponse {
}

// @public (undocumented)
export type SetConfigurationSettingResponse = ModelCreateOrUpdateConfigurationSettingResponse;
// Warning: (ae-forgotten-export) The symbol "PutKeyValueHeaders" needs to be exported by the entry point index.d.ts
//
// @public
export type PutKeyValueResponse = ConfigurationSetting & PutKeyValueHeaders & {
_response: coreHttp.HttpResponse & {
parsedHeaders: PutKeyValueHeaders;
bodyAsText: string;
parsedBody: ConfigurationSetting;
};
};


// (No @packageDocumentation comment for this package)
Expand Down
21 changes: 13 additions & 8 deletions sdk/appconfiguration/app-configuration/samples/helloworld.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// NOTE: replace with import { AppConfigurationClient } from "@azure/app-configuration"
// in a standalone project
import { AppConfigurationClient } from "../src"
Expand All @@ -9,19 +12,19 @@ export async function run() {
const connectionString = process.env["AZ_CONFIG_CONNECTION"]!;
const client = new AppConfigurationClient(connectionString);

const greetingKey = "Samples:Greeting";
const greetingKey = "Samples:Greeting";

await cleanupSampleValues([greetingKey], client);

// creating a new setting
console.log(`Adding in new setting ${greetingKey}`);
await client.addConfigurationSetting(greetingKey, { value: "Hello!" });
await client.addConfigurationSetting({ key: greetingKey, value: "Hello!" });

const newSetting = await client.getConfigurationSetting(greetingKey);
console.log(`${greetingKey} has been set to ${newSetting.value}`);

// changing the value of a setting
await client.setConfigurationSetting(greetingKey, { value: "Goodbye!" });
await client.setConfigurationSetting({ key: greetingKey, value: "Goodbye!" });

const updatedSetting = await client.getConfigurationSetting(greetingKey);
console.log(`${greetingKey} has been set to ${updatedSetting.value}`);
Expand All @@ -30,16 +33,18 @@ export async function run() {
await client.deleteConfigurationSetting(greetingKey, {});
console.log(`${greetingKey} has been deleted`);

await cleanupSampleValues([greetingKey], client);
await cleanupSampleValues([greetingKey], client);
}

async function cleanupSampleValues(keys: string[], client: AppConfigurationClient) {
const existingSettings = await client.listConfigurationSettings({
key: keys
keys: keys
});

for (const setting of existingSettings) {
await client.deleteConfigurationSetting(setting.key!, { label: setting.label });
if (existingSettings.items) {
for (const setting of existingSettings.items) {
await client.deleteConfigurationSetting(setting.key!, { label: setting.label });
}
}
}

Expand Down
Loading

0 comments on commit 60f4d2d

Please sign in to comment.