@@ -38,84 +38,99 @@ def logger(self) -> Logger:
3838 async def async_save (self , installation : Installation ):
3939 return self .save (installation )
4040
41+ async def async_save_bot (self , bot : Bot ):
42+ return self .save_bot (bot )
43+
4144 def save (self , installation : Installation ):
4245 none = "none"
4346 e_id = installation .enterprise_id or none
4447 t_id = installation .team_id or none
4548 workspace_path = f"{ self .client_id } /{ e_id } -{ t_id } "
4649
50+ self .save_bot (installation .to_bot ())
51+
4752 if self .historical_data_enabled :
4853 history_version : str = str (installation .installed_at )
49- entity : str = json .dumps (installation .to_bot ().__dict__ )
54+
55+ # per workspace
56+ entity : str = json .dumps (installation .__dict__ )
5057 response = self .s3_client .put_object (
5158 Bucket = self .bucket_name ,
5259 Body = entity ,
53- Key = f"{ workspace_path } /bot -latest" ,
60+ Key = f"{ workspace_path } /installer -latest" ,
5461 )
5562 self .logger .debug (f"S3 put_object response: { response } " )
5663 response = self .s3_client .put_object (
5764 Bucket = self .bucket_name ,
5865 Body = entity ,
59- Key = f"{ workspace_path } /bot -{ history_version } " ,
66+ Key = f"{ workspace_path } /installer -{ history_version } " ,
6067 )
6168 self .logger .debug (f"S3 put_object response: { response } " )
6269
63- # per workspace
70+ # per workspace per user
71+ u_id = installation .user_id or none
6472 entity : str = json .dumps (installation .__dict__ )
6573 response = self .s3_client .put_object (
6674 Bucket = self .bucket_name ,
6775 Body = entity ,
68- Key = f"{ workspace_path } /installer-latest" ,
76+ Key = f"{ workspace_path } /installer-{ u_id } - latest" ,
6977 )
7078 self .logger .debug (f"S3 put_object response: { response } " )
7179 response = self .s3_client .put_object (
7280 Bucket = self .bucket_name ,
7381 Body = entity ,
74- Key = f"{ workspace_path } /installer-{ history_version } " ,
82+ Key = f"{ workspace_path } /installer-{ u_id } - { history_version } " ,
7583 )
7684 self .logger .debug (f"S3 put_object response: { response } " )
7785
78- # per workspace per user
79- u_id = installation . user_id or none
86+ else :
87+ # per workspace
8088 entity : str = json .dumps (installation .__dict__ )
8189 response = self .s3_client .put_object (
8290 Bucket = self .bucket_name ,
8391 Body = entity ,
84- Key = f"{ workspace_path } /installer-{ u_id } - latest" ,
92+ Key = f"{ workspace_path } /installer-latest" ,
8593 )
8694 self .logger .debug (f"S3 put_object response: { response } " )
95+
96+ # per workspace per user
97+ u_id = installation .user_id or none
98+ entity : str = json .dumps (installation .__dict__ )
8799 response = self .s3_client .put_object (
88100 Bucket = self .bucket_name ,
89101 Body = entity ,
90- Key = f"{ workspace_path } /installer-{ u_id } -{ history_version } " ,
102+ Key = f"{ workspace_path } /installer-{ u_id } -latest " ,
91103 )
92104 self .logger .debug (f"S3 put_object response: { response } " )
93105
94- else :
95- entity : str = json .dumps (installation .to_bot ().__dict__ )
106+ def save_bot (self , bot : Bot ):
107+ none = "none"
108+ e_id = bot .enterprise_id or none
109+ t_id = bot .team_id or none
110+ workspace_path = f"{ self .client_id } /{ e_id } -{ t_id } "
111+
112+ if self .historical_data_enabled :
113+ history_version : str = str (bot .installed_at )
114+ entity : str = json .dumps (bot .__dict__ )
96115 response = self .s3_client .put_object (
97116 Bucket = self .bucket_name ,
98117 Body = entity ,
99118 Key = f"{ workspace_path } /bot-latest" ,
100119 )
101120 self .logger .debug (f"S3 put_object response: { response } " )
102-
103- # per workspace
104- entity : str = json .dumps (installation .__dict__ )
105121 response = self .s3_client .put_object (
106122 Bucket = self .bucket_name ,
107123 Body = entity ,
108- Key = f"{ workspace_path } /installer-latest " ,
124+ Key = f"{ workspace_path } /bot- { history_version } " ,
109125 )
110126 self .logger .debug (f"S3 put_object response: { response } " )
111127
112- # per workspace per user
113- u_id = installation .user_id or none
114- entity : str = json .dumps (installation .__dict__ )
128+ else :
129+ entity : str = json .dumps (bot .__dict__ )
115130 response = self .s3_client .put_object (
116131 Bucket = self .bucket_name ,
117132 Body = entity ,
118- Key = f"{ workspace_path } /installer- { u_id } -latest" ,
133+ Key = f"{ workspace_path } /bot -latest" ,
119134 )
120135 self .logger .debug (f"S3 put_object response: { response } " )
121136
0 commit comments