appwrite 23.1.0 → 24.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +2 -2
  3. data/lib/appwrite/enums/o_auth2_google_prompt.rb +9 -0
  4. data/lib/appwrite/enums/o_auth_provider.rb +0 -2
  5. data/lib/appwrite/enums/{auth_method.rb → project_auth_method_id.rb} +1 -1
  6. data/lib/appwrite/enums/{email_template_type.rb → project_email_template_id.rb} +1 -1
  7. data/lib/appwrite/enums/{email_template_locale.rb → project_email_template_locale.rb} +1 -1
  8. data/lib/appwrite/enums/project_key_scopes.rb +100 -0
  9. data/lib/appwrite/enums/project_o_auth2_google_prompt.rb +9 -0
  10. data/lib/appwrite/enums/project_o_auth_provider_id.rb +51 -0
  11. data/lib/appwrite/enums/{project_policy.rb → project_policy_id.rb} +1 -1
  12. data/lib/appwrite/enums/{protocol_id.rb → project_protocol_id.rb} +1 -1
  13. data/lib/appwrite/enums/{service_id.rb → project_service_id.rb} +2 -1
  14. data/lib/appwrite/enums/{secure.rb → project_smtp_secure.rb} +1 -1
  15. data/lib/appwrite/enums/scopes.rb +7 -0
  16. data/lib/appwrite/models/database.rb +2 -2
  17. data/lib/appwrite/models/insight.rb +107 -0
  18. data/lib/appwrite/models/insight_cta.rb +42 -0
  19. data/lib/appwrite/models/insight_list.rb +32 -0
  20. data/lib/appwrite/models/o_auth2_google.rb +8 -3
  21. data/lib/appwrite/models/presence.rb +71 -0
  22. data/lib/appwrite/models/presence_list.rb +36 -0
  23. data/lib/appwrite/models/project.rb +15 -285
  24. data/lib/appwrite/models/project_auth_method.rb +53 -0
  25. data/lib/appwrite/models/project_protocol.rb +49 -0
  26. data/lib/appwrite/models/project_service.rb +64 -0
  27. data/lib/appwrite/models/report.rb +82 -0
  28. data/lib/appwrite/models/report_list.rb +32 -0
  29. data/lib/appwrite/models/usage_event.rb +72 -0
  30. data/lib/appwrite/models/usage_event_list.rb +32 -0
  31. data/lib/appwrite/models/usage_gauge.rb +37 -0
  32. data/lib/appwrite/models/usage_gauge_list.rb +32 -0
  33. data/lib/appwrite/services/advisor.rb +173 -0
  34. data/lib/appwrite/services/presences.rb +199 -0
  35. data/lib/appwrite/services/project.rb +170 -52
  36. data/lib/appwrite/services/usage.rb +86 -0
  37. data/lib/appwrite.rb +28 -8
  38. metadata +30 -10
  39. data/lib/appwrite/models/auth_provider.rb +0 -47
