Class: Stigg::Resources::V1Beta::Customers::Assignments

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Assignments

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

Parameters:



74
75
76
# File 'lib/stigg/resources/v1_beta/customers/assignments.rb', line 74

def initialize(client:)
  @client = client
end

Instance Method Details

#list(id, after: nil, before: nil, capability_id: nil, entity_id: nil, limit: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1Beta::Customers::AssignmentListResponse>

Returns a cursor-paginated list of capability assignments for the given customer. An assignment ties an entity to a capability with a usage limit and reset cadence.

Parameters:

  • id (String)

    The customer identifier (owner) the assignments belong to

  • after (String)

    Return items that come after this cursor

  • before (String)

    Return items that come before this cursor

  • capability_id (String)

    Filter assignments to a specific capability refId

  • entity_id (String)

    Filter assignments to a specific entity refId

  • limit (Integer)

    Maximum number of items to return

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

Returns:

See Also:



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/stigg/resources/v1_beta/customers/assignments.rb', line 31

def list(id, params = {})
  parsed, options = Stigg::V1Beta::Customers::AssignmentListParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/v1-beta/customers/%1$s/assignments", id],
    query: query.transform_keys(capability_id: "capabilityId", entity_id: "entityId"),
    page: Stigg::Internal::MyCursorIDPage,
    model: Stigg::Models::V1Beta::Customers::AssignmentListResponse,
    options: options
  )
end

#upsert(id, assignments:, request_options: {}) ⇒ Stigg::Models::V1Beta::Customers::AssignmentUpsertResponse

Batched create-or-update of capability assignments. Existing assignments matched by (entityId, capabilityId) are updated; new pairs are created. On update, omitted fields (usageLimit, cadence) are preserved; on create both are required by the governance service.

Parameters:

Returns:

See Also:



60
61
62
63
64
65
66
67
68
69
# File 'lib/stigg/resources/v1_beta/customers/assignments.rb', line 60

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