wazuh-server

Wazuh Server

  • Canonical IS DevOps
Channel Revision Published Runs on
latest/edge 100 Today
Ubuntu 22.04
juju deploy wazuh-server --channel edge
Show information

Platform:

charms.wazuh_server.v0.wazuh_api

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.

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())


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
TThe 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
TThe 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

the relation data.

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.