Skip to content

Commit 82065d9

Browse files
authored
[AppConfig-V2] Add AppConfig V2 package to main branch (Azure#45076)
1 parent 4dfddfb commit 82065d9

File tree

77 files changed

+14075
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+14075
-0
lines changed

eng/versioning/version_client.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ com.azure.tools:azure-sdk-build-tool;1.0.0;1.1.0-beta.1
481481
com.azure.v2:azure-client-sdk-parent;2.0.0-beta.1;2.0.0-beta.1
482482
com.azure.v2:azure-core;2.0.0-beta.1;2.0.0-beta.1
483483
com.azure.v2:azure-core-test;2.0.0-beta.1;2.0.0-beta.1
484+
com.azure.v2:azure-data-appconfiguration;2.0.0-beta.1;2.0.0-beta.1
484485
com.azure.v2:azure-identity;2.0.0-beta.1;2.0.0-beta.1
485486
io.clientcore:clientcore-parent;1.0.0-beta.3;1.0.0-beta.3
486487
io.clientcore:core;1.0.0-beta.8;1.0.0-beta.9
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Release History
2+
3+
## 2.0.0-beta.1 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
### Bugs Fixed
10+
11+
### Other Changes
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Azure AppConfiguration client library for Java
2+
3+
## Getting started
4+
5+
## Key concepts
6+
7+
## Examples
8+
9+
## Troubleshooting
10+
11+
## Next steps
12+
13+
## Next steps Samples
14+
15+
## Contributing
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>com.azure</groupId>
9+
<artifactId>azure-code-customization-parent</artifactId>
10+
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-code-customization-parent;current} -->
11+
<relativePath>../../../parents/azure-code-customization-parent</relativePath>
12+
</parent>
13+
14+
<name>Microsoft Azure App Configuration client for Java</name>
15+
<description>This package contains client customization for Microsoft Azure App Configuration</description>
16+
17+
<groupId>com.azure.tools</groupId>
18+
<artifactId>azure-appconfiguration-customization</artifactId>
19+
<version>1.0.0-beta.1</version>
20+
<packaging>jar</packaging>
21+
</project>
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import com.azure.autorest.customization.ClassCustomization;
2+
import com.azure.autorest.customization.ConstructorCustomization;
3+
import com.azure.autorest.customization.Customization;
4+
import com.azure.autorest.customization.LibraryCustomization;
5+
import com.azure.autorest.customization.PackageCustomization;
6+
import com.azure.autorest.customization.JavadocCustomization;
7+
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
8+
import com.github.javaparser.ast.body.FieldDeclaration;
9+
import com.github.javaparser.StaticJavaParser;
10+
import com.github.javaparser.ast.Modifier;
11+
import com.github.javaparser.ast.NodeList;
12+
import com.github.javaparser.ast.body.Parameter;
13+
import com.github.javaparser.ast.stmt.BlockStmt;
14+
import org.slf4j.Logger;
15+
import java.util.Arrays;
16+
17+
/**
18+
* This class contains the customization code to customize the AutoRest generated code for OpenAI.
19+
*/
20+
public class AppConfigCustomizations extends Customization {
21+
22+
@Override
23+
public void customize(LibraryCustomization customization, Logger logger) {
24+
PackageCustomization models = customization.getPackage("com.azure.v2.data.appconfiguration.models");
25+
PackageCustomization appConfigPackages = customization.getPackage("com.azure.v2.data.appconfiguration");
26+
hideClient(appConfigPackages);
27+
hideModels(models);
28+
renameServiceVersionClassName(appConfigPackages);
29+
30+
// customizeKeyValueFilter(models.getClass("ConfigurationSettingsFilter"));
31+
// customizeKeyValueFields(models.getClass("SettingFields"));
32+
// customizeSnapshot(models.getClass("ConfigurationSnapshot"));
33+
}
34+
35+
private void hideModels(PackageCustomization models) {
36+
// TODO: move both 'Key' and 'KeyValue' class to implementation package
37+
models
38+
.getClass("Key")
39+
.setModifier(0);
40+
models
41+
.getClass("KeyValue")
42+
.setModifier(0);
43+
}
44+
45+
private void hideClient(PackageCustomization appConfigPackages) {
46+
// TODO: move both 'AzureAppConfigurationClient' and 'AzureAppConfigurationClientBuilder' class to implementation package
47+
appConfigPackages
48+
.getClass("AzureAppConfigurationClient")
49+
.setModifier(0);
50+
appConfigPackages
51+
.getClass("AzureAppConfigurationClientBuilder")
52+
.setModifier(0);
53+
}
54+
55+
private void renameServiceVersionClassName(PackageCustomization appConfigPackages) {
56+
appConfigPackages
57+
.getClass("AzureAppConfigurationServiceVersion")
58+
.rename("ConfigurationServiceVersion");
59+
}
60+
61+
// TODO: LRO is not support yet in codegen-v2, wait for codegen-v2 to support LRO
62+
// KeyValueFilter is used in LRO and no other place use it, so it is not generate setters.
63+
private void customizeKeyValueFilter(ClassCustomization classCustomization) {
64+
// Edit javadoc of `setLabel` method
65+
classCustomization.getMethod("setLabel")
66+
.getJavadoc()
67+
.setDescription("Set the label property: Filters {@link ConfigurationSetting} by their label field.");
68+
// Edit javadoc of `getKey` method
69+
classCustomization.getMethod("getKey")
70+
.getJavadoc()
71+
.setDescription("Get the key property: Filters {@link ConfigurationSetting} by their key field.");
72+
// Edit javadoc of `getLabel` method
73+
classCustomization.getMethod("getLabel")
74+
.getJavadoc()
75+
.setDescription("Get the label property: Filters {@link ConfigurationSetting} by their label field.");
76+
}
77+
78+
private void customizeSnapshot(ClassCustomization classCustomization) {
79+
classCustomization.customizeAst(ast -> {
80+
ast.addImport("java.time.Duration");
81+
82+
ast.getClassByName(classCustomization.getClassName()).ifPresent(clazz -> {
83+
// Transfer Long to Duration internally
84+
clazz.getMethodsByName("getRetentionPeriod").get(0)
85+
.setType("Duration")
86+
.setBody(StaticJavaParser.parseBlock("{ return this.retentionPeriod == null ? null : Duration.ofSeconds(this.retentionPeriod); }"));
87+
88+
clazz.getMethodsByName("setRetentionPeriod").get(0)
89+
.setParameter(0, new Parameter().setType("Duration").setName("retentionPeriod"))
90+
.setBody(StaticJavaParser.parseBlock("{ this.retentionPeriod = retentionPeriod == null ? null : retentionPeriod.getSeconds(); return this; }"));
91+
});
92+
});
93+
}
94+
95+
private void customizeKeyValueFields(ClassCustomization classCustomization) {
96+
classCustomization.customizeAst(ast -> {
97+
// Add imports required by class changes.
98+
ast.addImport("java.util.Locale");
99+
100+
ClassOrInterfaceDeclaration clazz = ast.getClassByName(classCustomization.getClassName()).get();
101+
102+
// Modify fromString() method
103+
104+
clazz.getMethodsByName("fromString").get(0)
105+
.setJavadocComment(StaticJavaParser.parseJavadoc(joinWithNewline(
106+
"Creates or finds a {@link SettingFields} from its string representation.",
107+
"@param name a name to look for.",
108+
"@return the corresponding {@link SettingFields}"
109+
)));
110+
111+
// Add class-level javadoc
112+
clazz.setJavadocComment(StaticJavaParser.parseJavadoc(joinWithNewline(
113+
"Fields in {@link ConfigurationSetting} that can be returned from GET queries.",
114+
"@see SettingSelector"
115+
)));
116+
117+
// Add toStringMapper static new method to SettingFields
118+
clazz.addMethod("toStringMapper", Modifier.Keyword.PUBLIC, Modifier.Keyword.STATIC).setType("String")
119+
.addParameter("SettingFields", "field")
120+
.setBody(new BlockStmt(new NodeList<>(StaticJavaParser.parseStatement("return field.toString().toLowerCase(Locale.US);"))))
121+
.addAnnotation(Deprecated.class)
122+
.setJavadocComment(StaticJavaParser.parseJavadoc(joinWithNewline(
123+
" * Converts the SettingFields to a string that is usable for HTTP requests and logging.",
124+
" * @param field SettingFields to map.",
125+
" * @return SettingFields as a lowercase string in the US locale.",
126+
" * @deprecated This method is no longer needed. SettingFields is using lower case enum value for the HTTP requests."
127+
)));
128+
});
129+
}
130+
131+
private static String joinWithNewline(String... lines) {
132+
return String.join("\n", lines);
133+
}
134+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<!--
2+
~ Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the MIT License.
4+
Code generated by Microsoft (R) TypeSpec Code Generator.
5+
-->
6+
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
7+
<modelVersion>4.0.0</modelVersion>
8+
<parent>
9+
<groupId>com.azure.v2</groupId>
10+
<artifactId>azure-client-sdk-parent</artifactId>
11+
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-client-sdk-parent;current} -->
12+
<relativePath>../../parents/azure-client-sdk-parent-v2</relativePath>
13+
</parent>
14+
15+
<groupId>com.azure.v2</groupId>
16+
<artifactId>azure-data-appconfiguration</artifactId>
17+
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-data-appconfiguration;current} -->
18+
<packaging>jar</packaging>
19+
20+
<name>Microsoft Azure client library for App Configuration</name>
21+
<description>This package contains the Microsoft Azure App Configuration client library.</description>
22+
<url>https://github.com/Azure/azure-sdk-for-java</url>
23+
24+
<licenses>
25+
<license>
26+
<name>The MIT License (MIT)</name>
27+
<url>http://opensource.org/licenses/MIT</url>
28+
<distribution>repo</distribution>
29+
</license>
30+
</licenses>
31+
32+
<scm>
33+
<url>https://github.com/Azure/azure-sdk-for-java</url>
34+
<connection>scm:git:[email protected]:Azure/azure-sdk-for-java.git</connection>
35+
<developerConnection>scm:git:[email protected]:Azure/azure-sdk-for-java.git</developerConnection>
36+
<tag>HEAD</tag>
37+
</scm>
38+
<developers>
39+
<developer>
40+
<id>microsoft</id>
41+
<name>Microsoft</name>
42+
</developer>
43+
</developers>
44+
<properties>
45+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
46+
<spotless.skip>false</spotless.skip>
47+
</properties>
48+
<dependencies>
49+
<dependency>
50+
<groupId>io.clientcore</groupId>
51+
<artifactId>core</artifactId>
52+
<version>1.0.0-beta.8</version> <!-- {x-version-update;io.clientcore:core;dependency} -->
53+
</dependency>
54+
<dependency>
55+
<groupId>com.azure.v2</groupId>
56+
<artifactId>azure-core</artifactId>
57+
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-core;dependency} -->
58+
</dependency>
59+
60+
<!-- Test scope -->
61+
<dependency>
62+
<groupId>com.azure.v2</groupId>
63+
<artifactId>azure-identity</artifactId>
64+
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-identity;dependency} -->
65+
<scope>test</scope>
66+
</dependency>
67+
68+
<dependency>
69+
<groupId>com.azure.v2</groupId>
70+
<artifactId>azure-core-test</artifactId>
71+
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure.v2:azure-core-test;dependency} -->
72+
<scope>test</scope>
73+
</dependency>
74+
75+
</dependencies>
76+
<build>
77+
<plugins>
78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-compiler-plugin</artifactId>
81+
<version>3.13.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-compiler-plugin;external_dependency} -->
82+
<executions>
83+
<execution>
84+
<id>run-annotation-processing</id>
85+
<phase>generate-sources</phase>
86+
<goals>
87+
<goal>compile</goal>
88+
</goals>
89+
<configuration>
90+
<source>1.8</source>
91+
<target>1.8</target>
92+
<release>8</release>
93+
<proc>only</proc>
94+
<generatedSourcesDirectory>${project.build.directory}/generated-sources/</generatedSourcesDirectory>
95+
<annotationProcessorPaths>
96+
<annotationProcessorPath>
97+
<groupId>io.clientcore</groupId>
98+
<artifactId>annotation-processor</artifactId>
99+
<version>1.0.0-beta.2</version> <!-- {x-version-update;io.clientcore:annotation-processor;dependency} -->
100+
</annotationProcessorPath>
101+
</annotationProcessorPaths>
102+
<annotationProcessors>
103+
<annotationProcessor>io.clientcore.annotation.processor.AnnotationProcessor</annotationProcessor>
104+
</annotationProcessors>
105+
<compilerArgs>
106+
<arg>-Xlint:-options</arg>
107+
</compilerArgs>
108+
<excludes>
109+
<exclude>module-info.java</exclude>
110+
</excludes>
111+
</configuration>
112+
</execution>
113+
</executions>
114+
<dependencies>
115+
<dependency>
116+
<groupId>io.clientcore</groupId>
117+
<artifactId>annotation-processor</artifactId>
118+
<version>1.0.0-beta.2</version> <!-- {x-version-update;io.clientcore:annotation-processor;dependency} -->
119+
</dependency>
120+
</dependencies>
121+
</plugin>
122+
</plugins>
123+
</build>
124+
</project>

0 commit comments

Comments
 (0)