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

[AutoPR azure-resourcemanager-postgresql] DBForPostgreSQL fixing s360 violations #7233

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
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-01-29)

- 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
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 @@ -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 @@ -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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private interface ServerAdministratorsService {
@Headers({"Content-Type: application/json"})
@Get(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL"
+ "/servers/{serverName}/Administrators/activeDirectory")
+ "/servers/{serverName}/administrators/activeDirectory")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<ServerAdministratorResourceInner>> get(
Expand All @@ -86,7 +86,7 @@ Mono<Response<ServerAdministratorResourceInner>> get(
@Headers({"Content-Type: application/json"})
@Put(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL"
+ "/servers/{serverName}/Administrators/activeDirectory")
+ "/servers/{serverName}/administrators/activeDirectory")
@ExpectedResponses({200, 202})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
Expand All @@ -102,7 +102,7 @@ Mono<Response<Flux<ByteBuffer>>> createOrUpdate(
@Headers({"Content-Type: application/json"})
@Delete(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSQL"
+ "/servers/{serverName}/Administrators/activeDirectory")
+ "/servers/{serverName}/administrators/activeDirectory")
@ExpectedResponses({200, 202, 204})
@UnexpectedResponseExceptionType(ManagementException.class)
Mono<Response<Flux<ByteBuffer>>> delete(
Expand Down
Loading