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

export interface CorsRuleArgs extends core.SchemaArgs {
  allowedHeaders?: core.Array<string> | core.ArrayOut<core.StringOut>;

  allowedMethods: core.Array<string> | core.ArrayOut<core.StringOut>;

  allowedOrigins: core.Array<string> | core.ArrayOut<core.StringOut>;

  exposeHeaders?: core.Array<string> | core.ArrayOut<core.StringOut>;

  id?: string | core.StringOut;

  maxAgeSeconds?: number | core.NumberOut;
}

export class CorsRule extends core.Schema<CorsRuleArgs> {
  @core.attr(String, { kind: "array" })
  public allowedHeaders?: core.Array<string> | core.ArrayOut<core.StringOut>;

  @core.attr(String, { kind: "array" })
  public allowedMethods!: core.Array<string> | core.ArrayOut<core.StringOut>;

  @core.attr(String, { kind: "array" })
  public allowedOrigins!: core.Array<string> | core.ArrayOut<core.StringOut>;

  @core.attr(String, { kind: "array" })
  public exposeHeaders?: core.Array<string> | core.ArrayOut<core.StringOut>;

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

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

export interface BucketCorsConfigurationArgs extends core.ResourceArgs {
  bucket: string | core.StringOut;

  corsRule: core.Array<CorsRule> | core.ArrayOut<CorsRule>;

  expectedBucketOwner?: string | core.StringOut;
}

export class BucketCorsConfiguration extends core.Resource<BucketCorsConfigurationArgs> {
  @core.attr(String)
  public bucket!: string | core.StringOut;

  @core.attr(CorsRule, { kind: "array" })
  public corsRule!: core.Array<CorsRule> | core.ArrayOut<CorsRule>;

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

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

  constructor(name: string, args?: BucketCorsConfigurationArgs) {
    super(name, "aws_s3_bucket_cors_configuration", args);
  }

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