createConstraint
Create constraint
Create a constraint for the segment. Constraints define conditions that must be met for a segment to match.
/flags/{flagId}/segments/{segmentId}/constraints
Usage and SDK Samples
curl -X POST\
-H "Accept: application/json"\
-H "Content-Type: application/json"\
"http://localhost:18000/api/v1/flags/{flagId}/segments/{segmentId}/constraints"
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.ConstraintApi;
import java.io.File;
import java.util.*;
public class ConstraintApiExample {
public static void main(String[] args) {
ConstraintApi apiInstance = new ConstraintApi();
CreateConstraintRequest body = {
"property" : "region",
"operator" : "EQ",
"value" : "US"
}; // CreateConstraintRequest |
Long flagId = 789; // Long | Numeric ID of the flag
Long segmentId = 789; // Long | Numeric ID of the segment
try {
Constraint result = apiInstance.createConstraint(body, flagId, segmentId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ConstraintApi#createConstraint");
e.printStackTrace();
}
}
}
import io.swagger.client.api.ConstraintApi;
public class ConstraintApiExample {
public static void main(String[] args) {
ConstraintApi apiInstance = new ConstraintApi();
CreateConstraintRequest body = {
"property" : "region",
"operator" : "EQ",
"value" : "US"
}; // CreateConstraintRequest |
Long flagId = 789; // Long | Numeric ID of the flag
Long segmentId = 789; // Long | Numeric ID of the segment
try {
Constraint result = apiInstance.createConstraint(body, flagId, segmentId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ConstraintApi#createConstraint");
e.printStackTrace();
}
}
}
CreateConstraintRequest *body = {
"property" : "region",
"operator" : "EQ",
"value" : "US"
}; //
Long *flagId = 789; // Numeric ID of the flag
Long *segmentId = 789; // Numeric ID of the segment
ConstraintApi *apiInstance = [[ConstraintApi alloc] init];
// Create constraint
[apiInstance createConstraintWith:body
flagId:flagId
segmentId:segmentId
completionHandler: ^(Constraint output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
var FlagentApi = require('flagent_api');
var api = new FlagentApi.ConstraintApi()
var body = {
"property" : "region",
"operator" : "EQ",
"value" : "US"
}; // {{CreateConstraintRequest}}
var flagId = 789; // {{Long}} Numeric ID of the flag
var segmentId = 789; // {{Long}} Numeric ID of the segment
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.createConstraint(bodyflagIdsegmentId, callback);
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace Example
{
public class createConstraintExample
{
public void main()
{
var apiInstance = new ConstraintApi();
var body = new CreateConstraintRequest(); // CreateConstraintRequest |
var flagId = 789; // Long | Numeric ID of the flag
var segmentId = 789; // Long | Numeric ID of the segment
try
{
// Create constraint
Constraint result = apiInstance.createConstraint(body, flagId, segmentId);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling ConstraintApi.createConstraint: " + e.Message );
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$api_instance = new Swagger\Client\ApiConstraintApi();
$body = {
"property" : "region",
"operator" : "EQ",
"value" : "US"
}; // CreateConstraintRequest |
$flagId = 789; // Long | Numeric ID of the flag
$segmentId = 789; // Long | Numeric ID of the segment
try {
$result = $api_instance->createConstraint($body, $flagId, $segmentId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ConstraintApi->createConstraint: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::SwaggerClient::Configuration;
use WWW::SwaggerClient::ConstraintApi;
my $api_instance = WWW::SwaggerClient::ConstraintApi->new();
my $body = WWW::SwaggerClient::Object::CreateConstraintRequest->new(); # CreateConstraintRequest |
my $flagId = 789; # Long | Numeric ID of the flag
my $segmentId = 789; # Long | Numeric ID of the segment
eval {
my $result = $api_instance->createConstraint(body => $body, flagId => $flagId, segmentId => $segmentId);
print Dumper($result);
};
if ($@) {
warn "Exception when calling ConstraintApi->createConstraint: $@\n";
}
from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = swagger_client.ConstraintApi()
body = {
"property" : "region",
"operator" : "EQ",
"value" : "US"
} # CreateConstraintRequest |
flagId = 789 # Long | Numeric ID of the flag
segmentId = 789 # Long | Numeric ID of the segment
try:
# Create constraint
api_response = api_instance.create_constraint(body, flagId, segmentId)
pprint(api_response)
except ApiException as e:
print("Exception when calling ConstraintApi->createConstraint: %s\n" % e)
Parameters
| Name | Description |
|---|---|
| flagId* |
Long
(int64)
Numeric ID of the flag
Required
|
| segmentId* |
Long
(int64)
Numeric ID of the segment
Required
|
| Name | Description |
|---|---|
| body * |