import * as core from "@terrascript/core";

export interface OnFailureArgs extends core.SchemaArgs {
  destination: string | core.StringOut;
}

export class OnFailure extends core.Schema<OnFailureArgs> {
  @core.attr(String)
  public destination!: string | core.StringOut;
}

export interface OnSuccessArgs extends core.SchemaArgs {
  destination: string | core.StringOut;
}

export class OnSuccess extends core.Schema<OnSuccessArgs> {
  @core.attr(String)
  public destination!: string | core.StringOut;
}

export interface DestinationConfigArgs extends core.SchemaArgs {
  onFailure?: OnFailure;

  onSuccess?: OnSuccess;
}

export class DestinationConfig extends core.Schema<DestinationConfigArgs> {
  @core.attr(OnFailure)
  public onFailure?: OnFailure;

  @core.attr(OnSuccess)
  public onSuccess?: OnSuccess;
}

export interface FunctionEventInvokeConfigArgs extends core.ResourceArgs {
  destinationConfig?: DestinationConfig;

  functionName: string | core.StringOut;

  maximumEventAgeInSeconds?: number | core.NumberOut;

  maximumRetryAttempts?: number | core.NumberOut;

  qualifier?: string | core.StringOut;
}

export class FunctionEventInvokeConfig extends core.Resource<FunctionEventInvokeConfigArgs> {
  @core.attr(DestinationConfig)
  public destinationConfig?: DestinationConfig;

  @core.attr(String)
  public functionName!: string | core.StringOut;

  @core.attr(String, { computed: true })
  public id!: string | core.StringOut;

  @core.attr(Number)
  public maximumEventAgeInSeconds?: number | core.NumberOut;

  @core.attr(Number)
  public maximumRetryAttempts?: number | core.NumberOut;

  @core.attr(String)
  public qualifier?: string | core.StringOut;

  constructor(name: string, args?: FunctionEventInvokeConfigArgs) {
    super(name, "aws_lambda_function_event_invoke_config", args);
  }

  public override getNamespace(): string {
    return "aws_lambda";
  }
}
