Skip to content

Commit

Permalink
match on AGO items through back-end service name
Browse files Browse the repository at this point in the history
  • Loading branch information
floptical committed Oct 28, 2024
1 parent 2f4376f commit 9ae96da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions databridge_etl_tools/ago/ago.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,25 @@ def org(self):
@property
def item(self):
'''Find the AGO object that we can perform actions on, sends requests to it's AGS endpoint in AGO.
Contains lots of attributes we'll need to access throughout this script.'''
Contains lots of attributes we'll need to access throughout this script.
Note: your item name needs to match the back-end service name of the AGO item exactly!!'''
if self._item is None:
try:
# "Feature Service" seems to pull up both spatial and table items in AGO
assert self.item_name.strip()
search_query = f'''owner:"{self.ago_user}" AND title:"{self.item_name}" AND type:"Feature Service"'''
search_query = f'''name:"{self.item_name}" AND type:"Feature Service"'''
self.logger.info(f'Searching for item with query: {search_query}')
items = self.org.content.search(search_query, outside_org=False)
for item in items:
print(item.name)
print(item.id)
for item in items:
# For items with spaces in their titles, AGO will smartly change out spaces to underscores
# Test for this too.
self.logger.info(f'Seeing if item title is a match: "{item.title}" to "{self.item_name}"..')
if (item.title.lower() == self.item_name.lower()) or (item.title == self.item_name.replace(' ', '_')):
self.logger.info(f'Seeing if item service name is a match: "{item.name}" to "{self.item_name}"..')
if item.name == self.item_name:
self._item = item
self.logger.info(f'Found item, url and id: {self.item.url}, {self.item.id}')
self.logger.info(f'Found item, url and id: {self.item.url}, {self.item.name}, {self.item.id}')
return self._item
# If item is still None, then fail out
if self._item is None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ py_modules = ['databridge_etl_tools']

[project]
name = "databridge-etl-tools"
version = "1.3.5"
version = "1.3.6"
description = "Command line tools to extract and load SQL data to various endpoints"
authors = [
{name = "citygeo", email = "[email protected]"},
Expand Down

0 comments on commit 9ae96da

Please sign in to comment.