@@ -0,0 +1,72 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class UsageEvent
6
+ attr_reader :metric
7
+ attr_reader :value
8
+ attr_reader :time
9
+ attr_reader :xpath
10
+ attr_reader :method
11
+ attr_reader :status
12
+ attr_reader :resource_type
13
+ attr_reader :resource_id
14
+ attr_reader :country_code
15
+ attr_reader :user_agent
16
+
17
+ def initialize(
18
+ metric:,
19
+ value:,
20
+ time:,
21
+ xpath:,
22
+ method:,
23
+ status:,
24
+ resource_type:,
25
+ resource_id:,
26
+ country_code:,
27
+ user_agent:
28
+ )
29
+ @metric = metric
30
+ @value = value
31
+ @time = time
32
+ @xpath = xpath
33
+ @method = method
34
+ @status = status
35
+ @resource_type = resource_type
36
+ @resource_id = resource_id
37
+ @country_code = country_code
38
+ @user_agent = user_agent
39
+ end
40
+
41
+ def self.from(map:)
42
+ UsageEvent.new(
43
+ metric: map["metric"],
44
+ value: map["value"],
45
+ time: map["time"],
46
+ xpath: map["path"],
47
+ method: map["method"],
48
+ status: map["status"],
49
+ resource_type: map["resourceType"],
50
+ resource_id: map["resourceId"],
51
+ country_code: map["countryCode"],
52
+ user_agent: map["userAgent"]
53
+ )
54
+ end
55
+
56
+ def to_map
57
+ {
58
+ "metric": @metric,
59
+ "value": @value,
60
+ "time": @time,
61
+ "path": @xpath,
62
+ "method": @method,
63
+ "status": @status,
64
+ "resourceType": @resource_type,
65
+ "resourceId": @resource_id,
66
+ "countryCode": @country_code,
67
+ "userAgent": @user_agent
68
+ }
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class UsageEventList
6
+ attr_reader :total
7
+ attr_reader :events
8
+
9
+ def initialize(
10
+ total:,
11
+ events:
12
+ )
13
+ @total = total
14
+ @events = events
15
+ end
16
+
17
+ def self.from(map:)
18
+ UsageEventList.new(
19
+ total: map["total"],
20
+ events: map["events"].map { |it| UsageEvent.from(map: it) }
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "total": @total,
27
+ "events": @events.map { |it| it.to_map }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,37 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class UsageGauge
6
+ attr_reader :metric
7
+ attr_reader :value
8
+ attr_reader :time
9
+
10
+ def initialize(
11
+ metric:,
12
+ value:,
13
+ time:
14
+ )
15
+ @metric = metric
16
+ @value = value
17
+ @time = time
18
+ end
19
+
20
+ def self.from(map:)
21
+ UsageGauge.new(
22
+ metric: map["metric"],
23
+ value: map["value"],
24
+ time: map["time"]
25
+ )
26
+ end
27
+
28
+ def to_map
29
+ {
30
+ "metric": @metric,
31
+ "value": @value,
32
+ "time": @time
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class UsageGaugeList
6
+ attr_reader :total
7
+ attr_reader :gauges
8
+
9
+ def initialize(
10
+ total:,
11
+ gauges:
12
+ )
13
+ @total = total
14
+ @gauges = gauges
15
+ end
16
+
17
+ def self.from(map:)
18
+ UsageGaugeList.new(
19
+ total: map["total"],
20
+ gauges: map["gauges"].map { |it| UsageGauge.from(map: it) }
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "total": @total,
27
+ "gauges": @gauges.map { |it| it.to_map }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,173 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ class Advisor < Service
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Get a list of all the project's analyzer reports. You can use the query
11
+ # params to filter your results.
12
+ #
13
+ #
14
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: appId, type, targetType, target, analyzedAt
15
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
16
+ #
17
+ # @return [ReportList]
18
+ def list_reports(queries: nil, total: nil)
19
+ api_path = '/reports'
20
+
21
+ api_params = {
22
+ queries: queries,
23
+ total: total,
24
+ }
25
+
26
+ api_headers = {
27
+ }
28
+
29
+ @client.call(
30
+ method: 'GET',
31
+ path: api_path,
32
+ headers: api_headers,
33
+ params: api_params,
34
+ response_type: Models::ReportList
35
+ )
36
+
37
+ end
38
+
39
+ # Get an analyzer report by its unique ID. The response includes the report's
40
+ # metadata and the nested insights it produced.
41
+ #
42
+ #
43
+ # @param [String] report_id Report ID.
44
+ #
45
+ # @return [Report]
46
+ def get_report(report_id:)
47
+ api_path = '/reports/{reportId}'
48
+ .gsub('{reportId}', report_id)
49
+
50
+ if report_id.nil?
51
+ raise Appwrite::Exception.new('Missing required parameter: "reportId"')
52
+ end
53
+
54
+ api_params = {
55
+ }
56
+
57
+ api_headers = {
58
+ }
59
+
60
+ @client.call(
61
+ method: 'GET',
62
+ path: api_path,
63
+ headers: api_headers,
64
+ params: api_params,
65
+ response_type: Models::Report
66
+ )
67
+
68
+ end
69
+
70
+ # Delete an analyzer report by its unique ID. Nested insights and CTA
71
+ # metadata are removed asynchronously by the deletes worker.
72
+ #
73
+ #
74
+ # @param [String] report_id Report ID.
75
+ #
76
+ # @return []
77
+ def delete_report(report_id:)
78
+ api_path = '/reports/{reportId}'
79
+ .gsub('{reportId}', report_id)
80
+
81
+ if report_id.nil?
82
+ raise Appwrite::Exception.new('Missing required parameter: "reportId"')
83
+ end
84
+
85
+ api_params = {
86
+ }
87
+
88
+ api_headers = {
89
+ "content-type": 'application/json',
90
+ }
91
+
92
+ @client.call(
93
+ method: 'DELETE',
94
+ path: api_path,
95
+ headers: api_headers,
96
+ params: api_params,
97
+ )
98
+
99
+ end
100
+
101
+ # List the insights produced under a single analyzer report. You can use the
102
+ # query params to filter your results further.
103
+ #
104
+ #
105
+ # @param [String] report_id Parent report ID.
106
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy
107
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
108
+ #
109
+ # @return [InsightList]
110
+ def list_insights(report_id:, queries: nil, total: nil)
111
+ api_path = '/reports/{reportId}/insights'
112
+ .gsub('{reportId}', report_id)
113
+
114
+ if report_id.nil?
115
+ raise Appwrite::Exception.new('Missing required parameter: "reportId"')
116
+ end
117
+
118
+ api_params = {
119
+ queries: queries,
120
+ total: total,
121
+ }
122
+
123
+ api_headers = {
124
+ }
125
+
126
+ @client.call(
127
+ method: 'GET',
128
+ path: api_path,
129
+ headers: api_headers,
130
+ params: api_params,
131
+ response_type: Models::InsightList
132
+ )
133
+
134
+ end
135
+
136
+ # Get an insight by its unique ID, scoped to its parent report.
137
+ #
138
+ #
139
+ # @param [String] report_id Parent report ID.
140
+ # @param [String] insight_id Insight ID.
141
+ #
142
+ # @return [Insight]
143
+ def get_insight(report_id:, insight_id:)
144
+ api_path = '/reports/{reportId}/insights/{insightId}'
145
+ .gsub('{reportId}', report_id)
146
+ .gsub('{insightId}', insight_id)
147
+
148
+ if report_id.nil?
149
+ raise Appwrite::Exception.new('Missing required parameter: "reportId"')
150
+ end
151
+
152
+ if insight_id.nil?
153
+ raise Appwrite::Exception.new('Missing required parameter: "insightId"')
154
+ end
155
+
156
+ api_params = {
157
+ }
158
+
159
+ api_headers = {
160
+ }
161
+
162
+ @client.call(
163
+ method: 'GET',
164
+ path: api_path,
165
+ headers: api_headers,
166
+ params: api_params,
167
+ response_type: Models::Insight
168
+ )
169
+
170
+ end
171
+
172
+ end
173
+ end
@@ -0,0 +1,199 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ class Presences < Service
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # List presence logs. Expired entries are filtered out automatically.
11
+ #
12
+ #
13
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK.
14
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
15
+ # @param [Integer] ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours).
16
+ #
17
+ # @return [PresenceList]
18
+ def list(queries: nil, total: nil, ttl: nil)
19
+ api_path = '/presences'
20
+
21
+ api_params = {
22
+ queries: queries,
23
+ total: total,
24
+ ttl: ttl,
25
+ }
26
+
27
+ api_headers = {
28
+ }
29
+
30
+ @client.call(
31
+ method: 'GET',
32
+ path: api_path,
33
+ headers: api_headers,
34
+ params: api_params,
35
+ response_type: Models::PresenceList
36
+ )
37
+
38
+ end
39
+
40
+ # Get a presence log by its unique ID. Entries whose `expiresAt` is in the
41
+ # past are treated as not found.
42
+ #
43
+ #
44
+ # @param [String] presence_id Presence unique ID.
45
+ #
46
+ # @return [Presence]
47
+ def get(presence_id:)
48
+ api_path = '/presences/{presenceId}'
49
+ .gsub('{presenceId}', presence_id)
50
+
51
+ if presence_id.nil?
52
+ raise Appwrite::Exception.new('Missing required parameter: "presenceId"')
53
+ end
54
+
55
+ api_params = {
56
+ }
57
+
58
+ api_headers = {
59
+ }
60
+
61
+ @client.call(
62
+ method: 'GET',
63
+ path: api_path,
64
+ headers: api_headers,
65
+ params: api_params,
66
+ response_type: Models::Presence
67
+ )
68
+
69
+ end
70
+
71
+ # Create or update a presence log by its user ID.
72
+ #
73
+ #
74
+ # @param [String] presence_id Presence unique ID.
75
+ # @param [String] user_id User ID.
76
+ # @param [String] status Presence status.
77
+ # @param [Array] permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
78
+ # @param [String] expires_at Presence expiry datetime.
79
+ # @param [Hash] metadata Presence metadata object.
80
+ #
81
+ # @return [Presence]
82
+ def upsert(presence_id:, user_id:, status:, permissions: nil, expires_at: nil, metadata: nil)
83
+ api_path = '/presences/{presenceId}'
84
+ .gsub('{presenceId}', presence_id)
85
+
86
+ if presence_id.nil?
87
+ raise Appwrite::Exception.new('Missing required parameter: "presenceId"')
88
+ end
89
+
90
+ if user_id.nil?
91
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
92
+ end
93
+
94
+ if status.nil?
95
+ raise Appwrite::Exception.new('Missing required parameter: "status"')
96
+ end
97
+
98
+ api_params = {
99
+ userId: user_id,
100
+ status: status,
101
+ permissions: permissions,
102
+ expiresAt: expires_at,
103
+ metadata: metadata,
104
+ }
105
+
106
+ api_headers = {
107
+ "content-type": 'application/json',
108
+ }
109
+
110
+ @client.call(
111
+ method: 'PUT',
112
+ path: api_path,
113
+ headers: api_headers,
114
+ params: api_params,
115
+ response_type: Models::Presence
116
+ )
117
+
118
+ end
119
+
120
+ # Update a presence log by its unique ID. Using the patch method you can pass
121
+ # only specific fields that will get updated.
122
+ #
123
+ #
124
+ # @param [String] presence_id Presence unique ID.
125
+ # @param [String] user_id User ID.
126
+ # @param [String] status Presence status.
127
+ # @param [String] expires_at Presence expiry datetime.
128
+ # @param [Hash] metadata Presence metadata object.
129
+ # @param [Array] permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
130
+ # @param [] purge When true, purge cached responses used by list presences endpoint.
131
+ #
132
+ # @return [Presence]
133
+ def update_presence(presence_id:, user_id:, status: nil, expires_at: nil, metadata: nil, permissions: nil, purge: nil)
134
+ api_path = '/presences/{presenceId}'
135
+ .gsub('{presenceId}', presence_id)
136
+
137
+ if presence_id.nil?
138
+ raise Appwrite::Exception.new('Missing required parameter: "presenceId"')
139
+ end
140
+
141
+ if user_id.nil?
142
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
143
+ end
144
+
145
+ api_params = {
146
+ userId: user_id,
147
+ status: status,
148
+ expiresAt: expires_at,
149
+ metadata: metadata,
150
+ permissions: permissions,
151
+ purge: purge,
152
+ }
153
+
154
+ api_headers = {
155
+ "content-type": 'application/json',
156
+ }
157
+
158
+ @client.call(
159
+ method: 'PATCH',
160
+ path: api_path,
161
+ headers: api_headers,
162
+ params: api_params,
163
+ response_type: Models::Presence
164
+ )
165
+
166
+ end
167
+
168
+ # Delete a presence log by its unique ID.
169
+ #
170
+ #
171
+ # @param [String] presence_id Presence unique ID.
172
+ #
173
+ # @return []
174
+ def delete(presence_id:)
175
+ api_path = '/presences/{presenceId}'
176
+ .gsub('{presenceId}', presence_id)
177
+
178
+ if presence_id.nil?
179
+ raise Appwrite::Exception.new('Missing required parameter: "presenceId"')
180
+ end
181
+
182
+ api_params = {
183
+ }
184
+
185
+ api_headers = {
186
+ "content-type": 'application/json',
187
+ }
188
+
189
+ @client.call(
190
+ method: 'DELETE',
191
+ path: api_path,
192
+ headers: api_headers,
193
+ params: api_params,
194
+ )
195
+
196
+ end
197
+
198
+ end
199
+ end