# Sample payloads

> Sample payloads for OneFuse Pluggable Module policies

---

Site [llms.txt](/llms.txt)

---

## F5 BIG-IP

To learn more about this OneFuse Pluggable Module, refer to [F5 BIG-IP](/docs/onefuse/configure/modules/f5-big-ip/).

Replace the value of `f5Endpoint` in the samples below with the name of the [Connection info](/docs/onefuse/configure/connection-info/) created for the F5 Endpoint.

### F5 sample 1: Using OneFuse modules

Sample payload below uses OneFuse Modules: Naming, IPAM, and DNS.

**Policy parameters:**

Sample payload for **Policy Parameters** for consuming this Module Policy via **VMware vRealize Automation**.

```jinja2
{% set vip_name = resource.onefuse_naming.vip.name | default("none", true) %}
{% set vip_ip = resource.onefuse_ipam.vip.ipAddress | default("none", true) %}
{% set dns_zone = "example.com" %}
{% set vip_dns_fqdn = resource.onefuse_dns.vip.records[0].name | default("none", true) %}
{% set tenant_name = "tenant_" + vip_name %}
{% set app_name = "application_" + vip_name %}
{% set pool_name = "pool_" + vip_name %}
{% set service_name = "service_" + vip_name %}

{
  "provisioningPayload": {
    "deploymentItems": {
      "plugin-bdi-54mjrf9h": {
        "parameters": {
          "resource_name": "{{vip_name}}",
          "skip_as3_install_check": false,
          "provisioning_as3_method": "POST",
          "provisioning_as3_path": "/mgmt/shared/appsvcs/declare?show=expanded",
          "provisioning_as3_data": {
            "class": "AS3",
            "action": "deploy",
            "persist": true,
            "declaration": {
              "class": "ADC",
              "schemaVersion": "3.0.0",
              "label": "{{vip_dns_fqdn}}",
              "remark": "Simple HTTP application with RR pool",
              "{{tenant_name}}": {
                "class": "Tenant",
                "{{app_name}}": {
                  "class": "Application",
                  "{{service_name}}": {
                    "class": "Service_HTTP",
                    "virtualAddresses": [
                      "{{vip_ip}}"
                    ],
                    "pool": "{{pool_name}}"
                  },
                  "{{pool_name}}": {
                    "class": "Pool",
                    "monitors": [
                      "http"
                    ],
                    "members": [
                      {
                        "servicePort": 80,
                        "serverAddresses": [
                          {% for key in members %}"{{ key.ip_address }}"{{ ", " if not loop.last else "" }}{% endfor %}
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "deprovisioning_as3_method": "DELETE",
          "deprovisioning_as3_path": "/mgmt/shared/appsvcs/declare/{{tenant_name}}",
          "deprovisioning_as3_data": "",
          "f5_endpoint": "F5_BIGIP_14",
          "onefuse_naming": [
            {
              "label": "vip",
              "endpoint": "onefuse",
              "policy": "vip_naming",
              "template_properties_override": {
                "text": "test2"
              }
            },
            {
              "label": "pool",
              "endpoint": "onefuse",
              "policy": "pool_naming",
              "template_properties_override": {}
            }
          ],
          "onefuse_ipam": [
            {
              "label": "vip",
              "endpoint": "onefuse",
              "policy": "F5_VIP",
              "template_properties_override": {},
              "hostname": "{{vip_name}}"
            }
          ],
          "onefuse_dns": [
            {
              "label": "vip",
              "endpoint": "onefuse",
              "policy": "F5_VIP",
              "template_properties_override": {
                "text": "test2"
              },
              "name": "{{vip_name}}",
              "value": "{{vip_ip}}",
              "zones": [
                "{{dns_zone}}"
              ]
            }
          ],
          "onefuse_property_sets": [
            {
              "label": "machine_naming_properties",
              "property_set_name": "template_portland_prod_windows_web",
              "template_properties_override": {
                "text": "test"
              }
            }
          ],
          "additive_key": "{{inputProperties.deploymentId | required("missing inputProperties.deploymentId")}}-{{OneFuse_Suffix | required("missing OneFuse_Suffix")}}",
          "additive_resource_name": "(member {{OneFuse_VmNic0.target}})",
          "additive_data": {
            "members": {
                "hostname": "{{OneFuse_VmNic0.target | required("missing OneFuse_VmNic0.target")}}",
                "ip_address": "{{OneFuse_VmNic0.ipAddress | required("missing OneFuse_VmNic0.ipAddress")}}"
            }
          },
          "f5_outputs": {
            "app_name": "{{app_name}}",
            "vip_name": "{{vip_name}}",
            "tenant_name": "{{tenant_name}}",
            "pool_name": "{{pool_name}}",
            "service_name": "{{service_name}}",
            "member_ips": "{{as3_results.declaration[tenant_name][app_name][pool_name].members.0.serverAddresses | default ([]) | tojson}}"
           }
        }
      }
    }
  }
}
```

