/* 
 * 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 GetLibraryItemsRequest {

    /**
     * A key representing a specific tag within the section.
     */
    @SpeakeasyMetadata("pathParam:style=simple,explode=false,name=tag")
    private Tag tag;

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

    /**
     * The type of media to retrieve.
     * 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 Optional<? extends GetLibraryItemsQueryParamType> type;

    /**
     * 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;

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

    /**
     * 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 GetLibraryItemsRequest(
            Tag tag,
            Optional<? extends IncludeGuids> includeGuids,
            Optional<? extends GetLibraryItemsQueryParamType> type,
            int sectionKey,
            Optional<? extends GetLibraryItemsQueryParamIncludeMeta> includeMeta,
            Optional<Integer> xPlexContainerStart,
            Optional<Integer> xPlexContainerSize) {
        Utils.checkNotNull(tag, "tag");
        Utils.checkNotNull(includeGuids, "includeGuids");
        Utils.checkNotNull(type, "type");
        Utils.checkNotNull(sectionKey, "sectionKey");
        Utils.checkNotNull(includeMeta, "includeMeta");
        Utils.checkNotNull(xPlexContainerStart, "xPlexContainerStart");
        Utils.checkNotNull(xPlexContainerSize, "xPlexContainerSize");
        this.tag = tag;
        this.includeGuids = includeGuids;
        this.type = type;
        this.sectionKey = sectionKey;
        this.includeMeta = includeMeta;
        this.xPlexContainerStart = xPlexContainerStart;
        this.xPlexContainerSize = xPlexContainerSize;
    }
    
    public GetLibraryItemsRequest(
            Tag tag,
            int sectionKey) {
        this(tag, Optional.empty(), Optional.empty(), sectionKey, Optional.empty(), Optional.empty(), Optional.empty());
    }

    /**
     * A key representing a specific tag within the section.
     */
    @JsonIgnore
    public Tag tag() {
        return tag;
    }

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

    /**
     * The type of media to retrieve.
     * 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
     * 
     */
    @SuppressWarnings("unchecked")
    @JsonIgnore
    public Optional<GetLibraryItemsQueryParamType> type() {
        return (Optional<GetLibraryItemsQueryParamType>) type;
    }

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

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

    /**
     * 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();
    }

    /**
     * A key representing a specific tag within the section.
     */
    public GetLibraryItemsRequest withTag(Tag tag) {
        Utils.checkNotNull(tag, "tag");
        this.tag = tag;
        return this;
    }

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

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

    /**
     * The type of media to retrieve.
     * 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 GetLibraryItemsRequest withType(GetLibraryItemsQueryParamType type) {
        Utils.checkNotNull(type, "type");
        this.type = Optional.ofNullable(type);
        return this;
    }

    /**
     * The type of media to retrieve.
     * 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 GetLibraryItemsRequest withType(Optional<? extends GetLibraryItemsQueryParamType> type) {
        Utils.checkNotNull(type, "type");
        this.type = type;
        return this;
    }

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

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

    /**
     * Adds the Meta object to the response
     * 
     */
    public GetLibraryItemsRequest withIncludeMeta(Optional<? extends GetLibraryItemsQueryParamIncludeMeta> includeMeta) {
        Utils.checkNotNull(includeMeta, "includeMeta");
        this.includeMeta = includeMeta;
        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 GetLibraryItemsRequest 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 GetLibraryItemsRequest 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 GetLibraryItemsRequest 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 GetLibraryItemsRequest 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;
        }
        GetLibraryItemsRequest other = (GetLibraryItemsRequest) o;
        return 
            Objects.deepEquals(this.tag, other.tag) &&
            Objects.deepEquals(this.includeGuids, other.includeGuids) &&
            Objects.deepEquals(this.type, other.type) &&
            Objects.deepEquals(this.sectionKey, other.sectionKey) &&
            Objects.deepEquals(this.includeMeta, other.includeMeta) &&
            Objects.deepEquals(this.xPlexContainerStart, other.xPlexContainerStart) &&
            Objects.deepEquals(this.xPlexContainerSize, other.xPlexContainerSize);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(
            tag,
            includeGuids,
            type,
            sectionKey,
            includeMeta,
            xPlexContainerStart,
            xPlexContainerSize);
    }
    
    @Override
    public String toString() {
        return Utils.toString(GetLibraryItemsRequest.class,
                "tag", tag,
                "includeGuids", includeGuids,
                "type", type,
                "sectionKey", sectionKey,
                "includeMeta", includeMeta,
                "xPlexContainerStart", xPlexContainerStart,
                "xPlexContainerSize", xPlexContainerSize);
    }
    
    public final static class Builder {
 
        private Tag tag;
 
        private Optional<? extends IncludeGuids> includeGuids;
 
        private Optional<? extends GetLibraryItemsQueryParamType> type = Optional.empty();
 
        private Integer sectionKey;
 
        private Optional<? extends GetLibraryItemsQueryParamIncludeMeta> includeMeta;
 
        private Optional<Integer> xPlexContainerStart;
 
        private Optional<Integer> xPlexContainerSize;  
        
        private Builder() {
          // force use of static builder() method
        }

        /**
         * A key representing a specific tag within the section.
         */
        public Builder tag(Tag tag) {
            Utils.checkNotNull(tag, "tag");
            this.tag = tag;
            return this;
        }

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

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

        /**
         * The type of media to retrieve.
         * 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(GetLibraryItemsQueryParamType type) {
            Utils.checkNotNull(type, "type");
            this.type = Optional.ofNullable(type);
            return this;
        }

        /**
         * The type of media to retrieve.
         * 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(Optional<? extends GetLibraryItemsQueryParamType> type) {
            Utils.checkNotNull(type, "type");
            this.type = type;
            return this;
        }

        /**
         * 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;
        }

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

        /**
         * Adds the Meta object to the response
         * 
         */
        public Builder includeMeta(Optional<? extends GetLibraryItemsQueryParamIncludeMeta> includeMeta) {
            Utils.checkNotNull(includeMeta, "includeMeta");
            this.includeMeta = includeMeta;
            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 GetLibraryItemsRequest build() {
            if (includeGuids == null) {
                includeGuids = _SINGLETON_VALUE_IncludeGuids.value();
            }
            if (includeMeta == null) {
                includeMeta = _SINGLETON_VALUE_IncludeMeta.value();
            }
            if (xPlexContainerStart == null) {
                xPlexContainerStart = _SINGLETON_VALUE_XPlexContainerStart.value();
            }
            if (xPlexContainerSize == null) {
                xPlexContainerSize = _SINGLETON_VALUE_XPlexContainerSize.value();
            }            return new GetLibraryItemsRequest(
                tag,
                includeGuids,
                type,
                sectionKey,
                includeMeta,
                xPlexContainerStart,
                xPlexContainerSize);
        }

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

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

        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>>() {});
    }
}

