Select to view content in your preferred language

where does the .size property come from in the code snippet for the ArcGIS API for Python User.items() method

1603
3
Jump to solution
03-31-2021 11:32 AM
AndresCastillo
MVP Regular Contributor
AndresCastillo_0-1617295419080.png

 

 
maybe the .size property comes from the ArcGIS Rest API Users, groups, and items Item Resources, but if that were the case, shouldn't we access the "resources" key first, get the desired index, then calling the .size property rather than accessing the .size property directly?:
 
 

 

 

{
  "total": <total number of resources on the item>,
  "start": <the first record index in the response>,
  "num": <the number of resources in the response>,
  "nextStart": <the next entry index>,
  "resources": [
    {
      "resource": "<resource1>",
      "created": <resource1 created datetime>,
      "size": <resource1 size>
    },
    {
      "resource": "<resource2>",
      "created": <resource2 created datetime>,
      "size": <resource2 size>
    },
    {
      "resource": "<resource3>",
      "created": <resource3 created datetime>,
      "size": <resource3 size>
    }
  ]
}

 

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

It's coming from the Item class, but there do seem to be a number of properties there that are not fully documented in the API docs. Calling dir(Item) on a Feature Layer, for instance, I see:

[
...
'title',
'type',
'snippet',
...
]

And other properties not listed. Interestingly, the documentation for the Item.update() method lists the various item properties that can be updated, and such properties are listed there!

I've also noticed that the contents of dir(Item) actually changes based on the item's type.

for i in gis.content.search('', max_items=-1):
    print(f'Length of dir: {len(dir(i))}    Type: {i.type}')
Length of dir: 143    Type: PDF
Length of dir: 145    Type: Feature Service
Length of dir: 144    Type: Feature Service
Length of dir: 142    Type: Form
Length of dir: 142    Type: Web Map

 

But that may be besides the point. The size property does seem to be consistently present across item types. There have been instances when the API docs just needed correcting.You could always submit a bug report at the Python API's GitHub repo.

- Josh Carlson
Kendall County GIS

View solution in original post

3 Replies
jcarlson
MVP Esteemed Contributor

It's coming from the Item class, but there do seem to be a number of properties there that are not fully documented in the API docs. Calling dir(Item) on a Feature Layer, for instance, I see:

[
...
'title',
'type',
'snippet',
...
]

And other properties not listed. Interestingly, the documentation for the Item.update() method lists the various item properties that can be updated, and such properties are listed there!

I've also noticed that the contents of dir(Item) actually changes based on the item's type.

for i in gis.content.search('', max_items=-1):
    print(f'Length of dir: {len(dir(i))}    Type: {i.type}')
Length of dir: 143    Type: PDF
Length of dir: 145    Type: Feature Service
Length of dir: 144    Type: Feature Service
Length of dir: 142    Type: Form
Length of dir: 142    Type: Web Map

 

But that may be besides the point. The size property does seem to be consistently present across item types. There have been instances when the API docs just needed correcting.You could always submit a bug report at the Python API's GitHub repo.

- Josh Carlson
Kendall County GIS
AndresCastillo
MVP Regular Contributor

Nice, thanks @jcarlson

dot tab after item did not show in the docstring any size property, but like you said, dir() does:

 

AndresCastillo_0-1617475200343.png

 

0 Kudos
AndresCastillo
MVP Regular Contributor

Also just noticed that in the second for loop in the try block of the API code sample, it should be user.items(folder=f), not user.folders(folder=f).

The API does not have any folders method for any of the classes in the arcgis.gis module

AndresCastillo_0-1617398965882.png

I will raise an issue in the API repo.

0 Kudos