Skip to content

Commit

Permalink
Generated from a0fcdf6dd585c7663d3d5bf86941f129a799eaf0 (#2379)
Browse files Browse the repository at this point in the history
Updating 'required' fields in RA request body to match existing stable API requirements
  • Loading branch information
AutorestCI authored Sep 11, 2018
1 parent a3532a1 commit 2379d59
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 162 deletions.
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

0 comments on commit 2379d59

Please sign in to comment.