# `Gemini.Types.Document`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L1)

Type definitions for RAG document management.

Documents are stored in RAG stores and used for semantic search and
retrieval-augmented generation (RAG) workflows.

## Document Lifecycle

1. Upload a file to a RAG store
2. Document is created with metadata
3. Document is indexed for search
4. Use in generation with grounding

## Example

    # List documents in a store
    {:ok, response} = Gemini.APIs.Documents.list("ragStores/my-store")

    # Get document metadata
    {:ok, doc} = Gemini.APIs.Documents.get("ragStores/my-store/documents/doc123")

    # Delete when no longer needed
    :ok = Gemini.APIs.Documents.delete(doc.name)

# `document_metadata`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L41)

```elixir
@type document_metadata() :: %{optional(String.t()) =&gt; String.t()}
```

Document metadata for custom properties.

# `document_state`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L32)

```elixir
@type document_state() :: :state_unspecified | :processing | :active | :failed
```

Document state enumeration.

# `t`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L44)

```elixir
@type t() :: %Gemini.Types.Document{
  chunk_count: integer() | nil,
  create_time: String.t() | nil,
  display_name: String.t() | nil,
  error: map() | nil,
  metadata: document_metadata() | nil,
  mime_type: String.t() | nil,
  name: String.t() | nil,
  size_bytes: integer() | nil,
  source_uri: String.t() | nil,
  state: document_state() | nil,
  update_time: String.t() | nil
}
```

Represents a document in a RAG store.

## Fields

- `name` - Resource name (e.g., "ragStores/abc/documents/xyz")
- `display_name` - Human-readable name
- `state` - Processing state
- `create_time` - When the document was created
- `update_time` - Last update timestamp
- `size_bytes` - Document size in bytes
- `source_uri` - Original source URI (if applicable)
- `mime_type` - MIME type of the document
- `metadata` - Custom metadata key-value pairs
- `error` - Error details if processing failed
- `chunk_count` - Number of chunks the document was split into

# `active?`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L120)

```elixir
@spec active?(t()) :: boolean()
```

Checks if the document is ready for use.

# `failed?`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L134)

```elixir
@spec failed?(t()) :: boolean()
```

Checks if the document processing failed.

# `from_api_response`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L80)

```elixir
@spec from_api_response(map()) :: t()
```

Creates a Document from API response.

# `get_id`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L141)

```elixir
@spec get_id(t()) :: String.t() | nil
```

Extracts the document ID from the full resource name.

# `get_store_id`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L154)

```elixir
@spec get_store_id(t()) :: String.t() | nil
```

Extracts the store ID from the document's full resource name.

# `parse_state`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L100)

```elixir
@spec parse_state(String.t() | nil) :: document_state() | nil
```

Parses document state from API string.

# `processing?`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L127)

```elixir
@spec processing?(t()) :: boolean()
```

Checks if the document is still processing.

# `state_to_api`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/document.ex#L111)

```elixir
@spec state_to_api(document_state()) :: String.t()
```

Converts state atom to API string.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
