Esri / Esri/arcgis-python-api

Initialize ItemProperties from dict

Aperta
#2,502 3 commenti 0 reazioni 1 assegnatario Rivendicata da @nanaeaubry Vedi su GitHub
enhancement
Lingua principale
Python
Stelle
2.2k
Fork
1.2k
Merge medio
2h 40m
PR unite (30g)
2

Descrizione

**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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.