# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# 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
#
#     http://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.


from pydantic import BaseModel, Field
from typing import Any, Dict, List, Optional


# Data models for Jobs
class CreateJobData(BaseModel):
    """Data model for create job operation."""

    job_name: str = Field(..., description='Name of the created job')
    job_id: Optional[str] = Field(None, description='ID of the created job')
    operation: str = Field(default='create', description='Operation performed')


class DeleteJobData(BaseModel):
    """Data model for delete job operation."""

    job_name: str = Field(..., description='Name of the deleted job')
    operation: str = Field(default='delete', description='Operation performed')


class GetJobData(BaseModel):
    """Data model for get job operation."""

    job_name: str = Field(..., description='Name of the job')
    job_details: Dict[str, Any] = Field(..., description='Complete job definition')
    operation: str = Field(default='get', description='Operation performed')


class GetJobsData(BaseModel):
    """Data model for get jobs operation."""

    jobs: List[Dict[str, Any]] = Field(..., description='List of jobs')
    count: int = Field(..., description='Number of jobs found')
    next_token: Optional[str] = Field(None, description='Token for pagination')
    operation: str = Field(default='list', description='Operation performed')


class StartJobRunData(BaseModel):
    """Data model for start job run operation."""

    job_name: str = Field(..., description='Name of the job')
    job_run_id: str = Field(..., description='ID of the job run')
    operation: str = Field(default='start_run', description='Operation performed')


class StopJobRunData(BaseModel):
    """Data model for stop job run operation."""

    job_name: str = Field(..., description='Name of the job')
    job_run_id: str = Field(..., description='ID of the job run')
    operation: str = Field(default='stop_run', description='Operation performed')


class UpdateJobData(BaseModel):
    """Data model for update job operation."""

    job_name: str = Field(..., description='Name of the updated job')
    operation: str = Field(default='update', description='Operation performed')


# Data models for Workflows
class CreateWorkflowData(BaseModel):
    """Data model for create workflow operation."""

    workflow_name: str = Field(..., description='Name of the created workflow')
    operation: str = Field(default='create-workflow', description='Creates a new workflow.')


class DeleteWorkflowData(BaseModel):
    """Data model for delete workflow operation."""

    workflow_name: str = Field(..., description='Name of the deleted workflow')
    operation: str = Field(default='delete-workflow', description='Deletes a workflow.')


class GetWorkflowData(BaseModel):
    """Data model for get workflow operation."""

    workflow_name: str = Field(..., description='Name of the workflow')
    workflow_details: Dict[str, Any] = Field(..., description='Complete workflow definition')
    operation: str = Field(
        default='get-workflow', description='Retrieves resource metadata for a workflow.'
    )


class ListWorkflowsData(BaseModel):
    """Data model for get workflows operation."""

    workflows: List[Dict[str, Any]] = Field(..., description='List of workflows')
    next_token: Optional[str] = Field(None, description='Token for pagination')
    operation: str = Field(
        default='list-workflows', description='Lists names of workflows created in the account.'
    )


class StartWorkflowRunData(BaseModel):
    """Data model for start workflow run operation."""

    workflow_name: str = Field(..., description='Name of the workflow')
    run_id: str = Field(..., description='ID of the workflow run')
    operation: str = Field(
        default='start-workflow-run', description='Starts a new run of the specified workflow.'
    )


# Data models for Triggers
class CreateTriggerData(BaseModel):
    """Data model for create trigger operation."""

    trigger_name: str = Field(..., description='Name of the created trigger')
    operation: str = Field(default='create-trigger', description='Creates a new trigger.')


class DeleteTriggerData(BaseModel):
    """Data model for delete trigger operation."""

    trigger_name: str = Field(..., description='Name of the deleted trigger')
    operation: str = Field(
        default='delete-trigger',
        description='Deletes a specified trigger. If the trigger is not found, no exception is thrown.',
    )


class GetTriggerData(BaseModel):
    """Data model for get trigger operation."""

    trigger_name: str = Field(..., description='Name of the trigger')
    trigger_details: Dict[str, Any] = Field(..., description='Complete trigger definition')
    operation: str = Field(
        default='get-trigger', description='Retrieves the definition of a trigger.'
    )


class GetTriggersData(BaseModel):
    """Data model for get triggers operation."""

    triggers: List[Dict[str, Any]] = Field(..., description='List of triggers')
    next_token: Optional[str] = Field(None, description='Token for pagination')
    operation: str = Field(
        default='get-triggers', description='Gets all the triggers associated with a job.'
    )


