Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateSnapshot Sample replaced with ReadOnly #6

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,15 @@ public void secretReferenceConfigurationSettingSample() {
}
}

/*
I've been unable to get the dependencies for CreateSnapshot, I suspect they're in the preview version
of the SDK. Once that is figured out this test should be able to be safely uncommented
@Test
public void createSnapshot() {
public void readOnly() {
try {
CreateSnapshot.main(appconfigEndpoint, clientSecretCredential);
ReadOnly.main(appconfigEndpoint, clientSecretCredential);
} catch (RuntimeException e) {
fail();
}
}
*/


@Test
public void conditionalRequestAsync() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.android.appconfiguration;

import android.util.Log;

import com.azure.data.appconfiguration.ConfigurationClient;
import com.azure.data.appconfiguration.ConfigurationClientBuilder;
import com.azure.data.appconfiguration.models.ConfigurationSetting;
import com.azure.identity.ClientSecretCredential;

/**
* Sample demonstrates how to set and clear read-only a configuration setting.
*/
public class ReadOnly {

private static final String TAG = "AppconfigReadOnlyOutput";
/**
* Runs the sample algorithm and demonstrates how to set and clear read-only a configuration setting.
*
*/
public static void main(String endpoint, ClientSecretCredential credential) {
// The connection string value can be obtained by going to your App Configuration instance in the Azure portal
// and navigating to "Access Keys" page under the "Settings" section.
final ConfigurationClient client = new ConfigurationClientBuilder()
.credential(credential)
.endpoint(endpoint)
.buildClient();

// Name of the key to add to the configuration service.
final String key = "hello";
final String value = "world";

final ConfigurationSetting setting = client.setConfigurationSetting(key, null, value);
// Read-Only
final ConfigurationSetting readOnlySetting = client.setReadOnly(setting.getKey(), setting.getLabel(), true);
Log.i(TAG, String.format("Setting is read-only now, Key: %s, Value: %s",
readOnlySetting.getKey(), readOnlySetting.getValue()));
// Clear Read-Only
final ConfigurationSetting clearedReadOnlySetting = client.setReadOnly(setting.getKey(), setting.getLabel(), false);
Log.i(TAG, String.format("Setting is no longer read-only, Key: %s, Value: %s",
clearedReadOnlySetting.getKey(), clearedReadOnlySetting.getValue()));
}
}