Skip to content

Commit 2f90c1a

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Optional GCP project and credential for GCS access
PiperOrigin-RevId: 889935432
1 parent e6a5de5 commit 2f90c1a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/google/adk/skills/_utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import pathlib
2121
from typing import Union
2222

23+
from google.auth import credentials as auth
2324
from google.cloud import storage
2425
from pydantic import ValidationError
2526
import yaml
@@ -301,6 +302,8 @@ def _list_skills_in_dir(
301302
def _list_skills_in_gcs_dir(
302303
bucket_name: str,
303304
skills_base_path: str = "",
305+
project_id: str | None = None,
306+
credentials: auth.Credentials | None = None,
304307
) -> Dict[str, models.Frontmatter]:
305308
"""List skills in a GCS directory.
306309
@@ -311,7 +314,7 @@ def _list_skills_in_gcs_dir(
311314
Returns:
312315
Dictionary mapping skill IDs to their frontmatter.
313316
"""
314-
client = storage.Client()
317+
client = storage.Client(project=project_id, credentials=credentials)
315318
bucket = client.bucket(bucket_name)
316319

317320
base_prefix = skills_base_path.strip("/")
@@ -350,13 +353,17 @@ def _load_skill_from_gcs_dir(
350353
bucket_name: str,
351354
skill_id: str,
352355
skills_base_path: str = "",
356+
project_id: str | None = None,
357+
credentials: auth.Credentials | None = None,
353358
) -> models.Skill:
354359
"""Load a complete skill from a GCS directory.
355360
356361
Args:
357362
bucket_name: Name of the GCS bucket.
358363
skill_id: The ID of the skill (directory name).
359364
skills_base_path: Base directory within the bucket (e.g., 'path/to/skills').
365+
project_id: Project ID to use for GCS client.
366+
credentials: Credentials to use for GCS client.
360367
361368
Returns:
362369
Skill object with all components loaded.
@@ -366,7 +373,8 @@ def _load_skill_from_gcs_dir(
366373
ValueError: If SKILL.md is invalid or the skill name does not match
367374
the directory name.
368375
"""
369-
client = storage.Client()
376+
377+
client = storage.Client(project=project_id, credentials=credentials)
370378
bucket = client.bucket(bucket_name)
371379

372380
base_prefix = skills_base_path.strip("/")

0 commit comments

Comments
 (0)