Skip to content

Commit 8578bfd

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Add ListSkills and DeleteSkill methods in Vertex AI Skill Registry SDK
PiperOrigin-RevId: 912730700
1 parent 2834b9b commit 8578bfd

6 files changed

Lines changed: 1461 additions & 1 deletion

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""Tests the skills.delete() method against the autopush endpoint."""
2+
3+
from tests.unit.vertexai.genai.replays import pytest_helper
4+
from vertexai._genai import types
5+
from google.genai import errors
6+
import pytest
7+
8+
pytestmark = pytest_helper.setup(
9+
file=__file__,
10+
globals_for_file=globals(),
11+
)
12+
13+
14+
def test_delete_skill(client, tmp_path):
15+
# Target the autopush sandbox endpoint for the Skill Registry API
16+
client._api_client._http_options.base_url = (
17+
"https://us-central1-autopush-aiplatform.sandbox.googleapis.com"
18+
)
19+
20+
# 1. Create a fresh unique skill first
21+
with open(tmp_path / "SKILL.md", "w") as f:
22+
f.write("# Test Skill\nTo be deleted.")
23+
24+
created_skill = client.skills.create(
25+
display_name="To Be Deleted Skill",
26+
description="Skill to be deleted",
27+
config=types.CreateSkillConfig(
28+
local_path=str(tmp_path), wait_for_completion=True
29+
),
30+
)
31+
32+
assert created_skill.name is not None
33+
34+
# 2. Delete the skill and wait for LRO completion
35+
client.skills.delete(
36+
name=created_skill.name,
37+
config=types.DeleteSkillConfig(wait_for_completion=True),
38+
)
39+
40+
# 3. Verify the skill is successfully deleted (Getting it should raise NotFound)
41+
with pytest.raises(errors.ClientError) as exc_info:
42+
client.skills.get(name=created_skill.name)
43+
44+
assert exc_info.value.code == 404
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Tests the skills.list() method against the autopush endpoint."""
2+
3+
from tests.unit.vertexai.genai.replays import pytest_helper
4+
from vertexai._genai import types
5+
6+
pytestmark = pytest_helper.setup(
7+
file=__file__,
8+
globals_for_file=globals(),
9+
)
10+
11+
12+
def test_list_skills(client):
13+
# Target the autopush sandbox endpoint for the Skill Registry API
14+
client._api_client._http_options.base_url = (
15+
"https://us-central1-autopush-aiplatform.sandbox.googleapis.com"
16+
)
17+
18+
skills = client.skills.list()
19+
for skill in skills:
20+
assert isinstance(skill, types.Skill)
21+
assert skill.name is not None

0 commit comments

Comments
 (0)