Giter Club home page Giter Club logo

kasapi.sh's Introduction

kasapi.sh

An interface between Bash and the ALL-INKL KAS API

Usage

Usage: kasapi.sh [-h] [command [argument]] [parameter [argument]] [parameter [argument]] ...

Default command: help

Commands:
 --help (-h)                    Show this help text
 --login (-l)                   Login to ALL-INKL and get a session token
 --function (-f)                API Function to call

Parameters:
 --no-session (-n)              Don't use/create session token for API request (default)
 --session (-s)                 Use/create session token, send request and return new token with result (if one got created)
 --token (-t)                   API session token for continuous API requests (implies --session)
 --params (-p)                  JSON formatted function parameters (defaults to "{}")

Setup

Copy config.example to config and enter your KAS Account details. Make sure to set the permissions accordingly!

cp config.example config
chmod 600 config
$EDITOR config

Example commands

Get a list of all domains (no parameters):

kasapi.sh -f "get_domains"

Get a list of all DNS entries of a zone:

kasapi.sh -f "get_dns_settings" -p '{"zone_host":"example.com."}'

(Note the single quotation marks around the JSON object, otherwise all other quotation marks have to be escaped!)

Set a new DNS record:

kasapi.sh -f "add_dns_settings" -p '{"zone_host":"example.com.","record_name":"_acme-challenge","record_type":"TXT","record_data":"'"${ACMEChallengeTokenValue}"'","record_aux":0}'

Error messages

ERROR: <Action> failed, faultstring: <faultstring returned by KAS API>

Some errors might look weird, for example some malformed JSON structures return the faultstring got_no_login_data.

The response

Right now you'll get the unparsed xml back, since xml parsers are not a standard tool on most Linux/Unix installations. For the get_domains request from above the response looks like this (whitespace added):

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://kasapi.kasserver.com/soap/KasApi.php" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://xml.apache.org/xml-soap" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
	<SOAP-ENV:Body>
		<ns1:KasApiResponse>
			<return xsi:type="ns2:Map">
				<item>
					<key xsi:type="xsd:string">Request</key>
					<value xsi:type="ns2:Map">
						<item>
							<key xsi:type="xsd:string">KasRequestTime</key>
							<value xsi:type="xsd:int">1451602800</value>
						</item>
						<item>
							<key xsi:type="xsd:string">KasRequestType</key>
							<value xsi:type="xsd:string">get_domains</value>
						</item>
						<item>
							<key xsi:type="xsd:string">KasRequestParams</key>
							<value SOAP-ENC:arrayType="xsd:ur-type[0]" xsi:type="SOAP-ENC:Array"/>
						</item>
					</value>
				</item>
				<item>
					<key xsi:type="xsd:string">Response</key>
					<value xsi:type="ns2:Map">
						<item>
							<key xsi:type="xsd:string">KasFloodDelay</key>
							<value xsi:type="xsd:int">2</value>
						</item>
						<item>
							<key xsi:type="xsd:string">ReturnString</key>
							<value xsi:type="xsd:string">TRUE</value>
						</item>
						<item>
							<key xsi:type="xsd:string">ReturnInfo</key>
							<value SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">
								<item xsi:type="ns2:Map">
									<item>
										<key xsi:type="xsd:string">domain_name</key>
										<value xsi:type="xsd:string">example.com</value>
									</item>
									<item>
										<key xsi:type="xsd:string">domain_redirect_status</key>
										<value xsi:type="xsd:int">0</value>
									</item>
									<item>
										<key xsi:type="xsd:string">domain_path</key>
										<value xsi:type="xsd:string">/example.com/</value>
									</item>
									<item>
										...
									</item>
								</item>
							</value>
						</item>
					</value>
				</item>
			</return>
		</ns1:KasApiResponse>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Other software

Some functions and the general structure of the code come from dehydrated by Lukas Schauer, licensed under the MIT License.

kasapi.sh's People

Contributors

o1oo11oo avatar yankee42 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.