Skip to content

Commit f96225b

Browse files
committed
Started implementation of password cap driver
Signed-off-by: Anton Kremenetsky <anton.kremenetsky@gmail.com>
1 parent e5e6d2e commit f96225b

6 files changed

Lines changed: 97 additions & 1 deletion

File tree

File renamed without changes.

genesis_core/agent/universal/drivers/secret/__init__.py

Whitespace-only changes.

genesis_core/agent/universal/drivers/secret/backend/__init__.py

Whitespace-only changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2025 Genesis Corporation.
2+
#
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
from __future__ import annotations
17+
18+
import abc
19+
import logging
20+
import typing as tp
21+
import uuid as sys_uuid
22+
23+
from gcl_sdk.agents.universal.dm import models
24+
from gcl_sdk.agents.universal.clients.backend import base
25+
from gcl_sdk.agents.universal.clients.backend import exceptions
26+
27+
28+
LOG = logging.getLogger(__name__)
29+
30+
AGENT_WORK_DIR = "/var/lib/genesis/universal_agent/"
31+
32+
33+
class DatabaseSecretBackendClient(base.AbstractBackendClient):
34+
"""Secret Backend client based on SQL database."""
35+
36+
def get(self, resource: models.Resource) -> dict[str, tp.Any]:
37+
"""Get the resource value in dictionary format."""
38+
39+
def create(self, resource: models.Resource) -> dict[str, tp.Any]:
40+
"""Creates the resource. Returns the created resource."""
41+
42+
def update(self, resource: models.Resource) -> dict[str, tp.Any]:
43+
"""Update the resource. Returns the updated resource."""
44+
45+
def list(self, kind: str, **kwargs) -> list[dict[str, tp.Any]]:
46+
"""Lists all resources by kind."""
47+
48+
def delete(self, resource: models.Resource) -> None:
49+
"""Delete the resource."""
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2025 Genesis Corporation.
2+
#
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
from __future__ import annotations
17+
18+
import logging
19+
20+
import bazooka
21+
22+
from gcl_sdk.clients.http import base
23+
from gcl_sdk.agents.universal.drivers import direct
24+
from gcl_sdk.agents.universal.storage import fs
25+
26+
from genesis_core.agent.universal.drivers.secret.backend import db as db_back
27+
28+
29+
LOG = logging.getLogger(__name__)
30+
31+
AGENT_WORK_DIR = "/var/lib/genesis/universal_agent/"
32+
33+
34+
class PasswordCapabilityDriver(direct.DirectAgentDriver):
35+
"""Password capability driver."""
36+
37+
def __init__(self, **kwargs):
38+
storage = fs.FileAgentStorage(
39+
AGENT_WORK_DIR, "password_cap_storage.json"
40+
)
41+
client = db_back.DatabaseSecretBackendClient(**kwargs)
42+
43+
super().__init__(storage=storage, client=client)
44+
45+
def get_capabilities(self) -> list[str]:
46+
"""Returns a list of capabilities supported by the driver."""
47+
return list(self._collection_map.keys())

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ gcl_sdk_event_payloads =
4141
IamUserRegistration = genesis_core.events.payloads:RegistrationEventPayload
4242
IamUserResetPassword = genesis_core.events.payloads:ResetPasswordEventPayload
4343
gcl_sdk_universal_agent =
44-
CoreCapabilityDriver = genesis_core.agent.universal.driver:CoreCapabilityDriver
44+
CoreCapabilityDriver = genesis_core.agent.universal.drivers.core:CoreCapabilityDriver

0 commit comments

Comments
 (0)