Skip to content

Commit

Permalink
CodeGen from PR 12951 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 639e4256631af60905b74c4791ea0746b9b04f58 into adf4870a5f77b950c953d7a8ad168cb00effa662
  • Loading branch information
SDKAuto committed Feb 25, 2021
1 parent cb09813 commit f13125f
Show file tree
Hide file tree
Showing 29 changed files with 638 additions and 46 deletions.
3 changes: 2 additions & 1 deletion sdk/postgresql/azure-resourcemanager-postgresql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release History

## 1.0.0-beta.2 (Unreleased)
## 1.0.0-beta.1 (2021-02-25)

- Azure Resource Manager PostgreSql client library for Java. This package contains Microsoft Azure SDK for PostgreSql Management SDK. The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, log files and configurations with new business model. Package tag package-2020-01-01. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt).

## 1.0.0-beta.1 (2020-12-16)

Expand Down
18 changes: 17 additions & 1 deletion sdk/postgresql/azure-resourcemanager-postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ Azure Resource Manager PostgreSql client library for Java.

This package contains Microsoft Azure SDK for PostgreSql Management SDK. The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security alert policies, log files and configurations with new business model. Package tag package-2020-01-01. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt).

## We'd love to hear your feedback

We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better.

If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together.

Thank you in advance for your collaboration. We really appreciate your time!

## Documentation

Various documentation is available to help you get started

- [API reference documentation][docs]

## Getting started

