PATCH request for the service to the ClickHouse Cloud API with an ipAccessList object. Its add and remove arrays list the entries to add and to remove, so you do not have to send the whole list.
Before you start
You need:- An API key that is allowed to read and to change the service. In the API reference, the
GETrequest for a service (“Get service details”) requires thecontrol-plane:service:viewpermission, and thePATCHrequest (“Update service basic details”) requirescontrol-plane:service:manage. A key with the admin role has full read and write permissions. A key with read-only permissions is not enough for thePATCHrequest. The list of console permissions also has a separatecontrol-plane:service:manage-ip-access-listpermission for IP access lists: if thePATCHrequest of a key with narrower permissions is rejected, check whether the key has it. - The ID of your organization and the ID of the service.
curl, and optionallyjqto print parts of the response.
See the current list
Request the service and print itsipAccessList:
source, which is an IPv4 address or an IPv4 range in CIDR notation, and an optional description.
Add and remove entries
Write the changes to a file. This example adds one address and one range, and removes one address:PATCH request to the service:
"status": 200 and returns the service in result, so the command prints its IP access list. If the request is rejected, the response has no result and the command prints null; run it without the jq part to read the error field of the response. To confirm the change, run the command from the previous section again.
Both arrays are optional: send only add to add entries, or only remove to remove them.
Things to know
- The API processes
removebeforeadd. To change the description of an entry, put the entry intoremoveand the new version intoaddof the same request. - In
remove, copy the entries from the current list as they are. - A service that allows access from anywhere has an entry with the source
0.0.0.0/0. Adding specific addresses restricts nothing while that entry is in the list, so remove it in the same request. Before you do, make sure thataddcontains every address your applications connect from. - IP access lists support only IPv4.
- The API key has an IP access list of its own. If the key is restricted to specific locations, the request must come from one of them.
- The list applies only to connections from the public internet, not to connections through PrivateLink, see setting IP filters.