The following snippet from the sample payload above can be modified to have the correct properties for the machine hostname/IP address.

```jinja2
{# expects 'OneFuse_VmNic0' properties to be resolved for the machine #}
"additive_data": {
  "members": {
      "hostname": "{{OneFuse_VmNic0.target | required("missing OneFuse_VmNic0.target")}}",
      "ip_address": "{{OneFuse_VmNic0.ipAddress | required("missing OneFuse_VmNic0.ipAddress")}}"
  }
}
```

<div class="alert alert-info" role="alert">


When consuming this module from an upstream provider other than VMware vRealize Automation, ensure that the properties defined get passed in accordingly.
</div>


### F5 sample 2: Minimal with randomizing IP address

Sample payload without OneFuse Modules and randomizing IP address.

**Policy parameters:**

Provide a value for the parameter `vipname` when calling this Policy from the API or an upstream provider.

```jinja2
{% set vip_name = vipname | required("vipname not supplied") %}
{% set tenant_name = "tenant_" + vip_name %}
{% set app_name = "application_" + vip_name %}
{% set pool_name = "pool_" + vip_name %}
{% set service_name = "service_" + vip_name %}

{
  "provisioningPayload": {
    "deploymentItems": {
      "plugin-bdi-54mjrf9h": {
        "parameters": {
          "resource_name": "{{vip_name}}",
          "skip_as3_install_check": false,
          "provisioning_as3_method": "POST",
          "provisioning_as3_path": "/mgmt/shared/appsvcs/declare",
          "provisioning_as3_data": {
            "class": "AS3",
            "action": "deploy",
            "persist": true,
            "declaration": {
              "class": "ADC",
              "schemaVersion": "3.0.0",
              "label": "{{vip_name}}",
              "remark": "Simple HTTP application with RR pool",
              "tenant_{{vip_name}}": {
                "class": "Tenant",
                "{{app_name}}": {
                  "class": "Application",
                  "{{service_name}}": {
                    "class": "Service_HTTP",
                    "virtualAddresses": [
                      "10.{{range(1, 254) | random}}.{{range(1, 254) | random}}.{{range(1, 254) | random}}"],
                    "pool": "{{pool_name}}"
                  },
                  "{{pool_name}}": {
                    "class": "Pool",
                    "monitors": [
                      "http"
                    ],
                    "members": [
                      {
                        "servicePort": 80,
                        "serverAddresses": [
                          "10.{{range(1, 254) | random}}.{{range(1, 254) | random}}.{{range(1, 254) | random}}", "10.{{range(1, 254) | random}}.{{range(1, 254) | random}}.{{range(1, 254) | random}}"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "deprovisioning_as3_method": "DELETE",
          "deprovisioning_as3_path": "/mgmt/shared/appsvcs/declare/tenant_{{vipname}}",
          "deprovisioning_as3_data": "",
          "f5_endpoint": "F5_BIGIP_14",
          "f5_outputs": {
            "app_name": "{{app_name}}",
            "vip_name": "{{vip_name}}",
            "tenant_name": "{{tenant_name}}",
            "pool_name": "{{pool_name}}",
            "service_name": "{{service_name}}",
            "member_ips": "{{as3_results.declaration[tenant_name][app_name][pool_name].members.0.serverAddresses | default ([]) | tojson}}"
           },
           "locking_level": "endpoint"
        }
      }
    }
  }
}
```

---

## Notifications

To learn more about this OneFuse Pluggable Module, refer to [Notifications](/docs/onefuse/configure/modules/notifications/).

Replace the value of `smtp_endpoint` in the samples below with the name of the [Connection info](/docs/onefuse/configure/connection-info/) created for the SMTP server.

### Notifications sample 1: Minimal with basic starter body message

Sample payload without OneFuse Modules. Provide static and/or dynamic values for required parameters. Update the HTML body accordingly.

**Policy parameters:**

```json
{
  "provisioningPayload": {
    "deploymentItems": {
      "plugin-bdi-ztm1h5m6": {
        "parameters": {
          "smtp_endpoint": "smtp",
          "use_tls": "true",
          "email_format": "html",
          "from_address": "",
          "from_name": "",
          "reply_to": [],
          "subject": "",
          "body": "<h1>{{ title }}</h1><p>{{ message }}</p>",
          "to_addresses": [],
          "cc_addresses": [],
          "bcc_addresses": [],
          "onefuse_property_sets": []
        }
      }
    }
  }
}
```

### Notifications sample 2: Minimal with basic starter body message using Property Sets

Sample payload without OneFuse Modules. Provide static and/or dynamic values for required parameters when calling this Policy from the API or an upstream provider. Update the HTML body accordingly.

