Skip to content
Open
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
24 changes: 18 additions & 6 deletions sdk/tools/azure-openrewrite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.18.4.1</version> <!-- {x-version-update;com.fasterxml.jackson.core:jackson-core;external_dependency} -->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.18.4.1</version> <!-- {x-version-update;com.fasterxml.jackson.core:jackson-core;external_dependency} -->
</dependency>
<!-- Jackson Dataformat Smile -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-smile</artifactId>
<version>2.18.4</version> <!-- {x-version-update;com.fasterxml.jackson.dataformat:jackson-dataformat-smile;external_dependency} -->
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-smile</artifactId>
<version>2.18.4</version> <!-- {x-version-update;com.fasterxml.jackson.dataformat:jackson-dataformat-smile;external_dependency} -->
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down Expand Up @@ -276,6 +276,12 @@
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-core;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure.v2</groupId>
<artifactId>azure-data-appconfiguration</artifactId>
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-data-appconfiguration;dependency} -->
<scope>test</scope>
</dependency>
</dependencies>
</profile>

Expand Down Expand Up @@ -372,6 +378,12 @@
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-identity;dependency} -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.azure.v2</groupId>
<artifactId>azure-data-appconfiguration</artifactId>
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-data-appconfiguration;dependency} -->
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------
# Migration Recipes for Azure appconfiguration Library
# --------------------------------------------------------------------
type: specs.openrewrite.org/v1beta/recipe
name: com.azure.openrewrite.migration.data.appconfiguration
displayName: Migrate from azure-appconfiguration to next generation stack
description: This recipe migrates the Azure appconfiguration library to the next generation stack.
recipeList:

- com.azure.openrewrite.recipe.azure.data.appconfiguration
- com.azure.openrewrite.recipe.azure.data.appconfiguration.models
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------
# Migration Recipes for azure.core.credential
# --------------------------------------------------------------------
type: specs.openrewrite.org/v1beta/recipe
name: com.azure.openrewrite.recipe.azure.data.appconfiguration.models
displayName: Migrate from azure.data.appconfiguration.models to next generation stack
description: This recipe migrates the azure.data.appconfiguration.models package to the next generation stack.
recipeList:

# --------------------------------------------------------------------
# ConfigurationAudience
# --------------------------------------------------------------------



# --------------------------------------------------------------------
# ConfigurationSetting
# --------------------------------------------------------------------

- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.ConfigurationSetting
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.ConfigurationSetting

# --------------------------------------------------------------------
# SettingLabelSelector
# --------------------------------------------------------------------

- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.SettingLabelSelector
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.SettingLabelSelector

# --------------------------------------------------------------------
# ConfigurationSettingsFilter
# --------------------------------------------------------------------

- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.ConfigurationSettingsFilter
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.ConfigurationSettingsFilter

# --------------------------------------------------------------------
# ConfigurationSnapshot
# --------------------------------------------------------------------

- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.ConfigurationSnapshot
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.ConfigurationSnapshot

# --------------------------------------------------------------------
# ConfigurationSnapshotStatus
# --------------------------------------------------------------------



# --------------------------------------------------------------------
# FeatureFlagConfigurationSetting
# --------------------------------------------------------------------

- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.FeatureFlagConfigurationSetting
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.FeatureFlagConfigurationSetting

# --------------------------------------------------------------------
# FeatureFlagFilter
# --------------------------------------------------------------------

- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.FeatureFlagFilter
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.FeatureFlagFilter

# --------------------------------------------------------------------
# SecretReferenceConfigurationSetting
# --------------------------------------------------------------------

- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.SecretReferenceConfigurationSetting
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.SecretReferenceConfigurationSetting

# --------------------------------------------------------------------
# SettingFields
# --------------------------------------------------------------------



# --------------------------------------------------------------------
# SettingLabel
# --------------------------------------------------------------------



# --------------------------------------------------------------------
# SettingLabelFields
# --------------------------------------------------------------------