### Prerequisites
Expand All @@ -18,7 +32,7 @@ This package contains Microsoft Azure SDK for PostgreSql Management SDK. The Mic
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-postgresql</artifactId>
<version>1.0.0-beta.1</version>
<version>1.0.0-beta.2</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand Down Expand Up @@ -75,6 +89,8 @@ For details on contributing to this repository, see the [contributing guide](htt
1. Create new Pull Request

<!-- LINKS -->
[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS
[docs]: https://azure.github.io/azure-sdk-for-java/
[jdk]: https://docs.microsoft.com/java/azure/jdk/
[azure_subscription]: https://azure.microsoft.com/free/
[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/identity/azure-identity
Expand Down
5 changes: 5 additions & 0 deletions sdk/postgresql/azure-resourcemanager-postgresql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
<legal><![CDATA[[INFO] Any downloads listed may be third party software. Microsoft grants you no rights for third party software.]]></legal>
</properties>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.13.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-management</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,31 @@ public PostgreSqlManager authenticate(TokenCredential credential, AzureProfile p
Objects.requireNonNull(credential, "'credential' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");

StringBuilder userAgentBuilder = new StringBuilder();
userAgentBuilder
.append("azsdk-java")
.append("-")
.append("com.azure.resourcemanager.postgresql")
.append("/")
.append("1.0.0-beta.1");
if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) {
userAgentBuilder
.append(" (")
.append(Configuration.getGlobalConfiguration().get("java.version"))
.append("; ")
.append(Configuration.getGlobalConfiguration().get("os.name"))
.append("; ")
.append(Configuration.getGlobalConfiguration().get("os.version"))
.append("; auto-generated)");
} else {
userAgentBuilder.append(" (auto-generated)");
}

if (retryPolicy == null) {
retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS);
}
List<HttpPipelinePolicy> policies = new ArrayList<>();
policies
.add(
new UserAgentPolicy(
null,
"com.azure.resourcemanager.postgresql",
"1.0.0-beta.1",
Configuration.getGlobalConfiguration()));
policies.add(new UserAgentPolicy(userAgentBuilder.toString()));
policies.add(new RequestIdPolicy());
HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(retryPolicy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.Response;
import com.azure.core.management.polling.PollResult;
import com.azure.core.util.Context;
Expand Down Expand Up @@ -125,4 +126,32 @@ ServerSecurityAlertPolicyInner createOrUpdate(
SecurityAlertPolicyName securityAlertPolicyName,
ServerSecurityAlertPolicyInner parameters,
Context context);

/**
* Get the server's threat detection policies.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param serverName The name of the server.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the server's threat detection policies.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
PagedIterable<ServerSecurityAlertPolicyInner> listByServer(String resourceGroupName, String serverName);

/**
* Get the server's threat detection policies.
*
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param serverName The name of the server.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the server's threat detection policies.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
PagedIterable<ServerSecurityAlertPolicyInner> listByServer(
String resourceGroupName, String serverName, Context context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public Response<Configuration> getWithResponse(

public PagedIterable<Configuration> listByServer(String resourceGroupName, String serverName) {
PagedIterable<ConfigurationInner> inner = this.serviceClient().listByServer(resourceGroupName, serverName);
return inner.mapPage(inner1 -> new ConfigurationImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new ConfigurationImpl(inner1, this.manager()));
}

public PagedIterable<Configuration> listByServer(String resourceGroupName, String serverName, Context context) {
PagedIterable<ConfigurationInner> inner =
this.serviceClient().listByServer(resourceGroupName, serverName, context);
return inner.mapPage(inner1 -> new ConfigurationImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new ConfigurationImpl(inner1, this.manager()));
}

public Configuration getById(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
@HeaderParam("Accept") String accept,
Context context);

@Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"})
@Headers({"Content-Type: application/json"})
@Delete(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL"
+ "/servers/{serverName}/databases/{databaseName}")
Expand All @@ -97,6 +97,7 @@ Mono<Response<Flux<ByteBuffer>>> delete(
@PathParam("resourceGroupName") String resourceGroupName,
@PathParam("serverName") String serverName,
@PathParam("databaseName") String databaseName,
@HeaderParam("Accept") String accept,
Context context);

@Headers({"Content-Type: application/json"})
Expand Down Expand Up @@ -452,6 +453,7 @@ private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
return Mono.error(new IllegalArgumentException("Parameter databaseName is required and cannot be null."));
}
final String apiVersion = "2017-12-01";
final String accept = "application/json";
return FluxUtil
.withContext(
context ->
Expand All @@ -463,6 +465,7 @@ private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
resourceGroupName,
serverName,
databaseName,
accept,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
Expand Down Expand Up @@ -505,6 +508,7 @@ private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
return Mono.error(new IllegalArgumentException("Parameter databaseName is required and cannot be null."));
}
final String apiVersion = "2017-12-01";
final String accept = "application/json";
context = this.client.mergeContext(context);
return service
.delete(
Expand All @@ -514,6 +518,7 @@ private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
resourceGroupName,
serverName,
databaseName,
accept,
context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ public Response<Database> getWithResponse(

public PagedIterable<Database> listByServer(String resourceGroupName, String serverName) {
PagedIterable<DatabaseInner> inner = this.serviceClient().listByServer(resourceGroupName, serverName);
return inner.mapPage(inner1 -> new DatabaseImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new DatabaseImpl(inner1, this.manager()));
}

public PagedIterable<Database> listByServer(String resourceGroupName, String serverName, Context context) {
PagedIterable<DatabaseInner> inner = this.serviceClient().listByServer(resourceGroupName, serverName, context);
return inner.mapPage(inner1 -> new DatabaseImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new DatabaseImpl(inner1, this.manager()));
}

public Database getById(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
@HeaderParam("Accept") String accept,
Context context);

@Headers({"Accept: application/json;q=0.9", "Content-Type: application/json"})
@Headers({"Content-Type: application/json"})
@Delete(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL"
+ "/servers/{serverName}/firewallRules/{firewallRuleName}")
Expand All @@ -97,6 +97,7 @@ Mono<Response<Flux<ByteBuffer>>> delete(
@PathParam("resourceGroupName") String resourceGroupName,
@PathParam("serverName") String serverName,
@PathParam("firewallRuleName") String firewallRuleName,
@HeaderParam("Accept") String accept,
Context context);

@Headers({"Content-Type: application/json"})
Expand Down Expand Up @@ -475,6 +476,7 @@ private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
.error(new IllegalArgumentException("Parameter firewallRuleName is required and cannot be null."));
}
final String apiVersion = "2017-12-01";
final String accept = "application/json";
return FluxUtil
.withContext(
context ->
Expand All @@ -486,6 +488,7 @@ private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
resourceGroupName,
serverName,
firewallRuleName,
accept,
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
Expand Down Expand Up @@ -529,6 +532,7 @@ private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
.error(new IllegalArgumentException("Parameter firewallRuleName is required and cannot be null."));
}
final String apiVersion = "2017-12-01";
final String accept = "application/json";
context = this.client.mergeContext(context);
return service
.delete(
Expand All @@ -538,6 +542,7 @@ private Mono<Response<Flux<ByteBuffer>>> deleteWithResponseAsync(
resourceGroupName,
serverName,
firewallRuleName,
accept,
context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public Response<FirewallRule> getWithResponse(

public PagedIterable<FirewallRule> listByServer(String resourceGroupName, String serverName) {
PagedIterable<FirewallRuleInner> inner = this.serviceClient().listByServer(resourceGroupName, serverName);
return inner.mapPage(inner1 -> new FirewallRuleImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new FirewallRuleImpl(inner1, this.manager()));
}

public PagedIterable<FirewallRule> listByServer(String resourceGroupName, String serverName, Context context) {
PagedIterable<FirewallRuleInner> inner =
this.serviceClient().listByServer(resourceGroupName, serverName, context);
return inner.mapPage(inner1 -> new FirewallRuleImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new FirewallRuleImpl(inner1, this.manager()));
}

public FirewallRule getById(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public LocationBasedPerformanceTiersImpl(

public PagedIterable<PerformanceTierProperties> list(String locationName) {
PagedIterable<PerformanceTierPropertiesInner> inner = this.serviceClient().list(locationName);
return inner.mapPage(inner1 -> new PerformanceTierPropertiesImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new PerformanceTierPropertiesImpl(inner1, this.manager()));
}

public PagedIterable<PerformanceTierProperties> list(String locationName, Context context) {
PagedIterable<PerformanceTierPropertiesInner> inner = this.serviceClient().list(locationName, context);
return inner.mapPage(inner1 -> new PerformanceTierPropertiesImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new PerformanceTierPropertiesImpl(inner1, this.manager()));
}

private LocationBasedPerformanceTiersClient serviceClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public LogFilesImpl(LogFilesClient innerClient, PostgreSqlManager serviceManager

public PagedIterable<LogFile> listByServer(String resourceGroupName, String serverName) {
PagedIterable<LogFileInner> inner = this.serviceClient().listByServer(resourceGroupName, serverName);
return inner.mapPage(inner1 -> new LogFileImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new LogFileImpl(inner1, this.manager()));
}

public PagedIterable<LogFile> listByServer(String resourceGroupName, String serverName, Context context) {
PagedIterable<LogFileInner> inner = this.serviceClient().listByServer(resourceGroupName, serverName, context);
return inner.mapPage(inner1 -> new LogFileImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new LogFileImpl(inner1, this.manager()));
}

private LogFilesClient serviceClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public <T, U> Mono<U> getLroFinalResultOrError(AsyncPollResponse<PollResult<T>,
if (managementError.getCode() == null || managementError.getMessage() == null) {
managementError = null;
}
} catch (IOException ioe) {
} catch (IOException | RuntimeException ioe) {
logger.logThrowableAsWarning(ioe);
}
}
Expand Down Expand Up @@ -484,7 +484,7 @@ private static final class HttpResponseImpl extends HttpResponse {
super(null);
this.statusCode = statusCode;
this.httpHeaders = httpHeaders;
this.responseBody = responseBody.getBytes(StandardCharsets.UTF_8);
this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8);
}

public int getStatusCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public void delete(
public PagedIterable<PrivateEndpointConnection> listByServer(String resourceGroupName, String serverName) {
PagedIterable<PrivateEndpointConnectionInner> inner =
this.serviceClient().listByServer(resourceGroupName, serverName);
return inner.mapPage(inner1 -> new PrivateEndpointConnectionImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new PrivateEndpointConnectionImpl(inner1, this.manager()));
}

public PagedIterable<PrivateEndpointConnection> listByServer(
String resourceGroupName, String serverName, Context context) {
PagedIterable<PrivateEndpointConnectionInner> inner =
this.serviceClient().listByServer(resourceGroupName, serverName, context);
return inner.mapPage(inner1 -> new PrivateEndpointConnectionImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new PrivateEndpointConnectionImpl(inner1, this.manager()));
}

public PrivateEndpointConnection getById(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public PrivateLinkResourcesImpl(PrivateLinkResourcesClient innerClient, PostgreS
public PagedIterable<PrivateLinkResource> listByServer(String resourceGroupName, String serverName) {
PagedIterable<PrivateLinkResourceInner> inner =
this.serviceClient().listByServer(resourceGroupName, serverName);
return inner.mapPage(inner1 -> new PrivateLinkResourceImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new PrivateLinkResourceImpl(inner1, this.manager()));
}

public PagedIterable<PrivateLinkResource> listByServer(
String resourceGroupName, String serverName, Context context) {
PagedIterable<PrivateLinkResourceInner> inner =
this.serviceClient().listByServer(resourceGroupName, serverName, context);
return inner.mapPage(inner1 -> new PrivateLinkResourceImpl(inner1, this.manager()));
return Utils.mapPage(inner, inner1 -> new PrivateLinkResourceImpl(inner1, this.manager()));
}

public PrivateLinkResource get(String resourceGroupName, String serverName, String groupName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private interface ReplicasService {
@Headers({"Content-Type: application/json"})
@Get(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL"
+ "/servers/{serverName}/Replicas")
+ "/servers/{serverName}/replicas")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<ServerListResult>> listByServer(
Expand Down
Loading

0 comments on commit f13125f

Please sign in to comment.