Skip to content

Feature/genai support #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "toin0u/digitalocean-v2",
"name": "hardcod3r/do-client",
"description": "DigitalOcean API v2 client for PHP",
"keywords": ["DigitalOcean", "API", "Cloud Hosting", "SSD", "VPS"],
"license": "MIT",
77 changes: 77 additions & 0 deletions digitalocean-genai-sdk-summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# DigitalOcean GenAI Laravel SDK Extension (Entity-Based)

## ✅ Supported Resources & Endpoints

---

### 🧠 Agents (`Agent.php` / `AgentEntity.php`)
- `GET /v2/gen-ai/agents` → `all(): Agent[]`
- `POST /v2/gen-ai/agents` → `create(array): Agent`
- `GET /v2/gen-ai/agents/{uuid}` → `retrieve(string): Agent`
- `PUT /v2/gen-ai/agents/{uuid}` → `update(string, array): Agent`
- `DELETE /v2/gen-ai/agents/{uuid}` → `destroy(string): void`

---

### 🔗 Agent Relationships (`AgentRelationship.php`)
- `GET /v2/gen-ai/agents/{uuid}/child_agents` → `list(string): Agent[]`
- `POST /v2/gen-ai/agents/{parent}/child_agents/{child}` → `attach(parent, child): Agent`
- `DELETE /v2/gen-ai/agents/{parent}/child_agents/{child}` → `detach(parent, child): void`

---

### 🔑 OpenAI Keys (`OpenAiKey.php` / `OpenAiKeyEntity.php`)
- `GET /v2/gen-ai/openai/keys` → `all(): OpenAiKey[]`
- `POST /v2/gen-ai/openai/keys` → `create(array): OpenAiKey`
- `GET /v2/gen-ai/openai/keys/{uuid}` → `retrieve(string): OpenAiKey`
- `PUT /v2/gen-ai/openai/keys/{uuid}` → `update(string, array): OpenAiKey`
- `DELETE /v2/gen-ai/openai/keys/{uuid}` → `destroy(string): void`
- `GET /v2/gen-ai/openai/keys/{uuid}/agents` → `listAgents(string): Agent[]`

---

### 👤 Anthropic Keys (`AnthropicKey.php` / `AnthropicKeyEntity.php`)
- `GET /v2/gen-ai/anthropic/keys` → `all(): AnthropicKey[]`
- `POST /v2/gen-ai/anthropic/keys` → `create(array): AnthropicKey`
- `GET /v2/gen-ai/anthropic/keys/{uuid}` → `retrieve(string): AnthropicKey`
- `PUT /v2/gen-ai/anthropic/keys/{uuid}` → `update(string, array): AnthropicKey`
- `DELETE /v2/gen-ai/anthropic/keys/{uuid}` → `destroy(string): void`
- `GET /v2/gen-ai/anthropic/keys/{uuid}/agents` → `listAgents(string): Agent[]`

---

### 📚 Knowledge Bases (`KnowledgeBase.php` / `KnowledgeBaseEntity.php`)
- `GET /v2/gen-ai/knowledge_bases` → `all(): KnowledgeBase[]`
- `POST /v2/gen-ai/knowledge_bases` → `create(array): KnowledgeBase`
- `GET /v2/gen-ai/knowledge_bases/{uuid}` → `retrieve(string): KnowledgeBase`
- `DELETE /v2/gen-ai/knowledge_bases/{uuid}` → `destroy(string): void`

---

### 🔍 Indexing Jobs (`IndexingJob.php` / `IndexingJobEntity.php`)
- `GET /v2/gen-ai/indexing_jobs` → `all(): IndexingJob[]`

---

## 🧩 Binding Summary (`Client.php`)

```php
$client->genAiAgent();
$client->genAiAgentRelationships();
$client->genAiOpenAiKeys();
$client->genAiAnthropicKeys();
$client->genAiKnowledgeBases();
$client->genAiIndexingJobs();
```

---

## 📦 Entities Implemented

- `Agent`
- `OpenAiKey`
- `AnthropicKey`
- `KnowledgeBase`
- `IndexingJob`

All extend `AbstractEntity` and use `setCreatedAt()`, `setUpdatedAt()`, etc. for normalization.
51 changes: 51 additions & 0 deletions src/Api/GenAi/Agent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

namespace DigitalOceanV2\Api\GenAi;

use DigitalOceanV2\Api\AbstractApi;
use DigitalOceanV2\Entity\GenAi\Agent as AgentEntity;
use stdClass;

class Agent extends AbstractApi
{
/**
* @return AgentEntity[]
*/
public function all(): array
{
$response = $this->get('gen-ai/agents');

return array_map(
fn ($agent) => new AgentEntity($agent),
$response->agents
);
}

public function create(array $data): AgentEntity
{
$response = $this->post('gen-ai/agents', $data);

return new AgentEntity($response->agent);
}

public function retrieve(string $uuid): AgentEntity
{
$response = $this->get("gen-ai/agents/{$uuid}");

return new AgentEntity($response->agent);
}

public function update(string $uuid, array $data): AgentEntity
{
$response = $this->put("gen-ai/agents/{$uuid}", $data);

return new AgentEntity($response->agent);
}

public function destroy(string $uuid): void
{
$this->delete("gen-ai/agents/{$uuid}");
}
}
24 changes: 24 additions & 0 deletions src/Api/GenAi/AgentRelationship.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php declare(strict_types=1);

namespace DigitalOceanV2\Api\GenAi;

use DigitalOceanV2\Api\AbstractApi;
use stdClass;

class AgentRelationship extends AbstractApi
{
public function list(string $uuid): stdClass
{
return $this->get("gen-ai/agents/{$uuid}/child_agents");
}

public function attach(string $parentUuid, string $childUuid): stdClass
{
return $this->post("gen-ai/agents/{$parentUuid}/child_agents/{$childUuid}");
}

public function detach(string $parentUuid, string $childUuid): void
{
$this->delete("gen-ai/agents/{$parentUuid}/child_agents/{$childUuid}");
}
}
64 changes: 64 additions & 0 deletions src/Api/GenAi/AnthropicKey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

declare(strict_types=1);

namespace DigitalOceanV2\Api\GenAi;

use DigitalOceanV2\Api\AbstractApi;
use DigitalOceanV2\Entity\GenAi\AnthropicKey as AnthropicKeyEntity;
use DigitalOceanV2\Entity\GenAi\Agent as AgentEntity;

class AnthropicKey extends AbstractApi
{
/**
* @return AnthropicKeyEntity[]
*/
public function all(): array
{
$response = $this->get('gen-ai/anthropic/keys');

return array_map(
fn ($key) => new AnthropicKeyEntity($key),
$response->keys
);
}

public function create(array $data): AnthropicKeyEntity
{
$response = $this->post('gen-ai/anthropic/keys', $data);

return new AnthropicKeyEntity($response->key);
}

public function retrieve(string $uuid): AnthropicKeyEntity
{
$response = $this->get("gen-ai/anthropic/keys/{$uuid}");

return new AnthropicKeyEntity($response->key);
}

public function update(string $uuid, array $data): AnthropicKeyEntity
{
$response = $this->put("gen-ai/anthropic/keys/{$uuid}", $data);

return new AnthropicKeyEntity($response->key);
}

public function destroy(string $uuid): void
{
$this->delete("gen-ai/anthropic/keys/{$uuid}");
}

/**
* @return AgentEntity[]
*/
public function listAgents(string $uuid): array
{
$response = $this->get("gen-ai/anthropic/keys/{$uuid}/agents");

return array_map(
fn ($agent) => new AgentEntity($agent),
$response->agents
);
}
}
24 changes: 24 additions & 0 deletions src/Api/GenAi/IndexingJob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace DigitalOceanV2\Api\GenAi;

use DigitalOceanV2\Api\AbstractApi;
use DigitalOceanV2\Entity\GenAi\IndexingJob as IndexingJobEntity;

class IndexingJob extends AbstractApi
{
/**
* @return IndexingJobEntity[]
*/
public function all(): array
{
$response = $this->get('gen-ai/indexing_jobs');

return array_map(
fn ($job) => new IndexingJobEntity($job),
$response->indexing_jobs
);
}
}
43 changes: 43 additions & 0 deletions src/Api/GenAi/KnowledgeBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace DigitalOceanV2\Api\GenAi;

use DigitalOceanV2\Api\AbstractApi;
use DigitalOceanV2\Entity\GenAi\KnowledgeBase as KnowledgeBaseEntity;

class KnowledgeBase extends AbstractApi
{
/**
* @return KnowledgeBaseEntity[]
*/
public function all(): array
{
$response = $this->get('gen-ai/knowledge_bases');

return array_map(
fn ($kb) => new KnowledgeBaseEntity($kb),
$response->knowledge_bases
);
}

public function create(array $data): KnowledgeBaseEntity
{
$response = $this->post('gen-ai/knowledge_bases', $data);

return new KnowledgeBaseEntity($response->knowledge_base);
}

public function retrieve(string $uuid): KnowledgeBaseEntity
{
$response = $this->get("gen-ai/knowledge_bases/{$uuid}");

return new KnowledgeBaseEntity($response->knowledge_base);
}

public function destroy(string $uuid): void
{
$this->delete("gen-ai/knowledge_bases/{$uuid}");
}
}
63 changes: 63 additions & 0 deletions src/Api/GenAi/OpenAiKey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

declare(strict_types=1);

namespace DigitalOceanV2\Api\GenAi;

use DigitalOceanV2\Api\AbstractApi;
use DigitalOceanV2\Entity\GenAi\OpenAiKey as OpenAiKeyEntity;

class OpenAiKey extends AbstractApi
{
/**
* @return OpenAiKeyEntity[]
*/
public function all(): array
{
$response = $this->get('gen-ai/openai/keys');

return array_map(
fn ($key) => new OpenAiKeyEntity($key),
$response->keys
);
}

public function create(array $data): OpenAiKeyEntity
{
$response = $this->post('gen-ai/openai/keys', $data);

return new OpenAiKeyEntity($response->key);
}

public function retrieve(string $uuid): OpenAiKeyEntity
{
$response = $this->get("gen-ai/openai/keys/{$uuid}");

return new OpenAiKeyEntity($response->key);
}

public function update(string $uuid, array $data): OpenAiKeyEntity
{
$response = $this->put("gen-ai/openai/keys/{$uuid}", $data);

return new OpenAiKeyEntity($response->key);
}

public function destroy(string $uuid): void
{
$this->delete("gen-ai/openai/keys/{$uuid}");
}

/**
* @return AgentEntity[]
*/
public function listAgents(string $uuid): array
{
$response = $this->get("gen-ai/openai/keys/{$uuid}/agents");

return array_map(
fn ($agent) => new \DigitalOceanV2\Entity\GenAi\Agent($agent),
$response->agents
);
}
}
Loading