/* 
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

package dev.plexapi.sdk.models.operations;


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.type.TypeReference;
import dev.plexapi.sdk.utils.LazySingletonValue;
import dev.plexapi.sdk.utils.SpeakeasyMetadata;
import dev.plexapi.sdk.utils.Utils;
import java.lang.Integer;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.util.Objects;
import java.util.Optional;


public class GetAllMediaLibraryRequest {

    /**
     * The unique key of the Plex library. 
     * Note: This is unique in the context of the Plex server.
     * 
     */
    @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=sectionKey")
    private int sectionKey;

    /**
     * The type of media to retrieve or filter by.
     * 1 = movie
     * 2 = show
     * 3 = season
     * 4 = episode
     * E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=type")
    private GetAllMediaLibraryQueryParamType type;

    /**
     * Adds the Meta object to the response
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=includeMeta")
    private Optional<? extends GetAllMediaLibraryQueryParamIncludeMeta> includeMeta;

    /**
     * Adds the Guid object to the response
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=includeGuids")
    private Optional<? extends QueryParamIncludeGuids> includeGuids;

    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=includeAdvanced")
    private Optional<? extends IncludeAdvanced> includeAdvanced;

    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=includeCollections")
    private Optional<? extends QueryParamIncludeCollections> includeCollections;

    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=includeExternalMedia")
    private Optional<? extends QueryParamIncludeExternalMedia> includeExternalMedia;

    /**
     * The index of the first item to return. If not specified, the first item will be returned.
     * If the number of items exceeds the limit, the response will be paginated.
     * By default this is 0
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=X-Plex-Container-Start")
    private Optional<Integer> xPlexContainerStart;

    /**
     * The number of items to return. If not specified, all items will be returned.
     * If the number of items exceeds the limit, the response will be paginated.
     * By default this is 50
     * 
     */
    @SpeakeasyMetadata("queryParam:style=form,explode=true,name=X-Plex-Container-Size")
    private Optional<Integer> xPlexContainerSize;

    @JsonCreator
    public GetAllMediaLibraryRequest(
            int sectionKey,
            GetAllMediaLibraryQueryParamType type,
            Optional<? extends GetAllMediaLibraryQueryParamIncludeMeta> includeMeta,
            Optional<? extends QueryParamIncludeGuids> includeGuids,
            Optional<? extends IncludeAdvanced> includeAdvanced,
            Optional<? extends QueryParamIncludeCollections> includeCollections,
            Optional<? extends QueryParamIncludeExternalMedia> includeExternalMedia,
            Optional<Integer> xPlexContainerStart,
            Optional<Integer> xPlexContainerSize) {
        Utils.checkNotNull(sectionKey, "sectionKey");
        Utils.checkNotNull(type, "type");
        Utils.checkNotNull(includeMeta, "includeMeta");
        Utils.checkNotNull(includeGuids, "includeGuids");
        Utils.checkNotNull(includeAdvanced, "includeAdvanced");
        Utils.checkNotNull(includeCollections, "includeCollections");
        Utils.checkNotNull(includeExternalMedia, "includeExternalMedia");
        Utils.checkNotNull(xPlexContainerStart, "xPlexContainerStart");
        Utils.checkNotNull(xPlexContainerSize, "xPlexContainerSize");
        this.sectionKey = sectionKey;
        this.type = type;
        this.includeMeta = includeMeta;
        this.includeGuids = includeGuids;
        this.includeAdvanced = includeAdvanced;
        this.includeCollections = includeCollections;
        this.includeExternalMedia = includeExternalMedia;
        this.xPlexContainerStart = xPlexContainerStart;
        this.xPlexContainerSize = xPlexContainerSize;
    }
    
    public GetAllMediaLibraryRequest(
            int sectionKey,
            GetAllMediaLibraryQueryParamType type) {
        this(sectionKey, type, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
    }

    /**
     * The unique key of the Plex library. 
     * Note: This is unique in the context of the Plex server.
     * 
     */
    @JsonIgnore
    public int sectionKey() {
        return sectionKey;
    }

    /**
     * The type of media to retrieve or filter by.
     * 1 = movie
     * 2 = show
     * 3 = season
     * 4 = episode
     * E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
     * 
     */
    @JsonIgnore
    public GetAllMediaLibraryQueryParamType type() {
        return type;
    }

    /**
     * Adds the Meta object to the response
     * 
     */
    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<GetAllMediaLibraryQueryParamIncludeMeta> includeMeta() {
        return (Optional<GetAllMediaLibraryQueryParamIncludeMeta>) includeMeta;
    }

    /**
     * Adds the Guid object to the response
     * 
     */
    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<QueryParamIncludeGuids> includeGuids() {
        return (Optional<QueryParamIncludeGuids>) includeGuids;
    }

    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<IncludeAdvanced> includeAdvanced() {
        return (Optional<IncludeAdvanced>) includeAdvanced;
    }

    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<QueryParamIncludeCollections> includeCollections() {
        return (Optional<QueryParamIncludeCollections>) includeCollections;
    }

    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<QueryParamIncludeExternalMedia> includeExternalMedia() {
        return (Optional<QueryParamIncludeExternalMedia>) includeExternalMedia;
    }

    /**
     * The index of the first item to return. If not specified, the first item will be returned.
     * If the number of items exceeds the limit, the response will be paginated.
     * By default this is 0
     * 
     */
    @JsonIgnore
    public Optional<Integer> xPlexContainerStart() {
        return xPlexContainerStart;
    }

    /**
     * The number of items to return. If not specified, all items will be returned.
     * If the number of items exceeds the limit, the response will be paginated.
     * By default this is 50
     * 
     */
    @JsonIgnore
    public Optional<Integer> xPlexContainerSize() {
        return xPlexContainerSize;
    }

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

    /**
     * The unique key of the Plex library. 
     * Note: This is unique in the context of the Plex server.
     * 
     */
    public GetAllMediaLibraryRequest withSectionKey(int sectionKey) {
        Utils.checkNotNull(sectionKey, "sectionKey");
        this.sectionKey = sectionKey;
        return this;
    }

    /**
     * The type of media to retrieve or filter by.
     * 1 = movie
     * 2 = show
     * 3 = season
     * 4 = episode
     * E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
     * 
     */
    public GetAllMediaLibraryRequest withType(GetAllMediaLibraryQueryParamType type) {
        Utils.checkNotNull(type, "type");
        this.type = type;
        return this;
    }

    /**
     * Adds the Meta object to the response
     * 
     */
    public GetAllMediaLibraryRequest withIncludeMeta(GetAllMediaLibraryQueryParamIncludeMeta includeMeta) {
        Utils.checkNotNull(includeMeta, "includeMeta");
        this.includeMeta = Optional.ofNullable(includeMeta);
        return this;
    }

    /**
     * Adds the Meta object to the response
     * 
     */
    public GetAllMediaLibraryRequest withIncludeMeta(Optional<? extends GetAllMediaLibraryQueryParamIncludeMeta> includeMeta) {
        Utils.checkNotNull(includeMeta, "includeMeta");
        this.includeMeta = includeMeta;
        return this;
    }

    /**
     * Adds the Guid object to the response
     * 
     */
    public GetAllMediaLibraryRequest withIncludeGuids(QueryParamIncludeGuids includeGuids) {
        Utils.checkNotNull(includeGuids, "includeGuids");
        this.includeGuids = Optional.ofNullable(includeGuids);
        return this;
    }

    /**
     * Adds the Guid object to the response
     * 
     */
    public GetAllMediaLibraryRequest withIncludeGuids(Optional<? extends QueryParamIncludeGuids> includeGuids) {
        Utils.checkNotNull(includeGuids, "includeGuids");
        this.includeGuids = includeGuids;
        return this;
    }

    public GetAllMediaLibraryRequest withIncludeAdvanced(IncludeAdvanced includeAdvanced) {
        Utils.checkNotNull(includeAdvanced, "includeAdvanced");
        this.includeAdvanced = Optional.ofNullable(includeAdvanced);
        return this;
    }

    public GetAllMediaLibraryRequest withIncludeAdvanced(Optional<? extends IncludeAdvanced> includeAdvanced) {
        Utils.checkNotNull(includeAdvanced, "includeAdvanced");
        this.includeAdvanced = includeAdvanced;
        return this;
    }

    public GetAllMediaLibraryRequest withIncludeCollections(QueryParamIncludeCollections includeCollections) {
        Utils.checkNotNull(includeCollections, "includeCollections");
        this.includeCollections = Optional.ofNullable(includeCollections);
        return this;
    }

    public GetAllMediaLibraryRequest withIncludeCollections(Optional<? extends QueryParamIncludeCollections> includeCollections) {
        Utils.checkNotNull(includeCollections, "includeCollections");
        this.includeCollections = includeCollections;
        return this;
    }

    public GetAllMediaLibraryRequest withIncludeExternalMedia(QueryParamIncludeExternalMedia includeExternalMedia) {
        Utils.checkNotNull(includeExternalMedia, "includeExternalMedia");
        this.includeExternalMedia = Optional.ofNullable(includeExternalMedia);
        return this;
    }

    public GetAllMediaLibraryRequest withIncludeExternalMedia(Optional<? extends QueryParamIncludeExternalMedia> includeExternalMedia) {
        Utils.checkNotNull(includeExternalMedia, "includeExternalMedia");
        this.includeExternalMedia = includeExternalMedia;
        return this;
    }

    /**
     * The index of the first item to return. If not specified, the first item will be returned.
     * If the number of items exceeds the limit, the response will be paginated.
     * By default this is 0
     * 
     */
    public GetAllMediaLibraryRequest withXPlexContainerStart(int xPlexContainerStart) {
        Utils.checkNotNull(xPlexContainerStart, "xPlexContainerStart");
        this.xPlexContainerStart = Optional.ofNullable(xPlexContainerStart);
        return this;
    }

    /**
     * The index of the first item to return. If not specified, the first item will be returned.
     * If the number of items exceeds the limit, the response will be paginated.
     * By default this is 0
     * 
     */
    public GetAllMediaLibraryRequest withXPlexContainerStart(Optional<Integer> xPlexContainerStart) {
        Utils.checkNotNull(xPlexContainerStart, "xPlexContainerStart");
        this.xPlexContainerStart = xPlexContainerStart;
        return this;
    }

    /**
     * The number of items to return. If not specified, all items will be returned.
     * If the number of items exceeds the limit, the response will be paginated.
     * By default this is 50
     * 
     */
    public GetAllMediaLibraryRequest withXPlexContainerSize(int xPlexContainerSize) {
        Utils.checkNotNull(xPlexContainerSize, "xPlexContainerSize");
        this.xPlexContainerSize = Optional.ofNullable(xPlexContainerSize);
        return this;
    }

    /**
     * The number of items to return. If not specified, all items will be returned.
     * If the number of items exceeds the limit, the response will be paginated.
     * By default this is 50
     * 
     */
    public GetAllMediaLibraryRequest withXPlexContainerSize(Optional<Integer> xPlexContainerSize) {
        Utils.checkNotNull(xPlexContainerSize, "xPlexContainerSize");
        this.xPlexContainerSize = xPlexContainerSize;
        return this;
    }
    
    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GetAllMediaLibraryRequest other = (GetAllMediaLibraryRequest) o;
        return 
            Objects.deepEquals(this.sectionKey, other.sectionKey) &&
            Objects.deepEquals(this.type, other.type) &&
            Objects.deepEquals(this.includeMeta, other.includeMeta) &&
            Objects.deepEquals(this.includeGuids, other.includeGuids) &&
            Objects.deepEquals(this.includeAdvanced, other.includeAdvanced) &&
            Objects.deepEquals(this.includeCollections, other.includeCollections) &&
            Objects.deepEquals(this.includeExternalMedia, other.includeExternalMedia) &&
            Objects.deepEquals(this.xPlexContainerStart, other.xPlexContainerStart) &&
            Objects.deepEquals(this.xPlexContainerSize, other.xPlexContainerSize);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(
            sectionKey,
            type,
            includeMeta,
            includeGuids,
            includeAdvanced,
            includeCollections,
            includeExternalMedia,
            xPlexContainerStart,
            xPlexContainerSize);
    }
    
    @Override
    public String toString() {
        return Utils.toString(GetAllMediaLibraryRequest.class,
                "sectionKey", sectionKey,
                "type", type,
                "includeMeta", includeMeta,
                "includeGuids", includeGuids,
                "includeAdvanced", includeAdvanced,
                "includeCollections", includeCollections,
                "includeExternalMedia", includeExternalMedia,
                "xPlexContainerStart", xPlexContainerStart,
                "xPlexContainerSize", xPlexContainerSize);
    }
    
    public final static class Builder {
 
        private Integer sectionKey;
 
        private GetAllMediaLibraryQueryParamType type;
 
        private Optional<? extends GetAllMediaLibraryQueryParamIncludeMeta> includeMeta;
 
        private Optional<? extends QueryParamIncludeGuids> includeGuids;
 
        private Optional<? extends IncludeAdvanced> includeAdvanced;
 
        private Optional<? extends QueryParamIncludeCollections> includeCollections;
 
        private Optional<? extends QueryParamIncludeExternalMedia> includeExternalMedia;
 
        private Optional<Integer> xPlexContainerStart;
 
        private Optional<Integer> xPlexContainerSize;  
        
        private Builder() {
          // force use of static builder() method
        }

        /**
         * The unique key of the Plex library. 
         * Note: This is unique in the context of the Plex server.
         * 
         */
        public Builder sectionKey(int sectionKey) {
            Utils.checkNotNull(sectionKey, "sectionKey");
            this.sectionKey = sectionKey;
            return this;
        }

        /**
         * The type of media to retrieve or filter by.
         * 1 = movie
         * 2 = show
         * 3 = season
         * 4 = episode
         * E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
         * 
         */
        public Builder type(GetAllMediaLibraryQueryParamType type) {
            Utils.checkNotNull(type, "type");
            this.type = type;
            return this;
        }

        /**
         * Adds the Meta object to the response
         * 
         */
        public Builder includeMeta(GetAllMediaLibraryQueryParamIncludeMeta includeMeta) {
            Utils.checkNotNull(includeMeta, "includeMeta");
            this.includeMeta = Optional.ofNullable(includeMeta);
            return this;
        }

        /**
         * Adds the Meta object to the response
         * 
         */
        public Builder includeMeta(Optional<? extends GetAllMediaLibraryQueryParamIncludeMeta> includeMeta) {
            Utils.checkNotNull(includeMeta, "includeMeta");
            this.includeMeta = includeMeta;
            return this;
        }

        /**
         * Adds the Guid object to the response
         * 
         */
        public Builder includeGuids(QueryParamIncludeGuids includeGuids) {
            Utils.checkNotNull(includeGuids, "includeGuids");
            this.includeGuids = Optional.ofNullable(includeGuids);
            return this;
        }

        /**
         * Adds the Guid object to the response
         * 
         */
        public Builder includeGuids(Optional<? extends QueryParamIncludeGuids> includeGuids) {
            Utils.checkNotNull(includeGuids, "includeGuids");
            this.includeGuids = includeGuids;
            return this;
        }

        public Builder includeAdvanced(IncludeAdvanced includeAdvanced) {
            Utils.checkNotNull(includeAdvanced, "includeAdvanced");
            this.includeAdvanced = Optional.ofNullable(includeAdvanced);
            return this;
        }

        public Builder includeAdvanced(Optional<? extends IncludeAdvanced> includeAdvanced) {
            Utils.checkNotNull(includeAdvanced, "includeAdvanced");
            this.includeAdvanced = includeAdvanced;
            return this;
        }

        public Builder includeCollections(QueryParamIncludeCollections includeCollections) {
            Utils.checkNotNull(includeCollections, "includeCollections");
            this.includeCollections = Optional.ofNullable(includeCollections);
            return this;
        }

        public Builder includeCollections(Optional<? extends QueryParamIncludeCollections> includeCollections) {
            Utils.checkNotNull(includeCollections, "includeCollections");
            this.includeCollections = includeCollections;
            return this;
        }

        public Builder includeExternalMedia(QueryParamIncludeExternalMedia includeExternalMedia) {
            Utils.checkNotNull(includeExternalMedia, "includeExternalMedia");
            this.includeExternalMedia = Optional.ofNullable(includeExternalMedia);
            return this;
        }

        public Builder includeExternalMedia(Optional<? extends QueryParamIncludeExternalMedia> includeExternalMedia) {
            Utils.checkNotNull(includeExternalMedia, "includeExternalMedia");
            this.includeExternalMedia = includeExternalMedia;
            return this;
        }

        /**
         * The index of the first item to return. If not specified, the first item will be returned.
         * If the number of items exceeds the limit, the response will be paginated.
         * By default this is 0
         * 
         */
        public Builder xPlexContainerStart(int xPlexContainerStart) {
            Utils.checkNotNull(xPlexContainerStart, "xPlexContainerStart");
            this.xPlexContainerStart = Optional.ofNullable(xPlexContainerStart);
            return this;
        }

        /**
         * The index of the first item to return. If not specified, the first item will be returned.
         * If the number of items exceeds the limit, the response will be paginated.
         * By default this is 0
         * 
         */
        public Builder xPlexContainerStart(Optional<Integer> xPlexContainerStart) {
            Utils.checkNotNull(xPlexContainerStart, "xPlexContainerStart");
            this.xPlexContainerStart = xPlexContainerStart;
            return this;
        }

        /**
         * The number of items to return. If not specified, all items will be returned.
         * If the number of items exceeds the limit, the response will be paginated.
         * By default this is 50
         * 
         */
        public Builder xPlexContainerSize(int xPlexContainerSize) {
            Utils.checkNotNull(xPlexContainerSize, "xPlexContainerSize");
            this.xPlexContainerSize = Optional.ofNullable(xPlexContainerSize);
            return this;
        }

        /**
         * The number of items to return. If not specified, all items will be returned.
         * If the number of items exceeds the limit, the response will be paginated.
         * By default this is 50
         * 
         */
        public Builder xPlexContainerSize(Optional<Integer> xPlexContainerSize) {
            Utils.checkNotNull(xPlexContainerSize, "xPlexContainerSize");
            this.xPlexContainerSize = xPlexContainerSize;
            return this;
        }
        
        public GetAllMediaLibraryRequest build() {
            if (includeMeta == null) {
                includeMeta = _SINGLETON_VALUE_IncludeMeta.value();
            }
            if (includeGuids == null) {
                includeGuids = _SINGLETON_VALUE_IncludeGuids.value();
            }
            if (includeAdvanced == null) {
                includeAdvanced = _SINGLETON_VALUE_IncludeAdvanced.value();
            }
            if (includeCollections == null) {
                includeCollections = _SINGLETON_VALUE_IncludeCollections.value();
            }
            if (includeExternalMedia == null) {
                includeExternalMedia = _SINGLETON_VALUE_IncludeExternalMedia.value();
            }
            if (xPlexContainerStart == null) {
                xPlexContainerStart = _SINGLETON_VALUE_XPlexContainerStart.value();
            }
            if (xPlexContainerSize == null) {
                xPlexContainerSize = _SINGLETON_VALUE_XPlexContainerSize.value();
            }            return new GetAllMediaLibraryRequest(
                sectionKey,
                type,
                includeMeta,
                includeGuids,
                includeAdvanced,
                includeCollections,
                includeExternalMedia,
                xPlexContainerStart,
                xPlexContainerSize);
        }

        private static final LazySingletonValue<Optional<? extends GetAllMediaLibraryQueryParamIncludeMeta>> _SINGLETON_VALUE_IncludeMeta =
                new LazySingletonValue<>(
                        "includeMeta",
                        "0",
                        new TypeReference<Optional<? extends GetAllMediaLibraryQueryParamIncludeMeta>>() {});

        private static final LazySingletonValue<Optional<? extends QueryParamIncludeGuids>> _SINGLETON_VALUE_IncludeGuids =
                new LazySingletonValue<>(
                        "includeGuids",
                        "0",
                        new TypeReference<Optional<? extends QueryParamIncludeGuids>>() {});

        private static final LazySingletonValue<Optional<? extends IncludeAdvanced>> _SINGLETON_VALUE_IncludeAdvanced =
                new LazySingletonValue<>(
                        "includeAdvanced",
                        "0",
                        new TypeReference<Optional<? extends IncludeAdvanced>>() {});

        private static final LazySingletonValue<Optional<? extends QueryParamIncludeCollections>> _SINGLETON_VALUE_IncludeCollections =
                new LazySingletonValue<>(
                        "includeCollections",
                        "0",
                        new TypeReference<Optional<? extends QueryParamIncludeCollections>>() {});

        private static final LazySingletonValue<Optional<? extends QueryParamIncludeExternalMedia>> _SINGLETON_VALUE_IncludeExternalMedia =
                new LazySingletonValue<>(
                        "includeExternalMedia",
                        "0",
                        new TypeReference<Optional<? extends QueryParamIncludeExternalMedia>>() {});

        private static final LazySingletonValue<Optional<Integer>> _SINGLETON_VALUE_XPlexContainerStart =
                new LazySingletonValue<>(
                        "X-Plex-Container-Start",
                        "0",
                        new TypeReference<Optional<Integer>>() {});

        private static final LazySingletonValue<Optional<Integer>> _SINGLETON_VALUE_XPlexContainerSize =
                new LazySingletonValue<>(
                        "X-Plex-Container-Size",
                        "50",
                        new TypeReference<Optional<Integer>>() {});
    }
}

