Class: Sumologic::Metadata::Folder

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/sumologic/metadata/folder.rb

Overview

Handles folder/content library operations Folders organize dashboards, searches, and other content NOTE: Content API uses v2, not v1

Instance Method Summary collapse

Constructor Details

#initialize(http_client:) ⇒ Folder

Returns a new instance of Folder.

Parameters:

  • http_client (Http::Client)

    HTTP client configured for v2 API



15
16
17
# File 'lib/sumologic/metadata/folder.rb', line 15

def initialize(http_client:)
  @http = http_client
end

Instance Method Details

#get(folder_id) ⇒ Hash

Get a specific folder by ID Returns folder details with children

Parameters:

  • folder_id (String)

    The folder ID

Returns:

  • (Hash)

    Folder data with children



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sumologic/metadata/folder.rb', line 40

def get(folder_id)
  data = @http.request(
    method: :get,
    path: "/content/folders/#{folder_id}"
  )

  log_info "Retrieved folder: #{data['name']} (#{folder_id})"
  data
rescue StandardError => e
  raise Error, "Failed to get folder #{folder_id}: #{e.message}"
end

#personalHash

Get the personal folder for the current user Returns folder with children

Returns:

  • (Hash)

    Personal folder data



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sumologic/metadata/folder.rb', line 23

def personal
  data = @http.request(
    method: :get,
    path: '/content/folders/personal'
  )

  log_info "Retrieved personal folder: #{data['name']}"
  data
rescue StandardError => e
  raise Error, "Failed to get personal folder: #{e.message}"
end

#tree(folder_id: nil, max_depth: 3) ⇒ Hash

List all items in a folder (recursive tree) Builds a tree structure of all content

Parameters:

  • folder_id (String) (defaults to: nil)

    Starting folder ID (nil for personal)

  • max_depth (Integer) (defaults to: 3)

    Maximum recursion depth (default: 3)

Returns:

  • (Hash)

    Folder tree with nested children



58
59
60
61
62
63
# File 'lib/sumologic/metadata/folder.rb', line 58

def tree(folder_id: nil, max_depth: 3)
  root = folder_id ? get(folder_id) : personal
  build_tree(root, 0, max_depth)
rescue StandardError => e
  raise Error, "Failed to build folder tree: #{e.message}"
end