from __future__ import annotations
import datetime
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Optional, TYPE_CHECKING, Union

@dataclass
class WithRequestPatchRequestBody(Parsable):
    # The callback URL specified for the data request. If specified, the Data Connection service calls the URL each time a job executes for the request. The service sends a POST request that provides job execution information. The JSON payload in the POST request contains the following: ``{ ``accountId``: ``account_id``, ``requestId``: ``request_id``, ``jobId``: ``data_connector_job_id``, ``state``: ``complete``, ``success``: true or false }``.If not specified, the Data Connection service does not provide a callback.
    callback_url: Optional[str] = None
    # The user-entered description of this data request.
    description: Optional[str] = None
    # The date and time when a one-time job execution or a recurring interval schedule begins, presented in ISO 8601 format.
    effective_from: Optional[datetime.datetime] = None
    # The date and time when the recurring interval schedule ends, presented in ISO 8601 format.
    effective_to: Optional[datetime.datetime] = None
    # The end date and time for the data extraction, in ISO 8601 format.This field applies only to schemas supporting date range extraction. The detailed schema documentation delivered with each data extract identifies the schemas and tables that support date range extraction.Additional notes on using ``startDate`` and ``endDate``:- If you provide only ``startDate`` or ``endDate`` (but not both), Data Connector uses that single date for both ``startDate`` and ``endDate``.- If you request more than the Maximum Date Range Allowed for an extraction, the default date range as documented in the schema documentation is returned.- For the ``activities`` service group, data replication can be delayed up to 20 minutes, so your requests should account for that delay.
    end_date: Optional[str] = None
    # The data request's active/inactive status. Possible values: ``true`` the request is active; ``false`` the request is inactive.
    is_active: Optional[bool] = None
    # (Legacy): A single project ID for the data request. Superseded by ``projectIdList``.
    project_id: Optional[str] = None
    # A list of up to 50 project IDs for the data request, which can include a single project or multiple projects. If ``projectId`` is also included, ``projectIdList`` takes precedence. Required for users with project admin permissions. Optional for users with executive overview permissions, who by default receive data for all projects unless ``projectIdList`` is provided.
    project_id_list: Optional[str] = None
    # The number of ``scheduleInterval`` units to wait between job execution for the request. For example, a ``scheduleInterval`` value of ``WEEK`` and a ``reoccuringInterval`` value of ``2`` means the job will run every two weeks.
    reoccuring_interval: Optional[int] = None
    # The scheduling interval unit for jobs spawned by this data request. This value is multiplied by the ``reoccurringInterval`` attribute to specify the length of the recurring interval at which jobs run. Possible values:- ``ONE_TIME``: Run the job only once- ``DAY``: Set the recurring job interval in days- ``WEEK``: Set the recurring job interval in weeks- ``MONTH``: Set the recurring job interval in months- ``YEAR``: Set the recurring job interval in yearsNote that recurring jobs start at the day and time when the request first spawns a job. This may be at the date and time specified in the attribute ``effectiveFrom``.This value is required.
    schedule_interval: Optional[str] = None
    # Send a notification email to the user upon job completion. Values: true or false (default is true)
    send_email: Optional[bool] = None
    # The service groups from which to extract data, separated by commas.Possible values: ``all``, ``activities``, ``admin``, ``assets``, ``checklists``, ``cost``, ``dailylogs``, ``forms``, ``iq``, ``issues``, ``locations``, ``markups``, ``meetingminutes``, ``photos``, ``relationships``, ``reviews``, ``rfis``, ``schedule``, ``sheets``, ``submittals``, ``submittalsacc``, ``transmittals``.Note that the ``admin`` service includes both project and account admin, and ``all`` produces an extract containing all currently available service groups.
    service_groups: Optional[list[str]] = None
    # The start date and time for the data extraction, in ISO 8601 format.This field applies only to schemas supporting date range extraction. The detailed schema documentation delivered with each data extract identifies the schemas and tables that support date range extraction.Additional notes on using ``startDate`` and ``endDate``:- If you provide only ``startDate`` or ``endDate`` (but not both), Data Connector uses that single date for both ``startDate`` and ``endDate``.- If you request more than the Maximum Date Range Allowed for an extraction, the default date range as documented in the schema documentation is returned.- For the ``activities`` service group, data replication can be delayed up to 20 minutes, so your requests should account for that delay.
    start_date: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> WithRequestPatchRequestBody:
        """
        Creates a new instance of the appropriate class based on discriminator value
        param parse_node: The parse node to use to read the discriminator value and create the object
        Returns: WithRequestPatchRequestBody
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return WithRequestPatchRequestBody()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        fields: dict[str, Callable[[Any], None]] = {
            "callbackUrl": lambda n : setattr(self, 'callback_url', n.get_str_value()),
            "description": lambda n : setattr(self, 'description', n.get_str_value()),
            "effectiveFrom": lambda n : setattr(self, 'effective_from', n.get_datetime_value()),
            "effectiveTo": lambda n : setattr(self, 'effective_to', n.get_datetime_value()),
            "endDate": lambda n : setattr(self, 'end_date', n.get_str_value()),
            "isActive": lambda n : setattr(self, 'is_active', n.get_bool_value()),
            "projectId": lambda n : setattr(self, 'project_id', n.get_str_value()),
            "projectIdList": lambda n : setattr(self, 'project_id_list', n.get_str_value()),
            "reoccuringInterval": lambda n : setattr(self, 'reoccuring_interval', n.get_int_value()),
            "scheduleInterval": lambda n : setattr(self, 'schedule_interval', n.get_str_value()),
            "sendEmail": lambda n : setattr(self, 'send_email', n.get_bool_value()),
            "serviceGroups": lambda n : setattr(self, 'service_groups', n.get_collection_of_primitive_values(str)),
            "startDate": lambda n : setattr(self, 'start_date', n.get_str_value()),
        }
        return fields
    
    def serialize(self,writer: SerializationWriter) -> None:
        """
        Serializes information the current object
        param writer: Serialization writer to use to serialize this model
        Returns: None
        """
        if writer is None:
            raise TypeError("writer cannot be null.")
        writer.write_str_value("callbackUrl", self.callback_url)
        writer.write_str_value("description", self.description)
        writer.write_datetime_value("effectiveFrom", self.effective_from)
        writer.write_datetime_value("effectiveTo", self.effective_to)
        writer.write_str_value("endDate", self.end_date)
        writer.write_bool_value("isActive", self.is_active)
        writer.write_str_value("projectId", self.project_id)
        writer.write_str_value("projectIdList", self.project_id_list)
        writer.write_int_value("reoccuringInterval", self.reoccuring_interval)
        writer.write_str_value("scheduleInterval", self.schedule_interval)
        writer.write_bool_value("sendEmail", self.send_email)
        writer.write_collection_of_primitive_values("serviceGroups", self.service_groups)
        writer.write_str_value("startDate", self.start_date)
    

