Skip to content
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 @@ -44,7 +44,7 @@ public interface RoleAssignment extends HasInner<RoleAssignmentInner>, Indexable
/**
* The entirety of the RoleAssignment definition.
*/
interface Definition extends DefinitionStages.Blank, DefinitionStages.WithProvider, DefinitionStages.WithScope, DefinitionStages.WithCreate {
interface Definition extends DefinitionStages.Blank, DefinitionStages.WithProvider, DefinitionStages.WithScope, DefinitionStages.WithProperties, DefinitionStages.WithCreate {
}

/**
Expand Down Expand Up @@ -74,7 +74,17 @@ interface WithScope {
/**
* Specifies scope.
*/
WithCreate withScope(String scope);
WithProperties withScope(String scope);
}

/**
* The stage of the roleassignment definition allowing to specify Properties.
*/
interface WithProperties {
/**
* Specifies properties.
*/
WithCreate withProperties(RoleAssignmentProperties properties);
}

/**
Expand All @@ -88,12 +98,22 @@ interface WithCreate extends Creatable<RoleAssignment> {
/**
* The template for a RoleAssignment update operation, containing all the settings that can be modified.
*/
interface Update extends Appliable<RoleAssignment> {
interface Update extends Appliable<RoleAssignment>, UpdateStages.WithProperties {
}

/**
* Grouping of RoleAssignment update stages.
*/
interface UpdateStages {
/**
* The stage of the roleassignment update allowing to specify Properties.
*/
interface WithProperties {
/**
* Specifies properties.
*/
Update withProperties(RoleAssignmentProperties properties);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class RoleAssignmentCreateParameters {
/**
* Role assignment properties.
*/
@JsonProperty(value = "properties")
@JsonProperty(value = "properties", required = true)
private RoleAssignmentProperties properties;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public class RoleAssignmentProperties {
/**
* The role definition ID used in the role assignment.
*/
@JsonProperty(value = "roleDefinitionId")
@JsonProperty(value = "roleDefinitionId", required = true)
private String roleDefinitionId;

/**
* The principal ID assigned to the role. This maps to the ID inside the
* Active Directory. It can point to a user, service principal, or security
* group.
*/
@JsonProperty(value = "principalId")
@JsonProperty(value = "principalId", required = true)
private String principalId;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ public interface RoleAssignments extends SupportsCreating<RoleAssignment.Definit
* Creates a role assignment by ID.
*
* @param roleAssignmentId The fully qualified ID of the role assignment, including the scope, resource name and resource type. Use the format, /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/{subId}/resourcegroups/{rgname}//providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}.
* @param properties Role assignment properties.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
Observable<RoleAssignment> createByIdAsync(String roleAssignmentId);
Observable<RoleAssignment> createByIdAsync(String roleAssignmentId, RoleAssignmentProperties properties);

/**
* Gets a role assignment by ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@
import com.microsoft.azure.management.authorization.v2015_07_01.RoleAssignment;
import com.microsoft.azure.arm.model.implementation.CreatableUpdatableImpl;
import rx.Observable;
import com.microsoft.azure.management.authorization.v2015_07_01.RoleAssignmentProperties;
import com.microsoft.azure.management.authorization.v2015_07_01.RoleAssignmentPropertiesWithScope;
import rx.functions.Func1;

class RoleAssignmentImpl extends CreatableUpdatableImpl<RoleAssignment, RoleAssignmentInner, RoleAssignmentImpl> implements RoleAssignment, RoleAssignment.Definition, RoleAssignment.Update {
private final AuthorizationManager manager;
private String scope;
private String roleAssignmentName;
private RoleAssignmentProperties cproperties;
private RoleAssignmentProperties uproperties;

RoleAssignmentImpl(String name, AuthorizationManager manager) {
super(name, new RoleAssignmentInner());
this.manager = manager;
// Set resource name
this.roleAssignmentName = name;
//
this.cproperties = new RoleAssignmentProperties();
this.uproperties = new RoleAssignmentProperties();
}

RoleAssignmentImpl(RoleAssignmentInner inner, AuthorizationManager manager) {
Expand All @@ -35,6 +41,8 @@ class RoleAssignmentImpl extends CreatableUpdatableImpl<RoleAssignment, RoleAssi
this.roleAssignmentName = IdParsingUtils.getValueFromIdByName(inner.id(), "roleAssignments");
this.scope = IdParsingUtils.getValueFromIdByPosition(inner.id(), 0);
//
this.cproperties = new RoleAssignmentProperties();
this.uproperties = new RoleAssignmentProperties();
}

@Override
Expand All @@ -45,14 +53,28 @@ public AuthorizationManager manager() {
@Override
public Observable<RoleAssignment> createResourceAsync() {
RoleAssignmentsInner client = this.manager().inner().roleAssignments();
return client.createAsync(this.scope, this.roleAssignmentName)
return client.createAsync(this.scope, this.roleAssignmentName, this.cproperties)
.map(new Func1<RoleAssignmentInner, RoleAssignmentInner>() {
@Override
public RoleAssignmentInner call(RoleAssignmentInner resource) {
resetCreateUpdateParameters();
return resource;
}
})
.map(innerToFluentMap(this));
}

@Override
public Observable<RoleAssignment> updateResourceAsync() {
RoleAssignmentsInner client = this.manager().inner().roleAssignments();
return client.createAsync(this.scope, this.roleAssignmentName)
return client.createAsync(this.scope, this.roleAssignmentName, this.uproperties)
.map(new Func1<RoleAssignmentInner, RoleAssignmentInner>() {
@Override
public RoleAssignmentInner call(RoleAssignmentInner resource) {
resetCreateUpdateParameters();
return resource;
}
})
.map(innerToFluentMap(this));
}

Expand All @@ -67,6 +89,10 @@ public boolean isInCreateMode() {
return this.inner().id() == null;
}

private void resetCreateUpdateParameters() {
this.cproperties = new RoleAssignmentProperties();
this.uproperties = new RoleAssignmentProperties();
}

@Override
public String id() {
Expand Down Expand Up @@ -99,4 +125,14 @@ public RoleAssignmentImpl withScope(String scope) {
return this;
}

@Override
public RoleAssignmentImpl withProperties(RoleAssignmentProperties properties) {
if (isInCreateMode()) {
this.cproperties = properties;
} else {
this.uproperties = properties;
}
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import rx.Observable;
import com.microsoft.azure.Page;
import com.microsoft.azure.management.authorization.v2015_07_01.RoleAssignment;
import com.microsoft.azure.management.authorization.v2015_07_01.RoleAssignmentProperties;

class RoleAssignmentsImpl extends WrapperImpl<RoleAssignmentsInner> implements RoleAssignments {
private final AuthorizationManager manager;
Expand Down Expand Up @@ -96,9 +97,9 @@ public RoleAssignment call(RoleAssignmentInner inner) {
}

@Override
public Observable<RoleAssignment> createByIdAsync(String roleAssignmentId) {
public Observable<RoleAssignment> createByIdAsync(String roleAssignmentId, RoleAssignmentProperties properties) {
RoleAssignmentsInner client = this.inner();
return client.createByIdAsync(roleAssignmentId)
return client.createByIdAsync(roleAssignmentId, properties)
.map(new Func1<RoleAssignmentInner, RoleAssignment>() {
@Override
public RoleAssignment call(RoleAssignmentInner inner) {
Expand Down
Loading