# LocalStack Resource Provider Base Class Scaffolding v2
#
# AUTOGENERATED FILE - DO NOT EDIT
#

from __future__ import annotations

from abc import ABC, abstractmethod
from pathlib import Path
from typing import TypedDict

import localstack.services.cloudformation.provider_utils as util
from localstack.services.cloudformation.resource_provider import (
    ProgressEvent,
    ResourceProvider,
    ResourceRequest,
)


class LambdaFunctionProperties(TypedDict):
    Code: Code | None
    Role: str | None
    Architectures: list[str] | None
    Arn: str | None
    CapacityProviderConfig: CapacityProviderConfig | None
    CodeSigningConfigArn: str | None
    DeadLetterConfig: DeadLetterConfig | None
    Description: str | None
    DurableConfig: DurableConfig | None
    Environment: Environment | None
    EphemeralStorage: EphemeralStorage | None
    FileSystemConfigs: list[FileSystemConfig] | None
    FunctionName: str | None
    FunctionScalingConfig: FunctionScalingConfig | None
    Handler: str | None
    ImageConfig: ImageConfig | None
    KmsKeyArn: str | None
    Layers: list[str] | None
    LoggingConfig: LoggingConfig | None
    MemorySize: int | None
    PackageType: str | None
    PublishToLatestPublished: bool | None
    RecursiveLoop: str | None
    ReservedConcurrentExecutions: int | None
    Runtime: str | None
    RuntimeManagementConfig: RuntimeManagementConfig | None
    SnapStart: SnapStart | None
    SnapStartResponse: SnapStartResponse | None
    Tags: list[Tag] | None
    TenancyConfig: TenancyConfig | None
    Timeout: int | None
    TracingConfig: TracingConfig | None
    VpcConfig: VpcConfig | None


class FunctionScalingConfig(TypedDict):
    MaxExecutionEnvironments: int | None
    MinExecutionEnvironments: int | None


class TracingConfig(TypedDict):
    Mode: str | None


class VpcConfig(TypedDict):
    Ipv6AllowedForDualStack: bool | None
    SecurityGroupIds: list[str] | None
    SubnetIds: list[str] | None


class RuntimeManagementConfig(TypedDict):
    UpdateRuntimeOn: str | None
    RuntimeVersionArn: str | None


class DurableConfig(TypedDict):
    ExecutionTimeout: int | None
    RetentionPeriodInDays: int | None


class SnapStart(TypedDict):
    ApplyOn: str | None


class FileSystemConfig(TypedDict):
    Arn: str | None
    LocalMountPath: str | None


class TenancyConfig(TypedDict):
    TenantIsolationMode: str | None


class Tag(TypedDict):
    Key: str | None
    Value: str | None


class ImageConfig(TypedDict):
    Command: list[str] | None
    EntryPoint: list[str] | None
    WorkingDirectory: str | None


class DeadLetterConfig(TypedDict):
    TargetArn: str | None


class LambdaManagedInstancesCapacityProviderConfig(TypedDict):
    CapacityProviderArn: str | None
    ExecutionEnvironmentMemoryGiBPerVCpu: float | None
    PerExecutionEnvironmentMaxConcurrency: int | None


class CapacityProviderConfig(TypedDict):
    LambdaManagedInstancesCapacityProviderConfig: (
        LambdaManagedInstancesCapacityProviderConfig | None
    )


class SnapStartResponse(TypedDict):
    ApplyOn: str | None
    OptimizationStatus: str | None


class Code(TypedDict):
    ImageUri: str | None
    S3Bucket: str | None
    S3Key: str | None
    S3ObjectVersion: str | None
    SourceKMSKeyArn: str | None
    ZipFile: str | None


class LoggingConfig(TypedDict):
    ApplicationLogLevel: str | None
    LogFormat: str | None
    LogGroup: str | None
    SystemLogLevel: str | None


class Environment(TypedDict):
    Variables: dict | None


class EphemeralStorage(TypedDict):
    Size: int | None


REPEATED_INVOCATION = "repeated_invocation"


