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 eventhub/resource-manager] EventHub: Added NetwrokruleSet API #3087

Merged
merged 3 commits into from
Mar 20, 2019
Merged
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 @@ -11,7 +11,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The response from the List namespace operation.
* Description of NetWorkRuleSet - IpRules resource.
*/
public class NWRuleSetIpRules {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The response from the List namespace operation.
* Description of VirtualNetworkRules - NetworkRules resource.
*/
public class NWRuleSetVirtualNetworkRules {
/**
Expand All @@ -21,7 +21,7 @@ public class NWRuleSetVirtualNetworkRules {
private Subnet subnet;

/**
* Value that indicates whether to ignore missing Vnet Service Endpoint.
* Value that indicates whether to ignore missing VNet Service Endpoint.
*/
@JsonProperty(value = "ignoreMissingVnetServiceEndpoint")
private Boolean ignoreMissingVnetServiceEndpoint;
Expand All @@ -47,7 +47,7 @@ public NWRuleSetVirtualNetworkRules withSubnet(Subnet subnet) {
}

/**
* Get value that indicates whether to ignore missing Vnet Service Endpoint.
* Get value that indicates whether to ignore missing VNet Service Endpoint.
*
* @return the ignoreMissingVnetServiceEndpoint value
*/
Expand All @@ -56,7 +56,7 @@ public Boolean ignoreMissingVnetServiceEndpoint() {
}

/**
* Set value that indicates whether to ignore missing Vnet Service Endpoint.
* Set value that indicates whether to ignore missing VNet Service Endpoint.
*
* @param ignoreMissingVnetServiceEndpoint the ignoreMissingVnetServiceEndpoint value to set
* @return the NWRuleSetVirtualNetworkRules object itself.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.microsoft.azure.arm.model.HasInner;
import com.microsoft.azure.management.eventhub.v2017_04_01.NamespaceAuthorizationRule;
import rx.Completable;
import com.microsoft.azure.management.eventhub.v2017_04_01.implementation.NetworkRuleSetInner;

/**
* Type representing Namespaces.
Expand Down Expand Up @@ -105,4 +106,25 @@ public interface Namespaces extends SupportsCreating<EHNamespace.DefinitionStage
*/
Observable<AccessKeys> regenerateKeysAsync(String resourceGroupName, String namespaceName, String authorizationRuleName, RegenerateAccessKeyParameters parameters);

/**
* Create or update NetworkRuleSet for a Namespace.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @param parameters The Namespace IpFilterRule.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<NetworkRuleSet> createOrUpdateNetworkRuleSetAsync(String resourceGroupName, String namespaceName, NetworkRuleSetInner parameters);

/**
* Gets NetworkRuleSet for a Namespace.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<NetworkRuleSet> getNetworkRuleSetAsync(String resourceGroupName, String namespaceName);

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Subnet {
/**
* Resource ID of Virtual Network Subnet.
*/
@JsonProperty(value = "id")
@JsonProperty(value = "id", required = true)
private String id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.microsoft.azure.management.eventhub.v2017_04_01.NamespaceAuthorizationRule;
import com.microsoft.azure.management.eventhub.v2017_04_01.AccessKeys;
import com.microsoft.azure.management.eventhub.v2017_04_01.RegenerateAccessKeyParameters;
import com.microsoft.azure.management.eventhub.v2017_04_01.NetworkRuleSet;

class NamespacesImpl extends GroupableResourcesCoreImpl<EHNamespace, EHNamespaceImpl, EHNamespaceInner, NamespacesInner, EventHubManager> implements Namespaces {
protected NamespacesImpl(EventHubManager manager) {
Expand Down Expand Up @@ -245,4 +246,28 @@ public AccessKeys call(AccessKeysInner inner) {
});
}

@Override
public Observable<NetworkRuleSet> createOrUpdateNetworkRuleSetAsync(String resourceGroupName, String namespaceName, NetworkRuleSetInner parameters) {
NamespacesInner client = this.inner();
return client.createOrUpdateNetworkRuleSetAsync(resourceGroupName, namespaceName, parameters)
.map(new Func1<NetworkRuleSetInner, NetworkRuleSet>() {
@Override
public NetworkRuleSet call(NetworkRuleSetInner inner) {
return new NetworkRuleSetImpl(inner, manager());
}
});
}

@Override
public Observable<NetworkRuleSet> getNetworkRuleSetAsync(String resourceGroupName, String namespaceName) {
NamespacesInner client = this.inner();
return client.getNetworkRuleSetAsync(resourceGroupName, namespaceName)
.map(new Func1<NetworkRuleSetInner, NetworkRuleSet>() {
@Override
public NetworkRuleSet call(NetworkRuleSetInner inner) {
return new NetworkRuleSetImpl(inner, manager());
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ interface NamespacesService {
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys")
Observable<Response<ResponseBody>> regenerateKeys(@Path("resourceGroupName") String resourceGroupName, @Path("namespaceName") String namespaceName, @Path("authorizationRuleName") String authorizationRuleName, @Path("subscriptionId") String subscriptionId, @Body RegenerateAccessKeyParameters parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.eventhub.v2017_04_01.Namespaces createOrUpdateNetworkRuleSet" })
@PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/networkRuleSets/default")
Observable<Response<ResponseBody>> createOrUpdateNetworkRuleSet(@Path("resourceGroupName") String resourceGroupName, @Path("namespaceName") String namespaceName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Body NetworkRuleSetInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.eventhub.v2017_04_01.Namespaces getNetworkRuleSet" })
@GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/networkRuleSets/default")
Observable<Response<ResponseBody>> getNetworkRuleSet(@Path("resourceGroupName") String resourceGroupName, @Path("namespaceName") String namespaceName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.eventhub.v2017_04_01.Namespaces listNext" })
@GET
Observable<Response<ResponseBody>> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
Expand Down Expand Up @@ -1653,6 +1661,186 @@ private ServiceResponse<AccessKeysInner> regenerateKeysDelegate(Response<Respons
.build(response);
}

/**
* Create or update NetworkRuleSet for a Namespace.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @param parameters The Namespace IpFilterRule.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the NetworkRuleSetInner object if successful.
*/
public NetworkRuleSetInner createOrUpdateNetworkRuleSet(String resourceGroupName, String namespaceName, NetworkRuleSetInner parameters) {
return createOrUpdateNetworkRuleSetWithServiceResponseAsync(resourceGroupName, namespaceName, parameters).toBlocking().single().body();
}

/**
* Create or update NetworkRuleSet for a Namespace.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @param parameters The Namespace IpFilterRule.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
public ServiceFuture<NetworkRuleSetInner> createOrUpdateNetworkRuleSetAsync(String resourceGroupName, String namespaceName, NetworkRuleSetInner parameters, final ServiceCallback<NetworkRuleSetInner> serviceCallback) {
return ServiceFuture.fromResponse(createOrUpdateNetworkRuleSetWithServiceResponseAsync(resourceGroupName, namespaceName, parameters), serviceCallback);
}

/**
* Create or update NetworkRuleSet for a Namespace.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @param parameters The Namespace IpFilterRule.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the NetworkRuleSetInner object
*/
public Observable<NetworkRuleSetInner> createOrUpdateNetworkRuleSetAsync(String resourceGroupName, String namespaceName, NetworkRuleSetInner parameters) {
return createOrUpdateNetworkRuleSetWithServiceResponseAsync(resourceGroupName, namespaceName, parameters).map(new Func1<ServiceResponse<NetworkRuleSetInner>, NetworkRuleSetInner>() {
@Override
public NetworkRuleSetInner call(ServiceResponse<NetworkRuleSetInner> response) {
return response.body();
}
});
}

/**
* Create or update NetworkRuleSet for a Namespace.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @param parameters The Namespace IpFilterRule.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the NetworkRuleSetInner object
*/
public Observable<ServiceResponse<NetworkRuleSetInner>> createOrUpdateNetworkRuleSetWithServiceResponseAsync(String resourceGroupName, String namespaceName, NetworkRuleSetInner parameters) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (namespaceName == null) {
throw new IllegalArgumentException("Parameter namespaceName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
if (parameters == null) {
throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
}
Validator.validate(parameters);
return service.createOrUpdateNetworkRuleSet(resourceGroupName, namespaceName, this.client.subscriptionId(), this.client.apiVersion(), parameters, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<NetworkRuleSetInner>>>() {
@Override
public Observable<ServiceResponse<NetworkRuleSetInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<NetworkRuleSetInner> clientResponse = createOrUpdateNetworkRuleSetDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}

private ServiceResponse<NetworkRuleSetInner> createOrUpdateNetworkRuleSetDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<NetworkRuleSetInner, ErrorResponseException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<NetworkRuleSetInner>() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}

/**
* Gets NetworkRuleSet for a Namespace.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the NetworkRuleSetInner object if successful.
*/
public NetworkRuleSetInner getNetworkRuleSet(String resourceGroupName, String namespaceName) {
return getNetworkRuleSetWithServiceResponseAsync(resourceGroupName, namespaceName).toBlocking().single().body();
}

/**
* Gets NetworkRuleSet for a Namespace.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
public ServiceFuture<NetworkRuleSetInner> getNetworkRuleSetAsync(String resourceGroupName, String namespaceName, final ServiceCallback<NetworkRuleSetInner> serviceCallback) {
return ServiceFuture.fromResponse(getNetworkRuleSetWithServiceResponseAsync(resourceGroupName, namespaceName), serviceCallback);
}

/**
* Gets NetworkRuleSet for a Namespace.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the NetworkRuleSetInner object
*/
public Observable<NetworkRuleSetInner> getNetworkRuleSetAsync(String resourceGroupName, String namespaceName) {
return getNetworkRuleSetWithServiceResponseAsync(resourceGroupName, namespaceName).map(new Func1<ServiceResponse<NetworkRuleSetInner>, NetworkRuleSetInner>() {
@Override
public NetworkRuleSetInner call(ServiceResponse<NetworkRuleSetInner> response) {
return response.body();
}
});
}

/**
* Gets NetworkRuleSet for a Namespace.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the NetworkRuleSetInner object
*/
public Observable<ServiceResponse<NetworkRuleSetInner>> getNetworkRuleSetWithServiceResponseAsync(String resourceGroupName, String namespaceName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (namespaceName == null) {
throw new IllegalArgumentException("Parameter namespaceName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
return service.getNetworkRuleSet(resourceGroupName, namespaceName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<NetworkRuleSetInner>>>() {
@Override
public Observable<ServiceResponse<NetworkRuleSetInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<NetworkRuleSetInner> clientResponse = getNetworkRuleSetDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}

private ServiceResponse<NetworkRuleSetInner> getNetworkRuleSetDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<NetworkRuleSetInner, ErrorResponseException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<NetworkRuleSetInner>() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}

/**
* Lists all the available Namespaces within a subscription, irrespective of the resource groups.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.microsoft.azure.ProxyResource;

/**
* Description of topic resource.
* Description of NetworkRuleSet resource.
*/
@JsonFlatten
public class NetworkRuleSetInner extends ProxyResource {
Expand Down