Skip to content

Commit 4d2f26f

Browse files
authored
PCBC-831 implement search index management (#115)
* Implement options * Implement API from cluster * Implement SearchIndexManager * Add SearchIndexManagerTest * shorten return type * Linting * update package.xml * Use wrap exception for VariousTasks test * update package.xml again
1 parent c4a662a commit 4d2f26f

20 files changed

+2098
-28
lines changed

Couchbase/Cluster.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,10 @@ public function queryIndexes(): QueryIndexManager
189189
* Creates a new search index manager object for managing search query indexes.
190190
*
191191
* @return SearchIndexManager
192-
* @throws UnsupportedOperationException
193192
*/
194193
public function searchIndexes(): SearchIndexManager
195194
{
196-
throw new UnsupportedOperationException();
195+
return new SearchIndexManager($this->core);
197196
}
198197

199198
/**
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2014-Present Couchbase, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
declare(strict_types=1);
20+
21+
namespace Couchbase\Management;
22+
23+
class AllowQueryingSearchIndexOptions
24+
{
25+
private ?int $timeoutMilliseconds;
26+
27+
/**
28+
* Static helper to make code more readable
29+
*
30+
* @return AllowQueryingSearchIndexOptions
31+
*
32+
* @since 4.1.5
33+
*/
34+
public static function build(): AllowQueryingSearchIndexOptions
35+
{
36+
return new AllowQueryingSearchIndexOptions();
37+
}
38+
39+
/**
40+
* Sets the operation timeout in milliseconds
41+
* @param int $milliseconds
42+
* @return $this
43+
*
44+
* @since 4.1.5
45+
*/
46+
public function timeout(int $milliseconds): AllowQueryingSearchIndexOptions
47+
{
48+
$this->timeoutMilliseconds = $milliseconds;
49+
return $this;
50+
}
51+
52+
/**
53+
* @param AllowQueryingSearchIndexOptions|null $options
54+
* @return array
55+
* @internal
56+
* @since 4.1.5
57+
*/
58+
public static function export(?AllowQueryingSearchIndexOptions $options): array
59+
{
60+
if ($options == null) {
61+
return [];
62+
}
63+
return [
64+
'timeoutMilliseconds' => $options->timeoutMilliseconds,
65+
];
66+
}
67+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2014-Present Couchbase, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
declare(strict_types=1);
20+
21+
namespace Couchbase\Management;
22+
23+
class AnalyzeDocumentOptions
24+
{
25+
private ?int $timeoutMilliseconds;
26+
27+
/**
28+
* Static helper to make code more readable
29+
*
30+
* @return AnalyzeDocumentOptions
31+
*
32+
* @since 4.1.5
33+
*/
34+
public static function build(): AnalyzeDocumentOptions
35+
{
36+
return new AnalyzeDocumentOptions();
37+
}
38+
39+
/**
40+
* Sets the operation timeout in milliseconds
41+
* @param int $milliseconds
42+
* @return $this
43+
*
44+
* @since 4.1.5
45+
*/
46+
public function timeout(int $milliseconds): AnalyzeDocumentOptions
47+
{
48+
$this->timeoutMilliseconds = $milliseconds;
49+
return $this;
50+
}
51+
52+
/**
53+
* @param AnalyzeDocumentOptions|null $options
54+
* @return array
55+
* @internal
56+
* @since 4.1.5
57+
*/
58+
public static function export(?AnalyzeDocumentOptions $options): array
59+
{
60+
if ($options == null) {
61+
return [];
62+
}
63+
return [
64+
'timeoutMilliseconds' => $options->timeoutMilliseconds,
65+
];
66+
}
67+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2014-Present Couchbase, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
declare(strict_types=1);
20+
21+
namespace Couchbase\Management;
22+
23+
class DisallowQueryingSearchIndexOptions
24+
{
25+
private ?int $timeoutMilliseconds;
26+
27+
/**
28+
* Static helper to make code more readable
29+
*
30+
* @return DisallowQueryingSearchIndexOptions
31+
*
32+
* @since 4.1.5
33+
*/
34+
public static function build(): DisallowQueryingSearchIndexOptions
35+
{
36+
return new DisallowQueryingSearchIndexOptions();
37+
}
38+
39+
/**
40+
* Sets the operation timeout in milliseconds
41+
* @param int $milliseconds
42+
* @return $this
43+
*
44+
* @since 4.1.5
45+
*/
46+
public function timeout(int $milliseconds): DisallowQueryingSearchIndexOptions
47+
{
48+
$this->timeoutMilliseconds = $milliseconds;
49+
return $this;
50+
}
51+
52+
/**
53+
* @param DisallowQueryingSearchIndexOptions|null $options
54+
* @return array
55+
* @internal
56+
* @since 4.1.5
57+
*/
58+
public static function export(?DisallowQueryingSearchIndexOptions $options): array
59+
{
60+
if ($options == null) {
61+
return [];
62+
}
63+
return [
64+
'timeoutMilliseconds' => $options->timeoutMilliseconds,
65+
];
66+
}
67+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2014-Present Couchbase, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
declare(strict_types=1);
20+
21+
namespace Couchbase\Management;
22+
23+
class DropSearchIndexOptions
24+
{
25+
private ?int $timeoutMilliseconds;
26+
27+
/**
28+
* Static helper to make code more readable
29+
*
30+
* @return DropSearchIndexOptions
31+
*
32+
* @since 4.1.5
33+
*/
34+
public static function build(): DropSearchIndexOptions
35+
{
36+
return new DropSearchIndexOptions();
37+
}
38+
39+
/**
40+
* Sets the operation timeout in milliseconds
41+
* @param int $milliseconds
42+
* @return $this
43+
*
44+
* @since 4.1.5
45+
*/
46+
public function timeout(int $milliseconds): DropSearchIndexOptions
47+
{
48+
$this->timeoutMilliseconds = $milliseconds;
49+
return $this;
50+
}
51+
52+
/**
53+
* @param DropSearchIndexOptions|null $options
54+
* @return array
55+
* @internal
56+
* @since 4.1.5
57+
*/
58+
public static function export(?DropSearchIndexOptions $options): array
59+
{
60+
if ($options == null) {
61+
return [];
62+
}
63+
return [
64+
'timeoutMilliseconds' => $options->timeoutMilliseconds,
65+
];
66+
}
67+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2014-Present Couchbase, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
declare(strict_types=1);
20+
21+
namespace Couchbase\Management;
22+
23+
class FreezePlanSearchIndexOptions
24+
{
25+
private ?int $timeoutMilliseconds;
26+
27+
/**
28+
* Static helper to make code more readable
29+
*
30+
* @return FreezePlanSearchIndexOptions
31+
*
32+
* @since 4.1.5
33+
*/
34+
public static function build(): FreezePlanSearchIndexOptions
35+
{
36+
return new FreezePlanSearchIndexOptions();
37+
}
38+
39+
/**
40+
* Sets the operation timeout in milliseconds
41+
* @param int $milliseconds
42+
* @return $this
43+
*
44+
* @since 4.1.5
45+
*/
46+
public function timeout(int $milliseconds): FreezePlanSearchIndexOptions
47+
{
48+
$this->timeoutMilliseconds = $milliseconds;
49+
return $this;
50+
}
51+
52+
/**
53+
* @param FreezePlanSearchIndexOptions|null $options
54+
* @return array
55+
* @internal
56+
* @since 4.1.5
57+
*/
58+
public static function export(?FreezePlanSearchIndexOptions $options): array
59+
{
60+
if ($options == null) {
61+
return [];
62+
}
63+
return [
64+
'timeoutMilliseconds' => $options->timeoutMilliseconds,
65+
];
66+
}
67+
}

0 commit comments

Comments
 (0)