---
title: Charmhub | Deploy Keystone K8S using Charmhub - The Open Operator Collection
description: Deploy the latest version of Keystone K8S as a Kubernetes Operator on
  any cloud.
url: https://charmhub.io/keystone-k8s/libraries/identity_resource
---

# Keystone K8S

[OpenStack Charmers](https://charmhub.io/publisher/openstack-charmers "View all packages from OpenStack Charmers")

* [OpenStack Charmers](https://charmhub.io/publisher/openstack-charmers "View all packages from OpenStack Charmers")

Platform:

2024.1/stable 060d2288

```
juju deploy keystone-k8s --channel 2024.1/stable
```

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

[Toggle side navigation](https://charmhub.io/keystone-k8s/libraries/identity_resource#drawer)

## charms.keystone\_k8s.v0.identity\_resource

* [*Docstrings*Docstrings](https://charmhub.io/keystone-k8s/libraries/identity_resource)
  [*Code*Source code](https://charmhub.io/keystone-k8s/libraries/identity_resource/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.keystone_k8s.v0.identity_resource
    ```

    [Download identity\_resource.py](https://charmhub.io/keystone-k8s/libraries/identity_resource/download)
  + *Last updated* 17 Oct 2023
  + *Revision* Library version 0.4

IdentityResourceProvides and Requires module.

This library contains the Requires and Provides classes for handling
the identity\_ops interface.

Import `IdentityResourceRequires` in your charm, with the charm object and the
relation name:
- self
- "identity\_ops"

Also provide additional parameters to the charm object:
- request

Three events are also available to respond to:
- provider\_ready
- provider\_goneaway
- response\_avaialable

A basic example showing the usage of this relation follows:

```
from charms.keystone_k8s.v0.identity_resource import IdentityResourceRequires

class IdentityResourceClientCharm(CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        # IdentityResource Requires
        self.identity_resource = IdentityResourceRequires(
            self, "identity_ops",
        )
        self.framework.observe(
            self.identity_resource.on.provider_ready, self._on_identity_resource_ready)
        self.framework.observe(
            self.identity_resource.on.provider_goneaway, self._on_identity_resource_goneaway)
        self.framework.observe(
            self.identity_resource.on.response_available, self._on_identity_resource_response)

    def _on_identity_resource_ready(self, event):
        '''React to the IdentityResource provider_ready event.

        This event happens when n IdentityResource relation is added to the
        model. Ready to send any ops to keystone.
        '''
        # Ready to send any ops.
        pass

    def _on_identity_resource_response(self, event):
        '''React to the IdentityResource response_available event.

        The IdentityResource interface will provide the response for the ops sent.
        '''
        # Read the response for the ops sent.
        pass

    def _on_identity_resource_goneaway(self, event):
        '''React to the IdentityResource goneaway event.

        This event happens when an IdentityResource relation is removed.
        '''
        # IdentityResource Relation has goneaway. No ops can be sent.
        pass
```

A sample ops request can be of format
{
"id":
"tag":
"ops": [
{
"name": ,
"params": {
<param 1>: <value 1>,
<param 2>: <value 2>
}
}
]
}

For any sensitive data in the ops params, the charm can create secrets and pass
secret id instead of sensitive data as part of ops request. The charm should
ensure to grant secret access to provider charm i.e., keystone over relation.
The secret content should hold the sensitive data with same name as param name.

---

Index

* [class IdentityOpsProviderReadyEvent](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityopsproviderreadyevent)
* [class IdentityOpsResponseEvent](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityopsresponseevent)
* [class IdentityOpsProviderGoneAwayEvent](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityopsprovidergoneawayevent)
* [class IdentityResourceResponseEvents](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourceresponseevents)
* [class IdentityResourceRequires](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourcerequires)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourcerequires-__init__)
* + [def response(
    self)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourcerequires-response)
* + [def save\_request\_in\_store(
    self,
    id,
    tag,
    ops,
    state)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourcerequires-save_request_in_store)
* + [def get\_request\_from\_store(
    self,
    id)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourcerequires-get_request_from_store)
* + [def is\_request\_processed(
    self,
    id)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourcerequires-is_request_processed)
* + [def get\_remote\_app\_data(
    self,
    key)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourcerequires-get_remote_app_data)
* + [def ready(
    self)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourcerequires-ready)
* + [def request\_ops(
    self,
    request)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourcerequires-request_ops)
* [class IdentityOpsRequestEvent](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityopsrequestevent)
* + [def \_\_init\_\_(
    self,
    handle,
    relation\_id,
    relation\_name,
    request)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityopsrequestevent-__init__)
* + [def snapshot(
    self)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityopsrequestevent-snapshot)
* + [def restore(
    self,
    snapshot)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityopsrequestevent-restore)
* [class IdentityResourceProviderEvents](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourceproviderevents)
* [class IdentityResourceProvides](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourceprovides)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourceprovides-__init__)
* + [def set\_ops\_response(
    self,
    relation\_id,
    relation\_name,
    ops\_response)](https://charmhub.io/keystone-k8s/libraries/identity_resource#identityresourceprovides-set_ops_response)

#### class IdentityOpsProviderReadyEvent

Description

Has IdentityOpsProviderReady Event. None

#### class IdentityOpsResponseEvent

Description

Has IdentityOpsResponse Event. None

#### class IdentityOpsProviderGoneAwayEvent

Description

Has IdentityOpsProviderGoneAway Event. None

#### class IdentityResourceResponseEvents

Description

Events class for `on`. None

#### class IdentityResourceRequires

Description

IdentityResourceRequires class. None

Methods

IdentityResourceRequires.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

IdentityResourceRequires.
response(

*self*
)

Description

Response object from keystone. None

IdentityResourceRequires.
save\_request\_in\_store(

*self*

,
id: str

,
tag: str

,
ops: list

,
state: int
)

Description

Save request in the store. None

IdentityResourceRequires.
get\_request\_from\_store(

*self*

,
id: str
)

Description

Get request from the stote. None

IdentityResourceRequires.
is\_request\_processed(

*self*

,
id: str
)

Description

Check if request is processed. None

IdentityResourceRequires.
get\_remote\_app\_data(

*self*

,
key: str
)

Description

Return the value for the given key from remote app data. None

IdentityResourceRequires.
ready(

*self*
)

Interface is ready or not.

Description

Interface is considered ready if the op request is processed
and response is sent. In case of non leader unit, just consider
the interface is ready.

IdentityResourceRequires.
request\_ops(

*self*

,
request: dict
)

Description

Request keystone ops. None

#### class IdentityOpsRequestEvent

Description

Has IdentityOpsRequest Event. None

Methods

IdentityOpsRequestEvent.
\_\_init\_\_(

*self*

,
handle

,
relation\_id

,
relation\_name

,
request
)

Description

Initialise event. None

IdentityOpsRequestEvent.
snapshot(

*self*
)

Description

Snapshot the event. None

IdentityOpsRequestEvent.
restore(

*self*

,
snapshot
)

Description

Restore the event. None

#### class IdentityResourceProviderEvents

Description

Events class for `on`. None

#### class IdentityResourceProvides

Description

IdentityResourceProvides class. None

Methods

IdentityResourceProvides.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

IdentityResourceProvides.
set\_ops\_response(

*self*

,
relation\_id: str

,
relation\_name: str

,
ops\_response: dict
)

Description

Set response to ops request. None
