File tree Expand file tree Collapse file tree 7 files changed +69
-1
lines changed Expand file tree Collapse file tree 7 files changed +69
-1
lines changed 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 @@ -31,6 +31,7 @@ def list(
3131 def create (
3232 class_name :,
3333 properties :,
34+ tenant : nil ,
3435 consistency_level : nil ,
3536 id : nil ,
3637 vector : nil
@@ -47,6 +48,7 @@ def create(
4748 req . body = { }
4849 req . body [ "class" ] = class_name
4950 req . body [ "properties" ] = properties
51+ req . body [ "tenant" ] = tenant unless tenant . blank?
5052 req . body [ "id" ] = id unless id . nil?
5153 req . body [ "vector" ] = vector unless vector . nil?
5254 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 ,
@@ -33,6 +34,7 @@ def get(
3334 ask : ask
3435 ) ,
3536 after : after ,
37+ tenant : tenant ,
3638 limit : limit ,
3739 offset : offset
3840 )
@@ -150,6 +152,7 @@ def get_query(
150152 ) {
151153 Get {
152154 #{ class_name } (
155+ tenant: $tenant,
153156 after: $after,
154157 limit: $limit,
155158 offset: $offset,
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,42 @@ 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+ response = client . connection . post ( "#{ PATH } /#{ class_name } /tenants" ) do |req |
104+ req . body = { }
105+ req . body = tenants . map { |tenant | { name : tenant } }
106+ end
107+
108+ if response . success?
109+ end
110+ response . body
111+ end
112+
113+ # List tenants of a class.
114+ def list_tenants ( class_name :)
115+ response = client . connection . get ( "#{ PATH } /#{ class_name } /tenants" )
116+ response . body if response . success?
117+ end
118+
119+ # Remove one or more tenants from a class.
120+ def remove_tenants (
121+ class_name :,
122+ tenants :
123+ )
124+ response = client . connection . delete ( "#{ PATH } /#{ class_name } /tenants" ) do |req |
125+ req . body = tenants
126+ end
127+
128+ if response . success?
129+ end
130+
131+ response . body
132+ end
133+
96134 # Add a property to an existing schema class.
97135 def add_property (
98136 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