Class: Stigg::Resources::V1Beta::Entities

Inherits:
Object
  • Object
show all
Defined in:
lib/stigg/resources/v1_beta/entities.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Entities

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 Entities.

Parameters:



144
145
146
# File 'lib/stigg/resources/v1_beta/entities.rb', line 144

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(id, ids:, request_options: {}) ⇒ Stigg::Models::V1Beta::EntityArchiveResponse

Archives entities in bulk for the given customer by id.

Parameters:

  • id (String)

    The customer identifier (owner) the entities belong to

  • ids (Array<String>)

    Entity identifiers to act on

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

Returns:

See Also:



81
82
83
84
85
86
87
88
89
90
# File 'lib/stigg/resources/v1_beta/entities.rb', line 81

def archive(id, params)
  parsed, options = Stigg::V1Beta::EntityArchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v1-beta/customers/%1$s/entities/archive", id],
    body: parsed,
    model: Stigg::Models::V1Beta::EntityArchiveResponse,
    options: options
  )
end

#list(id, after: nil, before: nil, include_archived: nil, limit: nil, type_ref_id: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1Beta::EntityListResponse>

Retrieves a paginated list of entities for the given customer.

Parameters:

  • id (String)

    The customer identifier (owner) the entities belong to

  • after (String)

    Return items that come after this cursor

  • before (String)

    Return items that come before this cursor

  • include_archived (Symbol, Stigg::Models::V1Beta::EntityListParams::IncludeArchived)

    Whether to include archived entities. One of: true, false

  • limit (Integer)

    Maximum number of items to return

  • type_ref_id (String)

    Filter results to entities of a specific entity type, by the type’s refId

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

Returns:

See Also:



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/stigg/resources/v1_beta/entities.rb', line 55

def list(id, params = {})
  parsed, options = Stigg::V1Beta::EntityListParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/v1-beta/customers/%1$s/entities", id],
    query: query.transform_keys(include_archived: "includeArchived", type_ref_id: "typeRefId"),
    page: Stigg::Internal::MyCursorIDPage,
    model: Stigg::Models::V1Beta::EntityListResponse,
    options: options
  )
end

#retrieve(entity_id, id:, request_options: {}) ⇒ Stigg::Models::V1Beta::EntityRetrieveResponse

Retrieves a single entity for the given customer by its identifier.

Parameters:

  • entity_id (String)

    The entity identifier (refId)

  • id (String)

    The customer identifier (owner) the entity belongs to

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

Returns:

See Also:



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/stigg/resources/v1_beta/entities.rb', line 20

def retrieve(entity_id, params)
  parsed, options = Stigg::V1Beta::EntityRetrieveParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/v1-beta/customers/%1$s/entities/%2$s", id, entity_id],
    model: Stigg::Models::V1Beta::EntityRetrieveResponse,
    options: options
  )
end

#unarchive(id, ids:, request_options: {}) ⇒ Stigg::Models::V1Beta::EntityUnarchiveResponse

Restores previously archived entities in bulk for the given customer by id.

Parameters:

  • id (String)

    The customer identifier (owner) the entities belong to

  • ids (Array<String>)

    Entity identifiers to act on

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

Returns:

See Also:



105
106
107
108
109
110
111
112
113
114
# File 'lib/stigg/resources/v1_beta/entities.rb', line 105

def unarchive(id, params)
  parsed, options = Stigg::V1Beta::EntityUnarchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v1-beta/customers/%1$s/entities/unarchive", id],
    body: parsed,
    model: Stigg::Models::V1Beta::EntityUnarchiveResponse,
    options: options
  )
end

#upsert(id, entities:, request_options: {}) ⇒ Stigg::Models::V1Beta::EntityUpsertResponse

Creates or updates entities in bulk for the given customer. Existing entities matched by id are updated; new ids are created.

Parameters:

Returns:

See Also:



130
131
132
133
134
135
136
137
138
139
# File 'lib/stigg/resources/v1_beta/entities.rb', line 130

def upsert(id, params)
  parsed, options = Stigg::V1Beta::EntityUpsertParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["api/v1-beta/customers/%1$s/entities", id],
    body: parsed,
    model: Stigg::Models::V1Beta::EntityUpsertResponse,
    options: options
  )
end