# generated by datamodel-codegen:
#   filename:  openapi.yaml
#   timestamp: 2021-12-31T02:46:33+00:00

from __future__ import annotations

from datetime import datetime
from enum import Enum
from typing import Annotated, Any, List, Optional

from pydantic import BaseModel, Extra, Field


class ServiceQuotaExceededException(BaseModel):
    __root__: Any


class InternalServerException(ServiceQuotaExceededException):
    pass


class ConflictException(ServiceQuotaExceededException):
    pass


class ValidationException(ServiceQuotaExceededException):
    pass


class ThrottlingException(ServiceQuotaExceededException):
    pass


class ResourceNotFoundException(ServiceQuotaExceededException):
    pass


class String(BaseModel):
    __root__: str


class Boolean(BaseModel):
    __root__: bool


class DeleteProfilingGroupResponse(BaseModel):
    """
    The structure representing the deleteProfilingGroupResponse.
    """

    pass


class PostAgentProfileResponse(DeleteProfilingGroupResponse):
    """
    The structure representing the postAgentProfileResponse.
    """

    pass


class Principal(String):
    pass


class SubmitFeedbackResponse(DeleteProfilingGroupResponse):
    """
    The structure representing the SubmitFeedbackResponse.
    """

    pass


class TagResourceResponse(DeleteProfilingGroupResponse):
    pass


class UntagResourceResponse(DeleteProfilingGroupResponse):
    pass


class ActionGroup(Enum):
    agentPermissions = 'agentPermissions'


class ProfilingGroupName(BaseModel):
    __root__: Annotated[str, Field(max_length=255, min_length=1, regex='^[\\w-]+$')]


class AgentParameters(BaseModel):
    pass

    class Config:
        extra = Extra.allow


class Integer(BaseModel):
    __root__: int


class AgentConfiguration(BaseModel):
    """
    The response of <a href="https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ConfigureAgent.html"> <code>ConfigureAgent</code> </a> that specifies if an agent profiles or not and for how long to return profiling data.
    """

    agentParameters: Optional[AgentParameters] = None
    periodInSeconds: Integer
    shouldProfile: Boolean


class AgentOrchestrationConfig(BaseModel):
    """
    Specifies whether profiling is enabled or disabled for a profiling group. It is used by <a href="https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ConfigureAgent.html"> <code>ConfigureAgent</code> </a> to enable or disable profiling for a profiling group.
    """

    profilingEnabled: Boolean


class AgentParameterField(Enum):
    SamplingIntervalInMilliseconds = 'SamplingIntervalInMilliseconds'
    ReportingIntervalInMilliseconds = 'ReportingIntervalInMilliseconds'
    MinimumTimeForReportingInMilliseconds = 'MinimumTimeForReportingInMilliseconds'
    MemoryUsageLimitPercent = 'MemoryUsageLimitPercent'
    MaxStackDepth = 'MaxStackDepth'


class AgentProfile(String):
    pass


class AggregatedProfile(String):
    pass


class AggregationPeriod(Enum):
    PT5M = 'PT5M'
    PT1H = 'PT1H'
    P1D = 'P1D'


class Timestamp(BaseModel):
    __root__: datetime


class AggregatedProfileTime(BaseModel):
    """
    Specifies the aggregation period and aggregation start time for an aggregated profile. An aggregated profile is used to collect posted agent profiles during an aggregation period. There are three possible aggregation periods (1 day, 1 hour, or 5 minutes).
    """

    period: Optional[AggregationPeriod] = None
    start: Optional[Timestamp] = None


class AnomalyInstanceId(BaseModel):
    __root__: Annotated[
        str, Field(regex='[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}')
    ]


class Period1(BaseModel):
    __root__: Annotated[str, Field(max_length=64, min_length=1)]


class UnprocessedEndTimeMap(BaseModel):
    pass

    class Config:
        extra = Extra.allow


class ChannelId(AnomalyInstanceId):
    pass


class ChannelUri(BaseModel):
    __root__: Annotated[
        str,
        Field(
            description='Channel URI uniquely identifies a Notification Channel. TopicArn is the uri for an SNS channel, emailId is uri for an email channel etc. Currently we only support SNS channels and thus required to be an ARN'
        ),
    ]


class ClientToken(BaseModel):
    __root__: Annotated[str, Field(max_length=64, min_length=1, regex='^[\\w-]+$')]


class ComputePlatform(Enum):
    Default = 'Default'
    AWSLambda = 'AWSLambda'


class FleetInstanceId(BaseModel):
    __root__: Annotated[str, Field(max_length=255, min_length=1)]


class Metadata(AgentParameters):
    pass


class ConfigureAgentRequest(BaseModel):
    """
    The structure representing the configureAgentRequest.
    """

    fleetInstanceId: Optional[FleetInstanceId] = None
    metadata: Optional[Metadata] = None


class TagsMap(AgentParameters):
    pass


class CreateProfilingGroupRequest(BaseModel):
    """
    The structure representing the createProfiliingGroupRequest.
    """

    agentOrchestrationConfig: Optional[AgentOrchestrationConfig] = None
    computePlatform: Optional[ComputePlatform] = None
    profilingGroupName: ProfilingGroupName
    tags: Optional[TagsMap] = None


class DeleteProfilingGroupRequest(BaseModel):
    """
    The structure representing the deleteProfilingGroupRequest.
    """

    pass


class DescribeProfilingGroupRequest(BaseModel):
    """
    The structure representing the describeProfilingGroupRequest.
    """

    pass


class Double(BaseModel):
    __root__: float


class EventPublisher(Enum):
    AnomalyDetection = 'AnomalyDetection'


class FeedbackType(Enum):
    Positive = 'Positive'
    Negative = 'Negative'


class FindingsReportId(AnomalyInstanceId):
    pass


class FindingsReportSummary(BaseModel):
    """
    Information about potential recommendations that might be created from the analysis of profiling data.
    """

    id: Optional[FindingsReportId] = None
    profileEndTime: Optional[Timestamp] = None
    profileStartTime: Optional[Timestamp] = None
    profilingGroupName: Optional[String] = None
    totalNumberOfFindings: Optional[Integer] = None


class FindingsReportSummaries(BaseModel):
    __root__: List[FindingsReportSummary]


class ThreadStates(BaseModel):
    __root__: List[String]


class MetricType(Enum):
    AggregatedRelativeTotalTime = 'AggregatedRelativeTotalTime'


class FrameMetricValue(Double):
    pass


class MaxResults(BaseModel):
    __root__: Annotated[int, Field(ge=1.0, le=1000.0)]


class PaginationToken(ClientToken):
    pass


class GetFindingsReportAccountSummaryRequest(BaseModel):
    """
    The structure representing the GetFindingsReportAccountSummaryRequest.
    """

    pass


class GetNotificationConfigurationRequest(BaseModel):
    """
    The structure representing the GetNotificationConfigurationRequest.
    """

    pass


class GetPolicyRequest(BaseModel):
    """
    The structure representing the <code>getPolicyRequest</code>.
    """

    pass


class RevisionId(AnomalyInstanceId):
    pass


class MaxDepth(BaseModel):
    __root__: Annotated[int, Field(ge=1.0, le=10000.0)]


class GetProfileRequest(BaseModel):
    """
    The structure representing the getProfileRequest.
    """

    pass


class Locale(BaseModel):
    __root__: Annotated[
        str,
        Field(
            description='BCP47 language code. Supported locales: de-DE, en-GB, en-US, es-ES, fr-FR, it-IT, ja-JP, ko-KR, pt-BR, zh-CN, zh-TW'
        ),
    ]


class GetRecommendationsRequest(BaseModel):
    """
    The structure representing the GetRecommendationsRequest.
    """

    pass


class ListFindingsReportsRequest(BaseModel):
    """
    The structure representing the ListFindingsReportsRequest.
    """

    pass