# --------------------------------------------------------------------
# SettingLabelSelector
# --------------------------------------------------------------------



# --------------------------------------------------------------------
# SettingSelector
# --------------------------------------------------------------------

- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.models.SettingSelector
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.models.SettingSelector

# --------------------------------------------------------------------
# SnapshotComposition
# --------------------------------------------------------------------



# --------------------------------------------------------------------
# SnapshotFields
# --------------------------------------------------------------------



# --------------------------------------------------------------------
# SnapshotSelector
# --------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
type: specs.openrewrite.org/v1beta/recipe
name: com.azure.openrewrite.recipe.azure.data.appconfiguration
displayName: Migrate from azure.data.appconfiguration to next generation stack
description: This recipe migrates the azure.data.appconfiguration package to the next generation stack.
recipeList:



# --------------------------------------------------------------------
# ConfigurationAsyncClient
# --------------------------------------------------------------------





# --------------------------------------------------------------------
# ConfigurationClient
# --------------------------------------------------------------------

- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.ConfigurationClient
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.ConfigurationClient


# --------------------------------------------------------------------
# ConfigurationClientBuilder
# --------------------------------------------------------------------

- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.azure.data.appconfiguration.ConfigurationClientBuilder
newFullyQualifiedTypeName: com.azure.v2.data.appconfiguration.ConfigurationClientBuilder


# --------------------------------------------------------------------
# ConfigurationServiceVersion
# --------------------------------------------------------------------


Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ recipeList:
# Code Migration Recipes
- com.azure.openrewrite.migration.core
- com.azure.openrewrite.migration.identity
- com.azure.openrewrite.migration.data.appconfiguration

# Code Styling recipes
- org.openrewrite.java.OrderImports:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.data.appconfiguration;

import com.azure.data.appconfiguration.ConfigurationClient;
import com.azure.data.appconfiguration.ConfigurationClientBuilder;
import com.azure.data.appconfiguration.models.ConfigurationSetting;
import com.azure.identity.DefaultAzureCredential;
import com.azure.identity.DefaultAzureCredentialBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.data.appconfiguration;

import com.azure.data.appconfiguration.models.ConfigurationSetting;
import com.azure.identity.DefaultAzureCredential;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.v2.data.appconfiguration.ConfigurationClient;
import com.azure.v2.data.appconfiguration.ConfigurationClientBuilder;
import com.azure.v2.data.appconfiguration.models.ConfigurationSetting;
import com.azure.v2.identity.DefaultAzureCredential;
import com.azure.v2.identity.DefaultAzureCredentialBuilder;

