Esri / hub-py

Python interface to ArcGIS Hub
https://github.com/esri/hub-py/wiki
Apache License 2.0
42 stars 13 forks source link

Search should allow user to provide site Domain #99

Closed ajturner closed 3 years ago

ajturner commented 4 years ago

Developers likely won't know the site item id. They should also have the option to get a site by the domain.

These should all work:

mySite = Hub.site.get_by_url("https://opendata.dc.gov")
mySite = Hub.site.get_by_url("opendata.dc.gov")
mySite = Hub.site.get_by_url("https://opendata.dc.gov/search")
ManushiM commented 4 years ago

This cannot work for a few reasons:

  1. Portal API only allows you to fetch items by itemid (unique identifier). If you want to search for something based on any other property (title, tags, owner, etc) you use the search method.
  2. Now the search method doesn't allow for searching by url since many items don't have a url property.
  3. I tried searching by title against the portal API, because I assumed the developers will know the name of their site. However, some old sites are of type Web Mapping Application (including DC) which does not filter when you have the default search condition of typekeywords:hubSite. And if I eliminate that condition, it returns initiatives/apps/maps every item that the title string matches. Not very helpful for the user again.
  4. I also tried adding a url parameter to our search method. So what it does is fetches all sites using portal api and then filters those that have this url string in the url property of the Site Object. Again, doesn't work for sites of another item-type because the api call fails to include it in the first place.
ajturner commented 4 years ago
  1. When provided a URL string, call the Hub domain service e.g. https://opendata.arcgis.com/utilities/domains/<domain>
  2. Get siteId, then make rest of calls.
ajturner commented 4 years ago

This domain lookup should be its own Python method on sites - something like getDomain(string) and getItemByDomain(string) and getOrgByDomain(string).

These can then be used in search as well as finding a Hub given the Domain URL. We've discussed before that getting the org id or the maps.arcgis.com domain will be unknown for civic devs that only know their Hub domain.

ManushiM commented 4 years ago

fix added here https://github.com/Esri/hub-py/pull/100