Class: WorkOS::FeatureFlags
- Inherits:
-
Object
- Object
- WorkOS::FeatureFlags
- Defined in:
- lib/workos/feature_flags.rb
Instance Method Summary collapse
-
#add_flag_target(resource_id:, slug:, request_options: {}) ⇒ void
Add a feature flag target.
-
#disable_feature_flag(slug:, request_options: {}) ⇒ WorkOS::FeatureFlag
Disable a feature flag.
-
#enable_feature_flag(slug:, request_options: {}) ⇒ WorkOS::FeatureFlag
Enable a feature flag.
-
#get_feature_flag(slug:, request_options: {}) ⇒ WorkOS::Flag
Get a feature flag.
-
#initialize(client) ⇒ FeatureFlags
constructor
A new instance of FeatureFlags.
-
#list_feature_flags(before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Flag>
List feature flags.
-
#list_organization_feature_flags(organization_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Flag>
List enabled feature flags for an organization.
-
#list_user_feature_flags(user_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Flag>
List enabled feature flags for a user.
-
#remove_flag_target(resource_id:, slug:, request_options: {}) ⇒ void
Remove a feature flag target.
Constructor Details
#initialize(client) ⇒ FeatureFlags
Returns a new instance of FeatureFlags.
9 10 11 |
# File 'lib/workos/feature_flags.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#add_flag_target(resource_id:, slug:, request_options: {}) ⇒ void
This method returns an undefined value.
Add a feature flag target
119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/workos/feature_flags.rb', line 119 def add_flag_target( resource_id:, slug:, request_options: {} ) @client.request( method: :post, path: "/feature-flags/#{WorkOS::Util.encode_path(slug)}/targets/#{WorkOS::Util.encode_path(resource_id)}", auth: true, request_options: ) nil end |
#disable_feature_flag(slug:, request_options: {}) ⇒ WorkOS::FeatureFlag
Disable a feature flag
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/workos/feature_flags.rb', line 80 def disable_feature_flag( slug:, request_options: {} ) response = @client.request( method: :put, path: "/feature-flags/#{WorkOS::Util.encode_path(slug)}/disable", auth: true, request_options: ) result = WorkOS::FeatureFlag.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#enable_feature_flag(slug:, request_options: {}) ⇒ WorkOS::FeatureFlag
Enable a feature flag
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/workos/feature_flags.rb', line 99 def enable_feature_flag( slug:, request_options: {} ) response = @client.request( method: :put, path: "/feature-flags/#{WorkOS::Util.encode_path(slug)}/enable", auth: true, request_options: ) result = WorkOS::FeatureFlag.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_feature_flag(slug:, request_options: {}) ⇒ WorkOS::Flag
Get a feature flag
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/workos/feature_flags.rb', line 61 def get_feature_flag( slug:, request_options: {} ) response = @client.request( method: :get, path: "/feature-flags/#{WorkOS::Util.encode_path(slug)}", auth: true, request_options: ) result = WorkOS::Flag.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#list_feature_flags(before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Flag>
List feature flags
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/workos/feature_flags.rb', line 20 def list_feature_flags( before: nil, after: nil, limit: nil, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/feature-flags", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_feature_flags( before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::Flag, filters: {before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#list_organization_feature_flags(organization_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Flag>
List enabled feature flags for an organization
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/workos/feature_flags.rb', line 160 def list_organization_feature_flags( organization_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/feature-flags", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_organization_feature_flags( organization_id: organization_id, before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::Flag, filters: {organization_id: organization_id, before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#list_user_feature_flags(user_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::Flag>
List enabled feature flags for a user
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/workos/feature_flags.rb', line 207 def list_user_feature_flags( user_id:, before: nil, after: nil, limit: nil, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/user_management/users/#{WorkOS::Util.encode_path(user_id)}/feature-flags", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_user_feature_flags( user_id: user_id, before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::Flag, filters: {user_id: user_id, before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#remove_flag_target(resource_id:, slug:, request_options: {}) ⇒ void
This method returns an undefined value.
Remove a feature flag target
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/workos/feature_flags.rb', line 138 def remove_flag_target( resource_id:, slug:, request_options: {} ) @client.request( method: :delete, path: "/feature-flags/#{WorkOS::Util.encode_path(slug)}/targets/#{WorkOS::Util.encode_path(resource_id)}", auth: true, request_options: ) nil end |