Nonfig
  • Home
  • Support

›Integrate SDKs

Overview

  • Introduction
  • Error Codes
  • Rate Limit
  • Restful APIs
  • More about SDKs

Getting Started Guides

  • NestJS Guide

Integrate SDKs

  • Overview
  • Java SDK
  • Nodejs SDK
  • Nestjs Plugin
  • Python SDK
  • .NET SDK

Install Agents

  • Overview
  • Kubernetes
  • Linux

Entities

  • Configuration
  • Organization
  • Policy
  • User

Python SDK

Nonfig has SDK (Software Development Kit) available for Python 3. You can checkout open source SDK available here.

Setup the SDK

To install the SDK, we use pip and tested with Python3.7 so far. Simply run the following command on your mac or add nonfig-sdk in the requirements.txt file of the project.

CLI
pip install nonfig-sdk

Initialize SDK

In order initialize the SDK, you need to make sure Setup the SDK step was successful.

In your python project, you could import the SDK directly using the following syntax.

To find out more about the standard values required and their details, checkout more about SDK settings.

Python
from nonfig.sdk import Nonfig

options = {
"app_id": "c1e8293f-58be-4c55-9db4-b1c39cbc1dcb", # Replace with your App ID
"app_secret": "XuuhXorEZqeRTJjHumGCgnPuZMdQgVvu", # Replace with your App Secret
"debug": True,
"cache_enable": True,
"cache_ttl": 60
}
nonfig = Nonfig(options)

// write your code..

The credentials like app_id and app_secret is what you could gather by creating a Consumer your dashboard.

Retrieve single configuration

For certain use cases, it is important to fetch a single particular configuration file. This could be derived for individual users, or segments, or even globally but for specific business case.

Python
from nonfig.sdk import Nonfig

options = {
...
}

nonfig = Nonfig(options) # See: Initialize SDK

configuration = nonfig.find_by_name("/production/feature_flags")
# configuration { id, name, data, type } : where <data> is serialized data.

The possible data types are: JSON, YAML, XML and TEXT. We obtain to remain neutral and that is why try not to enforce any particular serializer/de-serializer libraries. Therefore, data is just plain data in string format and depending upon type field, we presume that you are going to parse data respectively.

Retrive multiple configurations

Certainly, a setup of configurations are supposed to be retrieved on different scenarios. For example, when you start a server, or any critical operation being performed.

We have provided multiple ways to fetch multiple configurations in one go. Whether you fetch a single or multiple; recommendation of fair-usage is always there.

Often times, we recommend to use our cache feature provided by the SDK, so that if the application couldn't reach our servers for any reason, you shall sustain and thrive as a business. We firmly believe that none of the block in your software system should be a single point of failure.

Search by "Path" value

If you provide path as a destination directory where the configurations exists, the response shall be an array of configurations that is iterable and processable. Like a single configuration, you shall need to deserialize the content present inside data field by relying on type value.

Python
from nonfig.sdk import Nonfig

options = {
...
}

nonfig = Nonfig(options) # See: Initialize SDK

configurations = nonfig.find_by_path("/production/")
# configuration { id, name, data, type } : where <data> is serialized data.

Searh by configurations' Labels

To segment the configurations, we support Labels. Labels are nothing but just the simple string values that user could assign to the configuration.

By assigning labels and later retriving using those; it is possible to create segmented configurations. A segment could a subset of user identification, or geographical fence, or anything that makes segmentation sense in your Software application.

The response for this API call uses all the segments in AND clauses, meaning that we try to find precise list of configurations that matches all of your labels.

Python
from nonfig.sdk import Nonfig

options = {
...
}

nonfig = Nonfig(options) # See: Initialize SDK

configurations = nonfig.find_by_labels(["EU", "gender:m", "plan:Enterprise"])

Methods

constructor()

The constructor the class takes multiple optional and mandatory arguments. These parameters will then derive the behavior of the SDK integration.

To find out more about the standard values required and their details, checkout more about SDK settings here.

find_by_name(name: str)

TODO

find_by_path(path: str)

TODO

find_by_labels(labels: list

TODO

Last updated on 10/14/2020
← Nestjs Plugin.NET SDK →
  • Setup the SDK
  • Initialize SDK
  • Retrieve single configuration
  • Retrive multiple configurations
    • Search by "Path" value
    • Searh by configurations' Labels
  • Methods
    • constructor()
    • find_by_name(name: str)
    • find_by_path(path: str)
    • find_by_labels(labels: list
Nonfig
Sitemap
Available SDKsInstall Agent
References
HomeReport an issueVisit our websiteControl Plane
More
Blog
Copyright © 2020 nonfig. All rights reserved.