@@ -41,17 +41,27 @@ 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 {
45- create : ( tenants : TenantBC | TenantCreate | ( TenantBC | TenantCreate ) [ ] ) =>
55+ create : ( tenants ) =>
4656 new TenantsCreator ( connection , collection , parseValueOrValueArray ( tenants ) . map ( Serialize . tenantCreate ) )
4757 . do ( )
4858 . then ( ( res ) => res . map ( parseTenantREST ) ) ,
4959 get : async function ( ) {
5060 const check = await dbVersionSupport . supportsTenantsGetGRPCMethod ( ) ;
5161 return check . supports ? getGRPC ( ) : getREST ( ) ;
5262 } ,
53- getByNames : < T extends TenantBase > ( tenants : ( string | T ) [ ] ) => getGRPC ( tenants . map ( parseStringOrTenant ) ) ,
54- getByName : async < T extends TenantBase > ( tenant : string | T ) => {
63+ getByNames : ( tenants ) => getGRPC ( tenants . map ( parseStringOrTenant ) ) ,
64+ getByName : async ( tenant ) => {
5565 const tenantName = parseStringOrTenant ( tenant ) ;
5666 if ( await dbVersionSupport . supportsTenantGetRESTMethod ( ) . then ( ( check ) => ! check . supports ) ) {
5767 return getGRPC ( [ tenantName ] ) . then ( ( tenants ) => tenants [ tenantName ] ?? null ) ;
@@ -66,21 +76,36 @@ const tenants = (
6676 throw err ;
6777 } ) ;
6878 } ,
69- remove : < T extends TenantBase > ( tenants : string | T | ( string | T ) [ ] ) =>
79+ remove : ( tenants ) =>
7080 new TenantsDeleter (
7181 connection ,
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 ) => {
87+ return update (
88+ parseValueOrValueArray ( tenant ) . map ( ( tenant ) => ( {
89+ name : parseStringOrTenant ( tenant ) ,
90+ activityStatus : 'ACTIVE' ,
91+ } ) )
92+ ) ;
93+ } ,
94+ deactivate : ( tenant ) => {
95+ return update (
96+ parseValueOrValueArray ( tenant ) . map ( ( tenant ) => ( {
97+ name : parseStringOrTenant ( tenant ) ,
98+ activityStatus : 'INACTIVE' ,
99+ } ) )
100+ ) ;
101+ } ,
102+ offload : ( tenant ) => {
103+ return update (
104+ parseValueOrValueArray ( tenant ) . map ( ( tenant ) => ( {
105+ name : parseStringOrTenant ( tenant ) ,
106+ activityStatus : 'OFFLOADED' ,
107+ } ) )
108+ ) ;
84109 } ,
85110 } ;
86111} ;
@@ -166,7 +191,31 @@ export interface Tenants {
166191 * For details on the new activity statuses, see the docstring for the `Tenants` interface type.
167192 *
168193 * @param {TenantInput | TenantInput[] } tenants The tenant or tenants to update.
169- * @returns {Promise<Tenant[]> } The updated tenant(s) as a list of Tenant.
194+ * @returns {Promise<Tenant[]> } The updated tenants as a list of Tenant.
170195 */
171196 update : ( tenants : TenantBC | TenantUpdate | ( TenantBC | TenantUpdate ) [ ] ) => Promise < Tenant [ ] > ;
197+ /**
198+ * Activate the specified tenants for a collection in Weaviate.
199+ * The collection must have been created with multi-tenancy enabled.
200+ *
201+ * @param {string | TenantBase | (string | TenantBase)[] } tenant The tenants to activate.
202+ * @returns {Promise<Tenant[]> } The list of Tenants that have been activated.
203+ */
204+ activate : ( tenants : string | TenantBase | ( string | TenantBase ) [ ] ) => Promise < Tenant [ ] > ;
205+ /**
206+ * Deactivate the specified tenants for a collection in Weaviate.
207+ * The collection must have been created with multi-tenancy enabled.
208+ *
209+ * @param {string | TenantBase | (string | TenantBase)[] } tenants The tenants to deactivate.
210+ * @returns {Promise<Tenant[]> } The list of Tenants that have been deactivated.
211+ */
212+ deactivate : ( tenants : string | TenantBase | ( string | TenantBase ) [ ] ) => Promise < Tenant [ ] > ;
213+ /**
214+ * Offload the specified tenants for a collection in Weaviate.
215+ * The collection must have been created with multi-tenancy enabled.
216+ *
217+ * @param {string | TenantBase | (string | TenantBase)[] } tenants The tenants to offload.
218+ * @returns {Promise<Tenant[]> } The list of Tenants that have been offloaded.
219+ */
220+ offload : ( tenants : string | TenantBase | ( string | TenantBase ) [ ] ) => Promise < Tenant [ ] > ;
172221}
0 commit comments