All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.squidex.api.resources.apps.requests.UpdateClientDto Maven / Gradle / Ivy

package com.squidex.api.resources.apps.requests;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.Objects;
import java.util.Optional;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonDeserialize(builder = UpdateClientDto.Builder.class)
public final class UpdateClientDto {
    private final Optional name;

    private final Optional role;

    private final Optional allowAnonymous;

    private final Optional apiCallsLimit;

    private final Optional apiTrafficLimit;

    private UpdateClientDto(
            Optional name,
            Optional role,
            Optional allowAnonymous,
            Optional apiCallsLimit,
            Optional apiTrafficLimit) {
        this.name = name;
        this.role = role;
        this.allowAnonymous = allowAnonymous;
        this.apiCallsLimit = apiCallsLimit;
        this.apiTrafficLimit = apiTrafficLimit;
    }

    /**
     * @return The new display name of the client.
     */
    @JsonProperty("name")
    public Optional getName() {
        return name;
    }

    /**
     * @return The role of the client.
     */
    @JsonProperty("role")
    public Optional getRole() {
        return role;
    }

    /**
     * @return True to allow anonymous access without an access token for this client.
     */
    @JsonProperty("allowAnonymous")
    public Optional getAllowAnonymous() {
        return allowAnonymous;
    }

    /**
     * @return The number of allowed api calls per month for this client.
     */
    @JsonProperty("apiCallsLimit")
    public Optional getApiCallsLimit() {
        return apiCallsLimit;
    }

    /**
     * @return The number of allowed api traffic bytes per month for this client.
     */
    @JsonProperty("apiTrafficLimit")
    public Optional getApiTrafficLimit() {
        return apiTrafficLimit;
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) return true;
        return other instanceof UpdateClientDto && equalTo((UpdateClientDto) other);
    }

    private boolean equalTo(UpdateClientDto other) {
        return name.equals(other.name)
                && role.equals(other.role)
                && allowAnonymous.equals(other.allowAnonymous)
                && apiCallsLimit.equals(other.apiCallsLimit)
                && apiTrafficLimit.equals(other.apiTrafficLimit);
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.name, this.role, this.allowAnonymous, this.apiCallsLimit, this.apiTrafficLimit);
    }

    @Override
    public String toString() {
        return "UpdateClientDto{" + "name: " + name + ", role: " + role + ", allowAnonymous: " + allowAnonymous
                + ", apiCallsLimit: " + apiCallsLimit + ", apiTrafficLimit: " + apiTrafficLimit + "}";
    }

    public static Builder builder() {
        return new Builder();
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static final class Builder {
        private Optional name = Optional.empty();

        private Optional role = Optional.empty();

        private Optional allowAnonymous = Optional.empty();

        private Optional apiCallsLimit = Optional.empty();

        private Optional apiTrafficLimit = Optional.empty();

        private Builder() {}

        public Builder from(UpdateClientDto other) {
            name(other.getName());
            role(other.getRole());
            allowAnonymous(other.getAllowAnonymous());
            apiCallsLimit(other.getApiCallsLimit());
            apiTrafficLimit(other.getApiTrafficLimit());
            return this;
        }

        @JsonSetter(value = "name", nulls = Nulls.SKIP)
        public Builder name(Optional name) {
            this.name = name;
            return this;
        }

        public Builder name(String name) {
            this.name = Optional.of(name);
            return this;
        }

        @JsonSetter(value = "role", nulls = Nulls.SKIP)
        public Builder role(Optional role) {
            this.role = role;
            return this;
        }

        public Builder role(String role) {
            this.role = Optional.of(role);
            return this;
        }

        @JsonSetter(value = "allowAnonymous", nulls = Nulls.SKIP)
        public Builder allowAnonymous(Optional allowAnonymous) {
            this.allowAnonymous = allowAnonymous;
            return this;
        }

        public Builder allowAnonymous(Boolean allowAnonymous) {
            this.allowAnonymous = Optional.of(allowAnonymous);
            return this;
        }

        @JsonSetter(value = "apiCallsLimit", nulls = Nulls.SKIP)
        public Builder apiCallsLimit(Optional apiCallsLimit) {
            this.apiCallsLimit = apiCallsLimit;
            return this;
        }

        public Builder apiCallsLimit(Integer apiCallsLimit) {
            this.apiCallsLimit = Optional.of(apiCallsLimit);
            return this;
        }

        @JsonSetter(value = "apiTrafficLimit", nulls = Nulls.SKIP)
        public Builder apiTrafficLimit(Optional apiTrafficLimit) {
            this.apiTrafficLimit = apiTrafficLimit;
            return this;
        }

        public Builder apiTrafficLimit(Integer apiTrafficLimit) {
            this.apiTrafficLimit = Optional.of(apiTrafficLimit);
            return this;
        }

        public UpdateClientDto build() {
            return new UpdateClientDto(name, role, allowAnonymous, apiCallsLimit, apiTrafficLimit);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy