To delete a configuration object (for example, a policy), use a DELETE request with the ID of the object as the key.
You cannot delete policies or objects that are used in other policies (for example, you cannot delete a Time policy that is used in a Channel policy).
To delete an element of a list (for example, a user from a local user database), use a PUT request. The body the request should include the entire object, but remove the element you want to delete from the related list of the object.
You cannot delete built-in policies that are available on SPS by default.
You must commit your changes to take effect. For details, see Commit a transaction.
DELETE https:<IP-address-of-SPS>/api/configuration/<endpoint>/<object-id>
Cookie name | Description | Required | Values |
---|---|---|---|
session_id | Contains the authentication token of the user | Required |
The value of the session ID cookie received from the REST server in the authentication response, for example, a1f71d030e657634730b9e887cb59a5e56162860. For details on authentication, see Authenticate to the SPS REST API. Note that this session ID refers to the connection between the REST client and the SPS REST API. It is not related to the sessions that SPS records (and which also have a session ID, but in a different format). |
The following command deletes an RDP Channel policy.
curl --cookie cookies -X DELETE -https:<IP-address-of-SPS>/api/configuration/rdp/channel_policies/<object-id>
The following is a sample response received.
{ "meta": { "first": "/api/configuration/rdp/channel_policies/-20100", "href": "/api/configuration/rdp/channel_policies/<id-of-the-deleted-object>", "last": "/api/configuration/rdp/channel_policies/<id-of-the-deleted-object>", "next": null, "parent": "/api/configuration/rdp/channel_policies", "previous": "/api/configuration/rdp/channel_policies/655555", "transaction": "/api/transaction" } }
The following table lists the typical status and error codes for this request. For a complete list of error codes, see Application level error codes.
Code | Description | Notes |
---|---|---|
200 | OK | The resource was successfully deleted. |
401 | Unauthenticated | The requested resource cannot be retrieved because the client is not authenticated and the resource requires authorization to access it. The details section contains the path that was attempted to be accessed, but could not be retrieved. |
401 | AuthenticationFailure | Authenticating the user with the given credentials has failed. |
409 | Conflict | No open Transaction is available. Open a transaction before using this request. For details, see Open a transaction. |
To create a new object (for example, a new policy), complete the following steps.
Authenticate and open a transaction.
Post the new object as a JSON object to the appropriate resource URL.
If successful, the REST server creates an ID for the new object, and returns it in the key field of the response.
Commit the transaction.
Note the following points when you create a request:
Note that you cannot simply use the JSON from the response of a similar object. If the object contains references to other resources (for example, a Channel policy references a Time policy), then the JSON object contains an embedded meta object. To get a valid JSON that you can use, you have to replace this embedded object with the ID (key) of the referenced object. For example, the following is a reference to a Time policy:
"time_policy": { "key": "-100", "meta": { "href": "/api/configuration/policies/time_policies/-100" } }
In a POST or PUT request, you have to change it to the following:
"time_policy": "-100",
You have to include empty fields in the object as well, for example:
"users": [ { "certificates": [], "passwords": [ "<reference-to-password>" ], "public_keys": [], "username": "myusername" } ]
The API ignores any unrecognized or nonexistent keys that appear in the body of POST and PUT requests. For example, if you mistype the name of an optional key, it will be silently ignored.
The body wrapper that is displayed in the response is not needed when you create or modify an object, for example:
{ "name": "my-local-user-database", "users": [ { "certificates": [], "passwords": [ "<reference-to-password>" ], "public_keys": [], "username": "myusername" } ] }
POST https:<IP-address-of-SPS>/api/configuration/<path-to-the-parent-resource>
Header name | Description | Required | Values |
---|---|---|---|
Content-Type | Specifies the type of the data sent. SPS uses the JSON format | Required | application/json |
session_id | Contains the authentication token of the user | Required | The value of the session ID cookie received from the REST server in the authentication response, for example, a1f71d030e657634730b9e887cb59a5e56162860. For details on authentication, see Authenticate to the SPS REST API. |
The following command creates a new RDP Channel policy. The data content of the request is read from the file body.json
curl -H "Content-Type: application/json" -d @body.json --cookie session_id=1aca4793549c6f22aecd98bc1047d1bf32dd76ef -X POST https://<object-id>/api/configuration/rdp/channel_policies/
For a simple RDP Channel policy that uses the default settings and allows only the Drawing channel, the JSON object is the following.
{ "name": "drawing-only", "rules": [ { "actions": { "audit": true, "content_policy": null, "four_eyes": false, "ids": false }, "allowed_for": { "clients": [], "gateway_groups": [], "remote_groups": [], "servers": [], "time_policy": "-100" }, "channel": "#drawing" } ] }
The following is a sample response received, showing the properties of Content policy objects.
For details of the meta object, see Message format.
{ "key": "f79bcc85-bb8b-4fa5-a141-eb4cf2b6ef33", "meta": { "href": "/api/configuration/rdp/channel_policies/f79bcc85-bb8b-4fa5-a141-eb4cf2b6ef33", "parent": "/api/configuration/rdp/channel_policies", "transaction": "/api/transaction" } }
The following table lists the typical status and error codes for this request. For a complete list of error codes, see Application level error codes.
Code | Description | Notes |
---|---|---|
201 | Created | The new resource was successfully created. |
400 | Bad Request | The request body format is invalid. The data is not a properly formatted JSON object. |
401 | Unauthenticated | The requested resource cannot be retrieved because the client is not authenticated and the resource requires authorization to access it. The details section contains the path that was attempted to be accessed, but could not be retrieved. |
401 | AuthenticationFailure | Authenticating the user with the given credentials has failed. |
409 | Conflict | No open Transaction is available. Open a transaction before using this request. For details, see Open a transaction. |
417 | Expectation Failed |
If you receive the "417 - Expectation Failed" error code when using curl, use curl with the --http1.0 or the -H "Expect:" option. |
To modify or update an object, use a PUT request on the object you want to change. In the body of the request, you have to upload the entire object, not only the parameter that you want to change.
To delete an element of a list (for example, a user from a local user database), use a PUT request. The body the request should include the entire object, but remove the element you want to delete from the related list of the object.
Note the following points when you create a request:
Note that you cannot simply use the JSON from the response of a similar object. If the object contains references to other resources (for example, a Channel policy references a Time policy), then the JSON object contains an embedded meta object. To get a valid JSON that you can use, you have to replace this embedded object with the ID (key) of the referenced object. For example, the following is a reference to a Time policy:
"time_policy": { "key": "-100", "meta": { "href": "/api/configuration/policies/time_policies/-100" } }
In a POST or PUT request, you have to change it to the following:
"time_policy": "-100",
You have to include empty fields in the object as well, for example:
"users": [ { "certificates": [], "passwords": [ "<reference-to-password>" ], "public_keys": [], "username": "myusername" } ]
The API ignores any unrecognized or nonexistent keys that appear in the body of POST and PUT requests. For example, if you mistype the name of an optional key, it will be silently ignored.
The body wrapper that is displayed in the response is not needed when you create or modify an object, for example:
{ "name": "my-local-user-database", "users": [ { "certificates": [], "passwords": [ "<reference-to-password>" ], "public_keys": [], "username": "myusername" } ] }
PUT https:<IP-address-of-SPS>/api/configuration/<path-to-the-parent-resource>/<id-of-the-object-to-modify>
Header name | Description | Required | Values |
---|---|---|---|
Content-Type | Specifies the type of the data sent. SPS uses the JSON format | Required | application/json |
session_id | Contains the authentication token of the user | Required | The value of the session ID cookie received from the REST server in the authentication response, for example, a1f71d030e657634730b9e887cb59a5e56162860. For details on authentication, see Authenticate to the SPS REST API. |
The following command updates an RDP Channel policy. The data content of the request is read from the file body.json.
curl -H "Content-Type: application/json" -d @body.json --cookie session_id=07640a0bf14cdd361d8f5ae2b0b482a786c7a604 -X PUT https://10.40.255.17/api/configuration/rdp/channel_policies/<id-of-the-object-to-modify>
For a simple RDP Channel policy that uses the default settings and allows only the Drawing channel, the JSON object is the following.
{ "name": "drawing-only", "rules": [ { "actions": { "audit": true, "content_policy": null, "four_eyes": false, "ids": false }, "allowed_for": { "clients": [], "gateway_groups": [], "remote_groups": [], "servers": [], "time_policy": "-100" }, "channel": "#drawing" } ] }
The following is a sample response received.
For details of the meta object, see Message format.
{ "meta": { "first": "/api/configuration/rdp/channel_policies/-20100", "href": "/api/configuration/rdp/channel_policies/<id-of-the-modified-object>", "last": "/api/configuration/rdp/channel_policies/<id-of-the-modified-object>", "next": null, "parent": "/api/configuration/rdp/channel_policies", "previous": "/api/configuration/rdp/channel_policies/655555", "transaction": "/api/transaction" } }
The following table lists the typical status and error codes for this request. For a complete list of error codes, see Application level error codes.
Code | Description | Notes |
---|---|---|
201 | Created | The new resource was successfully created.. |
400 | Bad Request | The request body format is invalid. The data is not a properly formatted JSON object. |
401 | Unauthenticated | The requested resource cannot be retrieved because the client is not authenticated and the resource requires authorization to access it. The details section contains the path that was attempted to be accessed, but could not be retrieved. |
401 | AuthenticationFailure | Authenticating the user with the given credentials has failed. |
409 | Conflict | No open Transaction is available. Open a transaction before using this request. For details, see Open a transaction. |
417 | Expectation Failed |
If you receive the "417 - Expectation Failed" error code when using curl, use curl with the --http1.0 or the -H "Expect:" option. |
© ALL RIGHTS RESERVED. Términos de uso Privacidad Cookie Preference Center