Skip to content
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

Feature: Bedrock and Bedrock Agents #7597

Merged
merged 6 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions moto/backend_index.py
Expand Up @@ -22,6 +22,8 @@
("backup", re.compile("https?://backup\\.(.+)\\.amazonaws\\.com")),
("batch", re.compile("https?://batch\\.(.+)\\.amazonaws.com")),
("budgets", re.compile("https?://budgets\\.amazonaws\\.com")),
("bedrock", re.compile("https?://bedrock\\.(.+)\\.amazonaws\\.com")),
("bedrockagent", re.compile("https?://bedrock-agent\\.(.+)\\.amazonaws\\.com")),
("ce", re.compile("https?://ce\\.(.+)\\.amazonaws\\.com")),
("cloudformation", re.compile("https?://cloudformation\\.(.+)\\.amazonaws\\.com")),
("cloudfront", re.compile("https?://cloudfront\\.amazonaws\\.com")),
Expand Down
10 changes: 10 additions & 0 deletions moto/backends.py
Expand Up @@ -20,6 +20,8 @@
from moto.autoscaling.models import AutoScalingBackend
from moto.awslambda.models import LambdaBackend
from moto.batch.models import BatchBackend
from moto.bedrock.models import BedrockBackend
from moto.bedrockagent.models import AgentsforBedrockBackend
from moto.budgets.models import BudgetsBackend
from moto.ce.models import CostExplorerBackend
from moto.cloudformation.models import CloudFormationBackend
Expand Down Expand Up @@ -182,6 +184,8 @@ def get_service_from_url(url: str) -> Optional[str]:
"Literal['athena']",
"Literal['autoscaling']",
"Literal['batch']",
"Literal['bedrock']",
"Literal['bedrock-agent']",
"Literal['budgets']",
"Literal['ce']",
"Literal['cloudformation']",
Expand Down Expand Up @@ -344,6 +348,12 @@ def get_backend(
@overload
def get_backend(name: "Literal['batch']") -> "BackendDict[BatchBackend]": ...
@overload
def get_backend(name: "Literal['bedrock']") -> "BackendDict[BedrockBackend]": ...
@overload
def get_backend(
name: "Literal['bedrock-agent']",
) -> "BackendDict[AgentsforBedrockBackend]": ...
@overload
def get_backend(name: "Literal['budgets']") -> "BackendDict[BudgetsBackend]": ...
@overload
def get_backend(name: "Literal['ce']") -> "BackendDict[CostExplorerBackend]": ...
Expand Down
1 change: 1 addition & 0 deletions moto/bedrock/__init__.py
@@ -0,0 +1 @@
from .models import bedrock_backends # noqa: F401
33 changes: 33 additions & 0 deletions moto/bedrock/exceptions.py
@@ -0,0 +1,33 @@
"""Exceptions raised by the bedrock service."""

from moto.core.exceptions import JsonRESTError

# Bedrock.Client.exceptions.ResourceNotFoundException


class BedrockClientError(JsonRESTError):
code = 400


class ResourceNotFoundException(BedrockClientError):
def __init__(self, msg: str):
super().__init__("ResourceNotFoundException", f"{msg}")


class ResourceInUseException(BedrockClientError):
def __init__(self, msg: str):
super().__init__("ResourceInUseException", f"{msg}")


class ValidationException(BedrockClientError):
def __init__(self, msg: str):
super().__init__(
"ValidationException",
"Input validation failed. Check your request parameters and retry the request.",
f"{msg}",
)


class TooManyTagsException(BedrockClientError):
def __init__(self, msg: str):
super().__init__("TooManyTagsException", f"{msg}")