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.



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

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:

  • []



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

def delete_report(report_id:)
    api_path = '/reports/{reportId}'
        .gsub('{reportId}', report_id)

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

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": '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)


150
151
152
153
154
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
# File 'lib/appwrite/services/advisor.rb', line 150

def get_insight(report_id:, insight_id:)
    api_path = '/reports/{reportId}/insights/{insightId}'
        .gsub('{reportId}', report_id)
        .gsub('{insightId}', insight_id)

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

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

    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)


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

def get_report(report_id:)
    api_path = '/reports/{reportId}'
        .gsub('{reportId}', report_id)

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

    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)


115
116
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
# File 'lib/appwrite/services/advisor.rb', line 115

def list_insights(report_id:, queries: nil, total: nil)
    api_path = '/reports/{reportId}/insights'
        .gsub('{reportId}', report_id)

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

    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)


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

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