66from pydantic import Field
77
88from orb .domain .base .events .base_events import DomainEvent
9- from orb .domain .base .provider_interfaces import ProviderInstanceState , ProviderType
9+ from orb .domain .base .provider_interfaces import ProviderInstanceState
1010
1111
1212class ProviderOperationEvent (DomainEvent ):
1313 """Event raised for provider operations."""
1414
15- provider_type : ProviderType
15+ provider_type : str # e.g. "aws"
1616 operation_type : str # e.g., "create_instance", "terminate_instance"
1717 provider_resource_type : str # e.g., "instance", "volume"
1818 provider_resource_id : Optional [str ] = Field (default = None )
@@ -23,7 +23,7 @@ def model_post_init(self, __context: Any) -> None:
2323 """Initialize aggregate information after model creation."""
2424 # Set the base class fields
2525 object .__setattr__ (self , "aggregate_id" , self .provider_resource_id or str (uuid4 ()))
26- object .__setattr__ (self , "aggregate_type" , f"{ self .provider_type . value } _resource" )
26+ object .__setattr__ (self , "aggregate_type" , f"{ self .provider_type } _resource" )
2727 super ().model_post_init (__context )
2828 if not self .operation_type :
2929 raise ValueError ("Operation type cannot be empty" )
@@ -34,15 +34,15 @@ def model_post_init(self, __context: Any) -> None:
3434class ProviderRateLimitEvent (DomainEvent ):
3535 """Event raised when provider rate limiting occurs."""
3636
37- provider_type : ProviderType
37+ provider_type : str # e.g. "aws"
3838 service_name : str
3939 operation_name : str
4040 retry_after : Optional [int ] = Field (default = None ) # seconds
4141
4242 def model_post_init (self , __context : Any ) -> None :
4343 """Initialize aggregate information after model creation."""
44- object .__setattr__ (self , "aggregate_id" , f"{ self .provider_type . value } _{ self .service_name } " )
45- object .__setattr__ (self , "aggregate_type" , f"{ self .provider_type . value } _service" )
44+ object .__setattr__ (self , "aggregate_id" , f"{ self .provider_type } _{ self .service_name } " )
45+ object .__setattr__ (self , "aggregate_type" , f"{ self .provider_type } _service" )
4646 super ().model_post_init (__context )
4747 if not self .service_name :
4848 raise ValueError ("Service name cannot be empty" )
@@ -53,16 +53,16 @@ def model_post_init(self, __context: Any) -> None:
5353class ProviderCredentialsEvent (DomainEvent ):
5454 """Event raised for provider credentials operations."""
5555
56- provider_type : ProviderType
56+ provider_type : str # e.g. "aws"
5757 credential_type : str # e.g., "access_key", "service_account", "managed_identity"
5858 operation : str # e.g., "refresh", "validate", "expire"
5959 status : str # success, failure, warning
6060 message : Optional [str ] = Field (default = None )
6161
6262 def model_post_init (self , __context : Any ) -> None :
6363 """Initialize aggregate information after model creation."""
64- object .__setattr__ (self , "aggregate_id" , f"{ self .provider_type . value } _credentials" )
65- object .__setattr__ (self , "aggregate_type" , f"{ self .provider_type . value } _auth" )
64+ object .__setattr__ (self , "aggregate_id" , f"{ self .provider_type } _credentials" )
65+ object .__setattr__ (self , "aggregate_type" , f"{ self .provider_type } _auth" )
6666 super ().model_post_init (__context )
6767 if not self .credential_type :
6868 raise ValueError ("Credential type cannot be empty" )
@@ -75,7 +75,7 @@ def model_post_init(self, __context: Any) -> None:
7575class ProviderResourceStateChangedEvent (DomainEvent ):
7676 """Event raised when provider resource state changes."""
7777
78- provider_type : ProviderType
78+ provider_type : str # e.g. "aws"
7979 resource_type : str
8080 resource_id : str
8181 previous_state : Optional [ProviderInstanceState ] = Field (default = None )
@@ -86,7 +86,7 @@ def model_post_init(self, __context: Any) -> None:
8686 """Initialize aggregate information after model creation."""
8787 object .__setattr__ (self , "aggregate_id" , self .resource_id )
8888 object .__setattr__ (
89- self , "aggregate_type" , f"{ self .provider_type . value } _{ self .resource_type } "
89+ self , "aggregate_type" , f"{ self .provider_type } _{ self .resource_type } "
9090 )
9191 super ().model_post_init (__context )
9292 if not self .resource_type :
@@ -98,16 +98,16 @@ def model_post_init(self, __context: Any) -> None:
9898class ProviderConfigurationEvent (DomainEvent ):
9999 """Event raised for provider configuration changes."""
100100
101- provider_type : ProviderType
101+ provider_type : str # e.g. "aws"
102102 configuration_type : str # e.g., "region", "endpoint", "timeout"
103103 old_value : Optional [str ] = Field (default = None )
104104 new_value : Optional [str ] = Field (default = None )
105105 operation : str = Field (default = "update" ) # update, validate, reset
106106
107107 def model_post_init (self , __context : Any ) -> None :
108108 """Initialize aggregate information after model creation."""
109- object .__setattr__ (self , "aggregate_id" , f"{ self .provider_type . value } _config" )
110- object .__setattr__ (self , "aggregate_type" , f"{ self .provider_type . value } _configuration" )
109+ object .__setattr__ (self , "aggregate_id" , f"{ self .provider_type } _config" )
110+ object .__setattr__ (self , "aggregate_type" , f"{ self .provider_type } _configuration" )
111111 super ().model_post_init (__context )
112112 if not self .configuration_type :
113113 raise ValueError ("Configuration type cannot be empty" )
@@ -116,16 +116,16 @@ def model_post_init(self, __context: Any) -> None:
116116class ProviderHealthCheckEvent (DomainEvent ):
117117 """Event raised for provider health checks."""
118118
119- provider_type : ProviderType
119+ provider_type : str # e.g. "aws"
120120 service_name : str
121121 health_status : str # healthy, unhealthy, degraded
122122 response_time_ms : Optional [int ] = Field (default = None )
123123 error_message : Optional [str ] = Field (default = None )
124124
125125 def model_post_init (self , __context : Any ) -> None :
126126 """Initialize aggregate information after model creation."""
127- object .__setattr__ (self , "aggregate_id" , f"{ self .provider_type . value } _{ self .service_name } " )
128- object .__setattr__ (self , "aggregate_type" , f"{ self .provider_type . value } _health" )
127+ object .__setattr__ (self , "aggregate_id" , f"{ self .provider_type } _{ self .service_name } " )
128+ object .__setattr__ (self , "aggregate_type" , f"{ self .provider_type } _health" )
129129 super ().model_post_init (__context )
130130 if not self .service_name :
131131 raise ValueError ("Service name cannot be empty" )
0 commit comments