Class: Cerca::Resources::Agents

Inherits:
Object
  • Object
show all
Defined in:
lib/cerca/resources/agents.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Agents

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Agents.

Parameters:



192
193
194
# File 'lib/cerca/resources/agents.rb', line 192

def initialize(client:)
  @client = client
end

Instance Method Details

#create(configuration: nil, fleet_id: nil, metadata: nil, user_id: nil, request_options: {}) ⇒ Cerca::Models::Agent

Some parameter documentations has been truncated, see Models::AgentCreateParams for more details.

Create agent

Parameters:

  • configuration (Cerca::Models::Configuration)
  • fleet_id (String)
  • metadata (Hash{Symbol=>String})

    Arbitrary string metadata stored on an agent. Runtime enforces maximum key and v

  • user_id (String)
  • request_options (Cerca::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



26
27
28
29
# File 'lib/cerca/resources/agents.rb', line 26

def create(params = {})
  parsed, options = Cerca::AgentCreateParams.dump_request(params)
  @client.request(method: :post, path: "agents", body: parsed, model: Cerca::Agent, options: options)
end

#delete(agent_id, request_options: {}) ⇒ Cerca::Models::AgentDeleteResponse

Delete agent

Parameters:

Returns:

See Also:



115
116
117
118
119
120
121
122
# File 'lib/cerca/resources/agents.rb', line 115

def delete(agent_id, params = {})
  @client.request(
    method: :delete,
    path: ["agents/%1$s", agent_id],
    model: Cerca::Models::AgentDeleteResponse,
    options: params[:request_options]
  )
end

#list(active: nil, cursor: nil, fleet_id: nil, limit: nil, request_options: {}) ⇒ Cerca::Internal::AgentsCursorPage<Cerca::Models::AgentSummary>

Some parameter documentations has been truncated, see Models::AgentListParams for more details.

List agents

Parameters:

  • active (Symbol, Cerca::Models::AgentListParams::Active)

    When set to true, lists only agents with active or awaiting threads.

  • cursor (String)

    Opaque pagination cursor returned by a previous request.

  • fleet_id (String)

    Fleet to list agents from. Defaults to the API key’s default fleet when omitted.

  • limit (String)

    Maximum number of items to return. Defaults to 20 and preserves parseInt semanti

  • request_options (Cerca::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/cerca/resources/agents.rb', line 92

def list(params = {})
  parsed, options = Cerca::AgentListParams.dump_request(params)
  query = Cerca::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "agents",
    query: query.transform_keys(fleet_id: "fleetId"),
    page: Cerca::Internal::AgentsCursorPage,
    model: Cerca::AgentSummary,
    options: options
  )
end

#list_tools(agent_id, request_options: {}) ⇒ Cerca::Models::AgentListToolsResponse

List tools

Parameters:

Returns:

See Also:



134
135
136
137
138
139
140
141
# File 'lib/cerca/resources/agents.rb', line 134

def list_tools(agent_id, params = {})
  @client.request(
    method: :get,
    path: ["agents/%1$s/tools", agent_id],
    model: Cerca::Models::AgentListToolsResponse,
    options: params[:request_options]
  )
end

#retrieve(agent_id, request_options: {}) ⇒ Cerca::Models::Agent

Retrieve agent

Parameters:

Returns:

See Also:



41
42
43
44
45
46
47
48
# File 'lib/cerca/resources/agents.rb', line 41

def retrieve(agent_id, params = {})
  @client.request(
    method: :get,
    path: ["agents/%1$s", agent_id],
    model: Cerca::Agent,
    options: params[:request_options]
  )
end

#retrieve_config(agent_id, request_options: {}) ⇒ Cerca::Models::EffectiveConfiguration

Retrieve config

Parameters:

Returns:

See Also:



153
154
155
156
157
158
159
160
# File 'lib/cerca/resources/agents.rb', line 153

def retrieve_config(agent_id, params = {})
  @client.request(
    method: :get,
    path: ["agents/%1$s/config", agent_id],
    model: Cerca::EffectiveConfiguration,
    options: params[:request_options]
  )
end

#update(agent_id, configuration:, request_options: {}) ⇒ Cerca::Models::Agent

Update agent

Parameters:

Returns:

See Also:



61
62
63
64
65
66
67
68
69
70
# File 'lib/cerca/resources/agents.rb', line 61

def update(agent_id, params)
  parsed, options = Cerca::AgentUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["agents/%1$s", agent_id],
    body: parsed,
    model: Cerca::Agent,
    options: options
  )
end

#update_metadata(agent_id, metadata:, request_options: {}) ⇒ Cerca::Models::Agent

Some parameter documentations has been truncated, see Models::AgentUpdateMetadataParams for more details.

Update metadata

Parameters:

  • agent_id (String)
  • metadata (Hash{Symbol=>String})

    Arbitrary string metadata stored on an agent. Runtime enforces maximum key and v

  • request_options (Cerca::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



178
179
180
181
182
183
184
185
186
187
# File 'lib/cerca/resources/agents.rb', line 178

def (agent_id, params)
  parsed, options = Cerca::AgentUpdateMetadataParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["agents/%1$s/metadata", agent_id],
    body: parsed,
    model: Cerca::Agent,
    options: options
  )
end