@@ -41,6 +41,16 @@ const tenants = (
4141 } ) ;
4242 return result ;
4343 } ) ;
44+ const update = async ( tenants : TenantBC | TenantUpdate | ( TenantBC | TenantUpdate ) [ ] ) => {
45+ const out : Tenant [ ] = [ ] ;
46+ for await ( const res of Serialize . tenants ( parseValueOrValueArray ( tenants ) , Serialize . tenantUpdate ) . map (
47+ ( tenants ) =>
48+ new TenantsUpdater ( connection , collection , tenants ) . do ( ) . then ( ( res ) => res . map ( parseTenantREST ) )
49+ ) ) {
50+ out . push ( ...res ) ;
51+ }
52+ return out ;
53+ } ;
4454 return {
4555 create : ( tenants : TenantBC | TenantCreate | ( TenantBC | TenantCreate ) [ ] ) =>
4656 new TenantsCreator ( connection , collection , parseValueOrValueArray ( tenants ) . map ( Serialize . tenantCreate ) )
@@ -72,15 +82,24 @@ const tenants = (
7282 collection ,
7383 parseValueOrValueArray ( tenants ) . map ( parseStringOrTenant )
7484 ) . do ( ) ,
75- update : async ( tenants : TenantBC | TenantUpdate | ( TenantBC | TenantUpdate ) [ ] ) => {
76- const out : Tenant [ ] = [ ] ;
77- for await ( const res of Serialize . tenants ( parseValueOrValueArray ( tenants ) , Serialize . tenantUpdate ) . map (
78- ( tenants ) =>
79- new TenantsUpdater ( connection , collection , tenants ) . do ( ) . then ( ( res ) => res . map ( parseTenantREST ) )
80- ) ) {
81- out . push ( ...res ) ;
82- }
83- return out ;
85+ update,
86+ activate : ( tenant : string | TenantBase ) => {
87+ return update ( {
88+ name : parseStringOrTenant ( tenant ) ,
89+ activityStatus : 'ACTIVE' ,
90+ } ) ;
91+ } ,
92+ deactivate : ( tenant : string | TenantBase ) => {
93+ return update ( {
94+ name : parseStringOrTenant ( tenant ) ,
95+ activityStatus : 'INACTIVE' ,
96+ } ) ;
97+ } ,
98+ offload : ( tenant : string | TenantBase ) => {
99+ return update ( {
100+ name : parseStringOrTenant ( tenant ) ,
101+ activityStatus : 'OFFLOADED' ,
102+ } ) ;
84103 } ,
85104 } ;
86105} ;
@@ -169,4 +188,28 @@ export interface Tenants {
169188 * @returns {Promise<Tenant[]> } The updated tenant(s) as a list of Tenant.
170189 */
171190 update : ( tenants : TenantBC | TenantUpdate | ( TenantBC | TenantUpdate ) [ ] ) => Promise < Tenant [ ] > ;
191+ /**
192+ * Activate the specified tenant for a collection in Weaviate.
193+ * The collection must have been created with multi-tenancy enabled.
194+ *
195+ * @param {TenantBase | string } tenant The tenant to activate.
196+ * @returns {Promise<Tenant[]> } The activated tenant as a list of Tenant.
197+ */
198+ activate : ( tenant : string | TenantBase ) => Promise < Tenant [ ] > ;
199+ /**
200+ * Deactivate the specified tenant for a collection in Weaviate.
201+ * The collection must have been created with multi-tenancy enabled.
202+ *
203+ * @param {TenantBase | string } tenant The tenant to deactivate.
204+ * @returns {Promise<Tenant[]> } The deactivated tenant as a list of Tenant
205+ */
206+ deactivate : ( tenant : string | TenantBase ) => Promise < Tenant [ ] > ;
207+ /**
208+ * Offload the specified tenant for a collection in Weaviate.
209+ * The collection must have been created with multi-tenancy enabled.
210+ *
211+ * @param {TenantBase | string } tenant The tenant to offload.
212+ * @returns {Promise<Tenant[]> } The offloaded tenant as a list of Tenant
213+ */
214+ offload : ( tenant : string | TenantBase ) => Promise < Tenant [ ] > ;
172215}
0 commit comments