Before you can use the SWAT package, you will need a running CAS server. The SWAT package can connect to either the binary port or the HTTP port. If you have the option of either, the binary protocol will give you better performance.
Other than the CAS host and port, you just need a user name and password to connect. User names and passwords can be implemented in various ways, so you may need to see your system administrator on how to acquire an account.
To connect to a CAS server, you simply import SWAT and use the swat.CAS class to create a connection. This has a couple of different forms. The most basic is to pass the hostname, port, userid, and password.
In : import swat In : conn = swat.CAS(host, port, userid, password)
However, if you are using a REST connection to CAS, a URL is the more natural way to specify a host, port, and protocol.
In : conn = swat.CAS('https://my-cas-host.com:443/cas-shared-default-http/', ...: userid='...', password='...') ...:
Notice that in the URL case, userid and password, must be specified as keyword parameters since the port parameter is being skipped. Also, in this case we are using a proxy server that requires the base path of ‘cas-shared-default-http’. If you are connecting directly to a CAS server, this is typically not required.
Now that we have a connection to CAS, we can run some actions on it.
Running CAS Actions¶
To test your connection, you can run the serverstatus action.
In : out = conn.serverstatus()
Note: Grid node action status report: 1 nodes, 7 total actions executed. In : out