/**
* Sample demonstrates how to use AAD token to build a configuration client.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.data.appconfiguration;

import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.data.appconfiguration.models.ConfigurationSetting;
import com.azure.data.appconfiguration.ConfigurationClient;
import com.azure.data.appconfiguration.ConfigurationClientBuilder;

/**
* Sample demonstrates how to add, get, and delete a configuration setting by conditional request.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.data.appconfiguration;

import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.data.appconfiguration.models.ConfigurationSetting;
import com.azure.v2.data.appconfiguration.ConfigurationClient;
import com.azure.v2.data.appconfiguration.ConfigurationClientBuilder;
import com.azure.v2.data.appconfiguration.models.ConfigurationSetting;
import io.clientcore.core.http.models.RequestContext;
import io.clientcore.core.http.models.Response;

/**
* Sample demonstrates how to add, get, and delete a configuration setting by conditional request.
Expand All @@ -31,21 +31,21 @@ public static void main(String[] args) {
// given setting matches the one in the service, then the setting is updated. Otherwise, it is
// not updated.
// If the given setting is not exist in the service, the setting will be added to the service.
Response<ConfigurationSetting> settingResponse = client.setConfigurationSettingWithResponse(setting, true, Context.NONE);
Response<ConfigurationSetting> settingResponse = client.setConfigurationSettingWithResponse(setting, true, RequestContext.none());
System.out.printf("Status code: %s, Key: %s, Value: %s", settingResponse.getStatusCode(),
settingResponse.getValue().getKey(), settingResponse.getValue().getValue());

// If you want to conditionally retrieve the setting, set `ifChanged` to true. If the ETag of the
// given setting matches the one in the service, then 304 status code with null value returned in the response.
// Otherwise, a setting with new ETag returned, which is the latest setting retrieved from the service.
settingResponse = client.getConfigurationSettingWithResponse(setting, null, true, Context.NONE);
settingResponse = client.getConfigurationSettingWithResponse(setting, null, true, RequestContext.none());
System.out.printf("Status code: %s, Key: %s, Value: %s", settingResponse.getStatusCode(),
settingResponse.getValue().getKey(), settingResponse.getValue().getValue());

// If you want to conditionally delete the setting, set `ifUnchanged` to true. If the ETag of the
// given setting matches the one in the service, then the setting is deleted. Otherwise, it is
// not deleted.
client.deleteConfigurationSettingWithResponse(settingResponse.getValue(), true, Context.NONE);
client.deleteConfigurationSettingWithResponse(settingResponse.getValue(), true, RequestContext.none());
System.out.printf("Status code: %s, Key: %s, Value: %s", settingResponse.getStatusCode(),
settingResponse.getValue().getKey(), settingResponse.getValue().getValue());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.data.appconfiguration;

import com.azure.core.http.HttpHeaderName;
import com.azure.core.http.MatchConditions;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Configuration;
import com.azure.data.appconfiguration.models.ConfigurationSetting;
import com.azure.data.appconfiguration.models.SettingSelector;
import com.azure.data.appconfiguration.ConfigurationClient;
import com.azure.data.appconfiguration.ConfigurationClientBuilder;

import java.util.List;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.data.appconfiguration;

import com.azure.core.http.HttpHeaderName;
import com.azure.core.http.MatchConditions;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Configuration;
import com.azure.data.appconfiguration.models.ConfigurationSetting;
import com.azure.data.appconfiguration.models.SettingSelector;
import com.azure.v2.data.appconfiguration.ConfigurationClient;
import com.azure.v2.data.appconfiguration.ConfigurationClientBuilder;
import com.azure.v2.data.appconfiguration.models.ConfigurationSetting;
import com.azure.v2.data.appconfiguration.models.SettingSelector;
import io.clientcore.core.http.models.HttpHeaderName;
import io.clientcore.core.http.models.HttpMatchConditions;
import io.clientcore.core.http.paging.PagedIterable;
import io.clientcore.core.utils.configuration.Configuration;

import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -32,20 +32,20 @@ public static void main(String[] args) {

// Instantiate a client that will be used to call the service.
ConfigurationClient client = new ConfigurationClientBuilder()
.connectionString(connectionString)
.buildClient();
.connectionString(connectionString)
.buildClient();

// list all settings and get their page ETags
List<MatchConditions> matchConditionsList = client.listConfigurationSettings(null)
.streamByPage()
.collect(Collectors.toList())
.stream()
.map(pagedResponse -> new MatchConditions().setIfNoneMatch(
pagedResponse.getHeaders().getValue(HttpHeaderName.ETAG)))
.collect(Collectors.toList());
List<HttpMatchConditions> matchConditionsList = client.listConfigurationSettings(null)
.streamByPage()
.collect(Collectors.toList())
.stream()
.map(pagedResponse -> new HttpMatchConditions().setIfNoneMatch(
pagedResponse.getHeaders().getValue(HttpHeaderName.ETAG)))
.collect(Collectors.toList());

PagedIterable<ConfigurationSetting> settings = client.listConfigurationSettings(
new SettingSelector().setMatchConditions(matchConditionsList));
new SettingSelector().setMatchConditions(matchConditionsList));

settings.iterableByPage().forEach(pagedResponse -> {
int statusCode = pagedResponse.getStatusCode();
Expand Down
Loading
Loading