class LambdaFunctionProviderBase(ResourceProvider[LambdaFunctionProperties], ABC):
    TYPE = "AWS::Lambda::Function"  # Autogenerated. Don't change
    SCHEMA = util.get_schema_path(Path(__file__))  # Autogenerated. Don't change

    @abstractmethod
    def create(
        self,
        request: ResourceRequest[LambdaFunctionProperties],
    ) -> ProgressEvent[LambdaFunctionProperties]:
        """
        Create a new resource.

        Primary identifier fields:
          - /properties/FunctionName

        Required properties:
          - Code
          - Role

        Create-only properties:
          - /properties/FunctionName
          - /properties/PackageType
          - /properties/TenancyConfig

        Read-only properties:
          - /properties/SnapStartResponse
          - /properties/SnapStartResponse/ApplyOn
          - /properties/SnapStartResponse/OptimizationStatus
          - /properties/Arn

        IAM permissions required:
          - lambda:CreateFunction
          - lambda:GetFunction
          - lambda:PutFunctionConcurrency
          - iam:PassRole
          - s3:GetObject
          - s3:GetObjectVersion
          - ec2:DescribeSecurityGroups
          - ec2:DescribeSubnets
          - ec2:DescribeVpcs
          - elasticfilesystem:DescribeMountTargets
          - kms:CreateGrant
          - kms:Decrypt
          - kms:Encrypt
          - kms:GenerateDataKey
          - lambda:GetCodeSigningConfig
          - lambda:GetFunctionCodeSigningConfig
          - lambda:GetLayerVersion
          - lambda:GetRuntimeManagementConfig
          - lambda:PutRuntimeManagementConfig
          - lambda:TagResource
          - lambda:PutFunctionRecursionConfig
          - lambda:GetFunctionRecursionConfig
          - lambda:PutFunctionScalingConfig
          - lambda:PassCapacityProvider

        """
        raise NotImplementedError

    @abstractmethod
    def read(
        self,
        request: ResourceRequest[LambdaFunctionProperties],
    ) -> ProgressEvent[LambdaFunctionProperties]:
        """
        Fetch resource information

        IAM permissions required:
          - lambda:GetFunction
          - lambda:GetFunctionCodeSigningConfig
          - lambda:GetFunctionRecursionConfig
          - lambda:GetRuntimeManagementConfig
          - lambda:GetFunctionScalingConfig
        """
        raise NotImplementedError

    @abstractmethod
    def delete(
        self,
        request: ResourceRequest[LambdaFunctionProperties],
    ) -> ProgressEvent[LambdaFunctionProperties]:
        """
        Delete a resource

        IAM permissions required:
          - lambda:DeleteFunction
          - lambda:GetFunction
          - ec2:DescribeNetworkInterfaces
        """
        raise NotImplementedError

    @abstractmethod
    def update(
        self,
        request: ResourceRequest[LambdaFunctionProperties],
    ) -> ProgressEvent[LambdaFunctionProperties]:
        """
        Update a resource

        IAM permissions required:
          - lambda:DeleteFunctionConcurrency
          - lambda:GetFunction
          - lambda:PutFunctionConcurrency
          - lambda:TagResource
          - lambda:UntagResource
          - lambda:UpdateFunctionConfiguration
          - lambda:UpdateFunctionCode
          - iam:PassRole
          - s3:GetObject
          - s3:GetObjectVersion
          - ec2:DescribeSecurityGroups
          - ec2:DescribeSubnets
          - ec2:DescribeVpcs
          - elasticfilesystem:DescribeMountTargets
          - kms:CreateGrant
          - kms:Decrypt
          - kms:GenerateDataKey
          - lambda:GetRuntimeManagementConfig
          - lambda:PutRuntimeManagementConfig
          - lambda:PutFunctionCodeSigningConfig
          - lambda:DeleteFunctionCodeSigningConfig
          - lambda:GetCodeSigningConfig
          - lambda:GetFunctionCodeSigningConfig
          - lambda:PutFunctionRecursionConfig
          - lambda:GetFunctionRecursionConfig
          - lambda:PutFunctionScalingConfig
          - lambda:PublishVersion
          - lambda:PassCapacityProvider
        """
        raise NotImplementedError

    @abstractmethod
    def list(
        self,
        request: ResourceRequest[LambdaFunctionProperties],
    ) -> ProgressEvent[LambdaFunctionProperties]:
        """
        List available resources of this type
        IAM permissions required:
          - lambda:ListFunctions
        """
        raise NotImplementedError
