/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (4.3.1).
 * https://openapi-generator.tech Do not edit the class manually.
 */
package io.delphiplatform.api.v3.view;

import org.hibernate.validator.constraints.ParameterScriptAssert;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;

import io.delphiplatform.api.v3.constant.ApplicationConstants;
import io.delphiplatform.api.v3.model.SortOrder;
import io.delphiplatform.api.v3.model.gras.ProductVersion;
import io.delphiplatform.api.v3.model.gras.ProductVersions;
import io.delphiplatform.api.v3.view.interceptor.OnlyDeclaredParams;
import io.delphiplatform.api.v3.view.util.Params;

;

@Validated
public interface ProductVersionsApi {

    /**
     * GET /product-versions/{product_version_no} : Get one ProductVersion Resource route for getting a single
     * &#x60;ProductVersion&#x60;.  A Product Version is a group of Products that contain the same contents on different
     * Configurations. Configurations include formats like cassette, vinyl, CD, digital audio, etc. A Product Version
     * typically contains between 1 and &lt;10 Products.  A Product Version is mostly synonymous with a Product Family.
     * When users are discussing a Product Family, they typically are referring to a Product Version that is the head of
     * the Product Family.
     *
     * @param productVersionNo Primary key identifier for a &#x60;ProductVersion&#x60;. (required)
     * @return &#x60;ProductVersion&#x60; response object (status code 200) or A &#x60;400 Bad Request&#x60; response
     * status indicates a problem with the input provided by a client request. If you are receiving this error, check
     * your request parameters are valid.  (status code 400) or A &#x60;401 Unauthorized&#x60; response status indicates
     * that the request did not include a required Authorization header, or that there was a problem authenticating the
     * client. Possible problems include an expired or invalid token, or the Authorization header is not in the expected
     * format.  (status code 401) or A &#x60;404 Not Found&#x60; response status is returned when a single item queried
     * by primary key identifier was not found in the database, or an endpoint path was provided that does not exist.
     * (status code 404) or A &#x60;500 Internal Error&#x60; response status is returned for any application and server
     * level errors that are not already associated with another error status. A 500 is used as a generic fallback
     * error.  (status code 500)
     */
    @RequestMapping(value = "/product-versions/{product_version_no}",
        produces = {"application/json"},
        method = RequestMethod.GET)
    default ResponseEntity<ProductVersion> productVersionsGet(
        @PathVariable("product_version_no") Integer productVersionNo) {
        return findOne(productVersionNo);
    }

    ResponseEntity<ProductVersion> findOne(Integer productVersionNo);


    /**
     * GET /product-versions : Search for ProductVersions Resource route for getting a list of
     * &#x60;ProductVersion&#x60; with filtering based on provided parameters.  A Product Version is a group of Products
     * that contain the same contents on different Configurations. Configurations include formats like cassette, vinyl,
     * CD, digital audio, etc. A Product Version typically contains between 1 and &lt;10 Products.  A Product Version is
     * mostly synonymous with a Product Family. When users are discussing a Product Family, they typically are referring
     * to a Product Version that is the head of the Product Family.  At least one identifying parameter must be provided
     * when querying this endpoint (e.g.: &#x60;product_family_no&#x60;, &#x60;product_id, &#x60;project_id&#x60;, or
     * &#x60;rep_owner_key_array&#x60;).
     *
     * @param isProductFamilyHead Provide this parameter to only include Product Versions that are the Product Family
     *                            head. (optional)
     * @param productFamilyNo     Identifier used for a Product Family. (optional)
     * @param productId           Primary key identifier for a &#x60;Product&#x60;. (optional)
     * @param projectId           Primary key identifier for a (recording) &#x60;Project&#x60;. (optional)
     * @param repOwnerKey         Primary key identifier for a &#x60;RepertoireOwner&#x60; (&#x60;Company&#x60;).
     *                            (optional, default to new ArrayList&lt;&gt;())
     * @param limit               The maximum number of &#x60;items&#x60; to return in a single request (i.e.: a single
     *                            page). (optional)
     * @param offset              The number of &#x60;items&#x60; to offset (aka skip) for pagination.  (optional,
     *                            default to 0)
     * @param sortBy              Field name existing in the top level of an object in &#x60;items&#x60; by which to
     *                            sort the results. (optional)
     * @param sortOrder           Direction to sort the data. Default: &#x60;desc&#x60; if &#x60;sort_by&#x60; provided.
     *                            (optional, default to desc)
     * @return &#x60;ProductVersions&#x60; response object (status code 200) or A &#x60;400 Bad Request&#x60; response
     * status indicates a problem with the input provided by a client request. If you are receiving this error, check
     * your request parameters are valid.  (status code 400) or A &#x60;401 Unauthorized&#x60; response status indicates
     * that the request did not include a required Authorization header, or that there was a problem authenticating the
     * client. Possible problems include an expired or invalid token, or the Authorization header is not in the expected
     * format.  (status code 401) or A &#x60;500 Internal Error&#x60; response status is returned for any application
     * and server level errors that are not already associated with another error status. A 500 is used as a generic
     * fallback error.  (status code 500)
     */
    @OnlyDeclaredParams
    @ParameterScriptAssert(lang = "groovy",
        message = "Missing at least one identifying parameter from set: [product_family_no,"
            + " product_id, project_id, rep_owner_key]",
        script = "productFamilyNo != null || productId != null || projectId != null || repOwnerKey != null")
    @RequestMapping(value = "/product-versions",
        produces = {"application/json"},
        method = RequestMethod.GET)
    default ResponseEntity<ProductVersions> productVersionsSearch(
        @RequestParam(value = "is_product_family_head", required = false) Boolean isProductFamilyHead,
        @RequestParam(value = "product_family_no", required = false) Integer productFamilyNo,
        @RequestParam(value = "product_id", required = false) String productId,
        @RequestParam(value = "project_id", required = false) String projectId,
        @Pattern(regexp = ApplicationConstants.NOT_EMPTY_PATTERN)
        @RequestParam(value = "config_cat_key", required = false) String configCatKey,
        @Pattern(regexp = ApplicationConstants.NOT_EMPTY_PATTERN)
        @RequestParam(value = "config_key", required = false) String configKey,
        @RequestParam(value = "rep_owner_key", required = false) List<String> repOwnerKey,
        @Min(0) @Max(ApplicationConstants.MAX_PAGE_SIZE)
        @RequestParam(value = "limit", required = false) Integer limit,
        @Min(0) @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset,
        @RequestParam(value = "sort_by", required = false) String sortBy,
        @RequestParam(value = "sort_order", required = false, defaultValue = "desc") SortOrder sortOrder) {
        return getSearchData(Params.builder()
            .isProductFamilyHead(isProductFamilyHead)
            .productFamilyNo(productFamilyNo)
            .productId(productId)
            .projectId(projectId)
            .repOwnerKey(repOwnerKey)
            .configCatKey(configCatKey)
            .configKey(configKey)
            .limit(limit)
            .offset(offset)
            .sortBy(sortBy)
            .sortOrder(sortOrder)
            .build());
    }

    ResponseEntity<ProductVersions> getSearchData(Params params);


}
