Identifier: PER-12695 Title: Fix load options in c...
# permit-saas
p
Identifier: PER-12695 Title: Fix load options in create condition set State: Acceptance (Share) Status: started
a
I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
I can help you understand how to create condition sets in Permit.io. Based on the documentation, here's how you can create condition sets: Creating Condition Sets There are two types of condition sets you can create (1) : 1. ​*User Set*​ - a set of users that match specified conditions 2. ​*Resource Set*​ - a set of resources that match specified conditions Node.js SDK Example Using the Permit Node.js SDK, you can create condition sets with the
create
method (2) (3) :
Copy code
await permit.api.conditionSets.create({
  key: "blocked_users",
  name: "Blocked Users",
  type: "userset",
  conditions: {
    allOf: [{ allOf: [{ "user.blocked": { equals: true } }] }],
  },
}) ;
(3) For resource sets:
Copy code
await permit.api.conditionSets.create({
  key: "owned_plans",
  name: "Owned Plans",
  type: "resourceset",
  resource_id: "plan",
  conditions: {
    allOf: [
      { allOf: [{ "resource.owner": { equals: { ref: "user.key" } } }] },
    ],
  },
}) ;
Ruby SDK Example For Ruby, you can use the
create_condition_set
method (4) :
Copy code
api_instance = OpenapiClient::ConditionSetsApi.new
proj_id = 'proj_id_example' # String | Either the unique id of the project, or the URL-friendly key of the project (i.e: the \"slug\") .
env_id = 'env_id_example' # String | Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the \"slug\") .
condition_set_create = OpenapiClient::ConditionSetCreate.new # ConditionSetCreate | 

begin
  # Create Condition Set
  result = api_instance.create_condition_set(proj_id, env_id, condition_set_create)
  p result
rescue OpenapiClient::ApiError => e
  puts "Error when calling ConditionSetsApi->create_condition_set: #{e}"
end
(5) The condition sets use logical operators like
allOf
to combine multiple conditions (1) . You can then assign permissions to these condition sets in your policy rules (3) .
Hmm.. Seems there was an issue processing this question. Please try again or tag a team member.