Skip to content

Initialize ItemProperties from dict #2502

Description

@PeaceNlove

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

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

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions