Forum Stats

  • 3,769,600 Users
  • 2,252,990 Discussions
  • 7,875,117 Comments

Discussions

update ruleset api question

Michael.R.Taylor-Oracle
Michael.R.Taylor-Oracle Posts: 255 Employee
edited Mar 6, 2019 4:30PM in Dyn Community

Originally posted by leom on dyncommunity.com on 29 January 2019

Hi,

I have a question with this api
https://help.dyn.com/update-dsf-ruleset-api/

Is there a sample criteria for geoip that can be shared, how to call it for the REST api. I am getting confused with the description for ruleset criteria field in that page (also listed below) as to how that is constructed.

Thanks, Leo

string criteria — dependent upon criteria_type.
Valid values:
hash geoip — A hash where each element contains a list of ISO-3166 two letter codes to represent the names of countries and their subdivisions, one of the predefined groups, or one of the legacy regions.
array region — A list of ISO-3166 two letter codes representing Regions. Regions contain a set of countries.
array country — A list of ISO-3166 two letter codes representing Countries
array province — A list of ISO-3166 two letter codes representing Provinces

Best Answer

  • Michael.R.Taylor-Oracle
    Michael.R.Taylor-Oracle Posts: 255 Employee
    edited Mar 6, 2019 4:30PM Accepted Answer

    Originally posted by @thedavecarroll on dyncommunity.com on 6 February 2019

    My developer account does not have the Traffic Director add-on. However, after looking at the documentation, perhaps this JSON might be helpful.

    <span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"label"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="str" style="color: #008800;">"RulesetName"</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"ordering"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="lit" style="color: #006666;">1</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"publish"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="str" style="color: #008800;">"N"</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"criteria_type"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="str" style="color: #008800;">"geoip"</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"criteria"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="pun" style="color: #666600;">{</span><span class="pln" style="color: #000000;">                      </span><span class="str" style="color: #008800;">"country"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="pun" style="color: #666600;">[</span><span class="pln" style="color: #000000;">                                      </span><span class="str" style="color: #008800;">"US"</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">                                      </span><span class="str" style="color: #008800;">"CA"</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">                                      </span><span class="str" style="color: #008800;">"MX"</span><span class="pln" style="color: #000000;">                                  </span><span class="pun" style="color: #666600;">]</span><span class="pln" style="color: #000000;">                  </span><span class="pun" style="color: #666600;">},</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"response_pools"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="pun" style="color: #666600;">[</span><span class="pln" style="color: #000000;">                            </span><span class="str" style="color: #008800;">"dsf_response_pool_id"</span><span class="pln" style="color: #000000;">                        </span><span class="pun" style="color: #666600;">],</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"remove_orphans"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;"> </span><span class="str" style="color: #008800;">"N"</span><span class="pln" style="color: #000000;">  </span><span class="pln" style="color: #000000;"> </span><span class="pun" style="color: #666600;">}</span><span class="pln" style="color: #000000;"> </span><span class="pun" style="color: #666600;">{</span>

    If you are creating a new response pool at the same time, the JSON would be considerably larger.

    I'm not sure what you are using to test your API calls; personally, I use Insomnia (Windows). It has helped me numerous times.

    Also, I use PowerShell to translate hashtables into properly formatted JSON. You can find JSON formatters online.

    Hope that helps. Dave

Answers

  • Michael.R.Taylor-Oracle
    Michael.R.Taylor-Oracle Posts: 255 Employee
    edited Mar 6, 2019 4:30PM Accepted Answer

    Originally posted by @thedavecarroll on dyncommunity.com on 6 February 2019

    My developer account does not have the Traffic Director add-on. However, after looking at the documentation, perhaps this JSON might be helpful.

    <span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"label"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="str" style="color: #008800;">"RulesetName"</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"ordering"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="lit" style="color: #006666;">1</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"publish"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="str" style="color: #008800;">"N"</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"criteria_type"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="str" style="color: #008800;">"geoip"</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"criteria"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="pun" style="color: #666600;">{</span><span class="pln" style="color: #000000;">                      </span><span class="str" style="color: #008800;">"country"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="pun" style="color: #666600;">[</span><span class="pln" style="color: #000000;">                                      </span><span class="str" style="color: #008800;">"US"</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">                                      </span><span class="str" style="color: #008800;">"CA"</span><span class="pun" style="color: #666600;">,</span><span class="pln" style="color: #000000;">                                      </span><span class="str" style="color: #008800;">"MX"</span><span class="pln" style="color: #000000;">                                  </span><span class="pun" style="color: #666600;">]</span><span class="pln" style="color: #000000;">                  </span><span class="pun" style="color: #666600;">},</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"response_pools"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;">  </span><span class="pun" style="color: #666600;">[</span><span class="pln" style="color: #000000;">                            </span><span class="str" style="color: #008800;">"dsf_response_pool_id"</span><span class="pln" style="color: #000000;">                        </span><span class="pun" style="color: #666600;">],</span><span class="pln" style="color: #000000;">     </span><span class="str" style="color: #008800;">"remove_orphans"</span><span class="pun" style="color: #666600;">:</span><span class="pln" style="color: #000000;"> </span><span class="str" style="color: #008800;">"N"</span><span class="pln" style="color: #000000;">  </span><span class="pln" style="color: #000000;"> </span><span class="pun" style="color: #666600;">}</span><span class="pln" style="color: #000000;"> </span><span class="pun" style="color: #666600;">{</span>

    If you are creating a new response pool at the same time, the JSON would be considerably larger.

    I'm not sure what you are using to test your API calls; personally, I use Insomnia (Windows). It has helped me numerous times.

    Also, I use PowerShell to translate hashtables into properly formatted JSON. You can find JSON formatters online.

    Hope that helps. Dave