Bolton-and-Menk-GIS / restapi

Python API designed to work externally with ArcGIS REST Services to query and extract data, and view service properties. Uses arcpy for some functions if available, otherwise uses open source alternatives to interact with the ArcGIS REST API. Also includes a subpackage for administering ArcGIS Server Sites.
GNU General Public License v2.0
93 stars 31 forks source link

can't find a feature class inside a schema/owner #18

Open dncpax opened 5 years ago

dncpax commented 5 years ago

If you have 2 feature classes with the same name but in different schemas or different owners, both are found.

For example: user1.fcRivers user2.fcRivers

Code: # find services that have the parcels layer from this sde database ws = r'\arcserver2\SDE_Connections\MN_GIS_LIS.sde' feature_classes = ['user1.fcRivers'] matching = server.find_services_containing(ws, feature_classes)

This will match all services that use either feature classe, from user1 and user2.

It would be logical and useful to consider them different things.

dncpax commented 5 years ago

I can see that this may not be possible because of rest esri api limitations. Specifically, the service manifest strips the schema/owner from the feature class name, so this is not available: http://localhost:6080/arcgis/admin/services/Parks/Landmarks.MapServer/iteminfo/manifest/manifest.json This returns all layers with only name, no schema/owner...

CalebM1987 commented 5 years ago

Thanks for posting. This actually may be possible, as each database connection referenced by the service does have a VERSION in the connection string. I would need to test, but just looking at a manifest.json for one of our services:

{
    "databases": [{
        "byReference": true,
        "onServerWorkspaceFactoryProgID": "esriDataSourcesGDB.SdeWorkspaceFactory.1",
        "onServerConnectionString": "SERVER=<SQL-SERVER-NAME>;INSTANCE=sde:sqlserver:<SQL-SERVER-NAME>;DBCLIENT=sqlserver;DB_CONNECTION_PROPERTIES=<SQL-SERVER-NAME>;DATABASE=Carver;VERSION=dbo.DEFAULT;AUTHENTICATION_MODE=OSA",
        "onPremiseConnectionString": "SERVER=<SQL-SERVER-NAME>;INSTANCE=sde:sqlserver:<SQL-SERVER-NAME>;DBCLIENT=sqlserver;DB_CONNECTION_PROPERTIES=<SQL-SERVER-NAME>;DATABASE=Carver;VERSION=dbo.DEFAULT;AUTHENTICATION_MODE=OSA",
        "onServerName": "dbo.DEFAULT (<SQL-SERVER-NAME>)",
        "onPremisePath": "",
        "datasets": [{
            "onServerName": "Roads"
        }, {
            "onServerName": "Parcels"
        }, {
            "onServerName": "Street_Lights"
        }, {
            "onServerName": "Parks"
        }, {
            "onServerName": "Zoning"
        }]
    }],
    "resources": [{
        "onPremisePath": "\\\\<SERVER>\\WebGIS\\CARV\\CARV_Webmap_MS.mxd",
        "clientName": "",
        "serverPath": "\\\\<SERVER>\\arcgisserver\\directories\\arcgissystem\\arcgisinput\\CARV\\CARV_Webmap_MS.MapServer\\extracted\\v101\\CARV_Webmap_MS.msd"
    }]
}

You can see in the connection strings above, that it is referencing the default ;VERSION=dbo.DEFAULT;...Perhaps I could add an optional parameter where the user could specify a version, and if one is specified, we could probably filter the services by that version.

One disclaimer, all of our databsases use SQL Server, and since the link you provided was pointed to your localhost I could not examine the manifest.json and different types of databases will use different connection strings. But if they have a VERSION listed somewhere in it like what I showed above, I think it is probably doable.

dncpax commented 5 years ago

Hi @CalebM1987.

I think the version is not the solution. The issue I refer to is about 2 users having an FC with the same name, not in different versions. Imagine when there are no versions: the issue still occurs.

Since the the manifest strips the owner of the feature class I don't see any way to get this info. I thought about the user in the connection string, but that won't work when you login with a different user with read privileges...