Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

IP Address Enrichment API

This topic provides an introduction to the API, how to configure the API, types of methods and calls, and cURL examples.

Introduction to the API

NetObserv Flow provides an API for managing user-defined metadata (UDM) entries. The API allows for creating, reading, updating, and deleting UDM entries.

Configuring the API

To enable the API, set the following configuration values:

  • EF_PROCESSOR_ENRICH_IPADDR_METADATA_ENABLE: true

  • EF_PROCESSOR_ENRICH_IPADDR_METADATA_API_ENABLE: true

  • EF_PROCESSOR_ENRICH_IPADDR_METADATA_USERDEF_PATH: /etc/juniper/metadata/ipaddrs.yml

    *You can configure this setting to any location. However, it must be set to a specific value.

Note: This API follows the common configuration used by other APIs. You can optionally configure basic authentication (Basic Auth), TLS, and a different port.

API Context

API Replaces YAML File Usage

Using this API replaces manual updates to the UDM YAML file. The API updates the file to reflect the latest state but prevents the product from noticing or re-reading YAML file changes. Make sure the comments do not contain critical information before using the API.

Create or update calls, such as CreateUdm, removes all comments and might reorder stanzas in the file. The resulting file contains only data, excluding comments and formatting.

Warning About Caching

NetObserv caches UDM entries in memory. Modifications made through this API won't take immediate effect due to caching. The cache lasts for two hours by default.

API Methods

This section lists available API methods and provides examples for each.

CountUdms: POST /api/v1/enrich/ipaddr/udm.v1.UdmService/CountUdms

Returns the number of items in the DB.

This example assumes you begin with the following set of UDM entries.

Example

Output

ListUdms: POST /api/v1/enrich/ipaddr/udm.v1.UdmService/ListUdms

Returns a record that match the given key. Converts non-string metadata values, such as numbers, into strings.

Detailed Logic

The DB returns results based on the following conditions:

  • Without a key, the entire DB is returned.

  • With the exact option set to true, the key is matched exactly.

  • With the exact option set to false, all DB entries matching the key are returned.

  • If no key is specified, the exact option is ignored, and all UDMs are returned.

If the key is:

  • An IP address:

    The IP address is returned if it exists. Any CIDR or Range within the given CIDR is also returned if applicable.

  • A CIDR:

    Any IP, CIDR, or Range within the given CIDR is returned. For a Range, the first and last IPs must be within the CIDR. For example, in 192.168.1.0/24, the first IP is 192.168.1.0 and the last IP is 192.168.1.255.

  • A Range:

    Any IP, CIDR, or Range within the given Range is returned. For a CIDR, ensure the first and last IPs fall within the Range. The first and last IPs must be within the Range. For a given range R1, the database returns range R2 if R1.From <= R2.From and R2.To <= R1.To.

Note: ListUdms is safe for concurrent calls. You can safely call ListUdms concurrently for each key when querying multiple keys.

This example assumes you begin with the following set of UDM entries.

Example: List all UDM entries

Output

ListUDMKeys: POST /api/v1/enrich/ipaddr/udm.v1.UdmService/ListUdmKeys

Return keys matching the given key. This API is equivalent to calling ListUdms on the key and returns only UDMs keys. If no key is provided, it returns all keys. The rules are the same as specified in the ListUDMs Method.

The following examples assume you begin with this set of UDM entries.

List All Keys

Output

List a specific key

Output

List all keys matching a given key

Output

CreateUdm: POST /api/v1/enrich/ipaddr/udm.v1.UdmService/CreateUdm

Creates a UDM entry. Returns an error if the given key already exists.

Output

BatchCreateUdms: POST /api/v1/enrich/ipaddr/udm.v1.UdmService/BatchCreateUdm

Creates the given UDMs and returns them. Returns an error if any UDMs exist. Save updates to the .yml file atomically.

Output

This output shows the status of the DB after running the above example commands:

DeleteUdm : POST /api/v1/enrich/ipaddr/udm.v1.UdmService/DeleteUdm

Deletes the specified UDM. The key must match exactly. Deletes are atomic and updates the .yml file.

Example

Output

{}

Result

UpdateUdm: POST /api/v1/enrich/ipaddr/udm.v1.UdmService/UpdateUdm

  • Updates the given UDM with the provided data. The update_mask field specifies the fields to update. If empty, all fields are updated to their "zero value," including unspecified ones.

  • Returns the updated UDM or an error if the key is missing.

Example: Without an update_mask

Output

This command lacks an update_mask, so all unspecified fields in the UDM object were cleared.

Example: With an update_mask

Output

The command included an update_mask. As a result, only the vlan and tags fields were updated.

BatchUpdateUdms: POST /api/v1/enrich/ipaddr/udm.v1.UdmService/BatchUpdateUdms

Updates the UDMs with the provided data. Use the UpdateMask field to specify fields for updating. If the UpdateMask is empty, all fields, including unspecified ones, are updated to their "zero value." See the example below for details.

Returns updated UDMs or an error if any keys are missing. Updates are atomic and saved to the .yml file.

BatchUpdateUdmsuses aBatchUpdateUdmsRequest struct containing:

  • A slice of UpdateUdmRequest structs .

  • A single UpdateMask field for the batch.

Each UpdateUdmRequest struct has its own UpdateMask, which is ignored.

Without an update_mask

Output

No update_mask was specified, so all fields not mentioned were cleared.

With an update_mask

  • Update only the tags and metadata fields.

  • The vlan in the first UDM entry and the name in both UDMs are not updated.

  • Only the top-level update_mask field is valid.

  • The first request's "update_mask":"name" is ignored.

Output

Note: In a BatchUpdateUdms request, only the top-level update_mask field is used. The update_mask field in each request object is ignored.