Skip to content

Commit

Permalink
Update Anti-Spyware Profile documentation for improved clarity
Browse files Browse the repository at this point in the history
Enhanced the Anti-Spyware Profile documentation with detailed class definitions, comprehensive examples, and improved code snippets for creating, retrieving, updating, deleting, and listing profiles using the Strata Cloud Manager SDK. This update aims to provide a more streamlined and understandable guide for users working with Anti-Spyware Profiles.
  • Loading branch information
cdot65 committed Oct 17, 2024
1 parent 1a4f643 commit e319bb5
Show file tree
Hide file tree
Showing 2 changed files with 475 additions and 205 deletions.
234 changes: 117 additions & 117 deletions docs/sdk/config/security_services/anti_spyware.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
# Anti-Spyware Profile

The `AntiSpywareProfile` class manages Anti-Spyware Profiles in Palo Alto Networks' Strata Cloud Manager.
The `AntiSpywareProfile` class manages Anti-Spyware Profiles in Palo Alto Networks' Strata Cloud Manager. It provides
methods to create, retrieve, update, delete, and list Anti-Spyware Profiles using the Strata Cloud Manager API.

## Overview
## Class Definition

This class provides methods to create, retrieve, update, delete, and list Anti-Spyware Profiles using the Strata Cloud
Manager API. It supports operations within folders, snippets, or devices, and allows filtering of profiles based on
various criteria.
```python
class AntiSpywareProfile(BaseObject):
ENDPOINT = "/config/security/v1/anti-spyware-profiles"

def __init__(self, api_client):
super().__init__(api_client)
```

## Methods

### create

Creates a new Anti-Spyware Profile.

<div class="termy">

<!-- termynal -->

```python
def create(self, data: Dict[str, Any]) -> AntiSpywareProfileResponseModel:
```

</div>

#### Parameters

- `data` (Dict[str, Any]): A dictionary containing the Anti-Spyware Profile configuration.
Expand All @@ -36,24 +35,29 @@ def create(self, data: Dict[str, Any]) -> AntiSpywareProfileResponseModel:

<div class="termy">

<!-- termynal -->

```python
anti_spyware_profile = AntiSpywareProfile(api_client)
from pan_scm_sdk import SCMClient
from pan_scm_sdk.config.security import AntiSpywareProfile

client = SCMClient(client_id="your-client-id", client_secret="your-client-secret")
anti_spyware = AntiSpywareProfile(client)

profile_data = {
"name": "Custom Anti-Spyware Profile",
"description": "A custom anti-spyware profile",
"folder": "My Folder",
"name": "Example Profile",
"description": "An example Anti-Spyware Profile",
"folder": "Shared",
"rules": [
{
"name": "Block Critical Threats",
"severity": ["critical"],
"name": "Rule 1",
"severity": ["critical", "high"],
"category": "spyware",
"action": {"block_ip": {"track_by": "source", "duration": 300}}
"action": {"alert": {}}
}
]
}
created_profile = anti_spyware_profile.create(profile_data)

created_profile = anti_spyware.create(profile_data)
print(f"Created profile ID: {created_profile.id}")
```

</div>
Expand All @@ -62,16 +66,10 @@ created_profile = anti_spyware_profile.create(profile_data)

Retrieves an Anti-Spyware Profile by its ID.

<div class="termy">

<!-- termynal -->

```python
def get(self, object_id: str) -> AntiSpywareProfileResponseModel:
```

</div>

#### Parameters

- `object_id` (str): The ID of the Anti-Spyware Profile to retrieve.
Expand All @@ -84,11 +82,10 @@ def get(self, object_id: str) -> AntiSpywareProfileResponseModel:

<div class="termy">

<!-- termynal -->

```python
anti_spyware_profile = AntiSpywareProfile(api_client)
profile = anti_spyware_profile.get("profile-123")
profile_id = "1234567890abcdef"
retrieved_profile = anti_spyware.get(profile_id)
print(f"Retrieved profile name: {retrieved_profile.name}")
```

</div>
Expand All @@ -97,16 +94,10 @@ profile = anti_spyware_profile.get("profile-123")

Updates an existing Anti-Spyware Profile.

<div class="termy">

<!-- termynal -->

```python
def update(self, object_id: str, data: Dict[str, Any]) -> AntiSpywareProfileResponseModel:
```

</div>

#### Parameters

- `object_id` (str): The ID of the Anti-Spyware Profile to update.
Expand All @@ -120,23 +111,22 @@ def update(self, object_id: str, data: Dict[str, Any]) -> AntiSpywareProfileResp

<div class="termy">

<!-- termynal -->

```python
anti_spyware_profile = AntiSpywareProfile(api_client)
updated_data = {
"name": "Updated Anti-Spyware Profile",
"description": "An updated anti-spyware profile",
profile_id = "1234567890abcdef"
update_data = {
"description": "Updated Anti-Spyware Profile description",
"rules": [
{
"name": "Alert on High Threats",
"severity": ["high"],
"name": "Updated Rule",
"severity": ["critical", "high", "medium"],
"category": "spyware",
"action": {"alert": {}}
"action": {"drop": {}}
}
]
}
updated_profile = anti_spyware_profile.update("profile-123", updated_data)

updated_profile = anti_spyware.update(profile_id, update_data)
print(f"Updated profile description: {updated_profile.description}")
```

</div>
Expand All @@ -145,16 +135,10 @@ updated_profile = anti_spyware_profile.update("profile-123", updated_data)

Deletes an Anti-Spyware Profile.

<div class="termy">

<!-- termynal -->

```python
def delete(self, object_id: str) -> None:
```

</div>

#### Parameters

- `object_id` (str): The ID of the Anti-Spyware Profile to delete.
Expand All @@ -163,11 +147,10 @@ def delete(self, object_id: str) -> None:

<div class="termy">

<!-- termynal -->

```python
anti_spyware_profile = AntiSpywareProfile(api_client)
anti_spyware_profile.delete("profile-123")
profile_id = "1234567890abcdef"
anti_spyware.delete(profile_id)
print(f"Deleted profile with ID: {profile_id}")
```

</div>
Expand All @@ -176,10 +159,6 @@ anti_spyware_profile.delete("profile-123")

Lists Anti-Spyware Profiles based on specified criteria.

<div class="termy">

<!-- termynal -->

```python
def list(
self,
Expand All @@ -193,15 +172,13 @@ def list(
) -> List[AntiSpywareProfileResponseModel]:
```

</div>

#### Parameters

- `folder` (Optional[str]): The folder to list profiles from.
- `snippet` (Optional[str]): The snippet to list profiles from.
- `device` (Optional[str]): The device to list profiles from.
- `offset` (Optional[int]): The offset for pagination.
- `limit` (Optional[int]): The limit for pagination.
- `limit` (Optional[int]): The maximum number of profiles to return.
- `name` (Optional[str]): Filter profiles by name.
- `**filters`: Additional filters to apply.

