---
title: Charmhub | Deploy Wazuh Server using Charmhub - The Open Operator Collection
description: Deploy the latest version of Wazuh Server as a Kubernetes Operator on
  any cloud.
url: https://charmhub.io/wazuh-server/libraries/wazuh_api
---

# Wazuh Server

[Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

* [Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

Platform:

4.11/stable 19ff4c9d

```
juju deploy wazuh-server --channel 4.11/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/wazuh-server/libraries/wazuh_api#drawer)

## charms.wazuh\_server.v0.wazuh\_api

* [*Docstrings*Docstrings](https://charmhub.io/wazuh-server/libraries/wazuh_api)
  [*Code*Source code](https://charmhub.io/wazuh-server/libraries/wazuh_api/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.wazuh_server.v0.wazuh_api
    ```

    [Download wazuh\_api.py](https://charmhub.io/wazuh-server/libraries/wazuh_api/download)
  + *Last updated* 10 Nov 2026
  + *Revision* Library version 0.5

Library to manage the integration with the Wazuh Server charm.

This library contains the Requires and Provides classes for handling the integration
between an application and a charm providing the `wazuh-apli-client` integration.
This library also contains a `WazuhApiRelationData` class to wrap the data that will
be shared via the integration.

###### Requirer Charm

```
from charms.wazuh_server.v0.wazuh_api import WazuhApiDataAvailableEvent, WazuhApiRequires

class WazuhApiRequirerCharm(ops.CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.wazuh_api = wazuh_api.WazuhApiRequires(self)
        self.framework.observe(self.wazuh_api.on.wazuh_api_data_available, self._handler)
        ...

    def _handler(self, events: WazuhApiDataAvailableEvent) -> None:
        ...
```

As shown above, the library provides a custom event to handle the scenario in
which new Wazuh API data has been added or updated.

Credential reads refresh the consumer's tracked secret revision and read both
fields from one content snapshot. Requirers should also observe `secret-changed`
and call `get_relation_data()` when their credentials secret changes: rotating a
secret does not necessarily change the relation databag.

`get_relation_data()` returns `None` with a diagnostic when published data is
incomplete, invalid, or its secret is unavailable. Credential access through the
custom event raises `SecretError` when the secret cannot be used.

###### Provider Charm

Following the previous example, this is an example of the provider charm.

```
from charms.wazuh_server.v0.wazuh_api import import WazuhApiProvides

class WazuhApiProviderCharm(ops.CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.wazuh_api = WazuhApiProvides(self)
        ...
```

The WazuhApiProvides object wraps the list of relations into a `relations` property
and provides an `update_relation_data` method to update the relation data by passing
a `WazuhApiRelationData` data object.

```
class WazuhApiProviderCharm(ops.CharmBase):
    ...

    def _on_config_changed(self, _) -> None:
        for relation in self.model.relations[self.wazuh_api.relation_name]:
            self.wazuh_api.update_relation_data(relation, self._get_wazuh_api_data())
```

---

Index

* [class SecretError](https://charmhub.io/wazuh-server/libraries/wazuh_api#secreterror)
* [class WazuhApiRelationData](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapirelationdata)
* + [def to\_relation\_data(
    self)](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapirelationdata-to_relation_data)
* [class WazuhApiDataAvailableEvent](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapidataavailableevent)
* + [def endpoint(
    self)](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapidataavailableevent-endpoint)
* + [def user(
    self)](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapidataavailableevent-user)
* + [def password(
    self)](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapidataavailableevent-password)
* [class WazuhApiRequiresEvents](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapirequiresevents)
* [class WazuhApiRequires](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapirequires)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapirequires-__init__)
* + [def get\_relation\_data(
    self)](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapirequires-get_relation_data)
* [class WazuhApiProvides](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapiprovides)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapiprovides-__init__)
* + [def update\_relation\_data(
    self,
    relation,
    wazuh\_api\_data)](https://charmhub.io/wazuh-server/libraries/wazuh_api#wazuhapiprovides-update_relation_data)

#### class SecretError

Description

Common ancestor for Secrets related exceptions. None

#### class WazuhApiRelationData

Represent the relation data.

Attributes

endpoint

The API endpoint.

user

The user to authenticate against the API.

password

The password to authenticate against the API.

user\_credentials\_secret

The secret ID containing the API credentials.

Methods

WazuhApiRelationData.
to\_relation\_data(

*self*
)

Convert an instance of WazuhApiRelationData to the relation representation.

Returns

Dict containing the representation.

#### class WazuhApiDataAvailableEvent

Event emitted when relation data has changed.

Attributes

endpoint

The API endpoint.

user

The user to authenticate against the API.

password

The password to authenticate against the API.

Methods

WazuhApiDataAvailableEvent.
endpoint(

*self*
)

Description

Fetch the endpoint from the relation. None

WazuhApiDataAvailableEvent.
user(

*self*
)

Description

Fetch the user from the relation. None

WazuhApiDataAvailableEvent.
password(

*self*
)

Description

Fetch the password from the relation. None

#### class WazuhApiRequiresEvents

Wazuh API events.

Attributes

wazuh\_api\_data\_available

the WazuhApiDataAvailableEvent.

Description

This class defines the events that a requirer can emit.

#### class WazuhApiRequires

Requirer side of the Wazuh API client relation.

Attributes

on

events the provider can emit.

Methods

WazuhApiRequires.
\_\_init\_\_(

*self*

,
charm

,
relation\_name: str
)

Construct.

Arguments

charm

the provider charm.

relation\_name

the relation name.

WazuhApiRequires.
get\_relation\_data(

*self*
)

Retrieve the relation data.

Returns

WazuhApiRelationData

validated data, or None if not ready or unusable.

#### class WazuhApiProvides

Description

Provider side of the Wazuh API relation. None

Methods

WazuhApiProvides.
\_\_init\_\_(

*self*

,
charm

,
relation\_name: str
)

Construct.

Arguments

charm

the provider charm.

relation\_name

the relation name.

WazuhApiProvides.
update\_relation\_data(

*self*

,
relation

,
wazuh\_api\_data: WazuhApiRelationData
)

Update the relation data.

Arguments

relation

the relation for which to update the data.

wazuh\_api\_data

a WazuhApiRelationData instance wrapping the data to be updated.
