# Policy Filter

### What Are the Policy's Filters

They allow you to fine-tune where you want your deployments to be located. They are a part of the policy itself, but by how they are constructed, we found that it would be easier to understand on their documentation page.

{% hint style="info" %}
The policy data will not include the same structure depending on the policy's `type`. We will go through every `type` with examples.
{% endhint %}

### Location type

This is the option we would prefer in our North American fleet.

We will add a slight constraint to our North American fleet to show you how you can tweak the filters to your taste. Let's say you don't want any of your games to be located in Miami because you find that it is too far from your typical players' location.

You will need to choose an available field from ***city***, ***country***, ***continent***, ***administrative\_division***.

Next is the filter type. You can choose between:

* ***any*** - You want one or more of the values to match the potential locations.
* ***all*** - You want all the values to match the potential locations.
* ***not*** - You want all the values not to match the potential locations.

{% hint style="info" %}
You can create pretty complex policies, but be aware that your filters might be technically correct but impossible to process. If you create an \`all\` filter with three different cities, it will simply not work since no location can physically be in those three cities.
{% endhint %}

You can get all the geographical information about the locations with the [API](https://docs.edgegap.com/docs/api).

{% hint style="warning" %}
The different policies are independent of each other. So if you set a policy with a minimum number of 4 deployments in Canada and a policy with two in Montreal, you will end up with six deployments in total, even if Montreal is in Canada.
{% endhint %}

#### Using the Dashboard

The *data* for the policy is created in a small form with some predetermined values.

<figure><img src="https://3027732442-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR0dHSFv9ymoC0DO5G8J%2Fuploads%2Fgit-blob-c72933ba02260233a04c20643e7e66f40b64559b%2Ffilter-1.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Using the API

From the API, you must specify the type when updating the data field.

[API Reference](https://docs.edgegap.com/docs/api)

```json
{
  "type": "Location",
  "data": {
    "filters": [
      {
        "field": "continent",
        "filter_type": "all",
        "values": ["North America"]
      },
      {
        "field": "city",
        "filter_type": "not",
        "values": ["Miami"]
      }
    ]
  }
}
```

### Tag type

Tag type is less often useful for common use cases but can be very convenient if you need more technical filters like high clock CPU. The values will always be a key and a value separated with an equal sign.

You can get all the tags for each locations with the [API](https://docs.edgegap.com/docs/api). You will need to set the *tags* parameter to true.

#### Using the Dashboard

<figure><img src="https://3027732442-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR0dHSFv9ymoC0DO5G8J%2Fuploads%2Fgit-blob-f3b6d7fc7b464bbbe5aafd5d8ae7af262587d764%2Ffilter-4.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Using the API

[API Reference](https://docs.edgegap.com/docs/api)

```json
{
  "data": {
    "filters": [
      {
        "field": "location_tags",
        "filter_type": "any",
        "values": ["infrastructure=16523f"]
      }
    ]
  }
}
```

### Point type

Point type lets you give latitude and longitude coordinates. The fleet will create deployment at the closest location available from the point.

#### Using the Dashboard

<figure><img src="https://3027732442-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR0dHSFv9ymoC0DO5G8J%2Fuploads%2Fgit-blob-63eaa5cdba799bf51da14dffe0dfcdcfcf9dd2ab%2Ffilter-5.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Using the API

[API Reference](https://docs.edgegap.com/docs/api)

```json
{
  "data": {
    "coordinates": {
      "latitude": 45.5016,
      "longitude": -73.5672
    }
  }
}
```
