Class: Stigg::Resources::V1::Features

Inherits:
Object
  • Object
show all
Defined in:
lib/stigg/resources/v1/features.rb

Overview

Operations related to features

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Features

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

Parameters:



194
195
196
# File 'lib/stigg/resources/v1/features.rb', line 194

def initialize(client:)
  @client = client
end

Instance Method Details

#archive_feature(id, request_options: {}) ⇒ Stigg::Models::V1::Feature

Archives a feature, preventing it from being used in new entitlements.

Parameters:

  • id (String)

    The unique identifier of the entity

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

Returns:

See Also:



19
20
21
22
23
24
25
26
# File 'lib/stigg/resources/v1/features.rb', line 19

def archive_feature(id, params = {})
  @client.request(
    method: :post,
    path: ["api/v1/features/%1$s/archive", id],
    model: Stigg::V1::Feature,
    options: params[:request_options]
  )
end

#create_feature(id:, display_name:, feature_type:, description: nil, enum_configuration: nil, feature_status: nil, feature_units: nil, feature_units_plural: nil, metadata: nil, meter_type: nil, unit_transformation: nil, request_options: {}) ⇒ Stigg::Models::V1::Feature

Creates a new feature with the specified type, metering, and configuration.

Parameters:

Returns:

See Also:



59
60
61
62
63
64
65
66
67
68
# File 'lib/stigg/resources/v1/features.rb', line 59

def create_feature(params)
  parsed, options = Stigg::V1::FeatureCreateFeatureParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/v1/features",
    body: parsed,
    model: Stigg::V1::Feature,
    options: options
  )
end

#list_features(id: nil, after: nil, before: nil, created_at: nil, feature_type: nil, limit: nil, meter_type: nil, status: nil, request_options: {}) ⇒ Stigg::Internal::MyCursorIDPage<Stigg::Models::V1::FeatureListFeaturesResponse>

Retrieves a paginated list of features in the environment.

Parameters:

  • id (String)

    Filter by entity ID

  • after (String)

    Return items that come after this cursor

  • before (String)

    Return items that come before this cursor

  • created_at (Stigg::Models::V1::FeatureListFeaturesParams::CreatedAt)

    Filter by creation date using range operators: gt, gte, lt, lte

  • feature_type (String)

    Filter by feature type. Supports comma-separated values for multiple types

  • limit (Integer)

    Maximum number of items to return

  • meter_type (String)

    Filter by meter type. Supports comma-separated values for multiple types

  • status (String)

    Filter by feature status. Supports comma-separated values for multiple statuses

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

Returns:

See Also:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/stigg/resources/v1/features.rb', line 95

def list_features(params = {})
  parsed, options = Stigg::V1::FeatureListFeaturesParams.dump_request(params)
  query = Stigg::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/v1/features",
    query: query.transform_keys(
      created_at: "createdAt",
      feature_type: "featureType",
      meter_type: "meterType"
    ),
    page: Stigg::Internal::MyCursorIDPage,
    model: Stigg::Models::V1::FeatureListFeaturesResponse,
    options: options
  )
end

#retrieve_feature(id, request_options: {}) ⇒ Stigg::Models::V1::Feature

Retrieves a feature by its unique identifier.

Parameters:

  • id (String)

    The unique identifier of the entity

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

Returns:

See Also:



123
124
125
126
127
128
129
130
# File 'lib/stigg/resources/v1/features.rb', line 123

def retrieve_feature(id, params = {})
  @client.request(
    method: :get,
    path: ["api/v1/features/%1$s", id],
    model: Stigg::V1::Feature,
    options: params[:request_options]
  )
end

#unarchive_feature(id, request_options: {}) ⇒ Stigg::Models::V1::Feature

Restores an archived feature, allowing it to be used in entitlements again.

Parameters:

  • id (String)

    The unique identifier of the entity

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

Returns:

See Also:



143
144
145
146
147
148
149
150
# File 'lib/stigg/resources/v1/features.rb', line 143

def unarchive_feature(id, params = {})
  @client.request(
    method: :post,
    path: ["api/v1/features/%1$s/unarchive", id],
    model: Stigg::V1::Feature,
    options: params[:request_options]
  )
end

#update_feature(id, description: nil, display_name: nil, enum_configuration: nil, feature_units: nil, feature_units_plural: nil, metadata: nil, meter: nil, unit_transformation: nil, request_options: {}) ⇒ Stigg::Models::V1::Feature

Updates an existing feature’s properties such as display name, description, and configuration.

Parameters:

Returns:

See Also:



180
181
182
183
184
185
186
187
188
189
# File 'lib/stigg/resources/v1/features.rb', line 180

def update_feature(id, params = {})
  parsed, options = Stigg::V1::FeatureUpdateFeatureParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["api/v1/features/%1$s", id],
    body: parsed,
    model: Stigg::V1::Feature,
    options: options
  )
end