**Policy parameters:**

```json
{
  "provisioningPayload": {
    "deploymentItems": {
      "plugin-bdi-ztm1h5m6": {
        "parameters": {
          "smtp_endpoint": "{{ resource.onefuse_property_sets.emailSettings.rendered_properties.smtp_endpoint }}",
          "use_tls": "{{ resource.onefuse_property_sets.emailSettings.rendered_properties.use_tls }}",
          "email_format": "{{ resource.onefuse_property_sets.emailSettings.rendered_properties.email_format }}",
          "from_address": "",
          "from_name": "",
          "reply_to": [],
          "subject": "",
          "body": "<h1>{{ title }}</h1><p>{{ message }}</p>",
          "to_addresses": [],
          "cc_addresses": [],
          "bcc_addresses": [],
          "onefuse_property_sets": [
            {
              "label": "emailSettings",
              "property_set_name": "default_emailSettings",
              "template_properties_override": {}
            }
          ]
        }
      }
    }
  }
}
```

The example above presumes a Property Set named `default_emailSettings` was created with the following properties:

```json
{
  "email_format": "html",
  "use_tls": "true",
  "smtp_endpoint": "smtp"
}
```

<div class="alert alert-info" role="alert">


Format to reference properties from a Property Set within Policy Parameters:

`{{resource.onefuse_property_sets.<LABEL>.rendered_properties.<MY_PROPERTY_NAME>}}`
</div>


---

## ServiceNow REST Client

To learn more about this OneFuse Pluggable Module, refer to [ServiceNow REST Client](/docs/onefuse/configure/modules/servicenow-rest-client/).

Replace the values of the following parameters in the samples below:

| Parameter key | Notes |
| --- | --- |
| `servicenow_user_connection_info` | Name of the [Connection info](/docs/onefuse/configure/connection-info/) that utilizes Basic Authentication for the ServiceNow Endpoint. |
| `servicenow_oauth_connection_info` | Name of the [Connection info](/docs/onefuse/configure/connection-info/) that utilizes OAuth for the ServiceNow Endpoint. |
| `prov_api_path` | ServiceNow REST Client API Path for Provisioning. |
| `prov_json_data` | ServiceNow REST Client API Body in JSON format for Provisioning. |
| `deprov_api_path` | ServiceNow REST Client API Path for Deprovisioning, typically the same as the Provisioning API Path. |
| `deprov_json_data` | ServiceNow REST Client API Body in JSON format for Deprovisioning. |

### ServiceNow REST Client sample 1: ServiceNow Basic Auth using OneFuse IPAM module

Sample Payload below uses Basic Authentication with ServiceNow and OneFuse Module: IPAM.

**Policy parameters:**

```jinja2
{
  "provisioningPayload": {
    "deploymentItems": {
      "plugin-bdi-pfrq8kvj": {
        "parameters": {
          "servicenow_user_connection_info": "ServiceNow_Rest",
          "prov_api_path": "api/org/restposttest",
          "name": "{{OneFuse_Ipam_Nic0.hostname}}",
          "prov_json_data": {
            "name": "{{OneFuse_Ipam_Nic0.hostname}}",
            "description": "Provisioning {{description}}"
          },
          "deprov_api_path": "api/org/restposttest",
          "deprov_json_data": {
            "name": "{{OneFuse_Ipam_Nic0.hostname}}",
            "description": "Deprovisioning {{description}}"
          }
        }
      }
    }
  }
}
```

### ServiceNow REST Client sample 2: ServiceNow OAuth using OneFuse IPAM module

Sample Payload below uses OAuth with ServiceNow and OneFuse Module: IPAM.

**Policy parameters:**

```jinja2
{
  "provisioningPayload": {
    "deploymentItems": {
      "plugin-bdi-pfrq8kvj": {
        "parameters": {
          "servicenow_user_connection_info": "ServiceNow_Rest",
          "servicenow_oauth_connection_info": "ServiceNow_Rest_oauth",
          "oauth_api_path": "oauth_token.do",
          "prov_api_path": "api/org/restposttest",
          "name": "{{OneFuse_Ipam_Nic0.hostname}}",
          "prov_json_data": {
            "name": "{{OneFuse_Ipam_Nic0.hostname}}",
            "description": "Provisioning {{description}}"
          },
          "deprov_api_path": "api/org/restposttest",
          "deprov_json_data": {
            "name": "{{OneFuse_Ipam_Nic0.hostname}}",
            "description": "Deprovisioning {{description}}"
          }
        }
      }
    }
  }
}
```

**Optional policy parameters:**

| Parameter name | Description |
| --- | --- |
| `servicenow_oauth_connection_info` | Name of the Connection Info that has OAuth credentials. |
| `oauth_api_path` | OAuth API path. Default: `oauth_token.do`. |
