apiVersion: runtimeconditions.io/v1alpha1
kind: RuntimeConditionsExtensionDefinition
metadata:
  id: https://runtimeconditions.io/extensions/aws/secrets-manager/0.1.0/runtimeconditions.extension.yaml
  version: 0.1.0
  description: Declares the AWS Secrets Manager API operations a workload needs to call.
spec:
  kinds:
    - name: aws.secrets_manager
      description: Direct AWS Secrets Manager API access for application and platform workloads.
  interfaceTypes:
    - name: secret
      targetKind: aws.secrets_manager
      description: Calls that target one existing secret resolved by the platform.
    - name: service
      targetKind: aws.secrets_manager
      description: Service calls that can run without selecting an existing secret.
    - name: batch
      targetKind: aws.secrets_manager
      description: Batch calls that select secrets by identifiers or filters at runtime.
  interfaceFields:
    - name: operations
      targetKind: aws.secrets_manager
      targetType: secret
      description: Distinct Secrets Manager API operations required on the named secret.
    - name: operations
      targetKind: aws.secrets_manager
      targetType: service
      description: Distinct Secrets Manager service operations required by the workload.
    - name: operations
      targetKind: aws.secrets_manager
      targetType: batch
      description: Distinct Secrets Manager API operations required for batch access.
  fieldValues:
    - field: interface.operations[].name
      targetKind: aws.secrets_manager
      targetType: secret
      values:
        - AssociateCrossAccountReplica
        - CancelRotateSecret
        - DeleteResourcePolicy
        - DeleteSecret
        - DescribeSecret
        - DisassociateCrossAccountReplica
        - GetResourcePolicy
        - GetSecretValue
        - ListResourcePolicies
        - ListSecretVersionIds
        - PutResourcePolicy
        - PutSecretValue
        - RemoveRegionsFromReplication
        - ReplicateSecretToRegions
        - RestoreSecret
        - RotateSecret
        - StopReplicationToReplica
        - TagResource
        - UntagResource
        - UpdateSecret
        - UpdateSecretVersionStage
      valueDescriptions:
        AssociateCrossAccountReplica: 'Associate a primary secret with an existing replica in another AWS account.'
        CancelRotateSecret: 'Cancel scheduled rotation for the secret.'
        DeleteResourcePolicy: 'Remove a resource policy associated with the secret.'
        DeleteSecret: 'Schedule or request deletion of the secret.'
        DescribeSecret: 'Retrieve the secret''s metadata without reading its value.'
        DisassociateCrossAccountReplica: 'Detach a cross-account replica from the primary secret.'
        GetResourcePolicy: 'Retrieve a resource policy associated with the secret.'
        GetSecretValue: 'Retrieve the value of a version of the secret.'
        ListResourcePolicies: 'List the resource policies associated with the secret.'
        ListSecretVersionIds: 'List the versions of the secret.'
        PutResourcePolicy: 'Attach or update a resource policy for the secret.'
        PutSecretValue: 'Add a new version of the secret value.'
        RemoveRegionsFromReplication: 'Remove the secret''s replicas from specified regions.'
        ReplicateSecretToRegions: 'Replicate the secret to additional regions.'
        RestoreSecret: 'Cancel a scheduled deletion of the secret.'
        RotateSecret: 'Configure or initiate rotation for the secret.'
        StopReplicationToReplica: 'Promote a replica to an independent secret.'
        TagResource: 'Add or update tags on the secret.'
        UntagResource: 'Remove tags from the secret.'
        UpdateSecret: 'Update secret settings or add a new secret value.'
        UpdateSecretVersionStage: 'Move or remove a staging label on a secret version.'
    - field: interface.operations[].name
      targetKind: aws.secrets_manager
      targetType: service
      values:
        - CreateSecret
        - GetRandomPassword
        - ListSecrets
        - ValidateResourcePolicy
      valueDescriptions:
        CreateSecret: 'Create a secret through the Secrets Manager API.'
        GetRandomPassword: 'Generate a password through the Secrets Manager API.'
        ListSecrets: 'List secrets visible to the workload.'
        ValidateResourcePolicy: 'Validate a prospective resource policy, optionally for a particular secret.'
    - field: interface.operations[].name
      targetKind: aws.secrets_manager
      targetType: batch
      values:
        - BatchGetSecretValue
      valueDescriptions:
        BatchGetSecretValue: 'Retrieve values for multiple secrets selected by identifiers or filters.'
  schemas:
    - id: aws-secrets-manager-secret
      appliesToKind: aws.secrets_manager
      appliesToInterfaceType: secret
      description: Validates the secret interface and its supported Secrets Manager operations.
      schema:
        $schema: https://json-schema.org/draft/2020-12/schema
        type: object
        required: [name, kind, interface]
        properties:
          name:
            type: string
            pattern: '\S'
            description: Logical name the platform uses to resolve the secret.
          kind:
            const: aws.secrets_manager
            description: Selects AWS Secrets Manager API semantics.
          interface:
            type: object
            description: Calls that target one existing secret resolved by the platform.
            required: [type, operations]
            properties:
              type:
                const: secret
                description: Selects the secret scope for the required API operations.
              operations:
                type: array
                description: Distinct API operations required by the workload.
                minItems: 1
                uniqueItems: true
                items:
                  type: object
                  required: [name]
                  properties:
                    name:
                      description: Canonical name of a Secrets Manager API operation.
                      enum:
                        - AssociateCrossAccountReplica
                        - CancelRotateSecret
                        - DeleteResourcePolicy
                        - DeleteSecret
                        - DescribeSecret
                        - DisassociateCrossAccountReplica
                        - GetResourcePolicy
                        - GetSecretValue
                        - ListResourcePolicies
                        - ListSecretVersionIds
                        - PutResourcePolicy
                        - PutSecretValue
                        - RemoveRegionsFromReplication
                        - ReplicateSecretToRegions
                        - RestoreSecret
                        - RotateSecret
                        - StopReplicationToReplica
                        - TagResource
                        - UntagResource
                        - UpdateSecret
                        - UpdateSecretVersionStage
                  additionalProperties: false
            additionalProperties: false
    - id: aws-secrets-manager-service
      appliesToKind: aws.secrets_manager
      appliesToInterfaceType: service
      description: Validates the service interface and its supported Secrets Manager operations.
      schema:
        $schema: https://json-schema.org/draft/2020-12/schema
        type: object
        required: [kind, interface]
        properties:
          kind:
            const: aws.secrets_manager
            description: Selects AWS Secrets Manager API semantics.
          interface:
            type: object
            description: Service calls that can run without selecting an existing secret.
            required: [type, operations]
            properties:
              type:
                const: service
                description: Selects the service scope for the required API operations.
              operations:
                type: array
                description: Distinct API operations required by the workload.
                minItems: 1
                uniqueItems: true
                items:
                  type: object
                  required: [name]
                  properties:
                    name:
                      description: Canonical name of a Secrets Manager API operation.
                      enum:
                        - CreateSecret
                        - GetRandomPassword
                        - ListSecrets
                        - ValidateResourcePolicy
                  additionalProperties: false
            additionalProperties: false
    - id: aws-secrets-manager-batch
      appliesToKind: aws.secrets_manager
      appliesToInterfaceType: batch
      description: Validates the batch interface and its supported Secrets Manager operations.
      schema:
        $schema: https://json-schema.org/draft/2020-12/schema
        type: object
        required: [kind, interface]
        properties:
          kind:
            const: aws.secrets_manager
            description: Selects AWS Secrets Manager API semantics.
          interface:
            type: object
            description: Batch calls that select secrets by identifiers or filters at runtime.
            required: [type, operations]
            properties:
              type:
                const: batch
                description: Selects the batch scope for the required API operations.
              operations:
                type: array
                description: Distinct API operations required by the workload.
                minItems: 1
                uniqueItems: true
                items:
                  type: object
                  required: [name]
                  properties:
                    name:
                      description: Canonical name of a Secrets Manager API operation.
                      enum:
                        - BatchGetSecretValue
                  additionalProperties: false
            additionalProperties: false
