> For the complete documentation index, see [llms.txt](https://atd-dts.gitbook.io/moped-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atd-dts.gitbook.io/moped-documentation/product-management/integrations/arcgis-online.md).

# ArcGIS Online

## Updating the ArcGIS Online Components Database View

### Summary

We have an ETL ([code](https://github.com/cityofaustin/atd-moped/tree/main/moped-etl/arcgis)) that uses the `component_arcgis_online_view` Moped database view to push data about project components to an AGOL feature service with four layers:

* point
* line
* combined geometry
* feature points (one row per feature point in the MultiPoint geometries captured in Moped aka "exploded")

This describes the workflow of adding, updating, or removing fields in this service and the coordination it takes with the DTS Geospatial team.

{% hint style="danger" %}
There are two downstream dependencies of this database view that can break:

* [AGOL Feature Service](https://services.arcgis.com/0L95CJ0VTaxqcmED/ArcGIS/rest/services/Moped_Project_Components/FeatureServer/) (coordinate with the Geospatial team; see below)
* [PowerBI dataflow](https://atd-dts.gitbook.io/atd-staff-resources/power-bi/how-to/connecting-to-a-dataflow) (coordinate with the Data Science team; see below)
  {% endhint %}

### Datasets

We have staging and production feature services that should be considered when adding, editing, or removing fields:

* [Staging](https://austin.maps.arcgis.com/home/item.html?id=9b024bcea3694f0699bb1183788e6ee8#overview)
* [Production](https://austin.maps.arcgis.com/home/item.html?id=1c084c8756a84e6db7e2796c98c850a2#overview)

### Code updates

The database view and ETL GraphQL query must be updated with the new or updated field names.

Here is an example pull request: <https://github.com/cityofaustin/atd-moped/pull/1357>.

{% hint style="warning" %}
The production ETL will break if it tries to populate a field that does not exist in the AGOL feature service yet. The ETL will not break if the feature service has a field that is no longer populated by the ETL. This is an important consideration when planning updates to the feature services.
{% endhint %}

### Adding a new field

* Stage code changes for new field
* Submit a [service request](https://atd.knack.com/dts#new-service-request/) for the GIS team to add new field to the staging and production feature services. **The ETL will break if the production process tries to populate a field that does not exist in the feature service yet.**
* Release or patch to introduce new field into ETL
* Tell the Data Science team about this update so they can [update the PowerBI dataflow](https://github.com/cityofaustin/atd-data-tech/issues/18041#issuecomment-2195245633)

### Renaming an existing field

* Stage code change for field rename
* Submit a [service request](https://atd.knack.com/dts#new-service-request/) for the GIS team to add new column name to the staging and production feature services. **We keep the old column name to keep the ETL compatible and working with both the new and old field names**
* Release or patch to introduce new field into ETL
* Request GIS team remove the old field name from the staging and production feature services now that the production process is no longer populating it
* Tell the Data Science team about this update so they can [update the PowerBI dataflow](https://github.com/cityofaustin/atd-data-tech/issues/18041#issuecomment-2195245633)

### Removing an existing field

* Stage code change for field removal
* Release or patch to remove column from ETL
* **The ETL will not break with the changes up to this point.** The next step can be performed anytime after removing the fields from the code to clean up the AGOL dataset.
* Submit a [service request](https://atd.knack.com/dts#new-service-request/) for the GIS team to remove the field from the staging and production feature services once the production process is no longer populating it
* Tell the Data Science team about this update so they can [update the PowerBI dataflow](https://github.com/cityofaustin/atd-data-tech/issues/18041#issuecomment-2195245633)

### Links

* [Example service request](https://github.com/cityofaustin/atd-data-tech/issues/17906)

## ArcGIS Online Feature Service settings

{% hint style="danger" %}
Before making any changes to a feature service, check with the Geo team and let them know what we are trying to accomplish.
{% endhint %}

### Updating settings

Settings on the feature service level (the AGOL side) can be updated using the Admin Service Catalog endpoint described [here](https://developers.arcgis.com/rest/services-reference/online/update-definition-feature-service-.htm). The only setting that we have changed so far is the `xssPreventionInfo` setting to place the responsibility of sanitizing invalid HTML on the AGOL side.

To update this setting, go to <https://services.arcgis.com/0L95CJ0VTaxqcmED/ArcGIS/rest/admin/services/Moped_Project_Components/FeatureServer/updateDefinition?token=>.

You will need to fetch a token using the same mechanism we use in our [Moped <> AGOL ETL code](https://github.com/cityofaustin/atd-moped/tree/main/moped-etl/arcgis). Using an API development tool like Postman or Insomnia can be helpful for this, and it will require the same secrets used in the code.

Once a token is retrieved and place in the URL, the UI can be used to make a POST request through the form with new configuration in JSON format placed in the input labeled **Update Service Definition.**

**To update configuration, you should include only the configuration that you are trying to update.** Including unneeded configuration will produce errors. See this [esri post](https://community.esri.com/t5/arcgis-online-questions/how-to-use-the-update-definition-operation-on-a/m-p/1483647/highlight/true#M59511) for more context.

To update the sanitization config, the following JSON was used.

#### Original configuration shown in the Update Definition input

```json
{
  ...the rest of the config,
  "xssPreventionInfo" : {
    "xssPreventionEnabled" : true, 
    "xssPreventionRule" : "InputOnly", 
    "xssInputRule" : "rejectInvalid"
  },
  ...and a bunch more config
}
```

#### Updated configuration sent in input

```json
{
  "xssPreventionInfo" : {
    "xssPreventionEnabled" : true, 
    "xssPreventionRule" : "InputOnly", 
    "xssInputRule" : "sanitizeInvalid"
  }
}
```

Once you press the **Update Definition** button to send the payload, you will see a success message or an error if the JSON is invalid.

### Links

* <https://github.com/cityofaustin/atd-data-tech/issues/20842>
* <https://github.com/cityofaustin/atd-data-tech/issues/20801>
* <https://community.esri.com/t5/arcgis-online-questions/how-to-use-the-update-definition-operation-on-a/m-p/1483647/highlight/true#M59511>