class TimestampStructure(BaseModel):
    """
    A data type that contains a <code>Timestamp</code> object. This is specified using the ISO 8601 format. For example, 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020 1:15:02 PM UTC.
    """

    value: Timestamp


class OrderBy(Enum):
    TimestampDescending = 'TimestampDescending'
    TimestampAscending = 'TimestampAscending'


class ListProfileTimesRequest(BaseModel):
    """
    The structure representing the listProfileTimesRequest.
    """

    pass


class ListProfilingGroupsRequest(BaseModel):
    """
    The structure representing the listProfilingGroupsRequest.
    """

    pass


class ProfilingGroupNames(BaseModel):
    __root__: List[ProfilingGroupName]


class ProfilingGroupArn(String):
    pass


class ListTagsForResourceRequest(BaseModel):
    pass


class Match(BaseModel):
    """
    The part of a profile that contains a recommendation found during analysis.
    """

    frameAddress: Optional[String] = None
    targetFramesIndex: Optional[Integer] = None
    thresholdBreachValue: Optional[Double] = None


class Matches(BaseModel):
    __root__: List[Match]


class MetadataField(Enum):
    ComputePlatform = 'ComputePlatform'
    AgentId = 'AgentId'
    AwsRequestId = 'AwsRequestId'
    ExecutionEnvironment = 'ExecutionEnvironment'
    LambdaFunctionArn = 'LambdaFunctionArn'
    LambdaMemoryLimitInMB = 'LambdaMemoryLimitInMB'
    LambdaRemainingTimeInMilliseconds = 'LambdaRemainingTimeInMilliseconds'
    LambdaTimeGapBetweenInvokesInMilliseconds = (
        'LambdaTimeGapBetweenInvokesInMilliseconds'
    )
    LambdaPreviousExecutionTimeInMilliseconds = (
        'LambdaPreviousExecutionTimeInMilliseconds'
    )


class Strings(ThreadStates):
    pass


class Percentage(BaseModel):
    __root__: Annotated[float, Field(ge=0.0, le=100.0)]


class PostAgentProfileRequest(BaseModel):
    """
    The structure representing the postAgentProfileRequest.
    """

    agentProfile: AgentProfile


class Principals(BaseModel):
    __root__: Annotated[List[Principal], Field(max_items=50, min_items=1)]


class ProfileTime(BaseModel):
    """
    Contains the start time of a profile.
    """

    start: Optional[Timestamp] = None


class ProfilingStatus(BaseModel):
    """
    Profiling status includes information about the last time a profile agent pinged back, the last time a profile was received, and the aggregation period and start time for the most recent aggregated profile.
    """

    latestAgentOrchestratedAt: Optional[Timestamp] = None
    latestAgentProfileReportedAt: Optional[Timestamp] = None
    latestAggregatedProfile: Optional[AggregatedProfileTime] = None


class PutPermissionRequest(BaseModel):
    """
    The structure representing the <code>putPermissionRequest</code>.
    """

    principals: Principals
    revisionId: Optional[RevisionId] = None


class RemoveNotificationChannelRequest(BaseModel):
    """
    The structure representing the RemoveNotificationChannelRequest.
    """

    pass


class RemovePermissionRequest(BaseModel):
    """
    <pre><code> The structure representing the &lt;code&gt;removePermissionRequest&lt;/code&gt;.&lt;/p&gt; </code></pre>
    """

    pass


class SubmitFeedbackRequest(BaseModel):
    """
    The structure representing the SubmitFeedbackRequest.
    """

    comment: Optional[String] = None
    type: FeedbackType


class TagKeys(ThreadStates):
    pass


class TagResourceRequest(BaseModel):
    tags: TagsMap


class TargetFrame(ThreadStates):
    pass


class UntagResourceRequest(BaseModel):
    pass


class UpdateProfilingGroupRequest(BaseModel):
    """
    The structure representing the updateProfilingGroupRequest.
    """

    agentOrchestrationConfig: AgentOrchestrationConfig


