[PR #64] [MERGED] feat: add service_type argument to service create/update #63

Closed
opened 2026-02-27 23:18:54 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/sophos/sophos-firewall-sdk/pull/64
Author: @mamullen13316
Created: 5/13/2024
Status: Merged
Merged: 5/13/2024
Merged by: @mamullen13316

Base: mainHead: service_type


📝 Commits (1)

  • abc32f3 feat: add service_type argument to service create/update

📊 Changes

5 files changed (+110 additions, -22 deletions)

View changed files

📝 pyproject.toml (+1 -1)
📝 sophosfirewall_python/firewallapi.py (+66 -16)
📝 sophosfirewall_python/templates/createservice.j2 (+21 -2)
📝 sophosfirewall_python/templates/updateservice.j2 (+20 -1)
📝 sophosfirewall_python/tests/functional.py (+2 -2)

📄 Description

Adds a service_type argument to create_service() and update_service() so that additional service types can be supported.

  • TCPorUDP (already supported)
  • IP
  • ICMP
  • ICMPv6

When creating/updating IP services, it is only necessary to specify the protocol as it is shown in the UI. The protocol number is shown in the UI, however it is not used in the API. Similarly, for ICMP the types and codes should be provided using their names as shown in the UI rather than the numbers.

Examples:

resp = fw.create_service(name="test_esp", service_type="IP", service_list=[{"protocol": "ESP"}])

resp
{'Response': {'@APIVersion': '2000.2',
  '@IPS_CAT_VER': '1',
  '@IS_WIFI6': '0',
  'Login': {'status': 'Authentication Successful'},
  'Services': {'@transactionid': '',
   'Status': {'@code': '200',
    '#text': 'Configuration applied successfully.'}}}}

 resp = fw.update_service(name="test_esp", service_type="IP", service_list=[{"protocol": "AH"}])

 resp
{'Response': {'@APIVersion': '2000.2',
  '@IPS_CAT_VER': '1',
  '@IS_WIFI6': '0',
  'Login': {'status': 'Authentication Successful'},
  'Services': {'@transactionid': '',
   'Status': {'@code': '200',
    '#text': 'Configuration applied successfully.'}}}}

 fw.create_service(name="test_icmp_tracert", service_type="ICMP", service_list=[{"icmp_type": "Traceroute", "icmp_code": "Any Code"}])
 
{'Response': {'@APIVersion': '2000.2',
  '@IPS_CAT_VER': '1',
  '@IS_WIFI6': '0',
  'Login': {'status': 'Authentication Successful'},
  'Services': {'@transactionid': '',
   'Status': {'@code': '200',
    '#text': 'Configuration applied successfully.'}}}}

fw.update_service(name="test_icmp_tracert", service_type="ICMP", service_list=[{"icmp_type": "Destination Unreachable", "icmp_code": "Port Unreachable"}])
{'Response': {'@APIVersion': '2000.2',
  '@IPS_CAT_VER': '1',
  '@IS_WIFI6': '0',
  'Login': {'status': 'Authentication Successful'},
  'Services': {'@transactionid': '',
   'Status': {'@code': '200',
    '#text': 'Configuration applied successfully.'}}}}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/sophos/sophos-firewall-sdk/pull/64 **Author:** [@mamullen13316](https://github.com/mamullen13316) **Created:** 5/13/2024 **Status:** ✅ Merged **Merged:** 5/13/2024 **Merged by:** [@mamullen13316](https://github.com/mamullen13316) **Base:** `main` ← **Head:** `service_type` --- ### 📝 Commits (1) - [`abc32f3`](https://github.com/sophos/sophos-firewall-sdk/commit/abc32f3ec60899a8c1d6c565536bf8b90dfc3aea) feat: add service_type argument to service create/update ### 📊 Changes **5 files changed** (+110 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `pyproject.toml` (+1 -1) 📝 `sophosfirewall_python/firewallapi.py` (+66 -16) 📝 `sophosfirewall_python/templates/createservice.j2` (+21 -2) 📝 `sophosfirewall_python/templates/updateservice.j2` (+20 -1) 📝 `sophosfirewall_python/tests/functional.py` (+2 -2) </details> ### 📄 Description Adds a service_type argument to `create_service()` and `update_service()` so that additional service types can be supported. - TCPorUDP (already supported) - IP - ICMP - ICMPv6 When creating/updating IP services, it is only necessary to specify the protocol as it is shown in the UI. The protocol number is shown in the UI, however it is not used in the API. Similarly, for ICMP the types and codes should be provided using their names as shown in the UI rather than the numbers. Examples: ```python resp = fw.create_service(name="test_esp", service_type="IP", service_list=[{"protocol": "ESP"}]) resp {'Response': {'@APIVersion': '2000.2', '@IPS_CAT_VER': '1', '@IS_WIFI6': '0', 'Login': {'status': 'Authentication Successful'}, 'Services': {'@transactionid': '', 'Status': {'@code': '200', '#text': 'Configuration applied successfully.'}}}} resp = fw.update_service(name="test_esp", service_type="IP", service_list=[{"protocol": "AH"}]) resp {'Response': {'@APIVersion': '2000.2', '@IPS_CAT_VER': '1', '@IS_WIFI6': '0', 'Login': {'status': 'Authentication Successful'}, 'Services': {'@transactionid': '', 'Status': {'@code': '200', '#text': 'Configuration applied successfully.'}}}} fw.create_service(name="test_icmp_tracert", service_type="ICMP", service_list=[{"icmp_type": "Traceroute", "icmp_code": "Any Code"}]) {'Response': {'@APIVersion': '2000.2', '@IPS_CAT_VER': '1', '@IS_WIFI6': '0', 'Login': {'status': 'Authentication Successful'}, 'Services': {'@transactionid': '', 'Status': {'@code': '200', '#text': 'Configuration applied successfully.'}}}} fw.update_service(name="test_icmp_tracert", service_type="ICMP", service_list=[{"icmp_type": "Destination Unreachable", "icmp_code": "Port Unreachable"}]) {'Response': {'@APIVersion': '2000.2', '@IPS_CAT_VER': '1', '@IS_WIFI6': '0', 'Login': {'status': 'Authentication Successful'}, 'Services': {'@transactionid': '', 'Status': {'@code': '200', '#text': 'Configuration applied successfully.'}}}} ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem closed this issue 2026-02-27 23:18:54 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/sophos-firewall-sdk#63
No description provided.