Record Class S3Config

java.lang.Object
java.lang.Record
br.com.xadm.comum.armazenamento.S3Config
Record Components:
endpoint - URL do endpoint S3.
region - região S3 (deve bater com o servidor; default garage).
accessKeyId - access key id (GARAGE_ACCESS_KEY_ID).
secretAccessKey - secret access key (GARAGE_SECRET_ACCESS_KEY).
bucket - bucket dedicado deste app.
criarBucket - se true, cria o bucket no startup quando ausente.

@ConfigurationProperties("garage") public record S3Config(String endpoint, String region, @Nullable String accessKeyId, @Nullable String secretAccessKey, String bucket, boolean criarBucket) extends Record
Configuração do object storage S3-compatível (Garage) — prefixo garage.*. O prefixo nomeia o produto (Garage) que a casa opera; a API por baixo é a do S3 (AWS SDK v2), então a lib segue swappável a qualquer backend S3-compatível.

Os nomes casam com as envs que o broker da Central injeta no recurso, e o Micronaut as liga direto, sem linha no application.yml do app: GARAGE_ACCESS_KEY_ID → garage.access-key-id → accessKeyId(), GARAGE_SECRET_ACCESS_KEY → garage.secret-access-key → secretAccessKey().

Os nomes antigos (garage.access-key/garage.secret-key) seguem lidos pelo S3ClientFactory enquanto houver deploy com eles (dual-read) — ver o CHANGELOG do módulo. Por isso os dois componentes da credencial aceitam null: quem cobra a ausência dos dois pares é o S3ClientFactory, e só quando o ArmazenamentoModo grava ou lê do Garage.

Apps com backend nomeado (que não querem o prefixo global garage.*) sobrescrevem o bean via @Factory + @Replaces(S3Config.class), lendo o próprio prefixo — ver README.

  • Constructor Details

    • S3Config

      public S3Config(String endpoint, @Bindable(defaultValue="garage") String region, @Nullable @Nullable String accessKeyId, @Nullable @Nullable String secretAccessKey, String bucket, @Bindable(defaultValue="false") boolean criarBucket)
      Creates an instance of a S3Config record class.
      Parameters:
      endpoint - the value for the endpoint record component
      region - the value for the region record component
      accessKeyId - the value for the accessKeyId record component
      secretAccessKey - the value for the secretAccessKey record component
      bucket - the value for the bucket record component
      criarBucket - the value for the criarBucket record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • endpoint

      public String endpoint()
      Returns the value of the endpoint record component.
      Returns:
      the value of the endpoint record component
    • region

      @Bindable(defaultValue="garage") public String region()
      Returns the value of the region record component.
      Returns:
      the value of the region record component
    • accessKeyId

      @Nullable public @Nullable String accessKeyId()
      Returns the value of the accessKeyId record component.
      Returns:
      the value of the accessKeyId record component
    • secretAccessKey

      @Nullable public @Nullable String secretAccessKey()
      Returns the value of the secretAccessKey record component.
      Returns:
      the value of the secretAccessKey record component
    • bucket

      public String bucket()
      Returns the value of the bucket record component.
      Returns:
      the value of the bucket record component
    • criarBucket

      @Bindable(defaultValue="false") public boolean criarBucket()
      Returns the value of the criarBucket record component.
      Returns:
      the value of the criarBucket record component