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

Fixes management support for AuthorizationRules #14865

Merged
merged 11 commits into from
Sep 9, 2020
Original file line number Diff line number Diff line change
@@ -1,284 +1,70 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.messaging.servicebus.administration.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;

import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;

/** The AuthorizationRule model. */
@JacksonXmlRootElement(
localName = "AuthorizationRule",
namespace = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect")
@Fluent
public final class AuthorizationRule {
/*
* The authorization type.
*/
@JacksonXmlProperty(localName = "type", isAttribute = true)
private String type;

/*
* The claim type.
*/
@JacksonXmlProperty(
localName = "ClaimType",
namespace = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect")
private String claimType;

/*
* The claim value.
*/
@JacksonXmlProperty(
localName = "ClaimValue",
namespace = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect")
private String claimValue;

private static final class RightsWrapper {
@JacksonXmlProperty(localName = "AccessRights")
private final List<AccessRights> items;

@JsonCreator
private RightsWrapper(@JacksonXmlProperty(localName = "AccessRights") List<AccessRights> items) {
this.items = items;
}
}

/*
* Access rights of the entity. Values are 'Send', 'Listen', or 'Manage'
*/
@JacksonXmlProperty(
localName = "Rights",
namespace = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect")
private RightsWrapper rights;

/*
* The date and time when the authorization rule was created.
*/
@JacksonXmlProperty(
localName = "CreatedTime",
namespace = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect")
private OffsetDateTime createdTime;

/*
* The date and time when the authorization rule was modified.
*/
@JacksonXmlProperty(
localName = "ModifiedTime",
namespace = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect")
private OffsetDateTime modifiedTime;

/*
* The authorization rule key name
*/
@JacksonXmlProperty(
localName = "KeyName",
namespace = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect")
private String keyName;

/*
* The primary key of the authorization rule
*/
@JacksonXmlProperty(
localName = "PrimaryKey",
namespace = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect")
private String primaryKey;

/*
* The primary key of the authorization rule
*/
@JacksonXmlProperty(
localName = "SecondaryKey",
namespace = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect")
private String secondaryKey;

/**
* Get the type property: The authorization type.
*
* @return the type value.
*/
public String getType() {
return this.type;
}

/**
* Set the type property: The authorization type.
*
* @param type the type value to set.
* @return the AuthorizationRule object itself.
*/
public AuthorizationRule setType(String type) {
this.type = type;
return this;
}

/**
* Get the claimType property: The claim type.
*
* @return the claimType value.
*/
public String getClaimType() {
return this.claimType;
}

/**
* Set the claimType property: The claim type.
*
* @param claimType the claimType value to set.
* @return the AuthorizationRule object itself.
*/
public AuthorizationRule setClaimType(String claimType) {
this.claimType = claimType;
return this;
}

/**
* Get the claimValue property: The claim value.
*
* @return the claimValue value.
*/
public String getClaimValue() {
return this.claimValue;
}

/**
* Set the claimValue property: The claim value.
*
* @param claimValue the claimValue value to set.
* @return the AuthorizationRule object itself.
*/
public AuthorizationRule setClaimValue(String claimValue) {
this.claimValue = claimValue;
return this;
}

/**
* Get the rights property: Access rights of the entity. Values are 'Send', 'Listen', or 'Manage'.
*
* @return the rights value.
*/
public List<AccessRights> getRights() {
if (this.rights == null) {
this.rights = new RightsWrapper(new ArrayList<AccessRights>());
}
return this.rights.items;
}

/**
* Set the rights property: Access rights of the entity. Values are 'Send', 'Listen', or 'Manage'.
*
* @param rights the rights value to set.
* @return the AuthorizationRule object itself.
*/
public AuthorizationRule setRights(List<AccessRights> rights) {
this.rights = new RightsWrapper(rights);
return this;
}

/**
* Get the createdTime property: The date and time when the authorization rule was created.
*
* @return the createdTime value.
*/
public OffsetDateTime getCreatedTime() {
return this.createdTime;
}

/**
* Set the createdTime property: The date and time when the authorization rule was created.
*
* @param createdTime the createdTime value to set.
* @return the AuthorizationRule object itself.
*/
public AuthorizationRule setCreatedTime(OffsetDateTime createdTime) {
this.createdTime = createdTime;
return this;
}

/**
* Represents an authorization rule to access Service Bus entities.
*
* @see SharedAccessAuthorizationRule
*/
public interface AuthorizationRule {
/**
* Get the modifiedTime property: The date and time when the authorization rule was modified.
* Gets the access rights for the rule.
*
* @return the modifiedTime value.
* @return The access rights for the rule.
*/
public OffsetDateTime getModifiedTime() {
return this.modifiedTime;
}
List<AccessRights> getAccessRights();

/**
* Set the modifiedTime property: The date and time when the authorization rule was modified.
* Gets the claim type.
*
* @param modifiedTime the modifiedTime value to set.
* @return the AuthorizationRule object itself.
* @return The claim type.
*/
public AuthorizationRule setModifiedTime(OffsetDateTime modifiedTime) {
this.modifiedTime = modifiedTime;
return this;
}
String getClaimType();

/**
* Get the keyName property: The authorization rule key name.
* Gets the claim value.
*
* @return the keyName value.
* @return The claim value.
*/
public String getKeyName() {
return this.keyName;
}
String getClaimValue();

/**
* Set the keyName property: The authorization rule key name.
* Gets the date time this rule was created.
*
* @param keyName the keyName value to set.
* @return the AuthorizationRule object itself.
* @return The date time this rule was created.
*/
public AuthorizationRule setKeyName(String keyName) {
this.keyName = keyName;
return this;
}
OffsetDateTime getCreatedAt();

/**
* Get the primaryKey property: The primary key of the authorization rule.
* Gets the name of the authorization rule.
*
* @return the primaryKey value.
* @return name of the authoriation rule.
*/
public String getPrimaryKey() {
return this.primaryKey;
}
String getKeyName();

/**
* Set the primaryKey property: The primary key of the authorization rule.
* Gets the date time this rule was last modified.
*
* @param primaryKey the primaryKey value to set.
* @return the AuthorizationRule object itself.
* @return The date time this rule was last modified.
*/
public AuthorizationRule setPrimaryKey(String primaryKey) {
this.primaryKey = primaryKey;
return this;
}
OffsetDateTime getModifiedAt();

/**
* Get the secondaryKey property: The primary key of the authorization rule.
* Gets the primary key.
*
* @return the secondaryKey value.
* @return The primary key.
*/
public String getSecondaryKey() {
return this.secondaryKey;
}
String getPrimaryKey();

/**
* Set the secondaryKey property: The primary key of the authorization rule.
* Gets the secondary key.
*
* @param secondaryKey the secondaryKey value to set.
* @return the AuthorizationRule object itself.
* @return The secondary key.
*/
public AuthorizationRule setSecondaryKey(String secondaryKey) {
this.secondaryKey = secondaryKey;
return this;
}
String getSecondaryKey();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.azure.messaging.servicebus.administration.ServiceBusAdministrationClient;

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import static com.azure.messaging.servicebus.implementation.ServiceBusConstants.DEFAULT_DUPLICATE_DETECTION_DURATION;
Expand All @@ -24,6 +26,8 @@
*/
@Fluent
public class CreateQueueOptions {
private final List<AuthorizationRule> authorizationRules;

private Duration autoDeleteOnIdle;
private Duration defaultMessageTimeToLive;
private boolean deadLetteringOnMessageExpiration;
Expand Down Expand Up @@ -62,6 +66,7 @@ public class CreateQueueOptions {
* @throws IllegalArgumentException if {@code queueName} is an empty string.
*/
public CreateQueueOptions() {
this.authorizationRules = new ArrayList<>();
this.autoDeleteOnIdle = MAX_DURATION;
this.defaultMessageTimeToLive = MAX_DURATION;
this.duplicateDetectionHistoryTimeWindow = DEFAULT_DUPLICATE_DETECTION_DURATION;
Expand All @@ -85,6 +90,7 @@ public CreateQueueOptions() {
public CreateQueueOptions(QueueProperties queue) {
Objects.requireNonNull(queue, "'queue' cannot be null.");

this.authorizationRules = new ArrayList<>(queue.getAuthorizationRules());
this.autoDeleteOnIdle = queue.getAutoDeleteOnIdle();
this.defaultMessageTimeToLive = queue.getDefaultMessageTimeToLive();

Expand All @@ -106,6 +112,15 @@ public CreateQueueOptions(QueueProperties queue) {
this.userMetadata = queue.getUserMetadata();
}

/**
* Gets the authorization rules to control user access at entity level.
*
* @return The authorization rules to control user access at entity level.
*/
public List<AuthorizationRule> getAuthorizationRules() {
return authorizationRules;
}

/**
* Get the autoDeleteOnIdle property: ISO 8601 timeSpan idle interval after which the queue is automatically
* deleted. The minimum duration is 5 minutes.
Expand Down
Loading