class StartTriggerData(BaseModel):
    """Data model for start trigger operation."""

    trigger_name: str = Field(..., description='Name of the trigger')
    operation: str = Field(default='start-trigger', description='Starts an existing trigger.')


class StopTriggerData(BaseModel):
    """Data model for stop trigger operation."""

    trigger_name: str = Field(..., description='Name of the trigger')
    operation: str = Field(default='stop-trigger', description='Stops a specified trigger.')


# Data models for Job Runs
class GetJobRunData(BaseModel):
    """Data model for get job run operation."""

    job_name: str = Field(..., description='Name of the job')
    job_run_id: str = Field(..., description='ID of the job run')
    job_run_details: Dict[str, Any] = Field(..., description='Complete job run definition')
    operation: str = Field(default='get', description='Operation performed')


class GetJobRunsData(BaseModel):
    """Data model for get job runs operation."""

    job_name: str = Field(..., description='Name of the job')
    job_runs: List[Dict[str, Any]] = Field(..., description='List of job runs')
    count: int = Field(..., description='Number of job runs found')
    next_token: Optional[str] = Field(None, description='Token for pagination')
    operation: str = Field(default='list', description='Operation performed')


class BatchStopJobRunData(BaseModel):
    """Data model for batch stop job run operation."""

    job_name: str = Field(..., description='Name of the job')
    successful_submissions: List[Dict[str, Any]] = Field(
        ..., description='List of successfully stopped job run IDs'
    )
    failed_submissions: List[Dict[str, Any]] = Field(
        ..., description='List of failed stop attempts'
    )
    operation: str = Field(default='batch_stop', description='Operation performed')


# Data models for Bookmarks
class GetJobBookmarkData(BaseModel):
    """Data model for get job bookmark operation."""

    job_name: str = Field(..., description='Name of the job')
    bookmark_details: Dict[str, Any] = Field(..., description='Complete bookmark definition')
    operation: str = Field(default='get', description='Operation performed')


class ResetJobBookmarkData(BaseModel):
    """Data model for reset job bookmark operation."""

    job_name: str = Field(..., description='Name of the job')
    run_id: Optional[str] = Field(None, description='ID of the job run')
    operation: str = Field(default='reset', description='Operation performed')


# Data models for Sessions
class CreateSessionData(BaseModel):
    """Data model for create session operation."""

    session_id: str = Field(..., description='ID of the created session')
    session: Optional[Dict[str, Any]] = Field(None, description='Complete session object')
    operation: str = Field(default='create-session', description='Created a new session.')


class DeleteSessionData(BaseModel):
    """Data model for delete session operation."""

    session_id: str = Field(..., description='ID of the deleted session')
    operation: str = Field(default='delete-session', description='Deleted the session.')


class GetSessionData(BaseModel):
    """Data model for get session operation."""

    session_id: str = Field(..., description='ID of the session')
    session: Optional[Dict[str, Any]] = Field(None, description='Complete session object')
    operation: str = Field(default='get-session', description='Retrieves the session.')


class ListSessionsData(BaseModel):
    """Data model for list sessions operation."""

    sessions: List[Dict[str, Any]] = Field(..., description='List of sessions')
    ids: Optional[List[str]] = Field(None, description='List of session IDs')
    count: int = Field(..., description='Number of sessions found')
    next_token: Optional[str] = Field(None, description='Token for pagination')
    operation: str = Field(default='list-sessions', description='Retrieve a list of sessions.')


class StopSessionData(BaseModel):
    """Data model for stop session operation."""

    session_id: str = Field(..., description='ID of the stopped session')
    operation: str = Field(default='stop-session', description='Stops the session.')


# Data models for Statements
class RunStatementData(BaseModel):
    """Data model for run statement operation."""

    session_id: str = Field(..., description='ID of the session')
    statement_id: int = Field(..., description='ID of the statement')
    operation: str = Field(default='run-statement', description='Executes the statement.')


class CancelStatementData(BaseModel):
    """Data model for cancel statement operation."""

    session_id: str = Field(..., description='ID of the session')
    statement_id: int = Field(..., description='ID of the canceled statement')
    operation: str = Field(default='cancel-statement', description='Cancels the statement.')


