Skip to content

Instantly share code, notes, and snippets.

@indolering
Created February 8, 2016 23:37
Show Gist options
  • Save indolering/37e2755dc105bf20902a to your computer and use it in GitHub Desktop.
Save indolering/37e2755dc105bf20902a to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Test Console</title>
<script src="https://cdn.rawgit.com/indolering/2c007ed9906ff21b071f/raw/335dcbb7e5e0b6ef34af6da652d9d8d7fd341df4/sinon-1.17.3.js"></script>
<script src="https://rawgit.com/appirio-tech/auto-config-fake-server/master/dist/auto-config-fake-server.js"></script>
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="https://rawgit.com/swagger-api/swagger-js/master/browser/swagger-client.js"></script>
<script src='https://rawgit.com/indolering/4c6a45a0db3848e6bfb1/raw/d81ef5c8afdb97c2f8ef5e1f4b8d40ce1b10fe0c/easyapi-js.js' type='text/javascript'></script>
<script>
var swaggerJSONObject = {"swagger":"2.0","info":{"version":"1.0.0","title":"EasyAPI REST Services API","contact":{"name":"EasyDNS Technologies Inc","url":"http://easydns.com/","email":"easyapi@easydns.com"},"license":{"name":"LGPLv2.1","url":"https://www.gnu.org/licenses/lgpl-2.1.html"}},"host":"rest.easydns.net","basePath":"/","schemes":["https"],"consumes":["application/json"],"produces":["application/json","text/html","application/xml"],"paths":{"/domain/{domain}":{"get":{"tags":["domain","read"],"summary":"Get details about a domain on the system","operationId":"getDomainInfo","parameters":[{"name":"domain","in":"path","required":true,"type":"string","signature":"string","responseClassSignature":"string"}],"responses":{"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"409":{"description":"The requested resource already exists or can't be modified","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/domains/regstatus":{"get":{"tags":["domain","user","read"],"summary":"Get the reglock and renewal status for a users list of domains","operationId":"getRegStatus","parameters":[],"responses":{"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"409":{"description":"The requested resource already exists or can't be modified","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"post":{"tags":["domain","user","write"],"summary":"Set the reglock status of a set of domains owned by a user","operationId":"setRegStatus","parameters":[{"in":"body","name":"domains","required":false,"schema":{"type":"array","items":{"$ref":"#/definitions/RequestModelSetRegStatus"}},"signature":"Array[<span class=\"strong\">RequestModelSetRegStatus {</span><div><span class=\"propName required\">domain</span> (<span class=\"propType\">string</span>): <span class=\"propDesc\">The domain name to update</span>,</div><div><span class=\"propName \">reglock</span> (<span class=\"propType\">boolean</span>, <span class=\"propOptKey\">optional</span>): <span class=\"propDesc\">Turn on/off reglock at the registry</span>,</div><div><span class=\"propName \">renewal</span> (<span class=\"propType\">string</span>, <span class=\"propOptKey\">optional</span>): <span class=\"propDesc\">Set renewal action of domain</span></div><span class=\"strong\">}</span>]","sampleJSON":"[\n {\n \"domain\": \"string\",\n \"reglock\": true,\n \"renewal\": \"string\"\n }\n]","responseClassSignature":"Array[<span class=\"strong\">RequestModelSetRegStatus {</span><div><span class=\"propName required\">domain</span> (<span class=\"propType\">string</span>): <span class=\"propDesc\">The domain name to update</span>,</div><div><span class=\"propName \">reglock</span> (<span class=\"propType\">boolean</span>, <span class=\"propOptKey\">optional</span>): <span class=\"propDesc\">Turn on/off reglock at the registry</span>,</div><div><span class=\"propName \">renewal</span> (<span class=\"propType\">string</span>, <span class=\"propOptKey\">optional</span>): <span class=\"propDesc\">Set renewal action of domain</span></div><span class=\"strong\">}</span>]"}],"responses":{"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"409":{"description":"The requested resource already exists or can't be modified","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/user":{"get":{"tags":["user","read"],"summary":"Get details about a user","operationId":"getUserInfo","parameters":[],"responses":{"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"404":{"description":"The requested user does not exist or does not belong to authenticated user","schema":{"$ref":"#/definitions/ErrorModel"}},"409":{"description":"The requested resource already exists or can't be modified","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/zones/async/ux/records/add/{domain}/{type}":{"put":{"tags":["zone","write"],"summary":"Create a new record in a zone using async zone reloading","operationId":"addUXZoneRec","parameters":[{"name":"domain","in":"path","description":"The associated domain name","required":true,"type":"string","signature":"string","responseClassSignature":"string"},{"name":"data","in":"body","description":"The contents of the resource record (RR) to create in JSON encoded format","required":true,"schema":{"$ref":"#/definitions/RequestModelBasicBodyData"},"signature":"<span class=\"strong\">RequestModelBasicBodyData {</span><span class=\"strong\">}</span>","sampleJSON":"{}","responseClassSignature":"<span class=\"strong\">RequestModelBasicBodyData {</span><span class=\"strong\">}</span>"},{"name":"type","in":"path","description":"The type of resource record (RR) to create (i.e. A, CNAME, MX, etc)","required":true,"type":"string","signature":"string","responseClassSignature":"string"}],"responses":{"201":{"description":"The requested resource was created successfully. Expected response to a valid request"},"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"409":{"description":"The requested resource already exists and can't be created","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/zones/async/ux/records/{id}":{"post":{"tags":["zone","write"],"summary":"Modify an existing zone record using async zone reloading","operationId":"modUXZoneRec","parameters":[{"name":"id","in":"path","description":"The ID of the zone record to modify","required":true,"type":"integer","format":"int64","signature":"long","responseClassSignature":"long"},{"name":"data","in":"body","description":"The contents of the resource record (RR) to modify in JSON encoded format","required":true,"schema":{"$ref":"#/definitions/RequestModelBasicBodyData"},"signature":"<span class=\"strong\">RequestModelBasicBodyData {</span><span class=\"strong\">}</span>","sampleJSON":"{}","responseClassSignature":"<span class=\"strong\">RequestModelBasicBodyData {</span><span class=\"strong\">}</span>"}],"responses":{"200":{"description":"The requested modification to the zone record was made successfully"},"201":{"description":"The requested modification to the zone record was made successfully"},"403":{"description":"The request is understood, but it has been refused"},"409":{"description":"The requested resource already exists or can't be modified"},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/zones/records/add/{domain}/{type}":{"put":{"tags":["zone","write"],"summary":"Create a new record in a zone","operationId":"addZoneRec","parameters":[{"name":"domain","in":"path","description":"The associated domain name","required":true,"type":"string","signature":"string","responseClassSignature":"string"},{"name":"data","in":"body","description":"The contents of the resource record (RR) to create in JSON encoded format","required":true,"schema":{"$ref":"#/definitions/RequestModelBasicBodyData"},"signature":"<span class=\"strong\">RequestModelBasicBodyData {</span><span class=\"strong\">}</span>","sampleJSON":"{}","responseClassSignature":"<span class=\"strong\">RequestModelBasicBodyData {</span><span class=\"strong\">}</span>"},{"name":"type","in":"path","description":"The type of resource record (RR) to create (i.e. A, CNAME, MX, etc)","required":true,"type":"string","signature":"string","responseClassSignature":"string"}],"responses":{"201":{"description":"The requested resource was created successfully. Expected response to a valid request"},"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"409":{"description":"The requested resource already exists and can't be created","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/zones/records/all/{domain}":{"get":{"tags":["zone","read","list"],"summary":"Get a listing of all available zone records for a domain","operationId":"listZone","parameters":[{"name":"domain","in":"path","description":"The associated domain name","required":true,"type":"string","signature":"string","responseClassSignature":"string"}],"responses":{"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/zones/records/all/{domain}/search/{keyword}":{"get":{"tags":["zone","read","list","search"],"summary":"Get a listing of all available zone records for a domain that match the keyword string","operationId":"searchZone","parameters":[{"name":"domain","in":"path","description":"The associated domain name","required":true,"type":"string","signature":"string","responseClassSignature":"string"},{"name":"keyword","in":"path","description":"The keyword or string to match against existing resource records","required":true,"type":"string","signature":"string","responseClassSignature":"string"}],"responses":{"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}}},"parameters":[]},"/zones/records/soa/{domain}":{"get":{"tags":["zone","read"],"summary":"Get the current SOA value for a zone","operationId":"getZoneSOA","parameters":[{"name":"domain","in":"path","description":"The domain name to retrieve the SOA value for","required":true,"type":"string","signature":"string","responseClassSignature":"string"}],"responses":{"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/zones/records/{domain}/{id}":{"delete":{"tags":["zone","write"],"summary":"Delete an existing zone record","operationId":"delZoneRec","parameters":[{"name":"domain","in":"path","description":"The domain name that owns the zone record","required":true,"type":"string","signature":"string","responseClassSignature":"string"},{"name":"id","in":"path","description":"The zone record ID to delete from the zone","required":true,"type":"string","signature":"string","responseClassSignature":"string"}],"responses":{"200":{"description":"The requested deletion of the zone record was made successfully"},"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"409":{"description":"The requested resource already exists or can't be modified","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/zones/async/ux/records/{domain}/{id}":{"delete":{"tags":["ux","zone","write"],"summary":"Delete an existing zone record using async zone reloading","operationId":"delUXZoneRec","parameters":[{"name":"domain","in":"path","description":"The domain name that owns the zone record","required":true,"type":"string","signature":"string","responseClassSignature":"string"},{"name":"id","in":"path","description":"The zone record ID to delete from the zone","required":true,"type":"string","signature":"string","responseClassSignature":"string"}],"responses":{"200":{"description":"The requested deletion of the zone record was made successfully"},"403":{"description":"The request is understood, but it has been refused","schema":{"$ref":"#/definitions/ErrorModel"}},"409":{"description":"The requested resource already exists or can't be modified","schema":{"$ref":"#/definitions/ErrorModel"}},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/zones/records/{id}":{"post":{"tags":["zone","write"],"summary":"Modify an existing zone record","operationId":"modZoneRec","parameters":[{"name":"id","in":"path","description":"The ID of the zone record to modify","required":true,"type":"integer","format":"int64","signature":"long","responseClassSignature":"long"}],"responses":{"200":{"description":"The requested modification to the zone record was made successfully"},"403":{"description":"The request is understood, but it has been refused"},"409":{"description":"The requested resource already exists or can't be modified"},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/ux/errors/by/{domain}":{"get":{"tags":["ux","read"],"summary":"Get a listing of any outstanding zone reload errors","operationId":"getUXErrors","parameters":[{"name":"domain","in":"path","description":"The domain of the zone to check for errors","required":true,"type":"string","signature":"string","responseClassSignature":"string"}],"responses":{"200":{"description":"The request to get zone errors was made successfully"},"403":{"description":"The request is understood, but it has been refused"},"409":{"description":"The requested resource already exists or can't be modified"},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"put":{"tags":["ux","read"],"summary":"Get a listing of any outstanding zone reload errors","operationId":"createUXErrors","parameters":[{"name":"domain","in":"path","description":"The domain of the zone to check for errors","required":true,"type":"string","signature":"string","responseClassSignature":"string"},{"name":"data","in":"body","description":"The contents of the validation message to create in JSON encoded format","required":true,"schema":{"$ref":"#/definitions/RequestModelBasicBodyData"},"signature":"<span class=\"strong\">RequestModelBasicBodyData {</span><span class=\"strong\">}</span>","sampleJSON":"{}","responseClassSignature":"<span class=\"strong\">RequestModelBasicBodyData {</span><span class=\"strong\">}</span>"}],"responses":{"200":{"description":"The request to get zone errors was made successfully"},"403":{"description":"The request is understood, but it has been refused"},"409":{"description":"The requested resource already exists or can't be modified"},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}]},"parameters":[]},"/ux/errors":{"get":{"tags":["ux","read"],"summary":"Get a listing of any outstanding zone reload errors","operationId":"getUnseenUXErrors","responses":{"200":{"description":"The request to get zone errors was made successfully"},"403":{"description":"The request is understood, but it has been refused"},"409":{"description":"The requested resource already exists or can't be modified"},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}],"parameters":[]},"parameters":[]},"/ux/errors/all":{"get":{"tags":["ux","read"],"summary":"Get a listing of any outstanding zone reload errors","operationId":"getAllUXErrors","responses":{"200":{"description":"The request to get zone errors was made successfully"},"403":{"description":"The request is understood, but it has been refused"},"409":{"description":"The requested resource already exists or can't be modified"},"420":{"description":"Enhance your calm","schema":{"$ref":"#/definitions/ErrorModel"}},"default":{"description":"unexpected error"}},"security":[{"easyapi_basic":[]},{"api_combined_key":[]}],"parameters":[]},"parameters":[]}},"securityDefinitions":{"easyapi_basic":{"type":"basic"},"api_combined_key":{"type":"apiKey","name":"x-auth_combined","in":"header"}},"definitions":{"ErrorModel":{"type":"object","required":["msg","status"],"properties":{"msg":{"type":"string","description":"Resulting error message for a failed request"},"status":{"type":"integer","description":"The HTTP return code indicating the resulting status of the request","minimum":400,"maximum":500}}},"ResultModelZoneSOA":{"type":"object","required":["domain","soa"],"properties":{"domain":{"type":"string"},"soa":{"type":"integer","minimum":1}}},"ResultModelZoneList":{"type":"object","required":["data","msg","status","tm"],"properties":{"msg":{"type":"string"},"status":{"type":"integer","minimum":200,"maximum":200},"tm":{"type":"integer"},"data":{"$ref":"#/definitions/ResultModelZoneRecord"},"count":{"type":"integer"},"total":{"type":"integer"},"start":{"type":"integer"},"max":{"type":"integer"}}},"ResultModelZoneRecord":{"type":"object","required":["domain","host","id","rdata","type"],"properties":{"id":{"type":"integer"},"domain":{"type":"string"},"host":{"type":"string"},"ttl":{"type":"integer","minimum":300},"prio":{"type":"integer","minimum":0},"geozone_id":{"type":"integer","minimum":0},"type":{"type":"string"},"rdata":{"type":"string"},"last_mod":{"type":"string"}}},"ResultModelDomainInfo":{"type":"object","required":["domain","exists","expiry","onsystem"],"properties":{"domain":{"type":"string"},"exists":{"type":"string","description":"Does the domain currently exist at the registry"},"onsystem":{"type":"string","description":"Does the domain currently exist on the system"},"expiry":{"type":"string","description":"Expiry date of the domain in the system"}}},"ResultModelRegStatus":{"type":"object","required":["auto_renew","expiry","let_expire","local_registrar","reglock","renewal"],"properties":{"reglock":{"type":"boolean","description":"Is reglock for domain set to on or off"},"renewal":{"type":"string","description":"Indicates the current renewal action for the domain"},"auto_renew":{"type":"boolean","description":"Does the domain have automated renewal payments set up for this domain"},"auto_renew_card_id":{"type":"string","description":"If a domain is set to auto_renew this field will contain the stripe card id that will be used for this domain"},"let_expire":{"type":"boolean","description":"Is the domain set to automatically expire at HRS/SRS"},"let_expire_failed":{"type":"boolean","description":"This field is only present when attempts to get the let_expire value at HRS/SRS failed. Most often caused by invalid authentication info on the system for the domain"},"expiry":{"type":"string","description":"The expiry date for the domain on the system. Either the expiry date for the domain or the date service is next due"},"local_registrar":{"type":"boolean","description":"Indicates if the domain is registered by us or the registrar is someone else"}}},"RequestModelSetRegStatus":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","description":"The domain name to update"},"reglock":{"type":"boolean","description":"Turn on/off reglock at the registry"},"renewal":{"type":"string","description":"Set renewal action of domain"}}},"ResultModelSetRegStatus":{"type":"object","properties":{"msg":{"type":"string"},"tm":{"type":"integer"},"data":{"type":"array","items":{"$ref":"#/definitions/ResultModelSetRegStatusItem"}},"status":{"type":"integer"}}},"ResultModelSetRegStatusItem":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","description":"The domain to change the regstatus on"},"reglock":{"type":"boolean","description":"(OPTIONAL) The reglock setting provided by the user"},"renewal":{"type":"string","description":"(OPTIONAL) The renew setting provided by the caller"},"change_lock":{"type":"boolean","description":"(OPTIONAL) Set to true if a lock change was attempted"},"change_lock_failed":{"type":"boolean","description":"(OPTIONAL) Set to true if a lock change was attempted but failed"},"change_renew":{"type":"boolean","description":"(OPTIONAL) Set to true if a renewal action change was attempted"},"change_renew_failed":{"type":"boolean","description":"(OPTIONAL) Set to true if a renewal action change was attempted but failed"},"change_let_expire":{"type":"boolean","description":"(OPTIONAL) Set to true if a let_expire change was attempted"},"change_let_expire_failed":{"type":"boolean","description":"(OPTIONAL) Set to true if a let_expire change was attempted but failed"},"connect_failed":{"type":"boolean","description":"(OPTIONAL) Attempts to connect to the registry for this domain failed"},"invalid_renewal_state":{"type":"boolean","description":"(OPTIONAL) Based on the domain provided the renewal action change was invalid. For example trying to set a .CA domain to expire"}}},"ResultModelGetUserInfo":{"type":"object","required":["msg","status"],"properties":{"msg":{"type":"string"},"data":{"type":"array","items":{"$ref":"#/definitions/ResultModelGetUserInfoData"}},"status":{"type":"string"}}},"ResultModelGetUserInfoData":{"type":"object","properties":{"user":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"org_name":{"type":"string"},"address1":{"type":"string"},"address2":{"type":"string"},"address3":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"country":{"type":"string"},"postal_code":{"type":"string"},"currency":{"type":"string"}}},"RequestModelBasicBodyData":{"type":"object"}}};
AutoConfigFakeServer.init();
AutoConfigFakeServer.fakeServer.respondImmediately = true; // docs are at http://sinonjs.org/docs
AutoConfigFakeServer.fakeServer.autoRespond = true;
AutoConfigFakeServer.consume(swaggerJSONObject);
window.EasyAPI.Client({
"token": "uDummy.Token",
"key": "apiDummy.Key",
"user" : "username",
"env": "sandbox"
}, function(client){
window.client = client;
callToAPI();
}.bind(this));
function callToAPI(){
window.client.domain.getRegStatus(null, function(thing){
//the server is erroneously returning 400 on this request, but it should never be contacted anyway....
console.log("success!", thing)
}, function(thing){
console.log("failure!", thing)
})
}
</script>
</head>
<body>
<div>
<h2>Examples</h2>
<pre>
callToAPI();
client.domain.getRegStatus(null)
test.zone.listZone({"domain": "easytestgeneric.info"});
</pre>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment