
odata.msgraph.client.entity.OAuth2PermissionGrant Maven / Gradle / Ivy
package odata.msgraph.client.entity;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.github.davidmoten.odata.client.ClientException;
import com.github.davidmoten.odata.client.NameValue;
import com.github.davidmoten.odata.client.ODataEntityType;
import com.github.davidmoten.odata.client.RequestOptions;
import com.github.davidmoten.odata.client.UnmappedFields;
import com.github.davidmoten.odata.client.Util;
import com.github.davidmoten.odata.client.annotation.Property;
import com.github.davidmoten.odata.client.internal.ChangedFields;
import com.github.davidmoten.odata.client.internal.RequestHelper;
import com.github.davidmoten.odata.client.internal.UnmappedFieldsImpl;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import java.util.Optional;
/**
*
* Org.OData.Capabilities.V1.ChangeTracking
*
* Supported = true
*/@JsonPropertyOrder({
"@odata.type",
"clientId",
"consentType",
"principalId",
"resourceId",
"scope"})
@JsonInclude(Include.NON_NULL)
public class OAuth2PermissionGrant extends Entity implements ODataEntityType {
@Override
public String odataTypeName() {
return "microsoft.graph.oAuth2PermissionGrant";
}
@JsonProperty("clientId")
protected String clientId;
@JsonProperty("consentType")
protected String consentType;
@JsonProperty("principalId")
protected String principalId;
@JsonProperty("resourceId")
protected String resourceId;
@JsonProperty("scope")
protected String scope;
protected OAuth2PermissionGrant() {
super();
}
/**
* Returns a builder which is used to create a new
* instance of this class (given that this class is immutable).
*
* @return a new Builder for this class
*/
// Suffix used on builder factory method to differentiate the method
// from static builder methods on superclasses
public static Builder builderOAuth2PermissionGrant() {
return new Builder();
}
public static final class Builder {
private String id;
private String clientId;
private String consentType;
private String principalId;
private String resourceId;
private String scope;
private ChangedFields changedFields = ChangedFields.EMPTY;
Builder() {
// prevent instantiation
}
public Builder id(String id) {
this.id = id;
this.changedFields = changedFields.add("id");
return this;
}
public Builder clientId(String clientId) {
this.clientId = clientId;
this.changedFields = changedFields.add("clientId");
return this;
}
public Builder consentType(String consentType) {
this.consentType = consentType;
this.changedFields = changedFields.add("consentType");
return this;
}
public Builder principalId(String principalId) {
this.principalId = principalId;
this.changedFields = changedFields.add("principalId");
return this;
}
public Builder resourceId(String resourceId) {
this.resourceId = resourceId;
this.changedFields = changedFields.add("resourceId");
return this;
}
public Builder scope(String scope) {
this.scope = scope;
this.changedFields = changedFields.add("scope");
return this;
}
public OAuth2PermissionGrant build() {
OAuth2PermissionGrant _x = new OAuth2PermissionGrant();
_x.contextPath = null;
_x.changedFields = changedFields;
_x.unmappedFields = new UnmappedFieldsImpl();
_x.odataType = "microsoft.graph.oAuth2PermissionGrant";
_x.id = id;
_x.clientId = clientId;
_x.consentType = consentType;
_x.principalId = principalId;
_x.resourceId = resourceId;
_x.scope = scope;
return _x;
}
}
@Override
@JsonIgnore
public ChangedFields getChangedFields() {
return changedFields;
}
@Override
public void postInject(boolean addKeysToContextPath) {
if (addKeysToContextPath && id != null) {
contextPath = contextPath.clearQueries().addKeys(new NameValue(id.toString()));
}
}
@Property(name="clientId")
@JsonIgnore
public Optional getClientId() {
return Optional.ofNullable(clientId);
}
public OAuth2PermissionGrant withClientId(String clientId) {
OAuth2PermissionGrant _x = _copy();
_x.changedFields = changedFields.add("clientId");
_x.odataType = Util.nvl(odataType, "microsoft.graph.oAuth2PermissionGrant");
_x.clientId = clientId;
return _x;
}
@Property(name="consentType")
@JsonIgnore
public Optional getConsentType() {
return Optional.ofNullable(consentType);
}
public OAuth2PermissionGrant withConsentType(String consentType) {
OAuth2PermissionGrant _x = _copy();
_x.changedFields = changedFields.add("consentType");
_x.odataType = Util.nvl(odataType, "microsoft.graph.oAuth2PermissionGrant");
_x.consentType = consentType;
return _x;
}
@Property(name="principalId")
@JsonIgnore
public Optional getPrincipalId() {
return Optional.ofNullable(principalId);
}
public OAuth2PermissionGrant withPrincipalId(String principalId) {
OAuth2PermissionGrant _x = _copy();
_x.changedFields = changedFields.add("principalId");
_x.odataType = Util.nvl(odataType, "microsoft.graph.oAuth2PermissionGrant");
_x.principalId = principalId;
return _x;
}
@Property(name="resourceId")
@JsonIgnore
public Optional getResourceId() {
return Optional.ofNullable(resourceId);
}
public OAuth2PermissionGrant withResourceId(String resourceId) {
OAuth2PermissionGrant _x = _copy();
_x.changedFields = changedFields.add("resourceId");
_x.odataType = Util.nvl(odataType, "microsoft.graph.oAuth2PermissionGrant");
_x.resourceId = resourceId;
return _x;
}
@Property(name="scope")
@JsonIgnore
public Optional getScope() {
return Optional.ofNullable(scope);
}
public OAuth2PermissionGrant withScope(String scope) {
OAuth2PermissionGrant _x = _copy();
_x.changedFields = changedFields.add("scope");
_x.odataType = Util.nvl(odataType, "microsoft.graph.oAuth2PermissionGrant");
_x.scope = scope;
return _x;
}
public OAuth2PermissionGrant withUnmappedField(String name, String value) {
OAuth2PermissionGrant _x = _copy();
_x.setUnmappedField(name, value);
return _x;
}
@JsonAnySetter
private void setUnmappedField(String name, Object value) {
if (unmappedFields == null) {
unmappedFields = new UnmappedFieldsImpl();
}
unmappedFields.put(name, value);
}
@JsonAnyGetter
private UnmappedFieldsImpl unmappedFields() {
return unmappedFields == null ? UnmappedFieldsImpl.EMPTY : unmappedFields;
}
@Override
public UnmappedFields getUnmappedFields() {
return unmappedFields();
}
/**
* Submits only changed fields for update and returns an
* immutable copy of {@code this} with changed fields reset.
*
* @return a copy of {@code this} with changed fields reset
* @throws ClientException if HTTP response is not as expected
*/
public OAuth2PermissionGrant patch() {
RequestHelper.patch(this, contextPath, RequestOptions.EMPTY);
OAuth2PermissionGrant _x = _copy();
_x.changedFields = null;
return _x;
}
/**
* Submits all fields for update and returns an immutable copy of {@code this}
* with changed fields reset (they were ignored anyway).
*
* @return a copy of {@code this} with changed fields reset
* @throws ClientException if HTTP response is not as expected
*/
public OAuth2PermissionGrant put() {
RequestHelper.put(this, contextPath, RequestOptions.EMPTY);
OAuth2PermissionGrant _x = _copy();
_x.changedFields = null;
return _x;
}
private OAuth2PermissionGrant _copy() {
OAuth2PermissionGrant _x = new OAuth2PermissionGrant();
_x.contextPath = contextPath;
_x.changedFields = changedFields;
_x.unmappedFields = unmappedFields.copy();
_x.odataType = odataType;
_x.id = id;
_x.clientId = clientId;
_x.consentType = consentType;
_x.principalId = principalId;
_x.resourceId = resourceId;
_x.scope = scope;
return _x;
}
@Override
public String toString() {
StringBuilder b = new StringBuilder();
b.append("OAuth2PermissionGrant[");
b.append("id=");
b.append(this.id);
b.append(", ");
b.append("clientId=");
b.append(this.clientId);
b.append(", ");
b.append("consentType=");
b.append(this.consentType);
b.append(", ");
b.append("principalId=");
b.append(this.principalId);
b.append(", ");
b.append("resourceId=");
b.append(this.resourceId);
b.append(", ");
b.append("scope=");
b.append(this.scope);
b.append("]");
b.append(",unmappedFields=");
b.append(unmappedFields);
b.append(",odataType=");
b.append(odataType);
return b.toString();
}
}