class GetStatementData(BaseModel):
    """Data model for get statement operation."""

    session_id: str = Field(..., description='ID of the session')
    statement_id: int = Field(..., description='ID of the statement')
    statement: Optional[Dict[str, Any]] = Field(None, description='Complete statement definition')
    operation: str = Field(default='get-statement', description='Retrieves the statement.')


class ListStatementsData(BaseModel):
    """Data model for list statements operation."""

    session_id: str = Field(..., description='ID of the session')
    statements: List[Dict[str, Any]] = Field(..., description='List of statements')
    count: int = Field(..., description='Number of statements found')
    next_token: Optional[str] = Field(None, description='Token for pagination')
    operation: str = Field(
        default='list-statements', description='Lists statements for the session.'
    )


# Data models for Usage Profiles
class CreateUsageProfileData(BaseModel):
    """Data model for create usage profile operation."""

    profile_name: str = Field(..., description='Name of the created usage profile')
    operation: str = Field(default='create', description='Operation performed')


class DeleteUsageProfileData(BaseModel):
    """Data model for delete usage profile operation."""

    profile_name: str = Field(..., description='Name of the deleted usage profile')
    operation: str = Field(default='delete', description='Operation performed')


class GetUsageProfileData(BaseModel):
    """Data model for get usage profile operation."""

    profile_name: str = Field(..., description='Name of the usage profile')
    profile_details: Dict[str, Any] = Field(..., description='Complete usage profile definition')
    operation: str = Field(default='get', description='Operation performed')


class UpdateUsageProfileData(BaseModel):
    """Data model for update usage profile operation."""

    profile_name: str = Field(..., description='Name of the updated usage profile')
    operation: str = Field(default='update', description='Operation performed')


# Data models for Security
class CreateSecurityConfigurationData(BaseModel):
    """Data model for create security configuration operation."""

    config_name: str = Field(..., description='Name of the created security configuration')
    creation_time: str = Field(..., description='Creation timestamp in ISO format')
    encryption_configuration: Dict[str, Any] = Field(
        {}, description='Encryption configuration settings'
    )
    operation: str = Field(default='create', description='Operation performed')


class DeleteSecurityConfigurationData(BaseModel):
    """Data model for delete security configuration operation."""

    config_name: str = Field(..., description='Name of the deleted security configuration')
    operation: str = Field(default='delete', description='Operation performed')


class GetSecurityConfigurationData(BaseModel):
    """Data model for get security configuration operation."""

    config_name: str = Field(..., description='Name of the security configuration')
    config_details: Dict[str, Any] = Field(
        ..., description='Complete security configuration definition'
    )
    encryption_configuration: Dict[str, Any] = Field(
        {}, description='Encryption configuration settings'
    )
    creation_time: str = Field(..., description='Creation timestamp in ISO format')
    operation: str = Field(default='get', description='Operation performed')


# Data models for Encryption
class GetDataCatalogEncryptionSettingsData(BaseModel):
    """Data model for get data catalog encryption settings operation."""

    encryption_settings: Dict[str, Any] = Field(
        ..., description='Data catalog encryption settings'
    )
    operation: str = Field(default='get', description='Operation performed')


class PutDataCatalogEncryptionSettingsData(BaseModel):
    """Data model for put data catalog encryption settings operation."""

    operation: str = Field(default='put', description='Operation performed')


# Data models for Resource Policies
class GetResourcePolicyData(BaseModel):
    """Data model for get resource policy operation."""

    policy_hash: Optional[str] = Field(None, description='Hash of the resource policy')
    policy_in_json: Optional[str] = Field(None, description='Resource policy in JSON format')
    create_time: Optional[str] = Field(None, description='Creation timestamp in ISO format')
    update_time: Optional[str] = Field(None, description='Last update timestamp in ISO format')
    operation: str = Field(default='get', description='Operation performed')


class PutResourcePolicyData(BaseModel):
    """Data model for put resource policy operation."""

    policy_hash: Optional[str] = Field(None, description='Hash of the resource policy')
    operation: str = Field(default='put', description='Operation performed')


class DeleteResourcePolicyData(BaseModel):
    """Data model for delete resource policy operation."""

    operation: str = Field(default='delete', description='Operation performed')


# Data models for Crawlers
class CreateCrawlerData(BaseModel):
    """Data model for create crawler operation."""

    crawler_name: str = Field(..., description='Name of the created crawler')
    operation: str = Field(default='create', description='Operation performed')


