<?php

/*
 * Copyright 2005 - 2025 Centreon (https://www.centreon.com/)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * For more information : contact@centreon.com
 *
 */

declare(strict_types=1);

namespace Core\Resources\Infrastructure\API\CountResources;

use Symfony\Component\Validator\Constraints as Assert;

final readonly class CountResourcesInput
{
    public function __construct(
        #[Assert\NotBlank(message: 'search parameter is required')]
        #[Assert\Json(message: 'search parameter must be a valid JSON')]
        public mixed $search,
        #[Assert\NotNull(message: 'all_pages parameter is required')]
        #[Assert\Type('bool', message: 'all_pages parameter must be a boolean')]
        public mixed $allPages,
        #[Assert\When(
            expression: 'this.allPages === false',
            constraints: [
                new Assert\Sequentially([
                    new Assert\NotBlank(message: 'page parameter is required when all_pages is false'),
                    new Assert\Type('int', message: 'page parameter must be an integer'),
                    new Assert\Range(
                        minMessage: 'page parameter must be greater than 1',
                        min: 1
                    ),
                ]),
            ]
        )]
        public mixed $page,
        #[Assert\When(
            expression: 'this.allPages === false',
            constraints: [
                new Assert\NotBlank(message: 'limit parameter is required when all_pages is false'),
                new Assert\Type('int', message: 'limit parameter must be an integer'),
            ]
        )]
        public mixed $limit,
    ) {
    }
}
