Esri / Esri/arcgis-python-api

Initialize ItemProperties from dict

Open
#2,502 3 comments 0 reactions 1 assignee Claimed by @nanaeaubry View on GitHub
enhancement
Dominant language
Python
Stars
2.2k
Forks
1.2k
Avg merge
2h 40m
Merged PRs (30d)
2

Description

**Is your feature request related to a problem? Please describe.**
With the old deprecated contentmanager add function, it was possible to create a new PortalItem from a dict.
With the latest versions of ArcGIS API for Python we need to do this using a Folder and a ItemProperties object
In this case I cannot use my dict and I need to initialize the ItemProperties object.
There is no option to convert my dict to ItemProperties object and a dict unpack doesn't work

```python
item = {
"title":"Topo_RD",
"type":"Vector Tile Service",
"typeKeywords":["Data","Service","Vector Tile Service"],
"tags":["topo","rd","vector","tag"],
"url":"https://tiles.arcgis.com/tiles/nSZVuSZjHpEZZbRo/arcgis/rest/services/Topo_RD/VectorTileServer"
}
item_props = ItemProperties(item)
TypeError: ItemProperties.__init__() missing 1 required positional argument: 'item_type'

item_props = ItemProperties(**item)
TypeError: ItemProperties.__init__() got an unexpected keyword argument 'type'
```

**Describe the solution you'd like**
A ItemProperties.from_dict static function would be lovely

```python
itemprops = ItemProperties.from_dict(item_dict)
```

**Describe alternatives you've considered**
Right now I just do a folder.add(item_dict) but this isn't officially supported according to the docs and for instance the tags are not set in a proper way

**Additional context**
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.