Expand All @@ -213,93 +190,116 @@ def list(

<div class="termy">

<!-- termynal -->

```python
anti_spyware_profile = AntiSpywareProfile(api_client)
profiles = anti_spyware_profile.list(folder="My Folder", limit=10, name="Custom")
```
# List profiles in a specific folder
folder_profiles = anti_spyware.list(folder="Shared", limit=10)
print(f"Number of profiles in Shared folder: {len(folder_profiles)}")

</div>

## Error Handling
# List profiles with a specific name pattern
named_profiles = anti_spyware.list(name="Test*", limit=5)
print(f"Number of profiles starting with 'Test': {len(named_profiles)}")

The `AntiSpywareProfile` class may raise the following exceptions:
# List profiles with custom filters
custom_profiles = anti_spyware.list(folder="Custom", severity="high", limit=20)
print(f"Number of high-severity profiles in Custom folder: {len(custom_profiles)}")
```

- `ValidationError`: Raised when invalid container parameters are provided.
- `ValueError`: Raised when invalid pagination parameters are provided.
</div>

## Additional Examples
## Complete Example

### Creating a profile with threat exceptions
Here's a complete example demonstrating the usage of the `AntiSpywareProfile` class:

<div class="termy">

<!-- termynal -->

```python
anti_spyware_profile = AntiSpywareProfile(api_client)
profile_data = {
"name": "Profile with Exceptions",
"description": "Anti-spyware profile with threat exceptions",
"folder": "Security Policies",
from pan_scm_sdk import SCMClient
from pan_scm_sdk.config.security import AntiSpywareProfile

# Initialize the SCM client
client = SCMClient(client_id="your-client-id", client_secret="your-client-secret")

# Create an AntiSpywareProfile instance
anti_spyware = AntiSpywareProfile(client)

# Create a new Anti-Spyware Profile
new_profile_data = {
"name": "Comprehensive Anti-Spyware Profile",
"description": "A comprehensive Anti-Spyware Profile with multiple rules",
"folder": "Shared",
"cloud_inline_analysis": True,
"inline_exception_edl_url": ["https://example.com/edl1", "https://example.com/edl2"],
"inline_exception_ip_address": ["192.168.1.1", "10.0.0.1"],
"mica_engine_spyware_enabled": [
{"name": "MICA-Engine-1", "inline_policy_action": "alert"},
{"name": "MICA-Engine-2", "inline_policy_action": "drop"}
],
"rules": [
{
"name": "Default Rule",
"severity": ["any"],
"category": "any",
"action": {"alert": {}}
"name": "Critical Threats",
"severity": ["critical"],
"category": "spyware",
"action": {"block_ip": {"track_by": "source", "duration": 3600}},
"packet_capture": "single-packet"
},
{
"name": "High Severity Threats",
"severity": ["high"],
"category": "command-and-control",
"action": {"reset-both": {}},
"packet_capture": "extended-capture"
}
],
"threat_exception": [
{
"name": "Exception for Known IP",
"name": "Exception 1",
"packet_capture": "disable",
"action": {"allow": {}},
"exempt_ip": [{"name": "10.0.0.1"}]
"exempt_ip": [{"name": "192.168.100.1"}],
"notes": "Exemption for internal testing server"
}
]
}
created_profile = anti_spyware_profile.create(profile_data)
```

</div>
created_profile = anti_spyware.create(new_profile_data)
print(f"Created profile ID: {created_profile.id}")

### Updating a profile with MICA engine settings

<div class="termy">
# Retrieve the created profile
retrieved_profile = anti_spyware.get(created_profile.id)
print(f"Retrieved profile name: {retrieved_profile.name}")

<!-- termynal -->

```python
anti_spyware_profile = AntiSpywareProfile(api_client)
updated_data = {
"name": "Updated MICA Profile",
"description": "Profile with MICA engine settings",
"mica_engine_spyware_enabled": [
{
"name": "MICA-Engine-1",
"inline_policy_action": "alert"
},
{
"name": "MICA-Engine-2",
"inline_policy_action": "drop"
}
],
# Update the profile
update_data = {
"description": "Updated comprehensive Anti-Spyware Profile",
"rules": [
{
"name": "MICA Rule",
"severity": ["high", "critical"],
"name": "Updated Critical Threats",
"severity": ["critical", "high"],
"category": "spyware",
"action": {"reset_both": {}}
"action": {"reset-server": {}},
"packet_capture": "extended-capture"
}
]
}
updated_profile = anti_spyware_profile.update("profile-456", updated_data)

updated_profile = anti_spyware.update(created_profile.id, update_data)
print(f"Updated profile description: {updated_profile.description}")

# List profiles
list_result = anti_spyware.list(folder="Shared", limit=10)
print(f"Number of profiles in Shared folder: {len(list_result)}")

# Delete the profile
anti_spyware.delete(created_profile.id)
print(f"Deleted profile with ID: {created_profile.id}")
```

</div>

This example demonstrates creating, retrieving, updating, listing, and deleting an Anti-Spyware Profile using the
`AntiSpywareProfile` class.


---

## Related Models
Expand Down
Loading

0 comments on commit e319bb5

Please sign in to comment.