| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Chroma::DB; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use Moo; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
51
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
484
|
use MooX::ValidateSubs; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
6
|
1
|
|
|
1
|
|
1682
|
use WebService::Chroma::Collection; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
70
|
|
|
7
|
1
|
|
|
1
|
|
10
|
use Types::Standard qw/Str Int ArrayRef HashRef ScalarRef/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
validate_subs ( |
|
10
|
|
|
|
|
|
|
create_collection => { |
|
11
|
|
|
|
|
|
|
params => { |
|
12
|
|
|
|
|
|
|
name => [Str], |
|
13
|
|
|
|
|
|
|
configuration => [HashRef, 1], |
|
14
|
|
|
|
|
|
|
metadata => [HashRef, 1], |
|
15
|
|
|
|
|
|
|
get_or_create => [ScalarRef, 1] |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
}, |
|
18
|
|
|
|
|
|
|
get_collections => { |
|
19
|
|
|
|
|
|
|
params => { |
|
20
|
|
|
|
|
|
|
limit => [Int, 1], |
|
21
|
|
|
|
|
|
|
offset => [Int, 1] |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
}, |
|
24
|
|
|
|
|
|
|
get_collection => { |
|
25
|
|
|
|
|
|
|
params => { |
|
26
|
|
|
|
|
|
|
name => [Str], |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
}, |
|
29
|
|
|
|
|
|
|
delete_collection => { |
|
30
|
|
|
|
|
|
|
params => { |
|
31
|
|
|
|
|
|
|
name => [Str], |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
}, |
|
34
|
|
|
|
|
|
|
count_collections => { |
|
35
|
|
|
|
|
|
|
params => { } |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has ua => ( |
|
40
|
|
|
|
|
|
|
is => 'ro', |
|
41
|
|
|
|
|
|
|
required => 1, |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has tenant => ( |
|
45
|
|
|
|
|
|
|
is => 'ro', |
|
46
|
|
|
|
|
|
|
required => 1, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has name => ( |
|
50
|
|
|
|
|
|
|
is => 'ro', |
|
51
|
|
|
|
|
|
|
required => 1, |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub create_collection { |
|
56
|
|
|
|
|
|
|
my ($self, %data) = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $collection = $self->ua->post( |
|
59
|
|
|
|
|
|
|
url => sprintf('/api/v2/tenants/%s/databases/%s/collections', $self->tenant, $self->name), |
|
60
|
|
|
|
|
|
|
data => \%data |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return WebService::Chroma::Collection->new( |
|
64
|
|
|
|
|
|
|
ua => $self->ua, |
|
65
|
|
|
|
|
|
|
tenant => $self->tenant, |
|
66
|
|
|
|
|
|
|
db => $self->name, |
|
67
|
|
|
|
|
|
|
%{$collection} |
|
68
|
|
|
|
|
|
|
); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub get_collections { |
|
72
|
|
|
|
|
|
|
my ($self, %data) = @_; |
|
73
|
|
|
|
|
|
|
my $collections = $self->ua->get( |
|
74
|
|
|
|
|
|
|
url => sprintf('/api/v2/tenants/%s/databases/%s/collections', $self->tenant, $self->name), |
|
75
|
|
|
|
|
|
|
data => \%data |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
return [map { |
|
78
|
|
|
|
|
|
|
WebService::Chroma::Collection->new( |
|
79
|
|
|
|
|
|
|
ua => $self->ua, |
|
80
|
|
|
|
|
|
|
tenant => $self->tenant, |
|
81
|
|
|
|
|
|
|
db => $self->name, |
|
82
|
|
|
|
|
|
|
%{$_} |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
} @{$collections}] |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub get_collection { |
|
88
|
|
|
|
|
|
|
my ($self, %data) = @_; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $collection = $self->ua->get( |
|
91
|
|
|
|
|
|
|
url => sprintf('/api/v2/tenants/%s/databases/%s/collections/%s', $self->tenant, $self->name, $data{name}), |
|
92
|
|
|
|
|
|
|
); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
return WebService::Chroma::Collection->new( |
|
95
|
|
|
|
|
|
|
ua => $self->ua, |
|
96
|
|
|
|
|
|
|
tenant => $self->tenant, |
|
97
|
|
|
|
|
|
|
db => $self->name, |
|
98
|
|
|
|
|
|
|
%{$collection} |
|
99
|
|
|
|
|
|
|
); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub delete_collection { |
|
104
|
|
|
|
|
|
|
my ($self, %data) = @_; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $collection = $self->ua->delete( |
|
107
|
|
|
|
|
|
|
url => sprintf('/api/v2/tenants/%s/databases/%s/collections/%s', $self->tenant, $self->name, $data{name}), |
|
108
|
|
|
|
|
|
|
); |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
return $collection; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub count_collections { |
|
114
|
|
|
|
|
|
|
my ($self, %data) = @_; |
|
115
|
|
|
|
|
|
|
return $self->ua->get( |
|
116
|
|
|
|
|
|
|
url => sprintf('/api/v2/tenants/%s/databases/%s/collections_count', $self->tenant, $self->name), |
|
117
|
|
|
|
|
|
|
); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |