Class: Sumologic::Metadata::Content
- Inherits:
-
Object
- Object
- Sumologic::Metadata::Content
- Includes:
- Loggable
- Defined in:
- lib/sumologic/metadata/content.rb
Overview
Handles content library operations Uses v2 content API endpoints for path lookup and export
Constant Summary collapse
- EXPORT_POLL_INTERVAL =
seconds
2- EXPORT_MAX_WAIT =
seconds
120
Instance Method Summary collapse
-
#export(content_id) ⇒ Hash
Export a content item as JSON Handles the async job lifecycle: start → poll → fetch result.
-
#get_by_path(path) ⇒ Hash
Get a content item by its library path Returns item ID, type, name, and parent folder.
-
#initialize(http_client:) ⇒ Content
constructor
A new instance of Content.
Constructor Details
#initialize(http_client:) ⇒ Content
Returns a new instance of Content.
15 16 17 |
# File 'lib/sumologic/metadata/content.rb', line 15 def initialize(http_client:) @http = http_client end |
Instance Method Details
#export(content_id) ⇒ Hash
Export a content item as JSON Handles the async job lifecycle: start → poll → fetch result
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sumologic/metadata/content.rb', line 42 def export(content_id) # Start export job job = @http.request( method: :post, path: "/content/#{content_id}/export" ) job_id = job['id'] log_info "Started export job #{job_id} for content #{content_id}" # Poll until complete poll_export_status(content_id, job_id) # Fetch result result = @http.request( method: :get, path: "/content/#{content_id}/export/#{job_id}/result" ) log_info "Export complete for content #{content_id}" result rescue StandardError => e raise Error, "Failed to export content #{content_id}: #{e.}" end |
#get_by_path(path) ⇒ Hash
Get a content item by its library path Returns item ID, type, name, and parent folder
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sumologic/metadata/content.rb', line 24 def get_by_path(path) data = @http.request( method: :get, path: '/content/path', query_params: { path: path } ) log_info "Retrieved content at path: #{path}" data rescue StandardError => e raise Error, "Failed to get content at path '#{path}': #{e.}" end |