class FrameMetric(BaseModel):
    """
    The frame name, metric type, and thread states. These are used to derive the value of the metric for the frame.
    """

    frameName: String
    threadStates: ThreadStates
    type: MetricType


class ConfigureAgentResponse(BaseModel):
    """
    The structure representing the configureAgentResponse.
    """

    configuration: AgentConfiguration


class GetFindingsReportAccountSummaryResponse(BaseModel):
    """
    The structure representing the GetFindingsReportAccountSummaryResponse.
    """

    nextToken: Optional[PaginationToken] = None
    reportSummaries: FindingsReportSummaries


class GetPolicyResponse(BaseModel):
    """
    The structure representing the <code>getPolicyResponse</code>.
    """

    policy: String
    revisionId: RevisionId


class GetProfileResponse(BaseModel):
    """
    The structure representing the getProfileResponse.
    """

    profile: AggregatedProfile


class ListFindingsReportsResponse(BaseModel):
    """
    The structure representing the ListFindingsReportsResponse.
    """

    findingsReportSummaries: FindingsReportSummaries
    nextToken: Optional[PaginationToken] = None


class ListTagsForResourceResponse(BaseModel):
    tags: Optional[TagsMap] = None


class PutPermissionResponse(GetPolicyResponse):
    """
    The structure representing the <code>putPermissionResponse</code>.
    """

    pass


class RemovePermissionResponse(GetPolicyResponse):
    """
    The structure representing the <code>removePermissionResponse</code>.
    """

    pass


class Metric(BaseModel):
    """
    Details about the metric that the analysis used when it detected the anomaly. The metric what is analyzed to create recommendations. It includes the name of the frame that was analyzed and the type and thread states used to derive the metric value for that frame.
    """

    frameName: String
    threadStates: Strings
    type: MetricType


class UserFeedback(BaseModel):
    """
    Feedback that can be submitted for each instance of an anomaly by the user. Feedback is be used for improvements in generating recommendations for the application.
    """

    type: FeedbackType


class AnomalyInstance(BaseModel):
    """
    The specific duration in which the metric is flagged as anomalous.
    """

    endTime: Optional[Timestamp] = None
    id: String
    startTime: Timestamp
    userFeedback: Optional[UserFeedback] = None


class FrameMetrics(BaseModel):
    __root__: List[FrameMetric]


class BatchGetFrameMetricDataRequest(BaseModel):
    """
    The structure representing the BatchGetFrameMetricDataRequest.
    """

    frameMetrics: Optional[FrameMetrics] = None


class ListOfTimestamps(BaseModel):
    __root__: List[TimestampStructure]


class EventPublishers(BaseModel):
    __root__: Annotated[List[EventPublisher], Field(max_items=1, min_items=1)]


class ProfilingGroupDescription(BaseModel):
    """
    Contains information about a profiling group.
    """

    agentOrchestrationConfig: Optional[AgentOrchestrationConfig] = None
    arn: Optional[ProfilingGroupArn] = None
    computePlatform: Optional[ComputePlatform] = None
    createdAt: Optional[Timestamp] = None
    name: Optional[ProfilingGroupName] = None
    profilingStatus: Optional[ProfilingStatus] = None
    tags: Optional[TagsMap] = None
    updatedAt: Optional[Timestamp] = None


class FrameMetricValues(BaseModel):
    __root__: List[FrameMetricValue]


class ProfileTimes(BaseModel):
    __root__: List[ProfileTime]


class ProfilingGroupDescriptions(BaseModel):
    __root__: List[ProfilingGroupDescription]


class TargetFrames(BaseModel):
    __root__: List[TargetFrame]


class Pattern(BaseModel):
    """
    A set of rules used to make a recommendation during an analysis.
    """

    countersToAggregate: Optional[Strings] = None
    description: Optional[String] = None
    id: Optional[String] = None
    name: Optional[String] = None
    resolutionSteps: Optional[String] = None
    targetFrames: Optional[TargetFrames] = None
    thresholdPercent: Optional[Percentage] = None


