Class ResourceNameParser

java.lang.Object
org.a2aproject.sdk.grpc.mapper.ResourceNameParser

public class ResourceNameParser extends Object
Utility class for parsing gRPC resource names.

Provides methods to extract IDs and components from resource name strings following the pattern: "tasks/{taskId}/pushNotificationConfigs/{configId}"

  • Constructor Details

    • ResourceNameParser

      public ResourceNameParser()
  • Method Details

    • extractTaskId

      public static String extractTaskId(String resourceName)
      Extracts the task ID from a simple resource name like "tasks/{taskId}".
      Parameters:
      resourceName - the resource name (e.g., "tasks/abc123")
      Returns:
      the extracted task ID
    • defineTaskName

      public static String defineTaskName(String taskId)
      Define the task name form its taskId as in "tasks/{taskId}".
      Parameters:
      taskId - the taskId
      Returns:
      the task name
    • parseTaskPushNotificationConfigName

      public static String[] parseTaskPushNotificationConfigName(String resourceName)
      Parses a task push notification config resource name and extracts taskId and configId.

      Expected format: "tasks/{taskId}/pushNotificationConfigs/{configId}"

      Parameters:
      resourceName - the resource name to parse
      Returns:
      array with [taskId, configId]
      Throws:
      IllegalArgumentException - if the format is invalid
    • parseGetTaskPushNotificationConfigName

      public static String[] parseGetTaskPushNotificationConfigName(String resourceName)
      Parses a get task push notification config request name and extracts taskId and configId.

      Expected formats: - "tasks/{taskId}" (returns taskId for both values) - "tasks/{taskId}/pushNotificationConfigs/{configId}"

      Parameters:
      resourceName - the resource name to parse
      Returns:
      array with [taskId, configId]
      Throws:
      IllegalArgumentException - if the format is invalid
    • defineGetTaskPushNotificationConfigName

      public static String defineGetTaskPushNotificationConfigName(String taskId, String configId)
    • defineTaskPushNotificationConfigName

      public static String defineTaskPushNotificationConfigName(String taskId, String configId)
      Constructs a task push notification config resource name from task ID and config ID.

      Format: "tasks/{taskId}/pushNotificationConfigs/{configId}"

      Parameters:
      taskId - the task identifier
      configId - the push notification config identifier
      Returns:
      the formatted resource name
    • extractParentId

      public static String extractParentId(String parentName)
      Extracts the parent ID (task ID) from a parent resource name like "tasks/{taskId}".
      Parameters:
      parentName - the parent resource name
      Returns:
      the extracted parent ID