Package org.a2aproject.sdk.grpc.mapper
Class ResourceNameParser
java.lang.Object
org.a2aproject.sdk.grpc.mapper.ResourceNameParser
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringdefineGetTaskPushNotificationConfigName(String taskId, String configId) static StringdefineTaskName(String taskId) Define the task name form its taskId as in "tasks/{taskId}".static StringdefineTaskPushNotificationConfigName(String taskId, String configId) Constructs a task push notification config resource name from task ID and config ID.static StringextractParentId(String parentName) Extracts the parent ID (task ID) from a parent resource name like "tasks/{taskId}".static StringextractTaskId(String resourceName) Extracts the task ID from a simple resource name like "tasks/{taskId}".static String[]parseGetTaskPushNotificationConfigName(String resourceName) Parses a get task push notification config request name and extracts taskId and configId.static String[]parseTaskPushNotificationConfigName(String resourceName) Parses a task push notification config resource name and extracts taskId and configId.
-
Constructor Details
-
ResourceNameParser
public ResourceNameParser()
-
-
Method Details
-
extractTaskId
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
Define the task name form its taskId as in "tasks/{taskId}".- Parameters:
taskId- the taskId- Returns:
- the task name
-
parseTaskPushNotificationConfigName
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
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
-
defineTaskPushNotificationConfigName
Constructs a task push notification config resource name from task ID and config ID.Format: "tasks/{taskId}/pushNotificationConfigs/{configId}"
- Parameters:
taskId- the task identifierconfigId- the push notification config identifier- Returns:
- the formatted resource name
-
extractParentId
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
-