class Recommendation(BaseModel):
    """
    A potential improvement that was found from analyzing the profiling data.
    """

    allMatchesCount: Integer
    allMatchesSum: Double
    endTime: Timestamp
    pattern: Pattern
    startTime: Timestamp
    topMatches: Matches


class Channel(BaseModel):
    """
    Notification medium for users to get alerted for events that occur in application profile. We support SNS topic as a notification channel.
    """

    eventPublishers: EventPublishers
    id: Optional[ChannelId] = None
    uri: ChannelUri


class CreateProfilingGroupResponse(BaseModel):
    """
    The structure representing the createProfilingGroupResponse.
    """

    profilingGroup: ProfilingGroupDescription


class DescribeProfilingGroupResponse(CreateProfilingGroupResponse):
    """
    The structure representing the describeProfilingGroupResponse.
    """

    pass


class ListProfileTimesResponse(BaseModel):
    """
    The structure representing the listProfileTimesResponse.
    """

    nextToken: Optional[PaginationToken] = None
    profileTimes: ProfileTimes


class ListProfilingGroupsResponse(BaseModel):
    """
    The structure representing the listProfilingGroupsResponse.
    """

    nextToken: Optional[PaginationToken] = None
    profilingGroupNames: ProfilingGroupNames
    profilingGroups: Optional[ProfilingGroupDescriptions] = None


class UpdateProfilingGroupResponse(CreateProfilingGroupResponse):
    """
    The structure representing the updateProfilingGroupResponse.
    """

    pass


class Channels(BaseModel):
    __root__: Annotated[List[Channel], Field(max_items=2, min_items=1)]


class AddNotificationChannelsRequest(BaseModel):
    """
    The structure representing the AddNotificationChannelsRequest.
    """

    channels: Channels


class NotificationConfiguration(BaseModel):
    """
    The configuration for notifications stored for each profiling group. This includes up to to two channels and a list of event publishers associated with each channel.
    """

    channels: Optional[Channels] = None


class AnomalyInstances(BaseModel):
    __root__: List[AnomalyInstance]


class FrameMetricDatum(BaseModel):
    """
    Information about a frame metric and its values.
    """

    frameMetric: FrameMetric
    values: FrameMetricValues


class Recommendations(BaseModel):
    __root__: List[Recommendation]


class AddNotificationChannelsResponse(BaseModel):
    """
    The structure representing the AddNotificationChannelsResponse.
    """

    notificationConfiguration: Optional[NotificationConfiguration] = None


class GetNotificationConfigurationResponse(BaseModel):
    """
    The structure representing the GetNotificationConfigurationResponse.
    """

    notificationConfiguration: NotificationConfiguration


class RemoveNotificationChannelResponse(AddNotificationChannelsResponse):
    """
    The structure representing the RemoveNotificationChannelResponse.
    """

    pass


class Anomaly(BaseModel):
    """
    Details about an anomaly in a specific metric of application profile. The anomaly is detected using analysis of the metric data over a period of time.
    """

    instances: AnomalyInstances
    metric: Metric
    reason: String


class Anomalies(BaseModel):
    __root__: List[Anomaly]


class FrameMetricData(BaseModel):
    __root__: List[FrameMetricDatum]


class BatchGetFrameMetricDataResponse(BaseModel):
    """
    The structure representing the BatchGetFrameMetricDataResponse.
    """

    endTime: Timestamp
    endTimes: ListOfTimestamps
    frameMetricData: FrameMetricData
    resolution: AggregationPeriod
    startTime: Timestamp
    unprocessedEndTimes: UnprocessedEndTimeMap


class GetRecommendationsResponse(BaseModel):
    """
    The structure representing the GetRecommendationsResponse.
    """

    anomalies: Anomalies
    profileEndTime: Timestamp
    profileStartTime: Timestamp
    profilingGroupName: ProfilingGroupName
    recommendations: Recommendations
