File tree Expand file tree Collapse file tree 8 files changed +69
-2
lines changed Expand file tree Collapse file tree 8 files changed +69
-2
lines changed Original file line number Diff line number Diff line change 99
1010#  rspec failure tracking
1111.rspec_status 
12+ .rubocop.yml 
Original file line number Diff line number Diff line change 9393    yard  (0.9.34 )
9494
9595PLATFORMS 
96+   arm64-darwin-21 
9697  x86_64-darwin-19 
9798  x86_64-linux 
9899
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ class Objects < Base
88    def  list ( 
99      class_name : nil , 
1010      limit : nil , 
11+       tenant : nil , 
1112      offset : nil , 
1213      after : nil , 
1314      include : nil , 
@@ -16,6 +17,7 @@ def list(
1617    ) 
1718      response  =  client . connection . get ( PATH )  do  |req |
1819        req . params [ "class" ]  =  class_name  unless  class_name . nil? 
20+         req . params [ "tenant" ]  =  tenant  unless  tenant . nil? 
1921        req . params [ "limit" ]  =  limit  unless  limit . nil? 
2022        req . params [ "offset" ]  =  offset  unless  offset . nil? 
2123        req . params [ "after" ]  =  after  unless  after . nil? 
@@ -31,6 +33,7 @@ def list(
3133    def  create ( 
3234      class_name :, 
3335      properties :, 
36+       tenant : nil , 
3437      consistency_level : nil , 
3538      id : nil , 
3639      vector : nil 
@@ -47,6 +50,7 @@ def create(
4750        req . body  =  { } 
4851        req . body [ "class" ]  =  class_name 
4952        req . body [ "properties" ]  =  properties 
53+         req . body [ "tenant" ]  =  tenant  unless  tenant . blank? 
5054        req . body [ "id" ]  =  id  unless  id . nil? 
5155        req . body [ "vector" ]  =  vector  unless  vector . nil? 
5256      end 
Original file line number Diff line number Diff line change 66      class_name :, 
77      fields :, 
88      after : nil , 
9+       tenant : nil , 
910      limit : nil , 
1011      offset : nil , 
1112      sort : nil , 
@@ -21,6 +22,7 @@ def get(
2122      response  =  client . graphql . execute ( 
2223        get_query ( 
2324          class_name : class_name , 
25+           tenant : tenant , 
2426          fields : fields , 
2527          sort : sort , 
2628          where : where , 
@@ -131,7 +133,7 @@ def explore_query(
131133
132134    def  get_query ( 
133135      class_name :, 
134-       fields :, 
136+       fields :,   tenant :  nil , 
135137      where : nil , 
136138      near_text : nil , 
137139      near_vector : nil , 
@@ -153,6 +155,7 @@ def get_query(
153155              after: $after, 
154156              limit: $limit, 
155157              offset: $offset, 
158+               #{ tenant . present?  ? "tenant: #{ tenant }  "  : "" }  
156159              #{ near_text . present?  ? "nearText: #{ near_text }  "  : "" }  , 
157160              #{ near_vector . present?  ? "nearVector: #{ near_vector }  "  : "" }  , 
158161              #{ near_image . present?  ? "nearImage: #{ near_image }  "  : "" }  , 
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ def create(
2626      class_name :, 
2727      description : nil , 
2828      properties : nil , 
29+       multi_tenant : nil , 
2930      vector_index_type : nil , 
3031      vector_index_config : nil , 
3132      vectorizer : nil , 
@@ -42,6 +43,7 @@ def create(
4243        req . body [ "vectorizer" ]  =  vectorizer  unless  vectorizer . nil? 
4344        req . body [ "moduleConfig" ]  =  module_config  unless  module_config . nil? 
4445        req . body [ "properties" ]  =  properties  unless  properties . nil? 
46+         req . body [ "multiTenancyConfig" ]  =  { enabled : true }  unless  multi_tenant . nil? 
4547        req . body [ "invertedIndexConfig" ]  =  inverted_index_config  unless  inverted_index_config . nil? 
4648        req . body [ "replicationConfig" ]  =  replication_config  unless  replication_config . nil? 
4749      end 
@@ -93,6 +95,38 @@ def update(
9395      response . body 
9496    end 
9597
98+     # Adds one or more tenants to a class. 
99+     def  add_tenants ( 
100+       class_name :, 
101+       tenants :
102+     ) 
103+       client . connection . post ( "#{ PATH }  /#{ class_name }  /tenants" )  do  |req |
104+         tenants_str  =  tenants . map  {  |t | %({"name": "#{ t }  "})  } . join ( ", " ) 
105+         req . body  =  "[#{ tenants_str }  ]" 
106+       end 
107+     end 
108+ 
109+     # List tenants of a class. 
110+     def  list_tenants ( class_name :) 
111+       response  =  client . connection . get ( "#{ PATH }  /#{ class_name }  /tenants" ) 
112+       response . body 
113+     end 
114+ 
115+     # Remove one or more tenants from a class. 
116+     def  remove_tenants ( 
117+       class_name :, 
118+       tenants :
119+     ) 
120+       response  =  client . connection . delete ( "#{ PATH }  /#{ class_name }  /tenants" )  do  |req |
121+         req . body  =  tenants 
122+       end 
123+ 
124+       if  response . success? 
125+       end 
126+ 
127+       response . body 
128+     end 
129+ 
96130    # Add a property to an existing schema class. 
97131    def  add_property ( 
98132      class_name :, 
Original file line number Diff line number Diff line change 2626    it  "creates an object"  do 
2727      response  =  objects . create ( 
2828        class_name : "Question" , 
29+         tenant : "tenant_name" , 
2930        properties : { 
3031          answer : "42" , 
3132          question : "What is the meaning of life?" , 
Original file line number Diff line number Diff line change 5555        class_name : "Question" , 
5656        fields : "question, category" , 
5757        near_text : "{ concepts: [\" biology\" ] }" , 
58+         tenant : "tenant_name" , 
5859        limit : "1" 
5960      ) 
6061
Original file line number Diff line number Diff line change 5757      response  =  schema . create ( 
5858        class_name : "Question" , 
5959        description : "Information from a Jeopardy! question" , 
60+         multi_tenant : true , 
6061        properties : [ 
6162          { 
6263            dataType : [ "text" ] , 
111112    end 
112113  end 
113114
114-   xdescribe  "#add_property"  do 
115+   describe  "#add_property" 
116+ 
117+   describe  "#add_tenants"  do 
118+     let ( :response )  {  OpenStruct . new ( success? : true ,  body : class_fixture )  } 
119+ 
120+     before  do 
121+       allow_any_instance_of ( Faraday ::Connection ) . to  receive ( :post ) 
122+         . with ( "schema/Question/tenants" ) 
123+         . and_return ( response ) 
124+     end 
125+ 
126+     it  "returns the schema"  do 
127+       response  =  schema . add_tenants ( 
128+         class_name : "Question" , 
129+         tenants : [ "tenant1" ,  "tenant2" ] 
130+       ) 
131+       expect ( response . dig ( "class" ) ) . to  eq ( "Question" ) 
132+     end 
115133  end 
116134
135+   describe  "#list_tenants" 
136+ 
137+   describe  "#remove_tenants" 
138+ 
117139  describe  "#shards"  do 
118140    let ( :response )  {  OpenStruct . new ( success? : true ,  body : shard_fixture )  } 
119141
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments