Class: Appwrite::Advisor

Inherits:
Service show all
Defined in:
lib/appwrite/services/advisor.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Advisor

Returns a new instance of Advisor.



5
6
7
# File 'lib/appwrite/services/advisor.rb', line 5

def initialize(client)
    @client = client
end

Instance Method Details

#delete_report(report_id:) ⇒ Object

Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker.

Parameters:

  • report_id (String) —

    Report ID.

Returns:

  • []



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/appwrite/services/advisor.rb', line 82

def delete_report(
    report_id:
)
    if report_id.nil? || report_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "reportId"')
    end

    api_path = '/reports/{reportId}'
        .gsub('{reportId}', @client.encode_path(report_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )
end

#get_insight(report_id:, insight_id:) ⇒ Insight

Get an insight by its unique ID, scoped to its parent report.

Parameters:

  • report_id (String) —

    Parent report ID.

  • insight_id (String) —

    Insight ID.

Returns:

  • (Insight)


155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/appwrite/services/advisor.rb', line 155

def get_insight(
    report_id:,
    insight_id:
)
    if report_id.nil? || report_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "reportId"')
    end

    if insight_id.nil? || insight_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "insightId"')
    end

    api_path = '/reports/{reportId}/insights/{insightId}'
        .gsub('{reportId}', @client.encode_path(report_id))
        .gsub('{insightId}', @client.encode_path(insight_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Insight
    )
end

#get_report(report_id:) ⇒ Report

Get an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced.

Parameters:

  • report_id (String) —

    Report ID.

Returns:

  • (Report)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/appwrite/services/advisor.rb', line 49

def get_report(
    report_id:
)
    if report_id.nil? || report_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "reportId"')
    end

    api_path = '/reports/{reportId}'
        .gsub('{reportId}', @client.encode_path(report_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Report
    )
end

#list_insights(report_id:, queries: nil, total: nil) ⇒ InsightList

List the insights produced under a single analyzer report. You can use the query params to filter your results further.

Parameters:

  • report_id (String) —

    Parent report ID.

  • queries (Array) (defaults to: nil) —

    Array of query strings generated using the Query class provided by the SDK. Learn more about 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

  • [] —

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (InsightList)


117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/appwrite/services/advisor.rb', line 117

def list_insights(
    report_id:,
    queries: nil,
    total: nil
)
    if report_id.nil? || report_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "reportId"')
    end

    api_path = '/reports/{reportId}/insights'
        .gsub('{reportId}', @client.encode_path(report_id))

    api_params = {
        queries: queries,
        total: total,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::InsightList
    )
end

#list_reports(queries: nil, total: nil) ⇒ ReportList

Get a list of all the project's analyzer reports. You can use the query params to filter your results.

Parameters:

  • queries (Array) (defaults to: nil) —

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: appId, type, targetType, target, analyzedAt

  • [] —

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (ReportList)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/appwrite/services/advisor.rb', line 17

def list_reports(
    queries: nil,
    total: nil
)
    api_path = '/reports'

    api_params = {
        queries: queries,
        total: total,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::ReportList
    )
end