class DeleteCrawlerData(BaseModel):
    """Data model for delete crawler operation."""

    crawler_name: str = Field(..., description='Name of the deleted crawler')
    operation: str = Field(default='delete', description='Operation performed')


class GetCrawlerData(BaseModel):
    """Data model for get crawler operation."""

    crawler_name: str = Field(..., description='Name of the crawler')
    crawler_details: Dict[str, Any] = Field(..., description='Complete crawler definition')
    operation: str = Field(default='get', description='Operation performed')


class GetCrawlersData(BaseModel):
    """Data model for get crawlers operation."""

    crawlers: List[Dict[str, Any]] = Field(..., description='List of crawlers')
    count: int = Field(..., description='Number of crawlers found')
    next_token: Optional[str] = Field(None, description='Token for pagination')
    operation: str = Field(default='list', description='Operation performed')


class StartCrawlerData(BaseModel):
    """Data model for start crawler operation."""

    crawler_name: str = Field(..., description='Name of the crawler')
    operation: str = Field(default='start', description='Operation performed')


class StopCrawlerData(BaseModel):
    """Data model for stop crawler operation."""

    crawler_name: str = Field(..., description='Name of the crawler')
    operation: str = Field(default='stop', description='Operation performed')


class GetCrawlerMetricsData(BaseModel):
    """Data model for get crawler metrics operation."""

    crawler_metrics: List[Dict[str, Any]] = Field(..., description='List of crawler metrics')
    count: int = Field(..., description='Number of crawler metrics found')
    next_token: Optional[str] = Field(None, description='Token for pagination')
    operation: str = Field(default='get_metrics', description='Operation performed')


class StartCrawlerScheduleData(BaseModel):
    """Data model for start crawler schedule operation."""

    crawler_name: str = Field(..., description='Name of the crawler')
    operation: str = Field(default='start_schedule', description='Operation performed')


class StopCrawlerScheduleData(BaseModel):
    """Data model for stop crawler schedule operation."""

    crawler_name: str = Field(..., description='Name of the crawler')
    operation: str = Field(default='stop_schedule', description='Operation performed')


class BatchGetCrawlersData(BaseModel):
    """Data model for batch get crawlers operation."""

    crawlers: List[Any] = Field(..., description='List of crawlers')
    crawlers_not_found: List[str] = Field(..., description='List of crawler names not found')
    operation: str = Field(default='batch_get', description='Operation performed')


class ListCrawlersData(BaseModel):
    """Data model for list crawlers operation."""

    crawlers: List[Any] = Field(..., description='List of crawlers')
    count: int = Field(..., description='Number of crawlers found')
    next_token: Optional[str] = Field(None, description='Token for pagination')
    operation: str = Field(default='list', description='Operation performed')


class UpdateCrawlerData(BaseModel):
    """Data model for update crawler operation."""

    crawler_name: str = Field(..., description='Name of the updated crawler')
    operation: str = Field(default='update', description='Operation performed')


class UpdateCrawlerScheduleData(BaseModel):
    """Data model for update crawler schedule operation."""

    crawler_name: str = Field(..., description='Name of the crawler')
    operation: str = Field(default='update_schedule', description='Operation performed')


# Data models for Classifiers
class CreateClassifierData(BaseModel):
    """Data model for create classifier operation."""

    classifier_name: str = Field(..., description='Name of the created classifier')
    operation: str = Field(default='create', description='Operation performed')


class DeleteClassifierData(BaseModel):
    """Data model for delete classifier operation."""

    classifier_name: str = Field(..., description='Name of the deleted classifier')
    operation: str = Field(default='delete', description='Operation performed')


class GetClassifierData(BaseModel):
    """Data model for get classifier operation."""

    classifier_name: str = Field(..., description='Name of the classifier')
    classifier_details: Dict[str, Any] = Field(..., description='Complete classifier definition')
    operation: str = Field(default='get', description='Operation performed')


class GetClassifiersData(BaseModel):
    """Data model for get classifiers operation."""

    classifiers: List[Dict[str, Any]] = Field(..., description='List of classifiers')
    count: int = Field(..., description='Number of classifiers found')
    next_token: Optional[str] = Field(None, description='Token for pagination')
    operation: str = Field(default='list', description='Operation performed')


class UpdateClassifierData(BaseModel):
    """Data model for update classifier operation."""

    classifier_name: str = Field(..., description='Name of the updated classifier')
    operation: str = Field(default='update', description='Operation performed')
